summaryrefslogtreecommitdiff
path: root/system/s6-linux-init
diff options
context:
space:
mode:
Diffstat (limited to 'system/s6-linux-init')
-rw-r--r--system/s6-linux-init/APKBUILD116
-rw-r--r--system/s6-linux-init/rc.init9
-rw-r--r--system/s6-linux-init/rc.shutdown3
-rw-r--r--system/s6-linux-init/reboot.sh21
-rw-r--r--system/s6-linux-init/runlevel5
-rw-r--r--system/s6-linux-init/s6-linux-init-common.post-upgrade5
-rw-r--r--system/s6-linux-init/s6-linux-init-common.pre-deinstall5
-rw-r--r--system/s6-linux-init/s6-linux-init.post-install25
-rw-r--r--system/s6-linux-init/s6-linux-init.post-upgrade5
-rw-r--r--system/s6-linux-init/s6-linux-init.pre-deinstall5
10 files changed, 199 insertions, 0 deletions
diff --git a/system/s6-linux-init/APKBUILD b/system/s6-linux-init/APKBUILD
new file mode 100644
index 000000000..70f8bbefa
--- /dev/null
+++ b/system/s6-linux-init/APKBUILD
@@ -0,0 +1,116 @@
+# Contributor: Laurent Bercot <ska-adelie@skarnet.org>
+# Maintainer: Laurent Bercot <ska-adelie@skarnet.org>
+pkgname=s6-linux-init
+pkgver=1.0.1.0
+pkgrel=0
+pkgdesc="A s6-based init system"
+url="https://skarnet.org/software/$pkgname/"
+arch="all"
+options="!check" # No test suite.
+license="ISC"
+_skalibs_version=2.8.1.0
+depends="execline s6 s6-linux-init-common"
+makedepends="skalibs-dev>=$_skalibs_version execline-dev s6-dev utmps-dev"
+subpackages="$pkgname-common:common:noarch $pkgname-libs $pkgname-dev $pkgname-libs-dev:libsdev $pkgname-doc"
+source="https://skarnet.org/software/$pkgname/$pkgname-$pkgver.tar.gz rc.init runlevel rc.shutdown reboot.sh"
+install="$pkgname.post-install $pkgname.post-upgrade $pkgname.pre-deinstall"
+provides="/sbin/init=0"
+
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --enable-shared \
+ --enable-static \
+ --enable-allstatic \
+ --enable-static-libc \
+ --libdir=/usr/lib \
+ --libexecdir="/lib/$pkgname" \
+ --with-dynlib=/lib \
+ --enable-utmps
+ make
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+
+ for i in rc.init runlevel rc.shutdown ; do
+ cp -f "$srcdir/$i" "$pkgdir/etc/s6-linux-init/skel/"
+ chmod 0755 "$pkgdir/etc/s6-linux-init/skel/$i"
+ done
+
+ # static binaries don't work under fakeroot, so build a dynamic one just for us
+ touch src/init/s6-linux-init-maker.o
+ make s6-linux-init-maker LDFLAGS_NOSHARED=""
+
+ ./s6-linux-init-maker \
+ -u catchlog \
+ -1 \
+ -L \
+ -p "/usr/bin:/usr/sbin:/bin:/sbin" \
+ -m 022 \
+ -s /run/kernel_env \
+ -f "$pkgdir/etc/s6-linux-init/skel" \
+ -U "" \
+ "$pkgdir/etc/s6-linux-init/current"
+ mkdir -p -m 0755 "$pkgdir/sbin" "$pkgdir/etc/runlevels/empty" "$pkgdir/etc/sysctl.d"
+ echo 'kernel.ctrl-alt-del = 0' > "$pkgdir/etc/sysctl.d/ctrlaltdel.conf"
+ for i in init halt poweroff reboot shutdown telinit ; do
+ ln -sf "../etc/s6-linux-init/current/bin/$i" "$pkgdir/sbin/$i"
+ done
+}
+
+
+common() {
+ pkgdesc="Files for an s6 supervision tree, common to s6-linux-init and sysvinit"
+ depends="execline s6"
+ runimg="$pkgdir/etc/s6-linux-init/current/run-image"
+ subrunimg="$subpkgdir/etc/s6-linux-init/current/run-image"
+ install="$subpkgname.post-upgrade $subpkgname.pre-deinstall"
+ mkdir -p -m 0755 "$subrunimg/service/.s6-svscan" "$subrunimg/service/s6-svscan-log" "$subpkgdir/usr/share/s6-linux-init-common"
+ mv "$runimg/uncaught-logs" "$subrunimg/"
+ mv "$runimg/service/s6-svscan-log" "$subrunimg/service/"
+ mkdir -m 0755 "$runimg/service/s6-svscan-log"
+ mv "$subrunimg/service/s6-svscan-log/run" "$runimg/service/s6-svscan-log/"
+ cp -f "$srcdir/reboot.sh" "$subpkgdir/usr/share/s6-linux-init-common/"
+}
+
+
+libs() {
+ pkgdesc="$pkgdesc (shared libraries)"
+ depends="skalibs-libs>=$_skalibs_version"
+ mkdir -p "$subpkgdir/lib"
+ mv "$pkgdir"/lib/*.so.* "$subpkgdir/lib/"
+}
+
+
+dev() {
+ pkgdesc="$pkgdesc (development files)"
+ depends="skalibs-dev>=$_skalibs_version"
+ mkdir -p "$subpkgdir/usr"
+ mv "$pkgdir/usr/lib" "$pkgdir/usr/include" "$subpkgdir/usr/"
+}
+
+
+libsdev() {
+ pkgdesc="$pkgdesc (development files for dynamic linking)"
+ depends="$pkgname-dev"
+ mkdir -p "$subpkgdir/lib"
+ mv "$pkgdir"/lib/*.so "$subpkgdir/lib/"
+}
+
+
+doc() {
+ pkgdesc="$pkgdesc (documentation)"
+ depends=
+ install_if="docs $pkgname=$pkgver-r$pkgrel"
+ mkdir -p "$subpkgdir/usr/share/doc"
+ cp -a "$builddir/doc" "$subpkgdir/usr/share/doc/$pkgname"
+}
+
+sha512sums="0b40601b25f88464b5ff63b7eddf6ffa30eb868d2d9652f3d6a608b8f508e46712214d6e674f74136e57dd4504eb71ef585c725ba1a6566cfc0a025e70cfadc9 s6-linux-init-1.0.1.0.tar.gz
+756b0cbbe5dabb4631380c3c7ea199cc213224b2e36e50a2d012a61948170078b78bf49b85d886319fecf59843087f937d3d804723b2553ac9f94d088a2f0fd8 rc.init
+e73c3c32b118831074288d23fadace2158a2b15d5a13ffa73290b92a9e39c2a21c73d3b0eabea29bcbaa5f6381611fd8d0aaa6aa691ec7de91b8ef6ae404b6da runlevel
+7bb050248a5c2ab6a56c50c35f87cde724f97ff9882f5e60b0f0f2f14bd93c1df7d99fedc3d81c8519cf1a1ed90e03f1cbb9bf891c7b3618aa9a5f5738d262f4 rc.shutdown
+de702d3a221993cd3192dae4544842402dfbe362bcc4105f3071df15eb0aa6c218bf401bbf221298ee063f6545fe909fd54abf1d1e9222e13bcdc9a29f9a2b19 reboot.sh"
diff --git a/system/s6-linux-init/rc.init b/system/s6-linux-init/rc.init
new file mode 100644
index 000000000..f96ed4d5e
--- /dev/null
+++ b/system/s6-linux-init/rc.init
@@ -0,0 +1,9 @@
+#!/bin/sh -e
+
+rl="$1"
+shift
+
+/sbin/openrc sysinit
+/sbin/openrc boot
+
+exec /etc/s6-linux-init/current/scripts/runlevel "$rl"
diff --git a/system/s6-linux-init/rc.shutdown b/system/s6-linux-init/rc.shutdown
new file mode 100644
index 000000000..6fa64f6bc
--- /dev/null
+++ b/system/s6-linux-init/rc.shutdown
@@ -0,0 +1,3 @@
+#!/bin/sh -e
+
+exec /sbin/openrc empty
diff --git a/system/s6-linux-init/reboot.sh b/system/s6-linux-init/reboot.sh
new file mode 100644
index 000000000..d0d87aeb6
--- /dev/null
+++ b/system/s6-linux-init/reboot.sh
@@ -0,0 +1,21 @@
+#!/bin/sh -e
+
+# This script performs a "poor man's reboot" when the
+# init infrastructures are not there to do a proper one.
+# This is the case when the user *just* switched between
+# sysvinit and s6-linux-init, and needs to shut down the
+# old system but the shutdown binaries are the ones from
+# the new system.
+#
+# Always launch it from a console tty (tty1, ... tty6),
+# never from a network terminal or an xterm.
+
+trap "" INT HUP TERM
+mkdir -p -m 0755 /etc/runlevels/empty2
+/sbin/openrc empty2
+rmdir /etc/runlevels/empty2
+sync
+/etc/init.d/killprocs start
+/etc/init.d/savecache start
+/etc/init.d/mount-ro start
+/sbin/reboot -f
diff --git a/system/s6-linux-init/runlevel b/system/s6-linux-init/runlevel
new file mode 100644
index 000000000..f34018ea2
--- /dev/null
+++ b/system/s6-linux-init/runlevel
@@ -0,0 +1,5 @@
+#!/bin/sh -e
+
+test "$#" -gt 0 || { echo 'runlevel: fatal: too few arguments' 1>&2 ; exit 100 ; }
+
+exec /sbin/openrc "$1"
diff --git a/system/s6-linux-init/s6-linux-init-common.post-upgrade b/system/s6-linux-init/s6-linux-init-common.post-upgrade
new file mode 100644
index 000000000..335559a3c
--- /dev/null
+++ b/system/s6-linux-init/s6-linux-init-common.post-upgrade
@@ -0,0 +1,5 @@
+#!/bin/sh -e
+
+# apk does not handle fifos correctly.
+
+exec rm -f /etc/s6-linux-init/current/run-image/service/s6-svscan-log/fifo.apk-new
diff --git a/system/s6-linux-init/s6-linux-init-common.pre-deinstall b/system/s6-linux-init/s6-linux-init-common.pre-deinstall
new file mode 100644
index 000000000..691e2cca0
--- /dev/null
+++ b/system/s6-linux-init/s6-linux-init-common.pre-deinstall
@@ -0,0 +1,5 @@
+#!/bin/sh -e
+
+# apk does not handle fifos correctly.
+
+exec rm -f /etc/s6-linux-init/current/run-image/service/s6-svscan-log/fifo
diff --git a/system/s6-linux-init/s6-linux-init.post-install b/system/s6-linux-init/s6-linux-init.post-install
new file mode 100644
index 000000000..8e24f6d42
--- /dev/null
+++ b/system/s6-linux-init/s6-linux-init.post-install
@@ -0,0 +1,25 @@
+#!/bin/sh -e
+
+newv="$1"
+oldv="$2"
+
+cat <<EOF
+
+*
+* You installed the s6-linux-init package. If it's your first installation,
+* please ignore this message. But if you just removed the sysvinit
+* package in order to use s6-linux-init instead, please read on.
+*
+* In order to complete the switch, you need to reboot your machine. But
+* beware: just for this time, the usual shutdown commands won't work,
+* because they are designed to work with s6-linux-init but you are still
+* running sysvinit until you reboot. So, for your next reboot (and
+* only this one), the command you will need to run (as root, FROM A
+* CONSOLE TTY - not an xterm, not a network connection) is:
+*
+* /bin/sh /usr/share/s6-linux-init-common/reboot.sh
+*
+* Please save your work and perform that reboot as soon as you can.
+*
+
+EOF
diff --git a/system/s6-linux-init/s6-linux-init.post-upgrade b/system/s6-linux-init/s6-linux-init.post-upgrade
new file mode 100644
index 000000000..322de1e6b
--- /dev/null
+++ b/system/s6-linux-init/s6-linux-init.post-upgrade
@@ -0,0 +1,5 @@
+#!/bin/sh -e
+
+# apk does not handle fifos correctly.
+
+exec rm -f /etc/s6-linux-init/current/run-image/service/s6-linux-init-shutdownd/fifo.apk-new
diff --git a/system/s6-linux-init/s6-linux-init.pre-deinstall b/system/s6-linux-init/s6-linux-init.pre-deinstall
new file mode 100644
index 000000000..bc72c70a0
--- /dev/null
+++ b/system/s6-linux-init/s6-linux-init.pre-deinstall
@@ -0,0 +1,5 @@
+#!/bin/sh -e
+
+# apk does not handle fifos correctly.
+
+exec rm -f /etc/s6-linux-init/current/run-image/service/s6-linux-init-shutdownd/fifo