mrrl

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

spawn-pty (2638B)


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