diff options
| author | PS <p@0x53.net> | 2026-02-01 12:05:19 +0100 |
|---|---|---|
| committer | PS <p@0x53.net> | 2026-02-01 12:05:19 +0100 |
| commit | 466a79421d335c020bf2208692e9f7f41614f6f1 (patch) | |
| tree | dc9ae259c09e356f4cd04594b8b417ad63690721 | |
| download | goetia-s6-linux-init-466a79421d335c020bf2208692e9f7f41614f6f1.tar.gz goetia-s6-linux-init-466a79421d335c020bf2208692e9f7f41614f6f1.tar.bz2 goetia-s6-linux-init-466a79421d335c020bf2208692e9f7f41614f6f1.zip | |
version 0.2.0.0
37 files changed, 802 insertions, 0 deletions
@@ -0,0 +1,10 @@ +Main author: + Paul Sopka <psopka@sopka.ch> + +Contributors: + +Thanks to: + Laurent Bercot <ska-skaware@skarnet.org> + Dan J. Bernstein <djb@cr.yp.to> + Paul Jarc <prj@dogmap.org> + Jonathan de Boyne Pollard <J.deBoynePollard@NTLWorld.com> diff --git a/CONTRIBUTING b/CONTRIBUTING new file mode 100644 index 0000000..6279422 --- /dev/null +++ b/CONTRIBUTING @@ -0,0 +1,5 @@ + Please add a Signed-Off-By: line at the end of your commit, +which certifies that you have the right and authority to pass +it on as an open-source patch, as explicited in the Developer's +Certificate of Origin available in this project's DCO file, +or at https://developercertificate.org/ @@ -0,0 +1,13 @@ +Copyright (c) 2024-2025 Paul Sopka <psopka@sopka.ch> + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. @@ -0,0 +1,37 @@ +Developer Certificate of Origin +Version 1.1 + +Copyright (C) 2004, 2006 The Linux Foundation and its contributors. +1 Letterman Drive +Suite D4700 +San Francisco, CA, 94129 + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + + +Developer's Certificate of Origin 1.1 + +By making a contribution to this project, I certify that: + +(a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + +(b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the same open source license (unless I am + permitted to submit under a different license), as indicated + in the file; or + +(c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + +(d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. @@ -0,0 +1,83 @@ +Build Instructions +------------------ + +* Requirements + ------------ + + - A POSIX-compliant set of utils + - A set of OS specific utils + - s6 https://skarnet.org/software/s6/ + - s6-rc https://skarnet.org/software/s6-rc/ + - execline https://skarnet.org/software/execline/ + + This software will run on any operating system that implements +POSIX.1-2008, available at: + https://pubs.opengroup.org/onlinepubs/9699919799/ + + +* Standard usage + -------------- + + ./configure && make && sudo make install + + will work for most users. + + +* Customization + ------------- + + You can customize paths via flags given to configure. + See ./configure --help for a list of all available configure options. + +* Make variables + -------------- + + You can invoke make with a few variables for more configuration. + + INSTALL can be overridden on the make command line. This is +an even bigger hammer than running ./configure with environment +variables, so it is advised to only do this when it is the only way of +obtaining the behaviour you want. + + DESTDIR can be given on the "make install" command line in order to +install to a staging directory. + +* The slashpackage convention + --------------------------- + + The slashpackage convention (http://cr.yp.to/slashpackage.html) +is a package installation scheme that provides a few guarantees +over other conventions such as the FHS, for instance fixed +absolute pathnames. skarnet.org packages support it: use the +--enable-slashpackage option to configure, or +--enable-slashpackage=DIR for a prefixed DIR/package tree. +This option will activate slashpackage support during the build +and set slashpackage-compatible installation directories. +If $package_home is the home of the package, defined as +DIR/package/$category/$package-$version with the variables +read from the package/info file, then: + + --bindir is set to $package_home/command + --sbindir is also set to $package_home/command (slashpackage +differentiates root-only binaries by their Unix rights, not their +location in the filesystem) + --libdir is set to $package_home/ + + --prefix is pretty much ignored when you use --enable-slashpackage. +You should probably not use both --enable-slashpackage and --prefix. + + When using slashpackage, two additional Makefile targets are +available after "make install": + - "make update" changes the default version of the software to the +freshly installed one. (This is useful when you have several installed +versions of the same software, which slashpackage supports.) + - "make global-links" adds links from /command and /library.so to the +default version of the binaries and shared libraries. + + +* Out-of-tree builds + ------------------ + + This package does not support out-of-tree builds. It +is small, so it does not cost much to duplicate the entire +source tree if parallel builds are needed. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0e68c25 --- /dev/null +++ b/Makefile @@ -0,0 +1,87 @@ +# +# This makefile requires make compliant with POSIX Issue 8. +# It also reliably works with modern GNU make. +# Do not make changes here. +# Use the included .mak files. +# + +.POSIX: + +IT = conferror + +-include config.mak + +it: $(IT) + +conferror: + @echo "Please use ./configure first." ; exit 1 + +ALL_EXTRAS ::= +INSTALL_EXTRAS ::= + +-include package/extras.mak + +include package/targets.mak +include package/deps.mak + +INSTALL ::= ./tools/install.sh + +all: $(ALL_BINS) $(ALL_LIBS) $(ALL_EXTRAS) + +clean: + @exec rm -rf -- $(ALL_BINS) service source bundle etc + +distclean: clean + @exec rm -f -- config.mak + +tgz: distclean + @. package/info && \ + rm -rf /tmp/$$package-$$version && \ + cp -a . /tmp/$$package-$$version && \ + cd /tmp && \ + tar -zpcv --owner=0 --group=0 --numeric-owner --exclude=.git* -f /tmp/$$package-$$version.tar.gz $$package-$$version && \ + exec rm -rf /tmp/$$package-$$version + +install: $(INSTALL_BINS) $(INSTALL_LIBS) $(INSTALL_EXTRAS) + +$(ALL_BINS) $(ALL_LIBS): + @test -z $$(dirname "$@") || mkdir -p -- $$(dirname "$@") + exec sed \ + -e 's/@syslogdir@/$(syslogdir)/g' \ + -e 's/@usrlogdir@/$(usrlogdir)/g' \ + -e 's/@logdep@/$(logdep)/g' \ + -e 's/@logconfig@/$(logconfig)/g' \ + -e 's/@loguser@/$(loguser)/g' \ + -e 's/@sysconfdir@/$(sysconfdir)/g' \ + -e 's/@usrconfdir@/$(usrconfdir)/g' \ + -e 's/@tmpfsdir@/$(tmpfsdir)/g' \ + -e 's/@sysrundir@/$(sysrundir)/g' \ + -e 's/@usrrundir@/$(usrrundir)/g' \ + -e 's/@timeout@/$(timeout)/g' \ + -e 's/@shebangdir@/$(shebangdir)/g' \ + -- $^ > $@ + +$(INSTALL_BINS) $(INSTALL_LIBS): + exec $(INSTALL) -D -m 644 $^ $@ + grep -F -- $^ - < package/modes | { read name mode owner && \ + if [ x$${mode} != x ] ; then chmod $${mode} $@ ; fi && \ + if [ x$${owner} != x ] ; then chown -- $${owner} $@ ; fi ; } || exit 0 + + +$(DESTDIR)$(exthome): + exec $(INSTALL) -D -l $(package)-$(version) $@ + +$(SLASHCOMMAND_BINS): + exec $(INSTALL) -D -l $(exthome)/command/$$(basename $@) $@ + +update: $(DESTDIR)$(exthome) +global-links: $(SLASHCOMMAND_BINS) + +uninstall: + exec rm -f $(INSTALL_BINS) $(SLASHCOMMAND_BINS) + exec rm -Rf $(libdir) + +.PHONY: \ + it all clean distclean tgz update global-links \ + install uninstall \ + $(DESTDIR)$(exthome) $(SLASHCOMMAND_BINS) @@ -0,0 +1,6 @@ +Changelog for goetia-base. + +In 0.0.0.1 +---------- + + - Initial release diff --git a/configure b/configure new file mode 100755 index 0000000..5facfc0 --- /dev/null +++ b/configure @@ -0,0 +1,196 @@ +#!/bin/sh + +cd `dirname "$0"` +. package/info + +usage () { +cat <<EOF +Usage: $0 [OPTION]... [TARGET] + +Defaults for the options are specified in brackets. + +Installation directories: + --prefix=PREFIX main installation prefix [/] + --exec-prefix=EPREFIX installation prefix for executable files [PREFIX] + +Fine tuning of the installation directories: + --libdir=DIR service and source directories [PREFIX/lib/$package] + --bindir=BINDIR user executables [EPREFIX/bin] + +Binaries + --shebangdir=SHEBANGDIR dir used to find interpreters for scripts [PREFIX/bin] + +Logging + --syslogdir=LOGDIR system logdir [PREFIX/var/log/goetia] + --usrlogdir=LOGDIR user logdir appended to \${HOME} [.local/state/log] + + --logconfig=LOGCONFIG directives for autogenerated s6-log scripts [n3 T] + --loguser=LOGUSER user running all system s6-log processes [logger] + --logdep=LOGDEP dependencies for autogenerated system s6-log processes [mount] + +Other + --sysconfdir=CONFIGDIR systemtree configdir [PREFIX/etc/goetia/system] + --usrconfdir=CONFIGDIR usertree configdir appended to \${HOME} [.config/goetia] + + --tmpfsdir=TMPFSDIR tmpfs dir used for supervision trees [/run] + --sysrundir=SYSRUNDIR systemtree runtime dir appended to TMPFSDIR [system] + --usrrundir=USRRUNDIR usertree runtime dir appended to TMPFSDIR [user] + + --timeout=TIMEOUT Timeout in ms for s6-rc invocations in init and shutdown scripts [60000] + +Optional features: + --enable-slashpackage[=ROOT] assume /package installation at ROOT [disabled] + +EOF +exit 0 +} + +# Helper functions + +# If your system does not have printf, you can comment this, but it is +# generally not a good idea to use echo. +# See http://www.etalabs.net/sh_tricks.html +echo () { + printf %s\\n "$*" +} + +quote () { + tr '\n' ' ' <<EOF | grep '^[-[:alnum:]_=,./:]* $' >/dev/null 2>&1 && { echo "$1" ; return 0 ; } +$1 +EOF + echo "$1" | sed -e "s/'/'\\\\''/g" -e "1s/^/'/" -e "\$s/\$/'/" -e "s#^'\([-[:alnum:]_,./:]*\)=\(.*\)\$#\1='\2#" -e "s|\*/|* /|g" +} + +fail () { + echo "$*" + exit 1 +} + +fnmatch () { + eval "case \"\$2\" in $1) return 0 ;; *) return 1 ;; esac" +} + +stripdir () { + while eval "fnmatch '*/' \"\${$1}\"" ; do + eval "$1=\${$1%/}" + done +} + +escapeslash () { + echo "$1" | sed -e 's/\//\\\//g' +} + +# Actual script + +prefix= +exec_prefix='$prefix' +bindir='$exec_prefix/bin' +libdir='$prefix/lib/$package' + +shebangdir='$prefix/bin' + +syslogdir='$prefix/var/log/goetia' +usrlogdir='.local/state/log' + +logconfig='n3 T' +loguser='logger' +logdep='mount' + +sysconfdir='$prefix/etc/goetia/system' +usrconfdir='.config/goetia' + +tmpfsdir='$prefix/run' +sysrundir='system' +usrrundir='user' + +timeout=60000 + +slashpackage=false +sproot= +home= +exthome= +build= + +for arg ; do + case "$arg" in + --help) usage ;; + --prefix=*) prefix=${arg#*=} ;; + --exec-prefix=*) exec_prefix=${arg#*=} ;; + --bindir=*) bindir=${arg#*=} ;; + --libdir=*) libdir=${arg#*=} ;; + --shebangdir=*) shebangdir=${arg#*=} ;; + --syslogdir=*) syslogdir=${arg#*=} ;; + --usrlogdir=*) usrlogdir=${arg#*=} ;; + --logconfig=*) logconfig=${arg#*=} ;; + --loguser=*) loguser=${arg#*=} ;; + --logdep=*) logdep=${arg#*=} ;; + --sysconfdir=*) sysconfdir=${arg#*=} ;; + --usrconfdir=*) usrconfdir=${arg#*=} ;; + --tmpfsdir=*) tmpfsdir=${arg#*=} ;; + --sysrundir=*) sysrundir=${arg#*=} ;; + --usrrundir=*) usrrundir=${arg#*=} ;; + --timeout=*) timeout=${arg#*=} ;; + --enable-slashpackage=*) sproot=${arg#*=} ; slashpackage=true ; ;; + --enable-slashpackage) sproot= ; slashpackage=true ;; + --disable-slashpackage) sproot= ; installtype=fhs ;; + --enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;; + -* ) echo "$0: unknown option $arg" ;; + *=*) eval "${arg%%=*}=\${arg#*=}" ;; + *) target=$arg ;; + esac +done + +# Expand installation directories +stripdir prefix +for i in exec_prefix bindir libdir shebangdir syslogdir usrlogdir sysconfdir usrconfdir tmpfsdir sysrundir usrrundir sproot ; do + eval tmp=\${$i} + eval $i=$tmp + stripdir $i +done + +# Set slashpackage values +if $slashpackage ; then + home=${sproot}/package/${category}/${package}-${version} + exthome=${sproot}/package/${category}/${package} + extbinprefix=${exthome}/command + bindir=${home}/command + libdir=${home} +fi + +echo "Creating config.mak..." +cmdline=$(quote "$0") +for i ; do cmdline="$cmdline $(quote "$i")" ; done +exec 3>&1 1>config.mak +cat << EOF +# This file was generated by: +# $cmdline +# Any changes made here will be lost if configure is re-run. + +IT ::= all + +package ::= $package +prefix ::= $prefix +exec_prefix ::= $exec_prefix +bindir ::= $bindir +libdir ::= $libdir +shebangdir ::= $(escapeslash "$shebangdir") +syslogdir ::= $(escapeslash "$syslogdir") +usrlogdir ::= $(escapeslash "$usrlogdir") +logconfig ::= $(escapeslash "$logconfig") +loguser ::= $(escapeslash "$loguser") +logdep ::= $(escapeslash "$logdep") +sysconfdir ::= $(escapeslash "$sysconfdir") +usrconfdir ::= $(escapeslash "$usrconfdir") +tmpfsdir ::= $(escapeslash "$tmpfsdir") +sysrundir ::= $(escapeslash "$sysrundir") +usrrundir ::= $(escapeslash "$usrrundir") +timeout ::= $timeout +slashpackage ::= $slashpackage +sproot ::= $sproot +version ::= $version +home ::= $home +exthome ::= $exthome +EOF + +exec 1>&3 3>&- +echo " ... done." diff --git a/package/deps.mak b/package/deps.mak new file mode 100644 index 0000000..b6f8836 --- /dev/null +++ b/package/deps.mak @@ -0,0 +1,40 @@ +# +# This file has been generated by tools/gen-deps.sh +# + +system-init: src/bin/system-init +$(DESTDIR)$(bindir)/system-init: system-init +system-shutdown: src/bin/system-shutdown +$(DESTDIR)$(bindir)/system-shutdown: system-shutdown +s6-linux-init/scripts/rc.init: src/lib/s6-linux-init/scripts/rc.init +$(DESTDIR)$(libdir)/s6-linux-init/scripts/rc.init: s6-linux-init/scripts/rc.init +s6-linux-init/scripts/rc.shutdown.final: src/lib/s6-linux-init/scripts/rc.shutdown.final +$(DESTDIR)$(libdir)/s6-linux-init/scripts/rc.shutdown.final: s6-linux-init/scripts/rc.shutdown.final +s6-linux-init/scripts/rc.shutdown: src/lib/s6-linux-init/scripts/rc.shutdown +$(DESTDIR)$(libdir)/s6-linux-init/scripts/rc.shutdown: s6-linux-init/scripts/rc.shutdown +service/system/s6-linux-init-runleveld/run: src/lib/service/system/s6-linux-init-runleveld/run +$(DESTDIR)$(libdir)/service/system/s6-linux-init-runleveld/run: service/system/s6-linux-init-runleveld/run +service/system/s6-linux-init-runleveld/notification-fd: src/lib/service/system/s6-linux-init-runleveld/notification-fd +$(DESTDIR)$(libdir)/service/system/s6-linux-init-runleveld/notification-fd: service/system/s6-linux-init-runleveld/notification-fd +service/system/.s6-svscan/crash: src/lib/service/system/.s6-svscan/crash +$(DESTDIR)$(libdir)/service/system/.s6-svscan/crash: service/system/.s6-svscan/crash +service/system/.s6-svscan/SIGUSR1: src/lib/service/system/.s6-svscan/SIGUSR1 +$(DESTDIR)$(libdir)/service/system/.s6-svscan/SIGUSR1: service/system/.s6-svscan/SIGUSR1 +service/system/.s6-svscan/finish: src/lib/service/system/.s6-svscan/finish +$(DESTDIR)$(libdir)/service/system/.s6-svscan/finish: service/system/.s6-svscan/finish +service/system/.s6-svscan/SIGQUIT: src/lib/service/system/.s6-svscan/SIGQUIT +$(DESTDIR)$(libdir)/service/system/.s6-svscan/SIGQUIT: service/system/.s6-svscan/SIGQUIT +service/system/.s6-svscan/SIGINT: src/lib/service/system/.s6-svscan/SIGINT +$(DESTDIR)$(libdir)/service/system/.s6-svscan/SIGINT: service/system/.s6-svscan/SIGINT +service/system/.s6-svscan/SIGUSR2: src/lib/service/system/.s6-svscan/SIGUSR2 +$(DESTDIR)$(libdir)/service/system/.s6-svscan/SIGUSR2: service/system/.s6-svscan/SIGUSR2 +service/system/.s6-svscan/SIGWINCH: src/lib/service/system/.s6-svscan/SIGWINCH +$(DESTDIR)$(libdir)/service/system/.s6-svscan/SIGWINCH: service/system/.s6-svscan/SIGWINCH +service/system/.s6-svscan/SIGTERM: src/lib/service/system/.s6-svscan/SIGTERM +$(DESTDIR)$(libdir)/service/system/.s6-svscan/SIGTERM: service/system/.s6-svscan/SIGTERM +service/system/.s6-svscan/SIGPWR: src/lib/service/system/.s6-svscan/SIGPWR +$(DESTDIR)$(libdir)/service/system/.s6-svscan/SIGPWR: service/system/.s6-svscan/SIGPWR +service/system/s6-linux-init-shutdownd/run: src/lib/service/system/s6-linux-init-shutdownd/run +$(DESTDIR)$(libdir)/service/system/s6-linux-init-shutdownd/run: service/system/s6-linux-init-shutdownd/run +service/system/s6-linux-init-shutdownd/notification-fd: src/lib/service/system/s6-linux-init-shutdownd/notification-fd +$(DESTDIR)$(libdir)/service/system/s6-linux-init-shutdownd/notification-fd: service/system/s6-linux-init-shutdownd/notification-fd diff --git a/package/extras.mak b/package/extras.mak new file mode 100644 index 0000000..99d9465 --- /dev/null +++ b/package/extras.mak @@ -0,0 +1,9 @@ +DIRS ::= \ + $(DESTDIR)$(libdir)/s6-linux-init/env \ + $(DESTDIR)$(libdir)/s6-linux-init/run-image/system/service \ + $(DESTDIR)$(libdir)/s6-linux-init/run-image/system/uncaught-logs + +$(DIRS): + mkdir -p -m750 -- $@ + +INSTALL_EXTRAS ::= $(DIRS) diff --git a/package/info b/package/info new file mode 100644 index 0000000..b5bda5a --- /dev/null +++ b/package/info @@ -0,0 +1,4 @@ +package=goetia-s6-linux-init +version=0.0.0.1 +category=admin +package_macro_name=GOETIA-S6-LINUX-INIT diff --git a/package/modes b/package/modes new file mode 100644 index 0000000..51ec2ab --- /dev/null +++ b/package/modes @@ -0,0 +1,9 @@ +system-init 0755 +system-shutdown 0755 + +s6-linux-init/scripts/rc.init 0755 +s6-linux-init/scripts/rc.shutdown 0755 +s6-linux-init/scripts/rc.shutdown.final 0755 + +service/system/s6-linux-init-runleveld/run 0755 +service/system/s6-linux-init-shutdownd/run 0755 diff --git a/package/targets.mak b/package/targets.mak new file mode 100644 index 0000000..d70a6ed --- /dev/null +++ b/package/targets.mak @@ -0,0 +1,52 @@ +# +# This file has been generated by tools/gen-targets.sh +# + +ALL_BINS ::= \ + system-init \ + system-shutdown \ + +INSTALL_BINS ::= \ + $(DESTDIR)$(bindir)/system-init \ + $(DESTDIR)$(bindir)/system-shutdown \ + +SLASHCOMMAND_BINS ::= \ + $(DESTDIR)$(sproot)/command/system-init \ + $(DESTDIR)$(sproot)/command/system-shutdown \ + +ALL_LIBS ::= \ + s6-linux-init/scripts/rc.init \ + s6-linux-init/scripts/rc.shutdown.final \ + s6-linux-init/scripts/rc.shutdown \ + service/system/s6-linux-init-runleveld/run \ + service/system/s6-linux-init-runleveld/notification-fd \ + service/system/.s6-svscan/crash \ + service/system/.s6-svscan/SIGUSR1 \ + service/system/.s6-svscan/finish \ + service/system/.s6-svscan/SIGQUIT \ + service/system/.s6-svscan/SIGINT \ + service/system/.s6-svscan/SIGUSR2 \ + service/system/.s6-svscan/SIGWINCH \ + service/system/.s6-svscan/SIGTERM \ + service/system/.s6-svscan/SIGPWR \ + service/system/s6-linux-init-shutdownd/run \ + service/system/s6-linux-init-shutdownd/notification-fd \ + +INSTALL_LIBS ::= \ + $(DESTDIR)$(libdir)/s6-linux-init/scripts/rc.init \ + $(DESTDIR)$(libdir)/s6-linux-init/scripts/rc.shutdown.final \ + $(DESTDIR)$(libdir)/s6-linux-init/scripts/rc.shutdown \ + $(DESTDIR)$(libdir)/service/system/s6-linux-init-runleveld/run \ + $(DESTDIR)$(libdir)/service/system/s6-linux-init-runleveld/notification-fd \ + $(DESTDIR)$(libdir)/service/system/.s6-svscan/crash \ + $(DESTDIR)$(libdir)/service/system/.s6-svscan/SIGUSR1 \ + $(DESTDIR)$(libdir)/service/system/.s6-svscan/finish \ + $(DESTDIR)$(libdir)/service/system/.s6-svscan/SIGQUIT \ + $(DESTDIR)$(libdir)/service/system/.s6-svscan/SIGINT \ + $(DESTDIR)$(libdir)/service/system/.s6-svscan/SIGUSR2 \ + $(DESTDIR)$(libdir)/service/system/.s6-svscan/SIGWINCH \ + $(DESTDIR)$(libdir)/service/system/.s6-svscan/SIGTERM \ + $(DESTDIR)$(libdir)/service/system/.s6-svscan/SIGPWR \ + $(DESTDIR)$(libdir)/service/system/s6-linux-init-shutdownd/run \ + $(DESTDIR)$(libdir)/service/system/s6-linux-init-shutdownd/notification-fd \ + diff --git a/s6-linux-init/scripts/rc.init b/s6-linux-init/scripts/rc.init new file mode 100644 index 0000000..b34a2ef --- /dev/null +++ b/s6-linux-init/scripts/rc.init @@ -0,0 +1,14 @@ +#!@shebangdir@/execlineb -WS1 + +# ISC license. + +if -x0 -n { eltest -d /run//s6-rc } +foreground { echo "\ninit!\n" } +if { + s6-rc-init + -c /etc/goetia/system/compiled + -l /run//system/s6-rc + /run//system/service +} +foreground { echo "\nStarting bundle ${1}...\n" } +s6-rc -b -l /run//system/s6-rc -v2 -t10000 -up change ${1} diff --git a/s6-linux-init/scripts/rc.shutdown b/s6-linux-init/scripts/rc.shutdown new file mode 100644 index 0000000..18da7d6 --- /dev/null +++ b/s6-linux-init/scripts/rc.shutdown @@ -0,0 +1,5 @@ +#!@shebangdir@/execlineb -P + +# ISC license. + +s6-rc -b -l /run//system/s6-rc -v2 -Da -t10000 change diff --git a/s6-linux-init/scripts/rc.shutdown.final b/s6-linux-init/scripts/rc.shutdown.final new file mode 100644 index 0000000..eae8c35 --- /dev/null +++ b/s6-linux-init/scripts/rc.shutdown.final @@ -0,0 +1 @@ +#!@shebangdir@/execlineb -P diff --git a/src/bin/system-init b/src/bin/system-init new file mode 100755 index 0000000..3f7c561 --- /dev/null +++ b/src/bin/system-init @@ -0,0 +1,6 @@ +#!@shebangdir@/execlineb -P + +s6-linux-init + -v 1 -m 0022 + -c /etc/s6-linux-init/goetia + -p /command:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/libexec:/usr/local/libexec diff --git a/src/bin/system-shutdown b/src/bin/system-shutdown new file mode 100755 index 0000000..685f21b --- /dev/null +++ b/src/bin/system-shutdown @@ -0,0 +1,3 @@ +#!@shebangdir@/execlineb -S0 + +s6-linux-init-shutdown $@ diff --git a/src/lib/s6-linux-init/scripts/rc.init b/src/lib/s6-linux-init/scripts/rc.init new file mode 100755 index 0000000..42c72e2 --- /dev/null +++ b/src/lib/s6-linux-init/scripts/rc.init @@ -0,0 +1,14 @@ +#!@shebangdir@/execlineb -WS1 + +# ISC license. + +if -x0 -n { eltest -d @tmpfsdir@/@sysrundir@/s6-rc } +foreground { echo "\ninit!\n" } +if { + s6-rc-init + -c @sysconfdir@/compiled + -l @tmpfsdir@/@sysrundir@/s6-rc + @tmpfsdir@/@sysrundir@/service +} +foreground { echo "\nStarting bundle ${1}...\n" } +s6-rc -b -l @tmpfsdir@/@sysrundir@/s6-rc -v2 -t@timeout@ -up change ${1} diff --git a/src/lib/s6-linux-init/scripts/rc.shutdown b/src/lib/s6-linux-init/scripts/rc.shutdown new file mode 100755 index 0000000..37c2f52 --- /dev/null +++ b/src/lib/s6-linux-init/scripts/rc.shutdown @@ -0,0 +1,5 @@ +#!@shebangdir@/execlineb -P + +# ISC license. + +s6-rc -b -l @tmpfsdir@/@rundir@/system/s6-rc -v2 -Da -t10000 change diff --git a/src/lib/s6-linux-init/scripts/rc.shutdown.final b/src/lib/s6-linux-init/scripts/rc.shutdown.final new file mode 100755 index 0000000..eae8c35 --- /dev/null +++ b/src/lib/s6-linux-init/scripts/rc.shutdown.final @@ -0,0 +1 @@ +#!@shebangdir@/execlineb -P diff --git a/src/lib/service/system/.s6-svscan/SIGINT b/src/lib/service/system/.s6-svscan/SIGINT new file mode 100755 index 0000000..ea66bf3 --- /dev/null +++ b/src/lib/service/system/.s6-svscan/SIGINT @@ -0,0 +1,3 @@ +#!@shebangdir@/execlineb -P + +s6-linux-init-shutdown -a -r -- now diff --git a/src/lib/service/system/.s6-svscan/SIGPWR b/src/lib/service/system/.s6-svscan/SIGPWR new file mode 100755 index 0000000..1ae0ac8 --- /dev/null +++ b/src/lib/service/system/.s6-svscan/SIGPWR @@ -0,0 +1,3 @@ +#!@shebangdir@/execlineb -P + +s6-linux-init-shutdown -a -p -- now diff --git a/src/lib/service/system/.s6-svscan/SIGQUIT b/src/lib/service/system/.s6-svscan/SIGQUIT new file mode 100755 index 0000000..4d6fd2f --- /dev/null +++ b/src/lib/service/system/.s6-svscan/SIGQUIT @@ -0,0 +1,2 @@ +#!@shebangdir@/execlineb -P + diff --git a/src/lib/service/system/.s6-svscan/SIGTERM b/src/lib/service/system/.s6-svscan/SIGTERM new file mode 100755 index 0000000..4d6fd2f --- /dev/null +++ b/src/lib/service/system/.s6-svscan/SIGTERM @@ -0,0 +1,2 @@ +#!@shebangdir@/execlineb -P + diff --git a/src/lib/service/system/.s6-svscan/SIGUSR1 b/src/lib/service/system/.s6-svscan/SIGUSR1 new file mode 100755 index 0000000..1ae0ac8 --- /dev/null +++ b/src/lib/service/system/.s6-svscan/SIGUSR1 @@ -0,0 +1,3 @@ +#!@shebangdir@/execlineb -P + +s6-linux-init-shutdown -a -p -- now diff --git a/src/lib/service/system/.s6-svscan/SIGUSR2 b/src/lib/service/system/.s6-svscan/SIGUSR2 new file mode 100755 index 0000000..61f5411 --- /dev/null +++ b/src/lib/service/system/.s6-svscan/SIGUSR2 @@ -0,0 +1,3 @@ +#!@shebangdir@/execlineb -P + +s6-linux-init-shutdown -a -h -- now diff --git a/src/lib/service/system/.s6-svscan/SIGWINCH b/src/lib/service/system/.s6-svscan/SIGWINCH new file mode 100755 index 0000000..4d6fd2f --- /dev/null +++ b/src/lib/service/system/.s6-svscan/SIGWINCH @@ -0,0 +1,2 @@ +#!@shebangdir@/execlineb -P + diff --git a/src/lib/service/system/.s6-svscan/crash b/src/lib/service/system/.s6-svscan/crash new file mode 100755 index 0000000..f1a65b5 --- /dev/null +++ b/src/lib/service/system/.s6-svscan/crash @@ -0,0 +1,6 @@ +#!@shebangdir@/execlineb -P + +redirfd -w 2 /dev/console +fdmove -c 1 2 +foreground { s6-linux-init-echo -- "s6-svscan crashed. Rebooting." } +s6-linux-init-hpr -fr diff --git a/src/lib/service/system/.s6-svscan/finish b/src/lib/service/system/.s6-svscan/finish new file mode 100755 index 0000000..e405c85 --- /dev/null +++ b/src/lib/service/system/.s6-svscan/finish @@ -0,0 +1,6 @@ +#!@shebangdir@/execlineb -P + +redirfd -w 2 /dev/console +fdmove -c 1 2 +foreground { s6-linux-init-echo -- "s6-svscan exited. Rebooting." } +s6-linux-init-hpr -fr diff --git a/src/lib/service/system/s6-linux-init-runleveld/notification-fd b/src/lib/service/system/s6-linux-init-runleveld/notification-fd new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/src/lib/service/system/s6-linux-init-runleveld/notification-fd @@ -0,0 +1 @@ +3 diff --git a/src/lib/service/system/s6-linux-init-runleveld/run b/src/lib/service/system/s6-linux-init-runleveld/run new file mode 100755 index 0000000..aebacc4 --- /dev/null +++ b/src/lib/service/system/s6-linux-init-runleveld/run @@ -0,0 +1,7 @@ +#!@shebangdir@/execlineb -P + +fdmove -c 2 1 +fdmove 1 3 +s6-ipcserver -1 -a 0700 -c 1 -- s +s6-sudod -dt30000 -- +/etc/s6-linux-init/goetia/scripts/runlevel diff --git a/src/lib/service/system/s6-linux-init-shutdownd/notification-fd b/src/lib/service/system/s6-linux-init-shutdownd/notification-fd new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/src/lib/service/system/s6-linux-init-shutdownd/notification-fd @@ -0,0 +1 @@ +3 diff --git a/src/lib/service/system/s6-linux-init-shutdownd/run b/src/lib/service/system/s6-linux-init-shutdownd/run new file mode 100755 index 0000000..1b4fbf6 --- /dev/null +++ b/src/lib/service/system/s6-linux-init-shutdownd/run @@ -0,0 +1,3 @@ +#!@shebangdir@/execlineb -P + +s6-linux-init-shutdownd -d3 -c "/etc/s6-linux-init/goetia" -g 3000 diff --git a/tools/gen-deps.sh b/tools/gen-deps.sh new file mode 100755 index 0000000..fafb347 --- /dev/null +++ b/tools/gen-deps.sh @@ -0,0 +1,35 @@ +#!/bin/sh -e + +. package/info + +echo '#' +echo '# This file has been generated by tools/gen-deps.sh' +echo '#' +echo + +if test -d src/bin +then + cd src/bin + for FILE in $(find * -type f 2> /dev/null); do + echo "${FILE}: src/bin/${FILE}" + echo "\$(DESTDIR)\$(bindir)/${FILE}: ${FILE}" + done + cd ../.. +fi + +if test -d src/lib +then + cd src/lib + for FILE in $(find * -type f 2> /dev/null); do + echo "${FILE}: src/lib/${FILE}" + echo "\$(DESTDIR)\$(libdir)/${FILE}: ${FILE}" + done + cd ../.. +fi + +if test -f package/extras +then + for EXTRA in $(cat package/extras); do + echo "\$(DESTDIR)\$(libdir)/${EXTRA}: ${EXTRA}" + done +fi diff --git a/tools/gen-targets.sh b/tools/gen-targets.sh new file mode 100755 index 0000000..3280748 --- /dev/null +++ b/tools/gen-targets.sh @@ -0,0 +1,56 @@ +#!/bin/sh -e + +. package/info + +echo '#' +echo '# This file has been generated by tools/gen-targets.sh' +echo '#' +echo + +if test -d src/bin +then + cd src/bin + + echo "ALL_BINS ::= \\" + + for FILE in $(find * -type f 2> /dev/null) ; do + echo "\t${FILE} \\" + done + + echo + echo "INSTALL_BINS ::= \\" + + for FILE in $(find * -type f 2> /dev/null) ; do + echo "\t\$(DESTDIR)\$(bindir)/${FILE} \\" + done + + echo + echo "SLASHCOMMAND_BINS ::= \\" + + for FILE in $(find * -type f 2> /dev/null) ; do + echo "\t\$(DESTDIR)\$(sproot)/command/${FILE} \\" + done + + cd ../.. + echo +fi + +if test -d src/lib +then + cd src/lib + + echo "ALL_LIBS ::= \\" + for FILE in $(find * -type f 2> /dev/null) ; do + echo "\t${FILE} \\" + done + + echo + + echo "INSTALL_LIBS ::= \\" + for FILE in $(find * -type f 2> /dev/null) ; do + echo "\t\$(DESTDIR)\$(libdir)/${FILE} \\" + done + + cd ../.. + echo +fi diff --git a/tools/install.sh b/tools/install.sh new file mode 100755 index 0000000..e96dd7b --- /dev/null +++ b/tools/install.sh @@ -0,0 +1,69 @@ +#!/bin/sh + +usage() { + echo "usage: $0 [ -D ] [ -l ] [ -m mode ] [ -O owner:group ] src dst" 1>&2 + exit 1 +} + +mkdirp=false +symlink=false +mode=0755 +og= + +while getopts Dlm:O: name ; do + case "$name" in + D) mkdirp=true ;; + l) symlink=true ;; + m) mode=$OPTARG ;; + O) og=$OPTARG ;; + ?) usage ;; + esac +done +shift $(($OPTIND - 1)) + +test "$#" -eq 2 || usage +src=$1 +dst=$2 +tmp="$dst.tmp.$$" + +case "$dst" in + */) echo "$0: $dst ends in /" 1>&2 ; exit 1 ;; +esac + +set -C +set -e + +if $mkdirp ; then + umask 022 + case "$2" in + */*) mkdir -p "${dst%/*}" ;; + esac +fi + +trap 'rm -f "$tmp"' EXIT INT QUIT TERM HUP + +umask 077 + +if $symlink ; then + ln -s "$src" "$tmp" +else + cat < "$1" > "$tmp" + if test -n "$og" ; then + chown -- "$og" "$tmp" + fi + chmod -- "$mode" "$tmp" +fi + +mv -f "$tmp" "$dst" +if test -d "$dst" ; then + rm -f "$dst/$(basename $tmp)" + if $symlink ; then + mkdir "$tmp" + ln -s "$src" "$tmp/$(basename $dst)" + mv -f "$tmp/$(basename $dst)" "${dst%/*}" + rmdir "$tmp" + else + echo "$0: $dst is a directory" 1>&2 + exit 1 + fi +fi |
