mrrl

Minimal Reliable Reproducible Linux
git clone https://ccx.te2000.cz/git/mrrl
Log | Files | Refs | Submodules | README

system-config (4758B)


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