Commit 25f1db07 authored by Natanael Copa's avatar Natanael Copa

main/aports-build: refactor plugins

plugins was refactored in lua-aports-1.0.0 so configuration and plugin
code are separate. Plugins now goes to /usr/share/buildrepo/plugins and
config are in /etc/buildrepo/config.lua.

This makes it much easier to update the plugin code without manually
edit the config on each builder.
parent 4585856c
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=aports-build
pkgver=1.4
pkgrel=1
pkgver=1.5
pkgrel=0
pkgdesc="MQTT based build-on-git-push scripts for Alpine Linux"
url="https://alpinelinux.org"
arch="noarch"
license="GPL-2.0"
options="!check"
depends="abuild>2.20.0 mosquitto-clients openssh-client mqtt-exec rsync
lua-aports lua5.2-cjson lua5.2-mqtt-publish pigz"
lua-aports>1.0.0 lua5.2-cjson lua5.2-mqtt-publish pigz"
depends_dev=""
makedepends="$depends_dev mosquitto-dev"
install="$pkgname.pre-install"
......@@ -37,10 +37,16 @@ package() {
"$pkgdir"/etc/conf.d/mqtt-exec.aports-build
install -Dm644 "$srcdir"/report-build-errors.lua \
"$pkgdir"/etc/buildrepo/plugins.d/report-build-errors.lua
"$pkgdir"/usr/share/buildrepo/plugins/report-build-errors.lua
install -d "$pkgdir"/etc/buildrepo
cat >"$pkgdir"/etc/buildrepo/config.lua <<-EOF
-- logurlprefix = "http://build.alpinelinux.org/buildlogs/"
-- mqttbroker = "localhost"
-- logtarget = "distfiles.alpinelinux.org:/var/cache/distfiles/buildlogs/"
EOF
}
sha512sums="68504590f060be9c5c2fd7ce3e34f340eb7c07523d3395dd165dbf7068d8c7694b11c09c2727e17959120eb6697c9878ca1c32f6a335c56a044f6e1a8f8ea190 aports-build
821035bda47152c341ec94bf960fa67e3377051826712ceb74f39103e6e422777b6e082231bfb87865653d2b93b7d3154cfc24abf65a52e3e66da69412dd7e41 aports-build.initd
62ed5cb6d1fef03fa707512c8c99c572a91e64706ebcc2e7097108811818615618bab908292d0ba0ad2afe93a27333d9c91deb347d6c99703eb8983d1ee5f480 mqtt-exec.aports-build.confd
ded99f4c9474e4dc91605de71919deebbeb8e2e3ebcc9d61890f327bb6220d891a9f2a6c615929cc53bd8007b1a1dbd827bc55cd5cbdd1a6661fcdafa4912950 report-build-errors.lua"
cf0d8e65e517857ee781e451a1d3e6404cd72aeb5c7dba25017229ff79c4c43425712d2fcbbaad89af45a358e86f33467ac1df47e8fba0f30f81d84794e1206c report-build-errors.lua"
......@@ -6,12 +6,8 @@ local f = io.open("/proc/sys/kernel/hostname")
hostname = f:read()
f:close()
local urlprefix=("http://build.alpinelinux.org/buildlogs/%s"):format(hostname)
local m = {}
--local logtarget="distfiles.alpinelinux.org:/var/cache/distfiles/buildlogs/"..hostname
function shell_escape(args)
local ret = {}
for _,a in pairs(args) do
......@@ -30,13 +26,17 @@ function run(args)
return h:close(), outstr
end
function m.postbuild(aport, success, repodest, arch, logfile)
function m.postbuild(conf, aport, success)
-- upload log
local loghost,logdirprefix = (logtarget or ""):match("(.*):(.*)")
if logfile and loghost and logdirprefix then
local logdir = logdirprefix.."/"..aport:get_repo_name().."/"..aport.pkgname.."/"
local loghost,logdirprefix = (conf.logtarget or ""):match("(.*):(.*)")
if aport.logfile and loghost and logdirprefix then
local logdir = logdirprefix.."/"..hostname.."/"..aport:get_repo_name().."/"..aport.pkgname.."/"
run{"ssh", loghost, "mkdir", "-p", logdir}
run{"scp", logfile, loghost..":"..logdir}
run{"scp", aport.logfile, loghost..":"..logdir}
end
if not conf.mqttbroker then
return
end
local topic = ("build/%s/errors"):format(hostname)
......@@ -47,14 +47,15 @@ function m.postbuild(aport, success, repodest, arch, logfile)
pkgname = aport.pkgname,
hostname = hostname,
reponame = aport:get_repo_name(),
logurl = ("%s/%s/%s-%s-r%s.log"):format(
urlprefix,
logurl = ("%s/%s/%s/%s-%s-r%s.log"):format(
conf.logurlprefix or "https://build.alpinelinux.org/buildlogs",
hostname,
(string.match(aport.dir,"[^/]+/[^/]+$")),
aport.pkgname, aport.pkgver, aport.pkgrel),
status = success
}
end
publish.single(topic, payload, nil, true, "msg.alpinelinux.org")
publish.single(topic, payload, nil, true, conf.mqttbroker)
end
return m
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment