aboutsummaryrefslogtreecommitdiffstats
path: root/main/lua-aports
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2015-07-23 15:48:35 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2015-07-23 15:49:10 +0200
commit62efd50897c1854c7424c392b691911df2a61d8b (patch)
treec7771b1b056bc281a3bc6a66be14b4a91215d54b /main/lua-aports
parente3b247c49a79b8a03d70ad32b89ba93dd69e6534 (diff)
downloadaports-62efd50897c1854c7424c392b691911df2a61d8b.tar.bz2
aports-62efd50897c1854c7424c392b691911df2a61d8b.tar.xz
main/lua-aports: add support for buildrepo plugins
Diffstat (limited to 'main/lua-aports')
-rw-r--r--main/lua-aports/0001-buildrepo-add-support-for-plugins.d.patch85
-rw-r--r--main/lua-aports/0002-buildrepo-refactor.patch148
-rw-r--r--main/lua-aports/APKBUILD16
3 files changed, 245 insertions, 4 deletions
diff --git a/main/lua-aports/0001-buildrepo-add-support-for-plugins.d.patch b/main/lua-aports/0001-buildrepo-add-support-for-plugins.d.patch
new file mode 100644
index 0000000000..d7c78e1e85
--- /dev/null
+++ b/main/lua-aports/0001-buildrepo-add-support-for-plugins.d.patch
@@ -0,0 +1,85 @@
+From ace87a06e5782b6f7f2235094f32847fe836ea15 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Wed, 22 Jul 2015 15:57:35 +0200
+Subject: [PATCH 1/2] buildrepo: add support for plugins.d
+
+Make it possible to add hooks that are execute pre and post build.
+
+This can be used for posting build error messages, copying build logs
+etc.
+---
+ buildrepo.lua | 34 +++++++++++++++++++++++++++++-----
+ 1 file changed, 29 insertions(+), 5 deletions(-)
+
+diff --git a/buildrepo.lua b/buildrepo.lua
+index bc0a784..4fb9f12 100755
+--- a/buildrepo.lua
++++ b/buildrepo.lua
+@@ -4,6 +4,8 @@ local abuild = require("aports.abuild")
+ local apkrepo = require("aports.apkrepo")
+ local lfs = require("lfs")
+
++local pluginsdir = "/etc/buildrepo/plugins.d"
++
+ local function warn(formatstr, ...)
+ io.stderr:write(("WARNING: %s\n"):format(formatstr:format(...)))
+ io.stderr:flush()
+@@ -75,6 +77,26 @@ local function skip_aport(aport)
+ return true
+ end
+
++local function run_plugins(dirpath, func, ...)
++ local a = lfs.attributes(dirpath)
++ if a == nil or a.mode ~= "directory" then
++ return
++ end
++ local flist = {}
++ for f in lfs.dir(dirpath) do
++ if string.match(f, ".lua$") then
++ table.insert(flist, f)
++ end
++ end
++ table.sort(flist)
++ for i = 1,#flist do
++ local m = dofile(dirpath.."/"..flist[i])
++ if type(m[func]) == "function" then
++ m[func](...)
++ end
++ end
++end
++
+ local function build_aport(aport, repodest, logdir)
+ local success, errmsg = lfs.chdir(aport.dir)
+ if not success then
+@@ -92,10 +114,16 @@ local function build_aport(aport, repodest, logdir)
+ logredirect = ("> '%s' 2>&1"):format(logfile)
+ end
+ local cmd = ("REPODEST='%s' abuild -r -m %s"):format(repodest, logredirect)
+- success = os.execute(cmd)
++ run_plugins(pluginsdir, "prebuild", aport, logfile)
++ if opts.n then
++ success = true
++ else
++ success = os.execute(cmd)
++ end
+ if not success then
+ err("%s: Failed to build", aport.pkgname)
+ end
++ run_plugins(pluginsdir, "postbuild", aport, success, logfile)
+ return success
+ end
+
+@@ -136,10 +164,6 @@ 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)
+--
+2.4.6
+
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
+
diff --git a/main/lua-aports/APKBUILD b/main/lua-aports/APKBUILD
index aed2692f5b..4add2e8159 100644
--- a/main/lua-aports/APKBUILD
+++ b/main/lua-aports/APKBUILD
@@ -1,7 +1,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=lua-aports
pkgver=0.4
-pkgrel=0
+pkgrel=1
pkgdesc="Lua modules for parsing aports tree"
url="http://dev.alpinelinux.org/archive/lua-aports/"
arch="noarch"
@@ -13,6 +13,8 @@ install=""
replaces="abuild"
subpackages=""
source="http://dev.alpinelinux.org/archive/lua-aports/lua-aports-$pkgver.tar.xz
+ 0001-buildrepo-add-support-for-plugins.d.patch
+ 0002-buildrepo-refactor.patch
"
_builddir="$srcdir"/lua-aports-$pkgver
@@ -35,6 +37,12 @@ package() {
make DESTDIR="$pkgdir" install || return 1
}
-md5sums="61abfaedf5d7599d1322e62029b24a3e lua-aports-0.4.tar.xz"
-sha256sums="b29670416a476fd390083b1b013c099c727e1c4e56171cc5f7ab767dcf41aacc lua-aports-0.4.tar.xz"
-sha512sums="06571ce33872d846c8a72d31c8b8e86ce1824f3ae39875c4fe7dfcc6f69968ebb53b4ce4cf7349a1a717be2572dcea1b79f06d90d03f9fef88cc06703b830273 lua-aports-0.4.tar.xz"
+md5sums="61abfaedf5d7599d1322e62029b24a3e lua-aports-0.4.tar.xz
+400c3f87e3bfc0cece732ccc7273ab15 0001-buildrepo-add-support-for-plugins.d.patch
+45f3610919c1bddea841d4c91bccb3de 0002-buildrepo-refactor.patch"
+sha256sums="b29670416a476fd390083b1b013c099c727e1c4e56171cc5f7ab767dcf41aacc lua-aports-0.4.tar.xz
+fbee2b352b8a353b4f904a26cc311cc60f79eaa6b1202566a6c311e4c2bb4144 0001-buildrepo-add-support-for-plugins.d.patch
+99f971b242b283beea788d3d31d48b5143c1e134ae448c2bf7303b595159c6cf 0002-buildrepo-refactor.patch"
+sha512sums="06571ce33872d846c8a72d31c8b8e86ce1824f3ae39875c4fe7dfcc6f69968ebb53b4ce4cf7349a1a717be2572dcea1b79f06d90d03f9fef88cc06703b830273 lua-aports-0.4.tar.xz
+0d1bb484c6281b61e1e5b8862b7f73f1f2da9d4bc77260309f8bbd6a9ffd8c733424d42c194593a7434209277284dcf0bf8bea07d6b083df371b462e131cd3c9 0001-buildrepo-add-support-for-plugins.d.patch
+0af8a5ed6b57b8d72c4ec3715c02d3d47dc9bf7a88da665b15e2f7cabbe81e8d3b871acea28e85a962c1b2872e921efadb72674f71ef7a8a0ba7d9e5834bb11e 0002-buildrepo-refactor.patch"