Subject: [alpine-aports] [PATCH 0/5] Forgotten pre-install addgroup/adduser fixes and fixes.

From: Przemyslaw Pawelczyk <[email-masked]>
Date: Fri, 17 Jun 2016 03:47:28 +0200

This is a follow-up patch set to previous patch set called:

    Pre-upgrade/pre-install addgroup/adduser fixes.

This time some additional checks has been performed leading to further
improvements of the packages.

This again took longer than expected, sorry for that, but I am getting
more and more familiar with AL-related stuff.

---

Next step is going through all packages available in 3.4.1, that were
touched by commit ccc056dbf9d3, and checking whether they seem to work,
and if not, then preparing patches dedicated for 3.4 that should be
applied on top of:

* 1de4b02204f7 main/lighttpd: Fix lighttpd user's primary group.
* f27dface22b3 testing/at: Properly set primary group in .pre-install.
* 40521bdafd3c main/dovecot: Properly set primary group in .pre-install.
* 3c1fa46624bd main/{npre, postgrey}: Properly set primary group in .pre-install.
* a7d67c695ca2 main/[various]: Add group and use it as primary in .pre-* scripts.
* 5708404c50a7 community/[various]: Add group and use it as primary in .pre-* scripts.
* a835b6916533 testing/[various]: Add group and use it as primary in .pre-* scripts.

and non-bump patches from this patch set, as bumping will be done at the
very end, after additional fixing patches (if they will be needed).
I'll try to do it on Friday, but I unfortunately cannot guarantee
finishing by the end of the day.  Hopefully it should be mostly ready
after Sunday.

Przemyslaw Pawelczyk (5):
  testing/[various]: Add group and use it as primary in .pre-* scripts.
  testing/clapf: Fix a lot of problems.
  testing/buildbot: Fix some stuff.
  testing/buildbot-slave: Fix some stuff.
  testing/[various]: Bump pkgrel for fixes.

 testing/buildbot-slave/APKBUILD                   | 45 +++++++-----
 testing/buildbot-slave/buildbot-slave.pre-install |  3 +-
 testing/buildbot-slave/buildslave.initd           |  2 +-
 testing/buildbot/APKBUILD                         | 45 +++++++-----
 testing/buildbot/buildbot.pre-install             |  3 +-
 testing/buildbot/buildmaster.initd                | 17 ++++-
 testing/clapf/APKBUILD                            | 84 +++++++++++++----------
 testing/clapf/clapf.confd                         | 10 +--
 testing/clapf/clapf.initd                         | 34 +++++----
 testing/clapf/clapf.pre-install                   |  3 +-
 testing/clapf/ldflags.patch                       |  2 +-
 11 files changed, 149 insertions(+), 99 deletions(-)

-- 
2.6.6

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Przemyslaw Pawelczyk <[email-masked]>
Date: Fri, 17 Jun 2016 03:47:29 +0200

Fixes the problem I unintentionally brought in commit ccc056dbf9d3:
system user creation doesn't add same named group and uses nogroup as
primary group unless explicitly specified via -G.

Brings status quo regarding primary groups of users created in packages:
- testing/buildbot
- testing/buildbot-slave
- testing/clapf

It should have been part of commit a835b6916533, but was overlooked.
---
 testing/buildbot-slave/buildbot-slave.pre-install | 3 ++-
 testing/buildbot/buildbot.pre-install             | 3 ++-
 testing/clapf/clapf.pre-install                   | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/testing/buildbot-slave/buildbot-slave.pre-install b/testing/buildbot-slave/buildbot-slave.pre-install
index 695f71607bc4..7a1deeded1d6 100644
--- a/testing/buildbot-slave/buildbot-slave.pre-install
+++ b/testing/buildbot-slave/buildbot-slave.pre-install
@@ -1,5 +1,6 @@
 #!/bin/sh
 
-adduser -S -D -H -h /home/buildbot -s /sbin/nologin -g buildbot buildbot 2>/dev/null
+addgroup -S buildbot 2>/dev/null
+adduser -S -D -H -h /home/buildbot -s /sbin/nologin -G buildbot -g buildbot buildbot 2>/dev/null
 
 exit 0
