diff options
author | Laurent Bercot <ska-adelie@skarnet.org> | 2019-05-28 16:49:42 +0000 |
---|---|---|
committer | Laurent Bercot <ska-adelie@skarnet.org> | 2019-05-28 16:49:42 +0000 |
commit | 0b82d071e1d6c87e54e38b8ff5ecd3fb1c5a0c6e (patch) | |
tree | 857bb98173718d5ac1ab9fae804cf11677547c55 /system/sysvinit | |
parent | 2f010c77dd84a08136edf3b38dd5974c6f0b750b (diff) | |
download | packages-0b82d071e1d6c87e54e38b8ff5ecd3fb1c5a0c6e.tar.gz packages-0b82d071e1d6c87e54e38b8ff5ecd3fb1c5a0c6e.tar.bz2 packages-0b82d071e1d6c87e54e38b8ff5ecd3fb1c5a0c6e.tar.xz packages-0b82d071e1d6c87e54e38b8ff5ecd3fb1c5a0c6e.zip |
system/s6-linux-init: new package = new init system
This commit touches lots of things at once: it is necessary in order
to maintain consistency. The impacted packages are:
- s6-linux-init: new package. s6-linux-init mechanism plus
booting policy. s6-linux-init conflicts with sysvinit; you can
have one or the other, depending on what init you want to boot on.
* s6-linux-init-common: subpackage of s6-linux-init, containing
files used in the s6 supervision tree in both init cases.
Both s6-linux-init and sysvinit depend on s6-linux-init-common.
- s6: removed s6-svscanboot, which is policy, and only used
in the sysvinit case. The s6 package is pure mechanism now.
- utmps: adapted to the new location of the supervision tree, and
reliable files provided by s6-linux-init-common. It works as is
with both init systems.
- gettys-openrc: had to move its invocation from "openrc sysinit"
to "openrc default", because you can't make early gettys with
s6-linux-init (no control over stage 1), and you can't have a
supervision tree before sysinit with sysvinit (because /run is
mounted very late, in boot), so the only solution that works with
both is to make gettys late services.
- sysvinit: now has s6-svscanboot (starting the s6 supervision
tree from inittab), and a carefully crafted inittab that should
work in all cases. Getting the right order of inittab lines was
NOT easy, and I now hate sysvinit even more than I did before.
Note that with the current version of apk, you cannot switch from
sysvinit to s6-linux-init, or vice-versa, without an error. apk
says files conflict. Because it adds the new files before removing
the old ones. It should still work with apk -f, because the
.apk-new mechanism makes it so that there's no real collision while
you're switching, but it's still ugly as fuck and needs to be fixed
in apk before we make the switch available to users.
Diffstat (limited to 'system/sysvinit')
-rw-r--r-- | system/sysvinit/APKBUILD | 29 | ||||
-rw-r--r-- | system/sysvinit/inittab-2.88 | 20 | ||||
-rw-r--r-- | system/sysvinit/s6-svscanboot | 15 | ||||
-rw-r--r-- | system/sysvinit/sysvinit.post-install | 25 |
4 files changed, 76 insertions, 13 deletions
diff --git a/system/sysvinit/APKBUILD b/system/sysvinit/APKBUILD index d282e1e01..b95525084 100644 --- a/system/sysvinit/APKBUILD +++ b/system/sysvinit/APKBUILD @@ -2,21 +2,22 @@ # Maintainer: A. Wilcox <awilfox@adelielinux.org> pkgname=sysvinit pkgver=2.88 -pkgrel=5 +pkgrel=6 pkgdesc="System V-style init programs" url="https://savannah.nongnu.org/projects/sysvinit" arch="all" license="GPL-2.0+" -depends="s6" +depends="s6-linux-init-common" makedepends="linux-headers utmps-dev" -install="sysvinit.post-upgrade" +install="sysvinit.post-upgrade sysvinit.post-install" options="!check" -provides="/sbin/init" +provides="/sbin/init=0" subpackages="$pkgname-doc" source="https://download.savannah.nongnu.org/releases/sysvinit/sysvinit-${pkgver}dsf.tar.bz2 inittab-2.88 sysvinit-2.88-posix-header.patch utmpx.patch + s6-svscanboot " builddir="$srcdir/sysvinit-${pkgver}dsf" @@ -49,14 +50,30 @@ build() { make -C src } +_install_s6_stuff() +{ + svcimg="$pkgdir/etc/s6-linux-init/current/run-image/service" + mkdir -p -m 0755 "$pkgdir/sbin" "$svcimg/.s6-svscan" "$svcimg/s6-svscan-log" + { echo '#!/bin/execlineb -P' ; echo 'false' ; } > "$svcimg/.s6-svscan/crash" + chmod 0755 "$svcimg/.s6-svscan/crash" + { echo '#!/bin/execlineb -P' ; echo 's6-svc -X -- /run/service/s6-svscan-log' ; } > "$svcimg/.s6-svscan/finish" + chmod 0755 "$svcimg/.s6-svscan/finish" + { echo '#!/bin/execlineb -P' ; echo 'redirfd -rnb 0 fifo' ; echo 's6-setuidgid catchlog' ; echo 's6-log -bd3 -- t /run/uncaught-logs' ; } > "$svcimg/s6-svscan-log/run" + chmod 0755 "$svcimg/s6-svscan-log/run" + install -D -m 0755 "$srcdir"/s6-svscanboot "$pkgdir/sbin/s6-svscanboot" +} + package() { cd "$builddir" make -C src install ROOT="$pkgdir" rm "$pkgdir"/usr/bin/lastb || true install -D -m644 "$srcdir"/inittab-2.88 "$pkgdir"/etc/inittab + _install_s6_stuff } + sha512sums="0bd8eeb124e84fdfa8e621b05f796804ee69a9076b65f5115826bfa814ac1d5d28d31a5c22ebe77c86a93b2288edf4891adc0afaecc4de656c4ecda8a83807bf sysvinit-2.88dsf.tar.bz2 -52d301225bf0cb0c4d124d205cf3a1e1f4eca21a69179da4882359f79606562354fddf887da8203129bede1d073efa9cdd8fe84a327b51229248b22240b9d5dd inittab-2.88 +87668b49690091a227c0384fd2400f1006d24c27cc27a25efa7eba56839ccb1eead00b58ce4b654eab9c0208d68aa2cbb888fd5f2990905845aa9688442a69a0 inittab-2.88 27dfe089660a291cbcba06d8564bad11f7fd7c96629e72c2b005562689dc7d8bb479c760e980590906e98423b991ae0acd048713d3bc372174d55ed894abeb3f sysvinit-2.88-posix-header.patch -3605f88ac3faf7d12bf2269ca5d8625850d53e8583b573ab280fa17066c8e4e5217a0d17b94e47ea67a153ad3b88b433471a77544bd085f01f7d9d353ac16aae utmpx.patch" +3605f88ac3faf7d12bf2269ca5d8625850d53e8583b573ab280fa17066c8e4e5217a0d17b94e47ea67a153ad3b88b433471a77544bd085f01f7d9d353ac16aae utmpx.patch +30fc01b99350d9cb9e2d430f32c357fce571864e618f25fc2c82199f0ae36f3d81316b175af37ff779c0ef26780452877ff0355b3ea47e2ef4eadc823d085e98 s6-svscanboot" diff --git a/system/sysvinit/inittab-2.88 b/system/sysvinit/inittab-2.88 index e96205a06..f170042cf 100644 --- a/system/sysvinit/inittab-2.88 +++ b/system/sysvinit/inittab-2.88 @@ -16,30 +16,36 @@ # Default runlevel. id:3:initdefault: -# System initialization, mount local filesystems, etc. +# Early system initialization. si::sysinit:/sbin/openrc sysinit -# Further system initialization, brings up the boot runlevel. +# Further system initialization. +# The distinction between sysinit and boot is totally arbitrary. +# With the current OpenRC, sysinit does almost nothing and boot +# does almost everything. rc::bootwait:/sbin/openrc boot +# Start the s6 supervision tree. +s6:12345:respawn:/sbin/s6-svscanboot + +# Wait for the supervision tree to be operational before launching services. +s6n:12345:wait:/bin/sh -c 'until test -s /run/s6_ready ; do sleep 1 ; done' + l0:0:wait:/sbin/openrc shutdown -l0s:0:wait:/sbin/halt -hnp +l0s:0:wait:/sbin/poweroff -df l1:1:wait:/sbin/openrc single l2:2:wait:/sbin/openrc nonetwork l3:3:wait:/sbin/openrc default l4:4:wait:/sbin/openrc default l5:5:wait:/sbin/openrc default l6:6:wait:/sbin/openrc reboot -l6r:6:wait:/sbin/reboot -fin +l6r:6:wait:/sbin/reboot -df #z6:6:respawn:/sbin/sulogin # new-style single-user su0:S:wait:/sbin/openrc single su1:S:wait:/sbin/sulogin -# We now delegate all "respawn" services, including terminals, to s6. -s6:12345:respawn:/lib/s6/s6-svscanboot - # What to do at the "Three Finger Salute". ca:12345:ctrlaltdel:/sbin/shutdown -r now diff --git a/system/sysvinit/s6-svscanboot b/system/sysvinit/s6-svscanboot new file mode 100644 index 000000000..8c134b485 --- /dev/null +++ b/system/sysvinit/s6-svscanboot @@ -0,0 +1,15 @@ +#!/bin/execlineb -P + +define RUNIMG /etc/s6-linux-init/current/run-image +export PATH /usr/bin:/usr/sbin:/bin:/sbin +umask 022 +redirfd -r 0 /dev/null +if +{ + elglob -0 files ${RUNIMG}/* + cp -a $files /run/ +} +redirfd -w 3 /run/s6_ready +redirfd -wnb 1 /run/service/s6-svscan-log/fifo +fdmove -c 2 1 +s6-svscan -St0 -d3 /run/service diff --git a/system/sysvinit/sysvinit.post-install b/system/sysvinit/sysvinit.post-install new file mode 100644 index 000000000..4548041d9 --- /dev/null +++ b/system/sysvinit/sysvinit.post-install @@ -0,0 +1,25 @@ +#!/bin/sh -e + +newv="$1" +oldv="$2" + +cat <<EOF + +* +* You installed the sysvinit package. If it's your first installation, +* please ignore this message. But if you just removed the s6-linux-init +* package in order to use sysvinit 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 sysvinit but you are still +* running s6-linux-init 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 |