Mail archive
alpine-aports

[alpine-aports] [PATCH 3/9] main/s6: start a supervision tree in /run/service when installed, make doc package

From: Laurent Bercot <ska-devel_at_skarnet.org>
Date: Fri, 4 Nov 2016 19:16:35 +0100

---
 main/s6/APKBUILD          | 20 +++++++++++++-------
 main/s6/s6-svscanboot     | 40 ++++++++++++++++++++++++++++++++++++++++
 main/s6/s6.post-deinstall |  6 ++++++
 main/s6/s6.post-install   | 11 +++++++++++
 main/s6/s6.post-upgrade   | 11 +++++++++++
 main/s6/s6.pre-deinstall  |  9 +++++++++
 main/s6/s6.pre-install    |  5 +++++
 main/s6/s6.pre-upgrade    |  5 +++++
 main/s6/s6.trigger        |  3 +++
 9 files changed, 103 insertions(+), 7 deletions(-)
 create mode 100644 main/s6/s6-svscanboot
 create mode 100644 main/s6/s6.post-deinstall
 create mode 100644 main/s6/s6.post-install
 create mode 100644 main/s6/s6.post-upgrade
 create mode 100644 main/s6/s6.pre-deinstall
 create mode 100644 main/s6/s6.pre-install
 create mode 100644 main/s6/s6.pre-upgrade
 create mode 100644 main/s6/s6.trigger
diff --git a/main/s6/APKBUILD b/main/s6/APKBUILD
index 0c087af..0fb607a 100644
--- a/main/s6/APKBUILD
+++ b/main/s6/APKBUILD
_at_@ -2,17 +2,18 @@
 # Contributor: John Regan <john_at_jrjrtech.com>
 pkgname=s6
 pkgver=2.4.0.0
-pkgrel=0
+pkgrel=1
 pkgdesc="skarnet.org's small & secure supervision software suite."
 url="http://skarnet.org/software/$pkgname/"
 arch="all"
 license="ISC"
 depends="skalibs execline"
 depends_dev="skalibs-dev execline-dev"
-makedepends="$depends_dev"
-install=""
+makedepends="skalibs-dev execline-dev"
+install="$pkgname.pre-install $pkgname.pre-upgrade $pkgname.pre-deinstall $pkgname.post-install $pkgname.post-upgrade $pkgname.post-deinstall"
+triggers="s6.trigger=/run/service"
 subpackages="$pkgname-dev $pkgname-doc"
