mrrl

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

abduco (3183B)


      1 #!/usr/bin/env pthbs-build
      2 #+busybox.539513a18a06a21e4660004fea30f3658959c5c7f54488b66b5fee7120b0c27c
      3 #+busybox-findutils.3ba95afbbde5f39d6a3c0b17d82ff2e5350904cf19dd40acdf1c60ed126d3bda
      4 #+busybox-awk.4ac003d165540d0084cd08c1386f136343851ef344ac5ff844769b058049d859
      5 #+musl-cross-make.ef7f483eefcad5b8f2d6c8329e61a0acaca7864b88e9521cb839392c62f45676
      6 #+gnu-make.6c204d453a2d9b4e29dd7b9f93fc7c5a928284402b8646493cf72004f748753c
      7 #+busybox-diffutils.b820ef7a40bea977a2bf740425ae15b2d9a21097bcf3a2f5ec77c21782b9deb8
      8 #@git:8c32909a159aaa9484c82b71f05b7a73321eb491:abduco
      9 
     10 
     11 # - build script start -
     12 
     13 build_env_static() {
     14 	export LD_LIBRARY_PATH="$pthbs_build_environment/library"
     15 	export CPATH="$pthbs_build_environment/include"
     16 	export LDFLAGS="-static -L$pthbs_build_environment/library $LDFLAGS"
     17 }
     18 
     19 check_static() {
     20 	local exe || true
     21 	exe=$pthbs_destdir'/versions'/$pthbs_package/$1
     22 	if ! test -f $exe; then
     23 		printf '%s\n' "Error: file '$1' doesn't exist!"
     24 		exit 1
     25 	fi
     26 	local interp_info || true
     27 	interp_info=$(readelf --string-dump=.interp "$exe") || exit $?
     28 	if test x '!=' "x$interp_info"; then
     29 		printf '%s\n' "Error: '$1' is a dynamic binary!"
     30 		exit 1
     31 	fi
     32 }
     33 
     34 prefix=/versions/$pthbs_package
     35 dest=${pthbs_destdir%/}${prefix}
     36 cd 'abduco'
     37 
     38 build_env_static
     39 cat >config.mk <<EOF
     40 # Any changes made here will be lost if configure is re-run
     41 SRCDIR = .
     42 PREFIX = ${prefix}
     43 EXEC_PREFIX = \$(PREFIX)
     44 BINDIR = ${prefix}/command
     45 MANPREFIX = ${prefix}/man
     46 CC = cc
     47 CFLAGS = -pipe -Os
     48 LDFLAGS = -static
     49 EOF
     50 sed 's/^/> /' config.mk
     51 
     52 
     53 make -j${JOBS:-1} -l$((1+${JOBS:-1}))
     54 
     55 make DESTDIR="$pthbs_destdir" install
     56 
     57 # the Makefile hardcodes 'bin' despite configure undersanding BINDIR
     58 mv "${dest}/bin" "${dest}/command"
     59 
     60 
     61 
     62 check_static command/abduco
     63 
     64 
     65 
     66 cd "$pthbs_destdir/versions/$pthbs_package"
     67 find -type d -o -print | awk -F/ '
     68 BEGIN {
     69 	x["./command/abduco"]=1
     70 }
     71 
     72 function r1(s) {
     73 	sub("^[.]/[^/]*", ".", s)
     74 	return s
     75 }
     76 function s1(repl, s) {
     77 	sub("^[.]/[^/]*", "./"repl, s)
     78 	return s
     79 }
     80 function link(src) {
     81 	x[$0]=0
     82 	printf "%s\t%s\n", $0, src
     83 	printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr"
     84 }
     85 $1!="."{exit 1}
     86 
     87 
     88 $2 == "config" { link($0); next }
     89 $2 == "keys" { link($0); next }
     90 $2 == "zsh" { link($0); next }
     91 $2 == "env" { link($0); next }
     92 $2 == "command" { link($0); next }
     93 $2 == "bin" { link(s1("command", $0)); next }
     94 
     95 $2 == "library.so" { link($0); next }
     96 $2 == "library" { link($0); next }
     97 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next }
     98 $2 == "lib" && $NF ~ /\.so(\..*)?$/ { link(s1("library.so", $0)); next }
     99 
    100 $2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next }
    101 
    102 $2 == "man" { link($0); next }
    103 $2 == "info" { link($0); next }
    104 $2 == "doc" { link($0); next }
    105 $2 == "icons" { link($0); next }
    106 $2 == "terminfo" { link($0); next }
    107 $2 == "data" { link($0); next }
    108 $2 == "include" { link($0); next }
    109 
    110 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" }
    111 
    112 END {
    113 	for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" }
    114 	for(fname in x) {
    115 		if(x[fname]) {
    116 			printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr"
    117 			exit 3
    118 		}
    119 	}
    120 }' >.install-links.new
    121 mv .install-links.new .install-links
    122