aboutsummaryrefslogtreecommitdiffstats
path: root/main/lua-aports/0002-buildrepo-refactor.patch
diff options
context:
space:
mode:
Diffstat (limited to 'main/lua-aports/0002-buildrepo-refactor.patch')
-rw-r--r--main/lua-aports/0002-buildrepo-refactor.patch148
1 files changed, 148 insertions, 0 deletions
diff --git a/main/lua-aports/0002-buildrepo-refactor.patch b/main/lua-aports/0002-buildrepo-refactor.patch
new file mode 100644
index 0000000000..c140e8d83d
--- /dev/null
+++ b/main/lua-aports/0002-buildrepo-refactor.patch
@@ -0,0 +1,148 @@
+From 62478e8dc18cac0ffc3d30917f057b1d1d75f9f0 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Wed, 22 Jul 2015 17:00:31 +0200
+Subject: [PATCH 2/2] buildrepo: refactor
+
+- pass logfile directly to build_aport
+- run the plugin hooks from loop
+- pass progress status to prebuild plugins
+---
+ buildrepo.lua | 84 +++++++++++++++++++++++++++++++++++------------------------
+ 1 file changed, 50 insertions(+), 34 deletions(-)
+
+diff --git a/buildrepo.lua b/buildrepo.lua
+index 4fb9f12..5c4b931 100755
+--- a/buildrepo.lua
++++ b/buildrepo.lua
+@@ -97,36 +97,54 @@ local function run_plugins(dirpath, func, ...)
+ end
+ end
+
+-local function build_aport(aport, repodest, logdir)
++local function plugins_prebuild(...)
++ return run_plugins(pluginsdir, "prebuild", ...)
++end
++
++local function plugins_postbuild(...)
++ return run_plugins(pluginsdir, "postbuild", ...)
++end
++
++local function logfile_path(logdirbase, repo, aport)
++ if logdirbase == nil then
++ return nil
++ end
++ local dir = ("%s/%s/%s"):format(logdirbase, repo, aport.pkgname)
++ if not lfs.attributes(dir) then
++ local path = ""
++ for n in string.gmatch(dir, "[^/]+") do
++ path = path.."/"..n
++ lfs.mkdir(path)
++ end
++ end
++ return ("%s/%s-%s-r%s.log"):format(dir, aport.pkgname, aport.pkgver, aport.pkgrel)
++end
++
++
++local function build_aport(aport, repodest, logfile)
+ local success, errmsg = lfs.chdir(aport.dir)
+ if not success then
+ err("%s", errmsg)
+ return nil
+ end
+ local logredirect = ""
+- if logdir ~= nil then
+- local dir = ("%s/%s"):format(logdir, aport.pkgname)
+- if not lfs.attributes(dir) then
+- assert(lfs.mkdir(dir), dir)
+- end
+- local logfile = ("%s/%s-%s-r%s.log"):format(dir, aport.pkgname, aport.pkgver, aport.pkgrel)
+-
++ if logfile ~= nil then
+ logredirect = ("> '%s' 2>&1"):format(logfile)
+ end
+ local cmd = ("REPODEST='%s' abuild -r -m %s"):format(repodest, logredirect)
+- run_plugins(pluginsdir, "prebuild", aport, logfile)
+- if opts.n then
+- success = true
+- else
+- success = os.execute(cmd)
+- end
++ success = os.execute(cmd)
+ if not success then
+ err("%s: Failed to build", aport.pkgname)
+ end
+- run_plugins(pluginsdir, "postbuild", aport, success, logfile)
+ return success
+ end
+
++local function log_progress(progress, repo, aport)
++ info("%d/%d %d/%d %s/%s %s-r%s",
++ progress.tried, progress.total,
++ progress.repo_built, progress.repo_total,
++ repo, aport.pkgname, aport.pkgver, aport.pkgrel)
++end
+ -----------------------------------------------------------------
+ local opthelp = [[
+ -a DIR Set the aports base dir to DIR instead of $HOME/aports
+@@ -164,6 +182,10 @@ aportsdir = opts.a or ("%s/aports"):format(homedir)
+ repodest = opts.d or abuild.repodest or ("%s/packages"):format(homedir)
+ logdirbase = opts.l
+
++if opts.n then
++ build_aport = function() return true end
++end
++
+ stats = {}
+ for _,repo in pairs(args) do
+ local db = require('aports.db').new(aportsdir, repo)
+@@ -199,34 +221,28 @@ for _,repo in pairs(args) do
+ unsorted[aport.pkgname] = true
+ end
+
+- if logdirbase ~= nil then
+- logdir = ("%s/%s"):format(logdirbase, repo)
+- if not lfs.attributes(logdir) then
+- assert(lfs.mkdir(logdir), logdir)
+- end
+- end
+-
+ -- build packages
+ local built = 0
+ local tried = 0
+ for aport in db:each_in_build_order(pkgs) do
++ local logfile = logfile_path(logdirbase, repo, aport)
+ tried = tried + 1
+- local totally_built = stats[repo].relevant_aports - #pkgs + built
++ local progress = { tried = tried, total = #pkgs,
++ repo_built = stats[repo].relevant_aports - #pkgs + built,
++ repo_total = stats[repo].relevant_aports,
++ }
+ if not db:known_deps_exists(aport) then
+ warn("%s: Skipped due to missing dependencies", aport.pkgname)
+ elseif not (opts.s and skip_aport(aport)) then
+- info("%d/%d %d/%d %s/%s %s-r%s",
+- tried, #pkgs,
+- totally_built,
+- stats[repo].relevant_aports,
+- repo, aport.pkgname,
+- aport.pkgver, aport.pkgrel)
+- if build_aport(aport, repodest, logdir) then
++ log_progress(progress, repo, aport)
++ plugins_prebuild(aport, progress, logfile)
++ local success = build_aport(aport, repodest, logfile)
++ plugins_postbuild(aport, success, logfile)
++ if success then
+ built = built + 1
+- else
+- if not opts.k then
+- os.exit(1)
+- end
++ end
++ if not success and not opts.k then
++ os.exit(1)
+ end
+ end
+ end
+--
+2.4.6
+