commit 9639186099c18ebd3be6d66cb98071374ef58275 parent 04ef3eae8e913e0d484aef1deba0cb8ad2c30e1f Author: ccx <ccx@te2000.cz> Date: Sat, 16 Mar 2024 21:34:12 +0000 "core-system-conf" -> "system-config" Diffstat:
M | .gitmodules | | | 6 | +++--- |
D | packages/core-system-conf | | | 130 | ------------------------------------------------------------------------------- |
D | packages/core-system-init | | | 170 | ------------------------------------------------------------------------------- |
D | packages/core-system-rc | | | 72 | ------------------------------------------------------------------------ |
D | packages/core-system-scripts | | | 82 | ------------------------------------------------------------------------------- |
M | packages/default.environment | | | 8 | ++++---- |
D | sources/core-system-conf | | | 1 | - |
D | sources/core-system-init | | | 1 | - |
D | sources/core-system-scripts | | | 1 | - |
A | sources/system-config-init | | | 1 | + |
A | sources/system-config-scripts | | | 1 | + |
D | templates/pkg/core-system-conf | | | 77 | ----------------------------------------------------------------------------- |
D | templates/pkg/core-system-init | | | 123 | ------------------------------------------------------------------------------- |
D | templates/pkg/core-system-rc | | | 19 | ------------------- |
M | templates/pkg/default.environment | | | 8 | ++++---- |
A | templates/pkg/system-config | | | 77 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | templates/pkg/system-config-init | | | 123 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | templates/pkg/system-config-rc | | | 19 | +++++++++++++++++++ |
R | templates/pkg/core-system-scripts -> templates/pkg/system-config-scripts | | | 0 |
19 files changed, 232 insertions(+), 687 deletions(-)
diff --git a/.gitmodules b/.gitmodules @@ -66,13 +66,13 @@ path = sources/snaprep url = ./sources/snaprep [submodule "sources/core-system-conf"] - path = sources/core-system-conf + path = sources/system-config url = ./sources/core-system-conf [submodule "sources/core-system-init"] - path = sources/core-system-init + path = sources/system-config-init url = ./sources/core-system-init [submodule "sources/core-system-scripts"] - path = sources/core-system-scripts + path = sources/system-config-scripts url = ./sources/core-system-scripts [submodule "sources/patchelf"] path = sources/patchelf diff --git a/packages/core-system-conf b/packages/core-system-conf @@ -1,130 +0,0 @@ -#!/usr/bin/env pthbs-build -#+busybox.e60885fe93ee85c01831673bb29f0e62a64903f4ce3094e3dc35bc8ec8887ad9 -#+diffutils.fd5fae528e3d092e2e30271e8e273cd7fdecce4642547308ca3356e654c3990b -#+gnu-make.782c9e6625fd7420e2cd38b847afed19db3b3844cae8a0426a0dbf73e10d78e5 -#+aat.e073f6b23349ea7153987ad737fc80f909241ae4a0c0a22adc12392fcad71597 -#+fileset.22d9abf3009dbbfe507bd7ff93fdd0bf7f86ee0bc317b37b423b89d70ab950a2 -#+rsync.b356835b04c5d49533ce9cd7660fd7d61f50d1c1d527b123f46e3eb2f25d3989 -#+execline.9d9d14aad09d9643f578727ab1ed3363b975772358c4ac8e756abdad4fca7a3d -#+kbd.4d0b59602cb299724eca17b59bddd6fbb1a72ad73b0103801da528856c31d461 -#+mdevd.d0ffd7f79efbd9ff9af5e2a93e8fe5fae0d994325eb28e2af7e5d6783c50afb3 -#+s6-linux-utils.198acb1d9ef7c0d4eade19a06d07864bfda68d89e4d65990af8bc1026c069885 -#+s6-rc.6cefe2791153127e0a783521ab97f3b124f023f21cdc2eddadbb865496ad0b45 -#+s6.bb3974d7b49c2034b5064bac508beae2d4bfc1a7b6543aefcbc1af9e9e94f1a7 -#+zsh.762204e14953017be79e356d4bf9f7681625a750ecc951f3510bf144ea7b51bb -#+core-system-scripts.132a3b1c6b226dee79156049db1244ebeacdf5a4bfcffc74b6b97175dad000fd -#+logincaps.5faea56c51b05e8cb2f04ab7cbbb9fe7c6050e1f901fdecd616dca315b365dad -#@git:5ee4e9eacd49b46b482c5054801fcd16304dfa53:core-system-conf - -def_prefix() { - prefix=/versions/$pthbs_package -} -def_dest() { - dest=${pthbs_destdir%/}//versions/$pthbs_package -} -def_prefix -def_dest -err_notfound() { - printf >&2 'Executable not found for command "%s"\n' "$1" - exit 1 -} -linkdep() { - exe=$(command which "$1") || err_notfound "$1" - exe=$(realpath "$exe") - name=$(basename "$1") - if ! test -x "$exe"; then - printf 'Error: executable not found: %s\n' "$1" - fi - mkdir -p "$dest/deps/command" - ln -sf $exe "$dest/deps/command/$name" -} - -cd 'core-system-conf' - -printf '%s\n' >config/etc/motd \ - "Welcome to $(cat ./config/hostname)!" \ - 'Current running configuration was generated from core-system-conf:5ee4e9eacd49b46b482c5054801fcd16304dfa53' \ - 'Last change on 2024-03-15 02:27:41 +0000 by ccx' - -printf '%s\n' >config/etc/skel/loginexec \ - "#!$(which execlineb) -S0" \ - 'user_loginexec $@' -chmod +x config/etc/skel/loginexec - -env 'pthbs_path_core-system-conf'="$prefix" \ - 'pthbs_path_containers=/versions/env.a00885f01e307362180c83a60ff605b1d75d3df7a4ee95f8e9ee31067dd9f1a0' \ - 'pthbs_path_mdevd=/versions/env.9ff4ae1aa76157d331d77b75c4dec8d6fd85395776d90a931bfb285a671a5c32' \ - make -j${JOBS:-1} -l$((1+${JOBS:-1})) all - -sort -u build/execfile | while IFS= read exename; do - linkdep "$exename" -done - -mkdir "$dest/command" -awk -v "zsh=$(which zsh)" <./postinstall >"$dest/command/install-as-current-environment.postinstall" ' -NR==1 { print "#!" zsh; next } -/@@current@@/ { print "current=/run/current"; next } -/@@versions@@/ { print "versions='/versions'"; next } -1 -' -chmod +x "$dest/command/install-as-current-environment.postinstall" - -mkdir -p "$dest/config/" -rsync -ai ./config/ "$dest/config/" -rsync -ai ./out/ "$dest/config/" -mv -v keys "$dest/" - - -cd "$pthbs_destdir/versions/$pthbs_package" -find -type d -o -print | awk -F/ ' -BEGIN { -} - -function r1(s) { - sub("^[.]/[^/]*", ".", s) - return s -} -function s1(repl, s) { - sub("^[.]/[^/]*", "./"repl, s) - return s -} -function link(src) { - x[$0]=0 - printf "%s\t%s\n", $0, src - printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr" -} -$1!="."{exit 1} - - -$2 == "config" { link($0); next } -$2 == "keys" { link($0); next } -$2 == "command" { link($0); next } -$2 == "bin" { link(s1("command", $0)); next } - -$2 == "library.so" { link($0); next } -$2 == "library" { link($0); next } -$2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next } -$2 == "lib" && $NF ~ /\.so(|\..*)$/ { link(s1("library.so", $0)); next } - -$2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next } - -$2 == "man" { link($0); next } -$2 == "info" { link($0); next } -$2 == "doc" { link($0); next } -$2 == "icons" { link($0); next } -$2 == "terminfo" { link($0); next } -$2 == "data" { link($0); next } -$2 == "include" { link($0); next } - -{ printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" } - -END { - for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" } - for(fname in x) { - if(x[fname]) { - printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr" - exit 3 - } - } -}' >.install-links.new -mv .install-links.new .install-links diff --git a/packages/core-system-init b/packages/core-system-init @@ -1,170 +0,0 @@ -#!/usr/bin/env pthbs-build -#+busybox.e60885fe93ee85c01831673bb29f0e62a64903f4ce3094e3dc35bc8ec8887ad9 -#+s6.bb3974d7b49c2034b5064bac508beae2d4bfc1a7b6543aefcbc1af9e9e94f1a7 -#+s6-rc.6cefe2791153127e0a783521ab97f3b124f023f21cdc2eddadbb865496ad0b45 -#+s6-portable-utils.39f4babb8cd30769f1a931708e5442244b0305c36ddafe32348c7dc30c000b00 -#+s6-linux-init.396413eed542c149346f51a569f2d686c03b2104f4d062f52422e444ad9b502d -#+execline.9d9d14aad09d9643f578727ab1ed3363b975772358c4ac8e756abdad4fca7a3d -#+core-system-rc.f378d755570a3d8649ec7bd75ac3f96fe6f8692f81a2f82f36b483a71d1d12e7 - -s6rcdb=/versions/core-system-rc.f378d755570a3d8649ec7bd75ac3f96fe6f8692f81a2f82f36b483a71d1d12e7/config/s6-rc-db -prefix=/versions/$pthbs_package -pkgdir="$pthbs_destdir/$prefix" - -q() { - "s6-quote" "$@" -} - -qx() { - exe=$(realpath "$(which "$1")") - name=$(basename "$1") - if ! test -x "$exe"; then - printf 'Error: executable not found: %s\n' "$1" - fi - mkdir -p "$pkgdir/deps/command" - ln -sf $exe "$pkgdir/deps/command/$name" - "s6-quote" "$prefix/deps/command/$name" -} - -# Generate init ($pkgdir must not exist but parent dir does) -mkdir -p "$pthbs_destdir//versions" -s6-linux-init-maker \ - -p "/run/current/command:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \ - -G "$(q "$prefix/deps/command/env") TERM=linux $(q "$prefix/deps/command/getty") 38400 tty9" \ - -t 1 \ - -N \ - -c "$prefix" \ - "$pkgdir" - - -# Link deps that are passed to s6-l-i-m -qx env -qx getty - -# Link execlineb - can't quote shebang -qx execlineb -el=$prefix/deps/command/$name - -# Rewrite bin/init as it fails finding it's own s6-linux-init -s6-cat >"$pkgdir/bin/init.new" <<EOF || exit $? -#!$el -S0 -$(qx pthbs-enter) -$(qx s6-envdir) -I /run/current/env -EOF -s6-cat >>"$pkgdir/bin/init.new" <"$pkgdir/bin/init" -chmod +x "$pkgdir/bin/init.new" -mv -v "$pkgdir/bin/init.new" "$pkgdir/bin/init" - -# Rewrite dynamically generated scripts -s6-cat >"$pkgdir/scripts/rc.init" <<EOF || exit $? -#!$el -S1 -$(qx export) TERM "linux" -$(qx foreground) { $(qx s6-echo) "* Starting s6-rc from "$(q "$s6rcdb") } -$(qx if) { $(qx s6-rc-init) -d -c $(q "$s6rcdb") /run/service } -$prefix/scripts/runlevel \$1 -EOF - -s6-cat >"$pkgdir/scripts/rc.shutdown" <<EOF || exit $? -#!$el -P - -### Things to do before hardware halt/reboot/poweroff. -### Ideally, it should be a single call to the service manager, -### telling it to bring all the services down. - -$(qx redirfd) -w 1 /dev/console -$(qx redirfd) -w 2 /dev/console -$(qx s6-rc) -v2 -bDa change -EOF - -s6-cat >"$pkgdir/scripts/runlevel" <<EOF || exit $? -#!$el -S1 -export TERM "linux" - -# The requested runlevel is in "\$1" but currently ignored. - -# Run the service manager. -# Call it twice because the first time may spuriously "timeout" -# due to the clock jumping forward. - -$(qx ifelse) -X { - $(qx s6-rc) -v 2 -t 600000 -- change ok-all-but-tty -} { - # no timeout, start ttys properly - $(qx foreground) { $(qx s6-echo) "* System started normally (bundle ok-all-but-tty)" } - $(qx foreground) { sleep 0.3 } - $(qx foreground) { $(qx s6-svc) -d /run/service/console-log-tail } - $(qx s6-rc) -v 2 -t 600000 -- change ok-all -} -$(qx foreground) { $(qx s6-echo) "* System startup failure: retry" } -# try again without tty and then with -$(qx foreground) { $(qx s6-rc) -v 2 -t 600000 -- change ok-all-but-tty } -$(qx foreground) { $(qx sleep) 0.1 } -$(qx foreground) { $(qx s6-svc) -d /run/service/console-log-tail } -$(qx s6-rc) -v 2 -t 600000 -- change ok-all -EOF - -s6-mkdir "$pkgdir/run-image/service/console-log-tail" || exit $? -s6-cat >"$pkgdir/run-image/service/console-log-tail/run" <<EOF || exit $? -#!$el -P -$(qx redirfd) -w 1 /dev/console -$(qx fdmove) -c 2 1 -$(qx pipeline) -w { $(qx s6-tai64nlocal) } -$(qx tail) -F -n +1 /run/uncaught-logs/current -EOF -s6-chmod 755 "$pkgdir/run-image/service/console-log-tail/run" exit $? - - -cd "$pthbs_destdir/versions/$pthbs_package" -find -type d -o -print | awk -F/ ' -BEGIN { - x["./bin/init"]=1 - x["./bin/halt"]=1 - x["./bin/poweroff"]=1 - x["./bin/reboot"]=1} - -function r1(s) { - sub("^[.]/[^/]*", ".", s) - return s -} -function s1(repl, s) { - sub("^[.]/[^/]*", "./"repl, s) - return s -} -function link(src) { - x[$0]=0 - printf "%s\t%s\n", $0, src - printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr" -} -$1!="."{exit 1} - - -$2 == "command" { link($0); next } -$2 == "bin" { link(s1("command", $0)); next } - -$2 == "library.so" { link($0); next } -$2 == "library" { link($0); next } -$2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next } -$2 == "lib" && $NF ~ /\.so(|\..*)$/ { link(s1("library.so", $0)); next } - -$2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next } - -$2 == "man" { link($0); next } -$2 == "info" { link($0); next } -$2 == "doc" { link($0); next } -$2 == "icons" { link($0); next } -$2 == "terminfo" { link($0); next } -$2 == "data" { link($0); next } -$2 == "include" { link($0); next } - -{ printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" } - -END { - for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" } - for(fname in x) { - if(x[fname]) { - printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr" - exit 3 - } - } -}' >.install-links.new -mv .install-links.new .install-links diff --git a/packages/core-system-rc b/packages/core-system-rc @@ -1,72 +0,0 @@ -#!/usr/bin/env pthbs-build -#+busybox.e60885fe93ee85c01831673bb29f0e62a64903f4ce3094e3dc35bc8ec8887ad9 -#+busybox-diffutils.4f5a07b29246414b77a7d71b103263af8f1249d75ddcbd9864e00def3d6feded -#+s6-rc.6cefe2791153127e0a783521ab97f3b124f023f21cdc2eddadbb865496ad0b45 -#+fileset.22d9abf3009dbbfe507bd7ff93fdd0bf7f86ee0bc317b37b423b89d70ab950a2 -#+core-system-conf.884627adc68c3906312374e399fb5046a3e399347aec3439d0881ca88c6da497 - -def_prefix() { - prefix=/versions/$pthbs_package -} -def_dest() { - dest=${pthbs_destdir%/}//versions/$pthbs_package -} -def_dest - -src=/versions/core-system-conf.884627adc68c3906312374e399fb5046a3e399347aec3439d0881ca88c6da497/config/s6-rc-source -s6-rc-compile ./s6-rc-db "$src" -mkdir -p "$dest/config" -mv -v s6-rc-db "$dest/config/" - -cd "$pthbs_destdir/versions/$pthbs_package" -find -type d -o -print | awk -F/ ' -BEGIN { -} - -function r1(s) { - sub("^[.]/[^/]*", ".", s) - return s -} -function s1(repl, s) { - sub("^[.]/[^/]*", "./"repl, s) - return s -} -function link(src) { - x[$0]=0 - printf "%s\t%s\n", $0, src - printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr" -} -$1!="."{exit 1} - - -$2 == "config" { link($0); next } -$2 == "command" { link($0); next } -$2 == "bin" { link(s1("command", $0)); next } - -$2 == "library.so" { link($0); next } -$2 == "library" { link($0); next } -$2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next } -$2 == "lib" && $NF ~ /\.so(|\..*)$/ { link(s1("library.so", $0)); next } - -$2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next } - -$2 == "man" { link($0); next } -$2 == "info" { link($0); next } -$2 == "doc" { link($0); next } -$2 == "icons" { link($0); next } -$2 == "terminfo" { link($0); next } -$2 == "data" { link($0); next } -$2 == "include" { link($0); next } - -{ printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" } - -END { - for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" } - for(fname in x) { - if(x[fname]) { - printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr" - exit 3 - } - } -}' >.install-links.new -mv .install-links.new .install-links diff --git a/packages/core-system-scripts b/packages/core-system-scripts @@ -1,82 +0,0 @@ -#!/usr/bin/env pthbs-build -#+busybox.e60885fe93ee85c01831673bb29f0e62a64903f4ce3094e3dc35bc8ec8887ad9 -#+zsh.762204e14953017be79e356d4bf9f7681625a750ecc951f3510bf144ea7b51bb -#+pthbs-banginstall.d1e43ec62e6d2b3a2a03a2d9ce487f6fe768fb7131c09ce0d2dd9e165233cff1 -#@git:dc793695cc0632a808af9d4415f3b0cf0f4dfba2:core-system-scripts - -: ${JOBS:=1} -prefix=/versions/$pthbs_package -pkgdir="$pthbs_destdir/$prefix" -mkdir -p "$pkgdir/" -cd 'core-system-scripts' - -for d in bin sbin command; do - if test -d "$d"; then - pthbs-banginstall "$d"/* "$pkgdir" - fi -done - -if test -d vim; then - mkdir -p "$pkgdir/vimfiles/pack/plugins/start" - mv -v vim "$pkgdir/vimfiles/pack/plugins/start/$pthbs_package" -fi - -if test -d zsh-functions; then - mkdir -p "$pkgdir/zsh" - mv -v zsh-functions "$pkgdir/zsh/site-functions" -fi - -cd "$pthbs_destdir/versions/$pthbs_package" -find -type d -o -print | awk -F/ ' -BEGIN { - x["./command/s"]=1 - x["./command/issue-gen"]=1} - -function r1(s) { - sub("^[.]/[^/]*", ".", s) - return s -} -function s1(repl, s) { - sub("^[.]/[^/]*", "./"repl, s) - return s -} -function link(src) { - x[$0]=0 - printf "%s\t%s\n", $0, src - printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr" -} -$1!="."{exit 1} - - -$2 == "zsh" { link($0); next } -$2 == "vimfiles" { link($0); next } -$2 == "command" { link($0); next } -$2 == "bin" { link(s1("command", $0)); next } - -$2 == "library.so" { link($0); next } -$2 == "library" { link($0); next } -$2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next } -$2 == "lib" && $NF ~ /\.so(|\..*)$/ { link(s1("library.so", $0)); next } - -$2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next } - -$2 == "man" { link($0); next } -$2 == "info" { link($0); next } -$2 == "doc" { link($0); next } -$2 == "icons" { link($0); next } -$2 == "terminfo" { link($0); next } -$2 == "data" { link($0); next } -$2 == "include" { link($0); next } - -{ printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" } - -END { - for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" } - for(fname in x) { - if(x[fname]) { - printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr" - exit 3 - } - } -}' >.install-links.new -mv .install-links.new .install-links diff --git a/packages/default.environment b/packages/default.environment @@ -1,7 +1,7 @@ -#+core-system-conf.884627adc68c3906312374e399fb5046a3e399347aec3439d0881ca88c6da497 -#+core-system-rc.f378d755570a3d8649ec7bd75ac3f96fe6f8692f81a2f82f36b483a71d1d12e7 -#+core-system-scripts.132a3b1c6b226dee79156049db1244ebeacdf5a4bfcffc74b6b97175dad000fd -#+core-system-init.9332282dd4cc626f8cb05c3906c53b629eca7a4fd335c6c5619e2d52175c1102 +#+system-config.f5d7e5a11eaae279e472fe1739fdeb03feefc570410babf2cb47d87821980171 +#+system-config-rc.f5e2185bd14499a3355fc29957a75a6a3e750a5888654daf90b105c74b0e9964 +#+system-config-scripts.ac300ce9214b7e302ac630c3335cd537000ec030b409ee951e53c563d9f71891 +#+system-config-init.c0dc2ae81e74f4ce83ecc0cf889acf508904a856fe0e0819ae041ffca8ed642c #+busybox.e60885fe93ee85c01831673bb29f0e62a64903f4ce3094e3dc35bc8ec8887ad9 #+gnu-make.782c9e6625fd7420e2cd38b847afed19db3b3844cae8a0426a0dbf73e10d78e5 #+musl-cross-make.65f98305f5666435bf0c6b9ccedffae2179ff1b3286752756886f760cf7771d2 diff --git a/sources/core-system-conf b/sources/core-system-conf @@ -1 +0,0 @@ -Subproject commit 5ee4e9eacd49b46b482c5054801fcd16304dfa53 diff --git a/sources/core-system-init b/sources/core-system-init @@ -1 +0,0 @@ -Subproject commit e1bc62ec78acc46e723b0fb86d81f2ce69f4c0c5 diff --git a/sources/core-system-scripts b/sources/core-system-scripts @@ -1 +0,0 @@ -Subproject commit dc793695cc0632a808af9d4415f3b0cf0f4dfba2 diff --git a/sources/system-config-init b/sources/system-config-init @@ -0,0 +1 @@ +Subproject commit e1bc62ec78acc46e723b0fb86d81f2ce69f4c0c5 diff --git a/sources/system-config-scripts b/sources/system-config-scripts @@ -0,0 +1 @@ +Subproject commit dc793695cc0632a808af9d4415f3b0cf0f4dfba2 diff --git a/templates/pkg/core-system-conf b/templates/pkg/core-system-conf @@ -1,77 +0,0 @@ -{% extends "genlinks" %} -{%- block script %} -#+{{pkg_install_name("busybox")}} -#+{{pkg_install_name("diffutils")}} -#+{{pkg_install_name("gnu-make")}} -#+{{pkg_install_name("aat")}} -#+{{pkg_install_name("fileset")}} -#+{{pkg_install_name("rsync")}} -#+{{pkg_install_name("execline")}} -#+{{pkg_install_name("kbd")}} -#+{{pkg_install_name("mdevd")}} -#+{{pkg_install_name("s6-linux-utils")}} -#+{{pkg_install_name("s6-rc")}} -#+{{pkg_install_name("s6")}} -#+{{pkg_install_name("zsh")}} -#+{{pkg_install_name("core-system-scripts")}} -#+{{pkg_install_name("logincaps")}} -#@git:{{submodule.current[name]}}:{{name}} - -{% include "functions/vars" %} -def_prefix -def_dest -err_notfound() { - printf >&2 'Executable not found for command "%s"\n' "$1" - exit 1 -} -linkdep() { - exe=$(command which "$1") || err_notfound "$1" - exe=$(realpath "$exe") - name=$(basename "$1") - if ! test -x "$exe"; then - printf 'Error: executable not found: %s\n' "$1" - fi - mkdir -p "$dest/deps/command" - ln -sf $exe "$dest/deps/command/$name" -} - -cd '{{name}}' - -printf '%s\n' >config/etc/motd \ - "Welcome to $(cat ./config/hostname)!" \ - 'Current running configuration was generated from {{name}}:{{submodule.current[name]}}' \ - 'Last change on {{submodule.commit_info(submodule.current[name])}}' - -printf '%s\n' >config/etc/skel/loginexec \ - "#!$(which execlineb) -S0" \ - 'user_loginexec $@' -chmod +x config/etc/skel/loginexec - -env 'pthbs_path_{{name}}'="$prefix" \ - 'pthbs_path_containers={{pkg_install_dir("containers.environment")}}' \ - 'pthbs_path_mdevd={{pkg_install_dir("mdevd.environment")}}' \ - {{make}} all - -sort -u build/execfile | while IFS= read exename; do - linkdep "$exename" -done - -mkdir "$dest/command" -awk -v "zsh=$(which zsh)" <./postinstall >"$dest/command/install-as-current-environment.postinstall" ' -NR==1 { print "#!" zsh; next } -/@@current@@/ { print "current=/run/current"; next } -/@@versions@@/ { print "versions='{{versions}}'"; next } -1 -' -chmod +x "$dest/command/install-as-current-environment.postinstall" - -mkdir -p "$dest/config/" -rsync -ai ./config/ "$dest/config/" -rsync -ai ./out/ "$dest/config/" -mv -v keys "$dest/" - -{% endblock -%} -{% block rules %} -$2 == "config" { link($0); next } -$2 == "keys" { link($0); next } -{% endblock -%} diff --git a/templates/pkg/core-system-init b/templates/pkg/core-system-init @@ -1,123 +0,0 @@ -{% extends "genlinks" %} -{%- block script %} -#+{{pkg_install_name("busybox")}} -#+{{pkg_install_name("s6")}} -#+{{pkg_install_name("s6-rc")}} -#+{{pkg_install_name("s6-portable-utils")}} -#+{{pkg_install_name("s6-linux-init")}} -#+{{pkg_install_name("execline")}} -#+{{pkg_install_name("core-system-rc")}} - -s6rcdb={{pkg_install_dir("core-system-rc")}}/config/s6-rc-db -prefix={{versions}}/$pthbs_package -pkgdir="$pthbs_destdir/$prefix" - -q() { - "s6-quote" "$@" -} - -qx() { - exe=$(realpath "$(which "$1")") - name=$(basename "$1") - if ! test -x "$exe"; then - printf 'Error: executable not found: %s\n' "$1" - fi - mkdir -p "$pkgdir/deps/command" - ln -sf $exe "$pkgdir/deps/command/$name" - "s6-quote" "$prefix/deps/command/$name" -} - -# Generate init ($pkgdir must not exist but parent dir does) -mkdir -p "$pthbs_destdir/{{versions}}" -s6-linux-init-maker \ - -p "/run/current/command:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \ - -G "$(q "$prefix/deps/command/env") TERM=linux $(q "$prefix/deps/command/getty") 38400 tty9" \ - -t 1 \ - -N \ - -c "$prefix" \ - "$pkgdir" - - -# Link deps that are passed to s6-l-i-m -qx env -qx getty - -# Link execlineb - can't quote shebang -qx execlineb -el=$prefix/deps/command/$name - -# Rewrite bin/init as it fails finding it's own s6-linux-init -s6-cat >"$pkgdir/bin/init.new" <<EOF || exit $? -#!$el -S0 -$(qx pthbs-enter) -$(qx s6-envdir) -I /run/current/env -EOF -s6-cat >>"$pkgdir/bin/init.new" <"$pkgdir/bin/init" -chmod +x "$pkgdir/bin/init.new" -mv -v "$pkgdir/bin/init.new" "$pkgdir/bin/init" - -# Rewrite dynamically generated scripts -s6-cat >"$pkgdir/scripts/rc.init" <<EOF || exit $? -#!$el -S1 -$(qx export) TERM "linux" -$(qx foreground) { $(qx s6-echo) "* Starting s6-rc from "$(q "$s6rcdb") } -$(qx if) { $(qx s6-rc-init) -d -c $(q "$s6rcdb") /run/service } -$prefix/scripts/runlevel \$1 -EOF - -s6-cat >"$pkgdir/scripts/rc.shutdown" <<EOF || exit $? -#!$el -P - -### Things to do before hardware halt/reboot/poweroff. -### Ideally, it should be a single call to the service manager, -### telling it to bring all the services down. - -$(qx redirfd) -w 1 /dev/console -$(qx redirfd) -w 2 /dev/console -$(qx s6-rc) -v2 -bDa change -EOF - -s6-cat >"$pkgdir/scripts/runlevel" <<EOF || exit $? -#!$el -S1 -export TERM "linux" - -# The requested runlevel is in "\$1" but currently ignored. - -# Run the service manager. -# Call it twice because the first time may spuriously "timeout" -# due to the clock jumping forward. - -$(qx ifelse) -X { - $(qx s6-rc) -v 2 -t 600000 -- change ok-all-but-tty -} { - # no timeout, start ttys properly - $(qx foreground) { $(qx s6-echo) "* System started normally (bundle ok-all-but-tty)" } - $(qx foreground) { sleep 0.3 } - $(qx foreground) { $(qx s6-svc) -d /run/service/console-log-tail } - $(qx s6-rc) -v 2 -t 600000 -- change ok-all -} -$(qx foreground) { $(qx s6-echo) "* System startup failure: retry" } -# try again without tty and then with -$(qx foreground) { $(qx s6-rc) -v 2 -t 600000 -- change ok-all-but-tty } -$(qx foreground) { $(qx sleep) 0.1 } -$(qx foreground) { $(qx s6-svc) -d /run/service/console-log-tail } -$(qx s6-rc) -v 2 -t 600000 -- change ok-all -EOF - -s6-mkdir "$pkgdir/run-image/service/console-log-tail" || exit $? -s6-cat >"$pkgdir/run-image/service/console-log-tail/run" <<EOF || exit $? -#!$el -P -$(qx redirfd) -w 1 /dev/console -$(qx fdmove) -c 2 1 -$(qx pipeline) -w { $(qx s6-tai64nlocal) } -$(qx tail) -F -n +1 /run/uncaught-logs/current -EOF -s6-chmod 755 "$pkgdir/run-image/service/console-log-tail/run" exit $? - -{% endblock -%} -{% block genlinks_begin %} - x["./bin/init"]=1 - x["./bin/halt"]=1 - x["./bin/poweroff"]=1 - x["./bin/reboot"]=1 -{%- endblock %} diff --git a/templates/pkg/core-system-rc b/templates/pkg/core-system-rc @@ -1,19 +0,0 @@ -{% extends "genlinks" %} -{%- block script %} -#+{{pkg_install_name("busybox")}} -#+{{pkg_install_name("busybox-diffutils")}} -#+{{pkg_install_name("s6-rc")}} -#+{{pkg_install_name("fileset")}} -#+{{pkg_install_name("core-system-conf")}} - -{% include "functions/vars" %} -def_dest - -src={{pkg_install_dir("core-system-conf")}}/config/s6-rc-source -s6-rc-compile ./s6-rc-db "$src" -mkdir -p "$dest/config" -mv -v s6-rc-db "$dest/config/" -{% endblock -%} -{% block rules %} -$2 == "config" { link($0); next } -{% endblock -%} diff --git a/templates/pkg/default.environment b/templates/pkg/default.environment @@ -1,6 +1,6 @@ -#+{{pkg_install_name("core-system-conf")}} -#+{{pkg_install_name("core-system-rc")}} -#+{{pkg_install_name("core-system-scripts")}} -#+{{pkg_install_name("core-system-init")}} +#+{{pkg_install_name("system-config")}} +#+{{pkg_install_name("system-config-rc")}} +#+{{pkg_install_name("system-config-scripts")}} +#+{{pkg_install_name("system-config-init")}} {% include "pkg/userspace.environment" %}{# {% include "pkg/kernel.environment" %} #} diff --git a/templates/pkg/system-config b/templates/pkg/system-config @@ -0,0 +1,77 @@ +{% extends "genlinks" %} +{%- block script %} +#+{{pkg_install_name("busybox")}} +#+{{pkg_install_name("diffutils")}} +#+{{pkg_install_name("gnu-make")}} +#+{{pkg_install_name("aat")}} +#+{{pkg_install_name("fileset")}} +#+{{pkg_install_name("rsync")}} +#+{{pkg_install_name("execline")}} +#+{{pkg_install_name("kbd")}} +#+{{pkg_install_name("mdevd")}} +#+{{pkg_install_name("s6-linux-utils")}} +#+{{pkg_install_name("s6-rc")}} +#+{{pkg_install_name("s6")}} +#+{{pkg_install_name("zsh")}} +#+{{pkg_install_name("system-config-scripts")}} +#+{{pkg_install_name("logincaps")}} +#@git:{{submodule.current[name]}}:{{name}} + +{% include "functions/vars" %} +def_prefix +def_dest +err_notfound() { + printf >&2 'Executable not found for command "%s"\n' "$1" + exit 1 +} +linkdep() { + exe=$(command which "$1") || err_notfound "$1" + exe=$(realpath "$exe") + name=$(basename "$1") + if ! test -x "$exe"; then + printf 'Error: executable not found: %s\n' "$1" + fi + mkdir -p "$dest/deps/command" + ln -sf $exe "$dest/deps/command/$name" +} + +cd '{{name}}' + +printf '%s\n' >config/etc/motd \ + "Welcome to $(cat ./config/hostname)!" \ + 'Current running configuration was generated from {{name}}:{{submodule.current[name]}}' \ + 'Last change on {{submodule.commit_info(submodule.current[name])}}' + +printf '%s\n' >config/etc/skel/loginexec \ + "#!$(which execlineb) -S0" \ + 'user_loginexec $@' +chmod +x config/etc/skel/loginexec + +env 'pthbs_path_{{name}}'="$prefix" \ + 'pthbs_path_containers={{pkg_install_dir("containers.environment")}}' \ + 'pthbs_path_mdevd={{pkg_install_dir("mdevd.environment")}}' \ + {{make}} all + +sort -u build/execfile | while IFS= read exename; do + linkdep "$exename" +done + +mkdir "$dest/command" +awk -v "zsh=$(which zsh)" <./postinstall >"$dest/command/install-as-current-environment.postinstall" ' +NR==1 { print "#!" zsh; next } +/@@current@@/ { print "current=/run/current"; next } +/@@versions@@/ { print "versions='{{versions}}'"; next } +1 +' +chmod +x "$dest/command/install-as-current-environment.postinstall" + +mkdir -p "$dest/config/" +rsync -ai ./config/ "$dest/config/" +rsync -ai ./out/ "$dest/config/" +mv -v keys "$dest/" + +{% endblock -%} +{% block rules %} +$2 == "config" { link($0); next } +$2 == "keys" { link($0); next } +{% endblock -%} diff --git a/templates/pkg/system-config-init b/templates/pkg/system-config-init @@ -0,0 +1,123 @@ +{% extends "genlinks" %} +{%- block script %} +#+{{pkg_install_name("busybox")}} +#+{{pkg_install_name("s6")}} +#+{{pkg_install_name("s6-rc")}} +#+{{pkg_install_name("s6-portable-utils")}} +#+{{pkg_install_name("s6-linux-init")}} +#+{{pkg_install_name("execline")}} +#+{{pkg_install_name("system-config-rc")}} + +s6rcdb={{pkg_install_dir("system-config-rc")}}/config/s6-rc-db +prefix={{versions}}/$pthbs_package +pkgdir="$pthbs_destdir/$prefix" + +q() { + "s6-quote" "$@" +} + +qx() { + exe=$(realpath "$(which "$1")") + name=$(basename "$1") + if ! test -x "$exe"; then + printf 'Error: executable not found: %s\n' "$1" + fi + mkdir -p "$pkgdir/deps/command" + ln -sf $exe "$pkgdir/deps/command/$name" + "s6-quote" "$prefix/deps/command/$name" +} + +# Generate init ($pkgdir must not exist but parent dir does) +mkdir -p "$pthbs_destdir/{{versions}}" +s6-linux-init-maker \ + -p "/run/current/command:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \ + -G "$(q "$prefix/deps/command/env") TERM=linux $(q "$prefix/deps/command/getty") 38400 tty9" \ + -t 1 \ + -N \ + -c "$prefix" \ + "$pkgdir" + + +# Link deps that are passed to s6-l-i-m +qx env +qx getty + +# Link execlineb - can't quote shebang +qx execlineb +el=$prefix/deps/command/$name + +# Rewrite bin/init as it fails finding it's own s6-linux-init +s6-cat >"$pkgdir/bin/init.new" <<EOF || exit $? +#!$el -S0 +$(qx pthbs-enter) +$(qx s6-envdir) -I /run/current/env +EOF +s6-cat >>"$pkgdir/bin/init.new" <"$pkgdir/bin/init" +chmod +x "$pkgdir/bin/init.new" +mv -v "$pkgdir/bin/init.new" "$pkgdir/bin/init" + +# Rewrite dynamically generated scripts +s6-cat >"$pkgdir/scripts/rc.init" <<EOF || exit $? +#!$el -S1 +$(qx export) TERM "linux" +$(qx foreground) { $(qx s6-echo) "* Starting s6-rc from "$(q "$s6rcdb") } +$(qx if) { $(qx s6-rc-init) -d -c $(q "$s6rcdb") /run/service } +$prefix/scripts/runlevel \$1 +EOF + +s6-cat >"$pkgdir/scripts/rc.shutdown" <<EOF || exit $? +#!$el -P + +### Things to do before hardware halt/reboot/poweroff. +### Ideally, it should be a single call to the service manager, +### telling it to bring all the services down. + +$(qx redirfd) -w 1 /dev/console +$(qx redirfd) -w 2 /dev/console +$(qx s6-rc) -v2 -bDa change +EOF + +s6-cat >"$pkgdir/scripts/runlevel" <<EOF || exit $? +#!$el -S1 +export TERM "linux" + +# The requested runlevel is in "\$1" but currently ignored. + +# Run the service manager. +# Call it twice because the first time may spuriously "timeout" +# due to the clock jumping forward. + +$(qx ifelse) -X { + $(qx s6-rc) -v 2 -t 600000 -- change ok-all-but-tty +} { + # no timeout, start ttys properly + $(qx foreground) { $(qx s6-echo) "* System started normally (bundle ok-all-but-tty)" } + $(qx foreground) { sleep 0.3 } + $(qx foreground) { $(qx s6-svc) -d /run/service/console-log-tail } + $(qx s6-rc) -v 2 -t 600000 -- change ok-all +} +$(qx foreground) { $(qx s6-echo) "* System startup failure: retry" } +# try again without tty and then with +$(qx foreground) { $(qx s6-rc) -v 2 -t 600000 -- change ok-all-but-tty } +$(qx foreground) { $(qx sleep) 0.1 } +$(qx foreground) { $(qx s6-svc) -d /run/service/console-log-tail } +$(qx s6-rc) -v 2 -t 600000 -- change ok-all +EOF + +s6-mkdir "$pkgdir/run-image/service/console-log-tail" || exit $? +s6-cat >"$pkgdir/run-image/service/console-log-tail/run" <<EOF || exit $? +#!$el -P +$(qx redirfd) -w 1 /dev/console +$(qx fdmove) -c 2 1 +$(qx pipeline) -w { $(qx s6-tai64nlocal) } +$(qx tail) -F -n +1 /run/uncaught-logs/current +EOF +s6-chmod 755 "$pkgdir/run-image/service/console-log-tail/run" exit $? + +{% endblock -%} +{% block genlinks_begin %} + x["./bin/init"]=1 + x["./bin/halt"]=1 + x["./bin/poweroff"]=1 + x["./bin/reboot"]=1 +{%- endblock %} diff --git a/templates/pkg/system-config-rc b/templates/pkg/system-config-rc @@ -0,0 +1,19 @@ +{% extends "genlinks" %} +{%- block script %} +#+{{pkg_install_name("busybox")}} +#+{{pkg_install_name("busybox-diffutils")}} +#+{{pkg_install_name("s6-rc")}} +#+{{pkg_install_name("fileset")}} +#+{{pkg_install_name("system-config")}} + +{% include "functions/vars" %} +def_dest + +src={{pkg_install_dir("system-config")}}/config/s6-rc-source +s6-rc-compile ./s6-rc-db "$src" +mkdir -p "$dest/config" +mv -v s6-rc-db "$dest/config/" +{% endblock -%} +{% block rules %} +$2 == "config" { link($0); next } +{% endblock -%} diff --git a/templates/pkg/core-system-scripts b/templates/pkg/system-config-scripts