mrrl

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

getconf (2763B)


      1 #!/usr/bin/env pthbs-build
      2 #+busybox.539513a18a06a21e4660004fea30f3658959c5c7f54488b66b5fee7120b0c27c
      3 #+busybox-findutils.3ba95afbbde5f39d6a3c0b17d82ff2e5350904cf19dd40acdf1c60ed126d3bda
      4 #+busybox-awk.4ac003d165540d0084cd08c1386f136343851ef344ac5ff844769b058049d859
      5 #+musl-cross-make.ef7f483eefcad5b8f2d6c8329e61a0acaca7864b88e9521cb839392c62f45676
      6 #@sha256:d87d0cbb3690ae2c5d8cc218349fd8278b93855dd625deaf7ae50e320aad247c:getconf.c
      7 
      8 
      9 # - build script start -
     10 
     11 build_env_static() {
     12 	export LD_LIBRARY_PATH="$pthbs_build_environment/library"
     13 	export CPATH="$pthbs_build_environment/include"
     14 	export LDFLAGS="-static -L$pthbs_build_environment/library $LDFLAGS"
     15 }
     16 
     17 check_static() {
     18 	local exe || true
     19 	exe=$pthbs_destdir'/versions'/$pthbs_package/$1
     20 	if ! test -f $exe; then
     21 		printf '%s\n' "Error: file '$1' doesn't exist!"
     22 		exit 1
     23 	fi
     24 	local interp_info || true
     25 	interp_info=$(readelf --string-dump=.interp "$exe") || exit $?
     26 	if test x '!=' "x$interp_info"; then
     27 		printf '%s\n' "Error: '$1' is a dynamic binary!"
     28 		exit 1
     29 	fi
     30 }
     31 
     32 prefix=/versions/$pthbs_package
     33 dest=${pthbs_destdir%/}${prefix}
     34 cd '.'
     35 name='getconf'
     36 
     37 
     38 build_env_static
     39 gcc ${CFLAGS} -o "$name" "$name.c" $LDFLAGS
     40 
     41 install -d "$pthbs_destdir/$prefix/command"
     42 install -m 755 "$name" "$pthbs_destdir/$prefix/command"
     43 
     44 
     45 
     46 check_static "command/$name"
     47 
     48 
     49 
     50 cd "$pthbs_destdir/versions/$pthbs_package"
     51 find -type d -o -print | awk -F/ '
     52 BEGIN {
     53 	x["./command/getconf"]=1}
     54 
     55 function r1(s) {
     56 	sub("^[.]/[^/]*", ".", s)
     57 	return s
     58 }
     59 function s1(repl, s) {
     60 	sub("^[.]/[^/]*", "./"repl, s)
     61 	return s
     62 }
     63 function link(src) {
     64 	x[$0]=0
     65 	printf "%s\t%s\n", $0, src
     66 	printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr"
     67 }
     68 $1!="."{exit 1}
     69 
     70 
     71 $2 == "config" { link($0); next }
     72 $2 == "keys" { link($0); next }
     73 $2 == "zsh" { link($0); next }
     74 $2 == "env" { link($0); next }
     75 $2 == "command" { link($0); next }
     76 $2 == "bin" { link(s1("command", $0)); next }
     77 
     78 $2 == "library.so" { link($0); next }
     79 $2 == "library" { link($0); next }
     80 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next }
     81 $2 == "lib" && $NF ~ /\.so(\..*)?$/ { link(s1("library.so", $0)); next }
     82 
     83 $2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next }
     84 
     85 $2 == "man" { link($0); next }
     86 $2 == "info" { link($0); next }
     87 $2 == "doc" { link($0); next }
     88 $2 == "icons" { link($0); next }
     89 $2 == "terminfo" { link($0); next }
     90 $2 == "data" { link($0); next }
     91 $2 == "include" { link($0); next }
     92 
     93 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" }
     94 
     95 END {
     96 	for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" }
     97 	for(fname in x) {
     98 		if(x[fname]) {
     99 			printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr"
    100 			exit 3
    101 		}
    102 	}
    103 }' >.install-links.new
    104 mv .install-links.new .install-links
    105