system-config (4278B)
1 #!/usr/bin/env pthbs-build 2 #+busybox.f4ef3d511c029095beda8d21dd48f7730bec63fb09792ca951402d6620338089 3 #+diffutils.3624d5d708d8d0c246f53189fddbc8008971f0c085ba8ab2e2d4e177d6dc7940 4 #+gnu-make.444e811a68f4f16724e21354b710fad3592e53a2dbf7c0c78658f3d4e7c8e465 5 #+aat.9432aa485263e75ca3e43d6511c561a9cd328c417ebe26b890ed4a8061fee06f 6 #+fileset.7159458f5e8c9237e1e1708cafced263dd342d5fd24ccec97ae8092d9b1c5150 7 #+rsync.ba5e1b943d7caedd402b472208d5450dd417de7bd509aac5bf46f94d73bbc907 8 #+execline.c89bee1b1207461afa2d2ab9250f0940a2a6bbca3e45bdd60037049a75f4adf9 9 #+kbd.2a0ad895612242729ff63f689075b1bff9295cba0f3eac9c23d79aedf88f6f54 10 #+mdevd.ce53dc40e066f620a163354acb732a70f019902cf9dbdb45571d368eaf4f67b8 11 #+s6-linux-utils.f7e0654375f11beedafd731ad1dd66c0de8d03452bb8e38bb647cc51cc3adb2e 12 #+s6-rc.c131bb99b2054bcd9705c5a5652822938265a8587a54d2894667b8b620815c7f 13 #+s6.43f7ad2aaeb2646da287c5bddf7c29c44d3f7b68a976beee75b60da44b54759e 14 #+zsh.4ac9e4166454e8d60c15837b7ca4938abe99db029b3fffa11b1cfd54d40ae09b 15 #+system-config-scripts.4c00e32b8c4f6feef53b562356abd54830cc7e889149e4f8bcb928d6e6e93378 16 #+logincaps.81ffbb96fbc3c630eda5e1bb2249d6691f0fba11821f56c08ce3c42cbf186620 17 #@git:0a1466e946de353d1947a4cdb2210b5699c141dd:system-config 18 19 def_prefix() { 20 prefix=/versions/$pthbs_package 21 } 22 def_dest() { 23 dest=${pthbs_destdir%/}//versions/$pthbs_package 24 } 25 def_prefix 26 def_dest 27 err_notfound() { 28 printf >&2 'Executable not found for command "%s"\n' "$1" 29 exit 1 30 } 31 linkdep() { 32 exe=$(command which "$1") || err_notfound "$1" 33 exe=$(realpath "$exe") 34 name=$(basename "$1") 35 if ! test -x "$exe"; then 36 printf 'Error: executable not found: %s\n' "$1" 37 fi 38 mkdir -p "$dest/deps/command" 39 ln -sf $exe "$dest/deps/command/$name" 40 } 41 42 cd 'system-config' 43 44 printf '%s\n' >config/etc/motd \ 45 "Welcome to $(cat ./config/hostname)!" \ 46 'Current running configuration was generated from system-config:0a1466e946de353d1947a4cdb2210b5699c141dd' \ 47 'Last change on 2025-04-15 00:39:09 +0000 by Jan Pobrislo' 48 49 printf '%s\n' >config/etc/skel/loginexec \ 50 "#!$(which execlineb) -S0" \ 51 'user_loginexec $@' 52 chmod +x config/etc/skel/loginexec 53 54 env 'pthbs_path_system-config'="$prefix" \ 55 'pthbs_path_containers=/versions/env.567e2769b791f40be31d2a0d0f12d897b7756754dbd3bf62dc6593ae00dd011f' \ 56 'pthbs_path_mdevd=/versions/env.699c310193b7957c8ec17e16d6846443f99c198e3e2ce6425066f4523de2cf1e' \ 57 make -j${JOBS:-1} -l$((1+${JOBS:-1})) all 58 59 sort -u build/execfile | while IFS= read exename; do 60 linkdep "$exename" 61 done 62 63 mkdir "$dest/command" 64 awk -v "zsh=$(which zsh)" <./postinstall >"$dest/command/install-as-current-environment.postinstall" ' 65 NR==1 { print "#!" zsh; next } 66 /@@current@@/ { print "current=/run/current"; next } 67 /@@versions@@/ { print "versions='/versions'"; next } 68 1 69 ' 70 chmod +x "$dest/command/install-as-current-environment.postinstall" 71 72 mkdir -p "$dest/config/" 73 rsync -ai ./config/ "$dest/config/" 74 rsync -ai ./out/ "$dest/config/" 75 mv -v keys "$dest/" 76 77 78 cd "$pthbs_destdir/versions/$pthbs_package" 79 find -type d -o -print | awk -F/ ' 80 BEGIN { 81 } 82 83 function r1(s) { 84 sub("^[.]/[^/]*", ".", s) 85 return s 86 } 87 function s1(repl, s) { 88 sub("^[.]/[^/]*", "./"repl, s) 89 return s 90 } 91 function link(src) { 92 x[$0]=0 93 printf "%s\t%s\n", $0, src 94 printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr" 95 } 96 $1!="."{exit 1} 97 98 99 $2 == "config" { link($0); next } 100 $2 == "keys" { link($0); next } 101 $2 == "command" { link($0); next } 102 $2 == "bin" { link(s1("command", $0)); next } 103 104 $2 == "library.so" { link($0); next } 105 $2 == "library" { link($0); next } 106 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next } 107 $2 == "lib" && $NF ~ /\.so(|\..*)$/ { link(s1("library.so", $0)); next } 108 109 $2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next } 110 111 $2 == "man" { link($0); next } 112 $2 == "info" { link($0); next } 113 $2 == "doc" { link($0); next } 114 $2 == "icons" { link($0); next } 115 $2 == "terminfo" { link($0); next } 116 $2 == "data" { link($0); next } 117 $2 == "include" { link($0); next } 118 119 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" } 120 121 END { 122 for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" } 123 for(fname in x) { 124 if(x[fname]) { 125 printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr" 126 exit 3 127 } 128 } 129 }' >.install-links.new 130 mv .install-links.new .install-links