system-config (4269B)
1 #!/usr/bin/env pthbs-build 2 #+busybox.3664b94c09ea6d35ce73985026762c142829e53fed4a38541af3afb00c37dd4a 3 #+diffutils.811cee54633900909246e20210325e64c29140ee4246c91f4382b5ca3bac3f0b 4 #+gnu-make.529116171fecc2bdac7c70e109d28270d765379c8a52cf7c3ea7453195bbf42b 5 #+aat.0423de00911453c239f3943718170ad1d06ca9c7c938c0bce76a5f4aab9b0f70 6 #+fileset.998d2ed18930fb567363facae7e05fbc921118d02967e23506f72604e354a9d8 7 #+rsync.91a4dd56d8e661d8d4c3010d0185d3ae78d9a1868c955c7fa614b4381b3d4c76 8 #+execline.e08da9de6042531591759e132214cca8c47afe474d7b7ee228261351057ac9b9 9 #+kbd.cb15a816990ee9bce616e3f1545dc21b5e950b66c0286a687b63606f98705bb8 10 #+mdevd.371e7dea4838697393a45956d697ff6fc1e20275b5e890053604238eaf81311e 11 #+s6-linux-utils.a5014500cc578e6e754a93022b31a15e944fa75558738ad9cdaf9dcd29f0ba01 12 #+s6-rc.2a49d9dc336d58c9a691bb965db5143c9a0feee5cf00a16a9d6b62d493cb1fbf 13 #+s6.945bdb6cddcddb0d41cf7dc1a816fe6350eec79b0f3e5d7726fe4d90ed7844be 14 #+zsh.3d9297eaf146984d3769d01311c79c9bc450b0a35617f04b1e8260316348ba5a 15 #+system-config-scripts.737d882d87f53d188547dfb194a16c3004e0b81a4fa5b7b7eb3ae34d8da71fb8 16 #+logincaps.07aeb21399e3a13a0590022750959fc614904fe36784fc16cd886dfcc70c7aee 17 #@git:f9d071a4c5870d42d00d0ca496efac527388e6f4: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:f9d071a4c5870d42d00d0ca496efac527388e6f4' \ 47 'Last change on 2024-10-11 11:50:24 +0000 by ccx' 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.4c9133c096937fc18fcaf93474528034f03538cd59860cb665afdba2fa835d19' \ 56 'pthbs_path_mdevd=/versions/env.e1a2debba729e032fc7ed534deaeb5a4f1ce0792c16fbb022f7c053da667eed3' \ 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