diff --git a/testing/buildbot/buildbot.pre-install b/testing/buildbot/buildbot.pre-install
index 695f71607bc4..7a1deeded1d6 100644
--- a/testing/buildbot/buildbot.pre-install
+++ b/testing/buildbot/buildbot.pre-install
@@ -1,5 +1,6 @@
 #!/bin/sh
 
-adduser -S -D -H -h /home/buildbot -s /sbin/nologin -g buildbot buildbot 2>/dev/null
+addgroup -S buildbot 2>/dev/null
+adduser -S -D -H -h /home/buildbot -s /sbin/nologin -G buildbot -g buildbot buildbot 2>/dev/null
 
 exit 0
diff --git a/testing/clapf/clapf.pre-install b/testing/clapf/clapf.pre-install
index 01c4585c926a..7cbfaad04b90 100644
--- a/testing/clapf/clapf.pre-install
+++ b/testing/clapf/clapf.pre-install
@@ -1,5 +1,6 @@
 #!/bin/sh
 
-adduser -S -D -H -s /bin/false -g clamav clamav 2>/dev/null
+addgroup -S clamav 2>/dev/null
+adduser -S -D -H -s /bin/false -G clamav -g clamav clamav 2>/dev/null
 
 exit 0
-- 
2.6.6

---

---

From: Przemyslaw Pawelczyk <[email-masked]>
Date: Fri, 17 Jun 2016 03:47:30 +0200

* APKBUILD: Leverage default_prepare and use builddir (no _).
* APKBUILD: Update url and source url.
            Original tar seems not available anymore and there are no
            tags in clapf's bitbucket repository, so use commit marked
            as release of version that was shipped before.