-source="http://skarnet.org/software/$pkgname/$pkgname-$pkgver.tar.gz"
+source="http://skarnet.org/software/$pkgname/$pkgname-$pkgver.tar.gz s6-svscanboot"
 
 _builddir="$srcdir/$pkgname-$pkgver"
 prepare() {
_at_@ -41,6 +42,8 @@ build() {
 package() {
 	cd "$_builddir"
 	make DESTDIR="$pkgdir" install || return 1
+	cp -f "$srcdir/s6-svscanboot" "$pkgdir/lib/$pkgname/"
+	chmod 0755 "$pkgdir/lib/$pkgname/s6-svscanboot"
 }
 
 doc() {
_at_@ -49,6 +52,9 @@ doc() {
 	cp -a "$_builddir/doc" "$subpkgdir/usr/share/doc/$pkgname"
 }
 
-md5sums="d43d82d23ba2f4a00435648298bccc28  s6-2.4.0.0.tar.gz"
-sha256sums="5e788d5935dbcce76ac9a99cfcf6ee46a2ffb84220c84225df7589e9a3585560  s6-2.4.0.0.tar.gz"
-sha512sums="bd294fd6ec6bd5b696c52f8ef43de278a82d2b5ec4bcea3f32ab45f15b22b33633210f38709c1e736bab8ac4c560af6a307b2617709adfc8d5f9c0bce329dff2  s6-2.4.0.0.tar.gz"
+md5sums="d43d82d23ba2f4a00435648298bccc28  s6-2.4.0.0.tar.gz
+2b94208da23b0e4f93e48414b991eeef  s6-svscanboot"
+sha256sums="5e788d5935dbcce76ac9a99cfcf6ee46a2ffb84220c84225df7589e9a3585560  s6-2.4.0.0.tar.gz
+d80ce5c38ed48550316cd84fcbba497fdfa9ce4f6d30dda8f82e6b8c7705fdac  s6-svscanboot"
+sha512sums="bd294fd6ec6bd5b696c52f8ef43de278a82d2b5ec4bcea3f32ab45f15b22b33633210f38709c1e736bab8ac4c560af6a307b2617709adfc8d5f9c0bce329dff2  s6-2.4.0.0.tar.gz
+4b1d236e91620fd8627564a691744531778fdd7f58b43c9af316357301761b25fa28b47c228f9e030b54fa10b81195f96cf777e1a0ee59f8cc455309060a8021  s6-svscanboot"
diff --git a/main/s6/s6-svscanboot b/main/s6/s6-svscanboot
new file mode 100644
index 0000000..a7542a4
--- /dev/null
+++ b/main/s6/s6-svscanboot
_at_@ -0,0 +1,40 @@
+#!/bin/execlineb -S1
+
+if
+{
+  if -t { redirfd -w 2 /dev/null mkdir /run/uncaught-logs }
+  if { chown catchlog:catchlog /run/uncaught-logs }
+  chmod 2700 /run/uncaught-logs
+}
+
+if
+{
+  if -t { redirfd -w 2 /dev/null mkdir ${1} }
+  if { mkdir ${1}/.s6-svscan ${1}/s6-svscan-log }
+  if { ln -s /bin/false ${1}/.s6-svscan/crash }
+  if
+  {
+    redirfd -w 1 ${1}/.s6-svscan/finish
+    heredoc 0 "#!/bin/execlineb -P\nsleep 1\n"
+    cat
+  }
+  if { chmod 0755 ${1}/.s6-svscan/finish }
+  if { mkfifo -m 0600 ${1}/s6-svscan-log/fifo }
+  if
+  {
+    redirfd -w 1 ${1}/s6-svscan-log/run
+    heredoc 0 "#!/bin/execlineb -P
+redirfd -w 2 /dev/console
+redirfd -rnb 0 fifo
+s6-setuidgid catchlog
+exec -c
+s6-log t /run/uncaught-logs\n"
+    cat
+  }
+  chmod 0755 ${1}/s6-svscan-log/run
+}
+
+redirfd -r 0 /dev/null
+redirfd -wnb 1 ${1}/s6-svscan-log/fifo
+fdmove -c 2 1
+s6-svscan -St0 ${1}
diff --git a/main/s6/s6.post-deinstall b/main/s6/s6.post-deinstall
new file mode 100644
index 0000000..065e0c6
--- /dev/null
+++ b/main/s6/s6.post-deinstall
_at_@ -0,0 +1,6 @@
+#!/bin/sh
+
+rm -rf /run/service /run/uncaught-logs
+deluser catchlog
+delgroup catchlog
+exit 0
diff --git a/main/s6/s6.post-install b/main/s6/s6.post-install
new file mode 100644
index 0000000..84a8b04
--- /dev/null
+++ b/main/s6/s6.post-install
_at_@ -0,0 +1,11 @@
+#!/bin/sh
+
+if grep -qFx "::respawn:/lib/s6/s6-svscanboot /run/service" < /etc/inittab ; then
+  :
+else
+  cat >> /etc/inittab <<EOF
+# Launch and supervise s6-svscan
+::respawn:/lib/s6/s6-svscanboot /run/service
+EOF
+  kill -HUP 1
+fi
diff --git a/main/s6/s6.post-upgrade b/main/s6/s6.post-upgrade
new file mode 100644
index 0000000..84a8b04
--- /dev/null
+++ b/main/s6/s6.post-upgrade
_at_@ -0,0 +1,11 @@
+#!/bin/sh
+
+if grep -qFx "::respawn:/lib/s6/s6-svscanboot /run/service" < /etc/inittab ; then
+  :
+else
+  cat >> /etc/inittab <<EOF
+# Launch and supervise s6-svscan
+::respawn:/lib/s6/s6-svscanboot /run/service
+EOF
+  kill -HUP 1
+fi
diff --git a/main/s6/s6.pre-deinstall b/main/s6/s6.pre-deinstall
new file mode 100644
index 0000000..9d44c6f
--- /dev/null
+++ b/main/s6/s6.pre-deinstall
_at_@ -0,0 +1,9 @@
+#!/bin/sh -e
+
+stamp=`echo | /bin/s6-tai64n`
+tmp=/tmp/inittab.$$.${stamp%% }
+grep -vFx -e '# Launch and supervise s6-svscan' -e '::respawn:/lib/s6/s6-svscanboot /run/service' < /etc/inittab > "$tmp" || true
+mv -f "$tmp" /etc/inittab
+s6-svc -X /run/service/s6-svscan-log || true
+s6-svscanctl -q /run/service || true
+kill -HUP 1
diff --git a/main/s6/s6.pre-install b/main/s6/s6.pre-install
new file mode 100644
index 0000000..6d9b6d5
--- /dev/null
+++ b/main/s6/s6.pre-install
_at_@ -0,0 +1,5 @@
+#!/bin/sh
+
+addgroup -S catchlog 2>/dev/null
+adduser -S -D -H -s /bin/false -G catchlog -g catchlog catchlog 2>/dev/null
+exit 0
diff --git a/main/s6/s6.pre-upgrade b/main/s6/s6.pre-upgrade
new file mode 100644
index 0000000..6d9b6d5
--- /dev/null
+++ b/main/s6/s6.pre-upgrade
_at_@ -0,0 +1,5 @@
+#!/bin/sh
+
+addgroup -S catchlog 2>/dev/null
+adduser -S -D -H -s /bin/false -G catchlog -g catchlog catchlog 2>/dev/null
+exit 0
diff --git a/main/s6/s6.trigger b/main/s6/s6.trigger
new file mode 100644
index 0000000..8db8d9a
--- /dev/null
+++ b/main/s6/s6.trigger
_at_@ -0,0 +1,3 @@
+#!/bin/execlineb -P
+
+s6-svscanctl -aN /run/service
-- 
2.8.3
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Fri Nov 04 2016 - 19:16:35 GMT