From ffd7994da3b5c8021aa040f6ca4244f391eb9a0a Mon Sep 17 00:00:00 2001 From: davidovski Date: Wed, 30 Mar 2022 00:50:53 +0100 Subject: fixed initd scripts for udev and sysklogd --- extra/eudev/udev.initd | 22 ++++++++++++++++++++++ extra/eudev/udev_retry.initd | 31 +++++++++++++++++++++++++++++++ extra/sysklogd/sysklogd.initd | 3 +++ repo/meta/base.xibuild | 2 +- repo/system/bootscripts.xibuild | 11 ----------- repo/system/eudev.xibuild | 9 +++++++++ repo/system/openrc.xibuild | 23 +++++++++++++++-------- repo/system/sysklogd.xibuild | 6 ++++++ repo/system/sysvinit.xibuild | 25 ------------------------- repo/util/inetutils.xibuild | 1 + 10 files changed, 88 insertions(+), 45 deletions(-) create mode 100644 extra/eudev/udev.initd create mode 100644 extra/eudev/udev_retry.initd create mode 100644 extra/sysklogd/sysklogd.initd delete mode 100644 repo/system/bootscripts.xibuild delete mode 100644 repo/system/sysvinit.xibuild diff --git a/extra/eudev/udev.initd b/extra/eudev/udev.initd new file mode 100644 index 0000000..5ce2354 --- /dev/null +++ b/extra/eudev/udev.initd @@ -0,0 +1,22 @@ +#!/sbin/openrc-run + +start () { + # Start the udev daemon to continually watch for, and act on, + # uevents + /sbin/udevd --daemon + + # Now traverse /sys in order to "coldplug" devices that have + # already been discovered + /sbin/udevadm trigger --action=add --type=subsystems + /sbin/udevadm trigger --action=add --type=devices + /sbin/udevadm trigger --action=change --type=devices + + # Now wait for udevd to process the uevents we triggered + if ! is_true "$OMIT_UDEV_SETTLE"; then + /sbin/udevadm settle + fi + + # If any LVM based partitions are on the system, ensure they + # are activated so they can be used. + if [ -x /sbin/vgchange ]; then /sbin/vgchange -a y >/dev/null; fi +} diff --git a/extra/eudev/udev_retry.initd b/extra/eudev/udev_retry.initd new file mode 100644 index 0000000..cfe077c --- /dev/null +++ b/extra/eudev/udev_retry.initd @@ -0,0 +1,31 @@ +#!/sbin/openrc-run +start () { + echo "Retrying failed uevents, if any..." + + # As of udev-186, the --run option is no longer valid + #rundir=$(/sbin/udevadm info --run) + rundir=/run/udev + # From Debian: "copy the rules generated before / was mounted + # read-write": + + for file in ${rundir}/tmp-rules--*; do + dest=${file##*tmp-rules--} + [ "$dest" = '*' ] && break + cat $file >> /etc/udev/rules.d/$dest + rm -f $file + done + + # Re-trigger the uevents that may have failed, + # in hope they will succeed now + /bin/sed -e 's/#.*$//' /etc/sysconfig/udev_retry | /bin/grep -v '^$' | \ + while read line ; do + for subsystem in $line ; do + /sbin/udevadm trigger --subsystem-match=$subsystem --action=add + done + done + + # Now wait for udevd to process the uevents we triggered + if ! is_true "$OMIT_UDEV_RETRY_SETTLE"; then + /sbin/udevadm settle + fi +} diff --git a/extra/sysklogd/sysklogd.initd b/extra/sysklogd/sysklogd.initd new file mode 100644 index 0000000..74b13bd --- /dev/null +++ b/extra/sysklogd/sysklogd.initd @@ -0,0 +1,3 @@ +#!/sbin/openrc-run + +command=/bin/syslogd diff --git a/repo/meta/base.xibuild b/repo/meta/base.xibuild index 989c87a..7b2b6c2 100644 --- a/repo/meta/base.xibuild +++ b/repo/meta/base.xibuild @@ -1,5 +1,5 @@ #!/bin/sh -DEPS="bash bzip2 sbase findutils iana-etc file gawk gettext musl grep gzip iproute2 iputils xipkg pciutils procps-ng psmisc sed shadow tar util-linux xz linux-headers sysconfigs inetutils mkinitramfs genfstab eudev openrc sysvinit" +DEPS="bash bzip2 sbase findutils iana-etc file gawk gettext musl grep gzip iproute2 iputils xipkg pciutils procps-ng psmisc sed shadow tar util-linux xz linux-headers sysconfigs inetutils mkinitramfs genfstab eudev openrc kbd sysklogd" MAKEDEPS="grep python" DESC="The base system to be installed" diff --git a/repo/system/bootscripts.xibuild b/repo/system/bootscripts.xibuild deleted file mode 100644 index 6fe5e6f..0000000 --- a/repo/system/bootscripts.xibuild +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -MAKEDEPS="make " -DEPS="sh eudev" - -SOURCE=https://xi.davidovski.xyz/git/bootscripts.git -DESC="Bootscripts to initiate the system on boot" - -package () { - make DESTDIR=$PKG_DEST install -} diff --git a/repo/system/eudev.xibuild b/repo/system/eudev.xibuild index c6bb6da..fadd7e2 100644 --- a/repo/system/eudev.xibuild +++ b/repo/system/eudev.xibuild @@ -9,6 +9,8 @@ DESC="Programs for dynamic creation of device nodes" ADDITIONAL=" default-rules.patch load-fbcon.patch + udev.initd + udev_retry.initd " prepare () { @@ -30,4 +32,11 @@ build () { package () { make DESTDIR=$PKG_DEST install + + install -Dm 754 udev.initd $PKG_DEST/etc/init.d/udev + install -Dm 754 udev_retry.initd $PKG_DEST/etc/init.d/udev_retry + mkdir -p $PKG_DEST/etc/runlevels/boot/ + ln -s /etc/init.d/udev $PKG_DEST/etc/runlevels/boot/udev + ln -s /etc/init.d/udev_retry $PKG_DEST/etc/runlevels/boot/udev_retry + } diff --git a/repo/system/openrc.xibuild b/repo/system/openrc.xibuild index d7c061b..899a19e 100644 --- a/repo/system/openrc.xibuild +++ b/repo/system/openrc.xibuild @@ -43,7 +43,7 @@ prepare () { build () { export MKZSHCOMP=yes export MKBASHCOMP=yes - make LIBDIR=/lib LIBEXECDIR=/lib/rc + make LIBDIR=/lib LIBEXECDIR=/lib/rc MKSYSVINIT=yes } check () { @@ -51,18 +51,19 @@ check () { } package () { - make LIBEXECDIR=/lib/rc DESTDIR="$PKG_DEST/" install + make LIBEXECDIR=/lib/rc DESTDIR="$PKG_DEST/" MKSYSVINIT=yes install - rm -f "$PKG_DEST"/sbin/openrc-init "$PKG_DEST"/sbin/openrc-shutdown + # remove -n from ln in mtab + sed -i "s/ln -snf/ln -sf/g" $PKG_DEST/etc/init.d/mtab - # we cannot have anything turned on by default - rm -f "$PKG_DEST"/etc/runlevels/*/* + ln -s openrc-init $PKG_DEST/sbin/init # we still use our ifup/ifdown based net config - rm -f "$PKG_DEST"/etc/conf.d/network "$PKG_DEST"/etc/init.d/network + #rm -f "$PKG_DEST"/etc/conf.d/network "$PKG_DEST"/etc/init.d/network + + # our hostname init script reads hostname from /etc/hostname + rm -f "$pkgdir"/etc/conf.d/hostname - # our hostname init script reads hostname from /etc/hostname - rm -f "$PKG_DEST"/etc/conf.d/hostname # we override some of the scripts for i in *.initd; do @@ -95,6 +96,12 @@ package () { # remove deprecated /sbin/runscript to avoid conflict with minicom rm $PKG_DEST/sbin/runscript + + #spawn ttys + for x in tty1 tty2 tty3 tty4 tty5 tty6; do + ln -sf agetty $PKG_DEST/etc/init.d/agetty.$x + done + } postinstall () { diff --git a/repo/system/sysklogd.xibuild b/repo/system/sysklogd.xibuild index ac71d5f..8cf024e 100644 --- a/repo/system/sysklogd.xibuild +++ b/repo/system/sysklogd.xibuild @@ -5,6 +5,9 @@ DEPS="musl" PKG_VER=2.3.0 SOURCE=https://github.com/troglobit/sysklogd/releases/download/v$PKG_VER/sysklogd-$PKG_VER.tar.gz +ADDITIONAL=" +sysklogd.initd +" DESC="Programs for logging system messages" build () { @@ -27,4 +30,7 @@ user.* -/var/log/user.log # End /etc/syslog.conf EOF + install -Dm 754 sysklogd.initd $PKG_DEST/etc/init.d/sysklogd + mkdir -p $PKG_DEST/etc/runlevels/boot/ + ln -s /etc/init.d/sysklogd $PKG_DEST/etc/runlevels/boot/sysklogd } diff --git a/repo/system/sysvinit.xibuild b/repo/system/sysvinit.xibuild deleted file mode 100644 index f585b61..0000000 --- a/repo/system/sysvinit.xibuild +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -MAKEDEPS="make patch" -DEPS="sh musl" - -PKG_VER=3.01 -SOURCE=http://download.savannah.nongnu.org/releases/sysvinit/sysvinit-$PKG_VER.tar.xz -ADDITIONAL=" - https://www.linuxfromscratch.org/patches/lfs/development/sysvinit-$PKG_VER-consolidated-1.patch - " - -DESC="The sysvinit system for controlling startup, running and shutdown of the system" - - -prepare () { - patch -Np1 -i sysvinit-$PKG_VER-consolidated-1.patch -} - -build () { - make -} - -package () { - make ROOT=$PKG_DEST install -} diff --git a/repo/util/inetutils.xibuild b/repo/util/inetutils.xibuild index 05b1dd3..dd7adc5 100644 --- a/repo/util/inetutils.xibuild +++ b/repo/util/inetutils.xibuild @@ -24,4 +24,5 @@ build () { package () { make DESTDIR=$PKG_DEST install + rm $PKG_DEST/usr/bin/hostname } -- cgit v1.2.1