* APKBUILD: Introduce some constants for better DRY-ness,
            reformat package() function, create there a workdir
            (otherwise clapf won't start) and fix permissions.
* APKBUILD: make -j1 is deliberate, as it fails with more jobs,
            but I am not willing to spend any more time on this package.
* ldflags.patch: Set soname (otherwise -dev subpkg will haunt you).
* clapf.confd: Make it somewhat usable. TMPDIR seemed useless.
* clapf.initd: Rewrite using openrc-run default ssd functions.
* clapf.pre-install: Change user and group to clapf.

It has not been tested with mta, but at least it starts now if you have
virus databases present.  Run freshclam if you don't have them yet.
---
 testing/clapf/APKBUILD          | 82 +++++++++++++++++++++++------------------
 testing/clapf/clapf.confd       | 10 +++--
 testing/clapf/clapf.initd       | 34 +++++++++--------
 testing/clapf/clapf.pre-install |  4 +-
 testing/clapf/ldflags.patch     |  2 +-
 5 files changed, 75 insertions(+), 57 deletions(-)

diff --git a/testing/clapf/APKBUILD b/testing/clapf/APKBUILD
index a4cd101b1f68..efc2438be21d 100644
--- a/testing/clapf/APKBUILD
+++ b/testing/clapf/APKBUILD
@@ -4,7 +4,7 @@ pkgname=clapf
 pkgver=0.4.7.4
 pkgrel=1
 pkgdesc="clapf is an open source email content filter application"
-url="http://clapf.acts.hu"
+url="http://clapf.org"
 arch="all"
 license="as-is"
 depends="clamav-db"
@@ -12,31 +12,29 @@ depends_dev="gsl-dev mysql-dev clamav-dev zlib-dev bzip2-dev"
 makedepends="$depends_dev autoconf automake"
 install="$pkgname.pre-install"
 options="suid"
-pkgusers="clapf"
+CLAPF_USER="clapf"
+CLAPF_GROUP="clapf"
+pkgusers="$CLAPF_USER"
+pkggroups="$CLAPF_GROUP"
 subpackages="$pkgname-dev"
-source="http://clapf.acts.hu/clapf-$pkgver.tar.gz
+# * 31d2ce87967e released 0.4.7.4
+COMMIT=31d2ce87967e
+source="$pkgname-$pkgver-g$COMMIT.tar.gz::https://bitbucket.org/jsuto/$pkgname/get/$COMMIT.tar.gz
 	gsl-libs.patch
 	def__user.patch
 	ldflags.patch
+	clapf.confd
+	clapf.initd"
 
-	$pkgname.confd
-	$pkgname.initd"
-
-_builddir="$srcdir/$pkgname-$pkgver"
+builddir="$srcdir/jsuto-$pkgname-$COMMIT"
 
 prepare() {
-	local i
-	cd "$_builddir"
-	for i in $source; do
-		case $i in
-		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
-		esac
-	done
+	default_prepare || return 1
 	aclocal && autoconf
 }
 
 build() {
-	cd "$_builddir"
+	cd "$builddir"
 	./configure --prefix=/usr \
 		--sysconfdir=/etc \
 		--mandir=/usr/share/man \
@@ -51,7 +49,7 @@ build() {
 		--enable-policy \
 		--enable-whitelist \
 		--enable-blackhole \
-		--with-clapf-user=clapf \
+		--with-clapf-user=$CLAPF_USER \
 		--enable-language-detection \
 		--enable-memcached \
 		--enable-spamsum
@@ -60,30 +58,44 @@ build() {
 }
 
 package() {
-	cd "$_builddir"
-	make -j1 DESTDIR="$pkgdir" install || return 1
-        install -Dm755 "$srcdir/$pkgname".initd \
-		"$pkgdir/etc/init.d/$pkgname" || return 1
-        install -Dm644 "$srcdir/$pkgname".confd \
-                "$pkgdir/etc/cond.d/$pkgname" || return 1	
-	install -do $pkgname "$pkgdir"/var/run/clapf || return 1
+	cd "$builddir"
+	make -j1 DESTDIR="$pkgdir" install \
+		|| return 1
+	install -D -m 755 \
+	        "$srcdir"/clapf.initd \
+	        "$pkgdir"/etc/init.d/clapf \
+		|| return 1
+	install -D -m 644 \
+	        "$srcdir"/clapf.confd \
+	        "$pkgdir"/etc/conf.d/clapf \
+		|| return 1
+	install -d -o $CLAPF_USER -g $CLAPF_GROUP \
+	        "$pkgdir"/var/run/$pkgname \
+		|| return 1
+	mkdir -p \
+	      "$pkgdir"/var/spool/clapf/tmp \
+		|| return 1
+	chown -R $CLAPF_USER:$CLAPF_GROUP \
+	      "$pkgdir"/var/lib/clapf \
+	      "$pkgdir"/var/spool/clapf \
+		|| return 1
 }
 
-md5sums="e6be84e17886401b4818c6285a7b2888  clapf-0.4.7.4.tar.gz
+md5sums="0a38f56f717b170d8b6e5f780cd2281d  clapf-0.4.7.4-g31d2ce87967e.tar.gz
 7f480d5a8d0da4863b682deddfe47eff  gsl-libs.patch
 ba31f71c066f3f6159548808d2e26d8b  def__user.patch
-c6bd9005236f6a40c32fe1f04fafc94b  ldflags.patch
-385318b45b2bccdd76fd312576380735  clapf.confd
-263283c96608d696cd5e9eb9de921b16  clapf.initd"
-sha256sums="a38e5b28ff58119abf50054fac2c03b04f959251e844893f0c9f669ce76c99e3  clapf-0.4.7.4.tar.gz
+967743d70cdf21dd929117865c7053c0  ldflags.patch
+1e3786f78bbdfaba1f2d414f9fa19907  clapf.confd
+3ab39ee86b80ba8e19e8f41686d35bc6  clapf.initd"
+sha256sums="84b1e15462985531e865b5700200d1f0fc09289e5cce00f3d8ab0fdefe4b51cc  clapf-0.4.7.4-g31d2ce87967e.tar.gz
 4b4bb8530ac740a5279e0fdd959c6b706b3635792030f6b242e282f8d923202c  gsl-libs.patch
 0523e889808f6aa3ec71a34846cbdfc9d1b185463583dcd7239673d098402346  def__user.patch
-00035eb11386f40c68ebaea79c31659f19f4f5a29503d47e9e0d3a6efc32f9fe  ldflags.patch
-1c5c87adfa2efdaa55d7c8e07ac7ca6b4a068313723dbf46dd1d1ccaf3e54e6a  clapf.confd
-f5c849b01734115ff83e9a2bb0eb4a34bd25d20f646c7945a8887815a65f1ec3  clapf.initd"
-sha512sums="7eb95e25671d0ad4d37cd16f5c293bb7cc8466cbc3dd6b7ac250d75f277423f57012e57373bd8f69174bcb15e865caa33e97dd6adcb0a52553b6ce9069036b05  clapf-0.4.7.4.tar.gz
+d9b5fdbc6ca3118a3e382bcdca383ccca4cdac660303d39a7221bc6475f4eaac  ldflags.patch
+429a4a6f832cb00f5fcfa0218656bcefa68d80f1f6d2f21ee4dfe1dceef15f69  clapf.confd
+bafcb80e5f142f9680a7b8a94c848d84a6940d6c807122d0ed10f004c035faf9  clapf.initd"
+sha512sums="f13428be93cd170e24c70e608d15ef7d6054fa1d57dc9dae4efc4b78c464a1ab3102d99114ddfa3fe011e0a6b6ae2076ee46d5d64561604d0b758fae947d22da  clapf-0.4.7.4-g31d2ce87967e.tar.gz
 096ed4afe1b0fad569a172d6af952f1590d230dd38f6f0c4c0b1e7f29a1515fd887f1c099267aa926ce698864b75cb50626a9b7f49914549748d22ba7058a31d  gsl-libs.patch
 18b8bf55f20e86e05958f2b4a8bdea8bedeb712bc91bb9a6a67faa2928b545707d3391671ab843415fe11703fef4683594571136cf9b2ec87aa41b0875d34588  def__user.patch
-d71081b2f1bdc9f44ee5cee6e4149e6e53d5ef5415069814dd22d9c2df6eee0195b9e3466468d01d0b5bcfadfc20ec0eacfd1299d5f37cbe7f326ffab435972b  ldflags.patch
-99795b8063234c5dbf10da145660c39dfe3f121aa4bb17869abc0dcab5dfd765bfba033a701c8b70d57cb4fe2811d122da1e56506a1c45c0afdcc2102719d798  clapf.confd
-08e42083bcdfe39099d78db23961c0585883cfb3ad4b789376ca34d1d89556dbae153eeda281f08ffe179a4305188062c03ed1a53ca98d636c44ddbd7b40112a  clapf.initd"
+f391663c74ce55b33446bbca9cde61201147d8704f514a266ea1371a43231e34800a8dc6e9f3843849ac000aa49ec2cffc023795696b6127bb404df83493f10f  ldflags.patch
+f9d931f59710ca5ffae2d08d95d12d090dbbd932f8aa0ebb15e925704563834249e475e7ae8e845fb0f57396cdc11492b54efa0f5c228222f04a0e0c0e92caa5  clapf.confd
+c4dff1a3627f9de640dbe6c9a7c69f0e8357f9c63a3fb41f3c6c1e7ee6caec431be6f473002847f1fd2c6c41f7d2730ae134a5b04c9df77502b0905657f524e8  clapf.initd"
diff --git a/testing/clapf/clapf.confd b/testing/clapf/clapf.confd
index f31009d75d19..8edf00cfb291 100644
--- a/testing/clapf/clapf.confd
+++ b/testing/clapf/clapf.confd
@@ -1,4 +1,6 @@
-#
-# Config file for /etc/init.d/clapf
-#
-TMPDIR="/var/lib/clapf"
+# /etc/conf.d/clapf: config file for /etc/init.d/clapf
+
+#CLAPF_USER=clapf
+#CLAPF_GROUP=clapf
+#CLAPF_CONF=/etc/clapf.conf
+#CLAPF_OPTS="-c $CLAPF_CONF"
diff --git a/testing/clapf/clapf.initd b/testing/clapf/clapf.initd
index eaf2aa49e3b6..b3e6c6dd9056 100644
--- a/testing/clapf/clapf.initd
+++ b/testing/clapf/clapf.initd
@@ -1,23 +1,27 @@
-#!/sbin/runscript
-# Copyright 1999-2005 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header:
+#!/sbin/openrc-run
+
+description="Email content filter"
+extra_started_commands="reload"
+
+command="/usr/sbin/clapf"
+pidfile="/var/run/clapf/clapf.pid"
+CLAPF_CONF="${CLAPF_CONF:-/etc/clapf.conf}"
+CLAPF_USER="${CLAPF_USER:-clapf}"
+CLAPF_GROUP="${CLAPF_GROUP:-clapf}"
+command_user="$CLAPF_USER${CLAPF_GROUP:+:}$CLAPF_GROUP"
+command_args="${CLAPF_OPTS:--c $CLAPF_CONF}"
+command_background="YES"
 
 depend() {
 	need net
-        use logger
+	use logger
 	before mta
 }
 
-start() {
-	ebegin "Starting clapf"
-	start-stop-daemon --start --quiet --user clapf --background \
-	--exec /usr/sbin/clapf --make-pidfile --pid /var/run/clapf/clapf.pid -- -c /etc/clapf.conf
-	eend $?
-}
-
-stop() {
-	ebegin "Stopping clapf"
-	start-stop-daemon --stop --quiet --pidfile /var/run/clapf/clapf.pid
+reload() {
+	ebegin "Reloading ${name:-$RC_SVCNAME}"
+	start-stop-daemon --signal HUP \
+		${command:+--exec} $command \
+		${pidfile:+--pidfile} $pidfile
 	eend $?
 }
diff --git a/testing/clapf/clapf.pre-install b/testing/clapf/clapf.pre-install
index 7cbfaad04b90..b2207408ad60 100644
--- a/testing/clapf/clapf.pre-install
+++ b/testing/clapf/clapf.pre-install
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-addgroup -S clamav 2>/dev/null
-adduser -S -D -H -s /bin/false -G clamav -g clamav clamav 2>/dev/null
+addgroup -S clapf 2>/dev/null
+adduser -S -D -H -h /var/lib/clapf -s /bin/false -G clapf -g clapf clapf 2>/dev/null
 
 exit 0
diff --git a/testing/clapf/ldflags.patch b/testing/clapf/ldflags.patch
index 1f5a76d9de80..0dfd02de6a8d 100644
--- a/testing/clapf/ldflags.patch
+++ b/testing/clapf/ldflags.patch
@@ -23,7 +23,7 @@ index 9512aca..6b4388e 100644
  	ranlib libclapf.a
 -	#$(CC) -shared -Wl,-soname,libclapf.so.$(CLAPF_VERSION) -o libclapf.so.$(LIBCLAPF_VERSION) $(OBJS) $(SQL_OBJS) $(LIBS) $(LDAP_LIBS) @LDFLAGS@
 -	$(CC) -shared -Wl -o libclapf.so.$(LIBCLAPF_VERSION) $(OBJS) $(SQL_OBJS) $(LIBS) $(LDAP_LIBS) @LDFLAGS@
-+	$(CC) @LDFLAGS@ -shared -o libclapf.so.$(LIBCLAPF_VERSION) $(OBJS) $(SQL_OBJS) $(LIBS) $(LDAP_LIBS)
++	$(CC) @LDFLAGS@ -shared -Wl,-soname,libclapf.so.$(CLAPF_VERSION) -o libclapf.so.$(LIBCLAPF_VERSION) $(OBJS) $(SQL_OBJS) $(LIBS) $(LDAP_LIBS)
  	ln -sf libclapf.so.$(LIBCLAPF_VERSION) libclapf.so
  	ln -sf libclapf.so.$(LIBCLAPF_VERSION) libclapf.so.$(CLAPF_VERSION)
  
-- 
2.6.6

---

---

From: Przemyslaw Pawelczyk <[email-masked]>
Date: Fri, 17 Jun 2016 03:47:31 +0200

* APKBUILD: Leverage default_prepare and use builddir (no _).
* APKBUILD: Introduce some constants for better DRY-ness,
            reformat package() function, create there a workdir
            (otherwise buildbot won't start).
* buildmaster.initd: Put openrc-run in shebang.
                     Add create command, which is a wrapper around
                     `buildbot create-master -r $BASEDIR`.

It has not been truly tested, but at least it starts now if you perform
following command before starting buildmaster:

    /etc/init.d/buildmaster create
---
 testing/buildbot/APKBUILD          | 43 ++++++++++++++++++++++----------------
 testing/buildbot/buildmaster.initd | 17 ++++++++++++++-
 2 files changed, 41 insertions(+), 19 deletions(-)

diff --git a/testing/buildbot/APKBUILD b/testing/buildbot/APKBUILD
index f9d62dd10441..73ac3ddc12c8 100644
--- a/testing/buildbot/APKBUILD
+++ b/testing/buildbot/APKBUILD
@@ -13,42 +13,49 @@ depends="python py-twisted
 depends_dev=""
 makedepends="python-dev"
 install="${pkgname}.pre-install"
+BUILDBOT_USER=buildbot
+BUILDBOT_GROUP=buildbot
+pkgusers="$BUILDBOT_USER"
+pkggroups="$BUILDBOT_GROUP"
 subpackages=""
 source="https://pypi.python.org/packages/source/b/buildbot/buildbot-$pkgver.tar.gz
 	buildmaster.initd
 	buildmaster.confd"
 
-_builddir="$srcdir"/buildbot-$pkgver
+builddir="$srcdir"/$pkgname-$pkgver
+
 prepare() {
-	local i
-	cd "$_builddir"
-	for i in $source; do
-		case $i in
-		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
-		esac
-	done
+	default_prepare || return 1
 }
 
 build() {
-	cd "$_builddir"
+	cd "$builddir"
 	python setup.py build || return 1
 }
 
 package() {
-	cd "$_builddir"
-	python setup.py install --prefix=/usr --root="$pkgdir" || return 1
-        install -m755 -D "$srcdir"/buildmaster.initd \
-		"$pkgdir"/etc/init.d/buildmaster || return 1
-	install -m644 -D "$srcdir"/buildmaster.confd \
-		"$pkgdir"/etc/conf.d/buildmaster || return 1
+	cd "$builddir"
+	python setup.py install --prefix=/usr --root="$pkgdir" \
+		|| return 1
+	install -D -m 755 \
+	        "$srcdir"/buildmaster.initd \
+	        "$pkgdir"/etc/init.d/buildmaster \
+		|| return 1
+	install -D -m 644 \
+	        "$srcdir"/buildmaster.confd \
+	        "$pkgdir"/etc/conf.d/buildmaster \
+		|| return 1
+	install -d -o $BUILDBOT_USER -g $BUILDBOT_GROUP \
+	        "$pkgdir"/var/lib/buildmaster \
+		|| return 1
 }
 
 md5sums="b4c723d1e0324ea19511e622e420c6e7  buildbot-0.8.9.tar.gz
-8e175460da21111cb05c7c85fd8a0740  buildmaster.initd
+b8a4cd31065d2fcd305e76c9e4bd2103  buildmaster.initd
 b3cd43ecb53b66433e0384ad922ffde1  buildmaster.confd"
 sha256sums="6b9e465e6d4825fe1f09d28505318fdb1a75b283c80a140af0f2e2a5039cfa8a  buildbot-0.8.9.tar.gz
-ac3b4aeb9fc1447a53150f66d58baf3258d607577e7d34241ec1a86ff19c436e  buildmaster.initd
+ddc5b7c504702da9e7452d04070a65afb8f0ff9082b3f62e8dfcebc8c2e5256e  buildmaster.initd
 bb7f93e3867b32a25e2445a66d40573fa5073a80e73e35ae2a904db715f870c6  buildmaster.confd"
 sha512sums="5788b268689d8594592c2c5dc8c2d0178aca64c1816c7faa0181b446f8b657a4781dbb9a9d4ea0965ccfcd217dc485973fda01bf9d7cac638328dfef01959484  buildbot-0.8.9.tar.gz
-19d7c094b55c1444530b55694bbc64d5f49270df0b7a7103b67e498aa97666580fb263a488f8572d66eb83119ad3c9b1d28942d83faa874a70e032e1a50a1547  buildmaster.initd
+2e65d22f1b94433ba11839fb3434d072f9ff8132396b03fdcdb3b437778679d1699534296fbb851d2661a3a7a0bce4ef1f94c49e7910419557e4055f2ed1a4d5  buildmaster.initd
 d9339c30d3a92e92b41b0e3139ec89ecbd1460b0e4ee6c6fe2560c4307b2eb3f29b838c2f2312b9c7049bd95eaf652d09039227c691af805bc25a36999ec1840  buildmaster.confd"
diff --git a/testing/buildbot/buildmaster.initd b/testing/buildbot/buildmaster.initd
index 313365f3a676..05c1a10104e8 100644
--- a/testing/buildbot/buildmaster.initd
+++ b/testing/buildbot/buildmaster.initd
@@ -1,8 +1,9 @@
-#!/sbin/runscript
+#!/sbin/openrc-run
 # Copyright 1999-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 extra_started_commands="reload"
+extra_stopped_commands="create"
 
 depend() {
 	need net
@@ -52,3 +53,17 @@ reload() {
 		"${BASEDIR}"/buildmaster.pid
 	eend $?
 }
+
+create() {
+	if [ -e "${BASEDIR}"/buildbot.tac -o -e "${BASEDIR}"/master.cfg ]; then
+		eerror "${BASEDIR} already contains buildbot.tac or master.cfg"
+		return 1
+	fi
+	ebegin "Creating buildmaster in ${BASEDIR}"
+	start-stop-daemon -u "${USERNAME}" \
+		--exec /usr/bin/buildbot \
+		-- create-master -r "${BASEDIR}"
+	mv "${BASEDIR}"/master.cfg.sample "${BASEDIR}"/master.cfg
+	ewarn "Remember to customize exemplary master.cfg in ${BASEDIR}"
+	eend $?
+}
-- 
2.6.6

---

---

From: Przemyslaw Pawelczyk <[email-masked]>
Date: Fri, 17 Jun 2016 03:47:32 +0200

* buildslave.initd: Put openrc-run in shebang.

It has not been tested, as buildslave setup is a bit more complicated.
http://docs.buildbot.net/0.8.9/manual/installation.html#creating-a-buildslave
---
 testing/buildbot-slave/APKBUILD         | 43 +++++++++++++++++++--------------
 testing/buildbot-slave/buildslave.initd |  2 +-
 2 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/testing/buildbot-slave/APKBUILD b/testing/buildbot-slave/APKBUILD
index 959da40b6def..b8cdcacc9697 100644
--- a/testing/buildbot-slave/APKBUILD
+++ b/testing/buildbot-slave/APKBUILD
@@ -11,42 +11,49 @@ depends="python py-twisted"
 depends_dev=""
 makedepends="python-dev py-setuptools"
 install="buildbot-slave.pre-install"
+BUILDBOT_USER=buildbot
+BUILDBOT_GROUP=buildbot
+pkgusers="$BUILDBOT_USER"
+pkggroups="$BUILDBOT_GROUP"
 subpackages=""
 source="https://pypi.python.org/packages/source/b/buildbot-slave/buildbot-slave-$pkgver.tar.gz
 	buildslave.initd
 	buildslave.confd"
 
-_builddir="$srcdir"/buildbot-slave-$pkgver
+builddir="$srcdir"/$pkgname-$pkgver
+
 prepare() {
-	local i
-	cd "$_builddir"
-	for i in $source; do
-		case $i in
-		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
-		esac
-	done
+	default_prepare || return 1
 }
 
 build() {
-	cd "$_builddir"
+	cd "$builddir"
 
 package() {
-	cd "$_builddir"
-	python setup.py install --prefix=/usr --root="$pkgdir" || return 1
-        install -m755 -D "$srcdir"/buildslave.initd \
-		"$pkgdir"/etc/init.d/buildslave || return 1
-	install -m644 -D "$srcdir"/buildslave.confd \
-		"$pkgdir"/etc/conf.d/buildslave || return 1
+	cd "$builddir"
+	python setup.py install --prefix=/usr --root="$pkgdir" \
+		|| return 1
+	install -D -m 755 \
+	        "$srcdir"/buildslave.initd \
+	        "$pkgdir"/etc/init.d/buildslave \
+		|| return 1
+	install -D -m 644 \
+	        "$srcdir"/buildslave.confd \
+	        "$pkgdir"/etc/conf.d/buildslave \
+		|| return 1
+	install -d -o $BUILDBOT_USER -g $BUILDBOT_GROUP \
+	        "$pkgdir"/var/lib/buildslave \
+		|| return 1
 }
 
 md5sums="b4c085dcad558b61af5233d1ea1ed750  buildbot-slave-0.8.9.tar.gz
-2247778c260d7d14745d1fed9d44e84e  buildslave.initd
+6a07c39a20fd2de62eeac38332fc5ec4  buildslave.initd
 3baaa33c0bc00e0fb6784f8c41482488  buildslave.confd"
 sha256sums="864ca4a975bdbe3e973812a7d4ac7ffaf6f9ea5b6364e9ddb2fc92bccacf93af  buildbot-slave-0.8.9.tar.gz
-9f4c8d6946ebda59966256856a58dc0eae8581aa072dc0a018fe2f6b50af4170  buildslave.initd
+5c3247e53ae214b4c1913e8eccbf7c43f8707ec217deb1f4ec6bec4f351fbf09  buildslave.initd
 c324eee07561afd8be623b46cd8f50cbbac5f1e42f2c493aa75dbaace6dcfa6f  buildslave.confd"
 sha512sums="3cc6b0cafe752fcfe5b91b70faff249cffb2dbfc03274cccffccd739ec448b66986db171924d14ba4de85e843b2f67a36650bcb965f600ec1dd8278f6198a283  buildbot-slave-0.8.9.tar.gz
-b891240feaea7e96f5912f87ad88e45b9a877a1cb48d4dcac701f76ff5df212de52b84e5319df1d5064bce0c8aaf1ceac4af9b81d0fdb57a3840c6aefe0a3d6f  buildslave.initd
+217a9e3f774bcc7e7773d6e3047dbbabe196d168f814485ae54d1a94b330616fd80ad82bfa67c9b6185c39b780eae7a71776e727810ff4df337baca44d5fdbda  buildslave.initd
 54fc03a82cebf874c18d1bd739a6640677cfcd540b47a9929e6f5d63a83bd64bee615b033a72b49ab5fa3da69b16ff657805392ab0a68e0d33e48581fc8bb017  buildslave.confd"
diff --git a/testing/buildbot-slave/buildslave.initd b/testing/buildbot-slave/buildslave.initd
index 17e22abdc7cb..587c7ccb3bb5 100644
--- a/testing/buildbot-slave/buildslave.initd
+++ b/testing/buildbot-slave/buildslave.initd
@@ -1,4 +1,4 @@
-#!/sbin/runscript
+#!/sbin/openrc-run
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-- 
2.6.6

---

---

From: Przemyslaw Pawelczyk <[email-masked]>
Date: Fri, 17 Jun 2016 03:47:33 +0200

* 2811e023bc75 testing/[various]: Add group and use it as primary in .pre-* scripts.
testing/buildbot-slave/buildbot-slave.pre-install
testing/buildbot/buildbot.pre-install
testing/clapf/clapf.pre-install

* c9dca511744b testing/clapf: Fix a lot of problems.
testing/clapf/APKBUILD
testing/clapf/clapf.confd
testing/clapf/clapf.initd
testing/clapf/clapf.pre-install
testing/clapf/ldflags.patch

* d36d9cd0a06e testing/buildbot: Fix some stuff.
testing/buildbot/APKBUILD
testing/buildbot/buildmaster.initd

* 15023743c545 testing/buildbot-slave: Fix some stuff.
testing/buildbot-slave/APKBUILD
testing/buildbot-slave/buildslave.initd
---
 testing/buildbot-slave/APKBUILD | 2 +-
 testing/buildbot/APKBUILD       | 2 +-
 testing/clapf/APKBUILD          | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/testing/buildbot-slave/APKBUILD b/testing/buildbot-slave/APKBUILD
index b8cdcacc9697..71c5187ad3b5 100644
--- a/testing/buildbot-slave/APKBUILD
+++ b/testing/buildbot-slave/APKBUILD
@@ -2,7 +2,7 @@
 # Maintainer:
 pkgname=buildbot-slave
 pkgver=0.8.9
-pkgrel=1
+pkgrel=2
 pkgdesc="Buildbot slave daemon"
 url="http://buildbot.net/"
 arch="noarch"
diff --git a/testing/buildbot/APKBUILD b/testing/buildbot/APKBUILD
index 73ac3ddc12c8..5926ddf553e1 100644
--- a/testing/buildbot/APKBUILD
+++ b/testing/buildbot/APKBUILD
@@ -2,7 +2,7 @@
 # Maintainer:
 pkgname=buildbot
 pkgver=0.8.9
-pkgrel=1
+pkgrel=2
 pkgdesc="Continuous integration testing framework"
 url="http://buildbot.net/"
 arch="noarch"
diff --git a/testing/clapf/APKBUILD b/testing/clapf/APKBUILD
index efc2438be21d..df7cc0d57f41 100644
--- a/testing/clapf/APKBUILD
+++ b/testing/clapf/APKBUILD
@@ -2,7 +2,7 @@
 # Maintainer:
 pkgname=clapf
 pkgver=0.4.7.4
-pkgrel=1
+pkgrel=2
 pkgdesc="clapf is an open source email content filter application"
 url="http://clapf.org"
 arch="all"
-- 
2.6.6

---