mrrl

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

patchelf:bootstrap (3008B)


      1 #!/usr/bin/env pthbs-build
      2 #@pragma:nosandbox
      3 #@pragma:nopath
      4 #@git:523f401584d9584e76c9c77004e7abeb9e6c4551:patchelf
      5 
      6 
      7 # - build script start -
      8 
      9 autotools_config() {
     10 	prefix=/versions/$pthbs_package
     11 	./configure -C \
     12 		--prefix="$prefix" \
     13 		--build="$(${CC:-gcc} -dumpmachine)" \
     14 		--bindir="$prefix/command" \
     15 		--sbindir="$prefix/command" \
     16 		--infodir="$prefix/info" \
     17 		--localedir="$prefix/locale" \
     18 		--mandir="$prefix/man" \
     19 		--libdir="$prefix/library" \
     20 		--docdir="$prefix/doc/patchelf" \
     21 		--datadir="$prefix/data" \
     22 		--datarootdir="$prefix/data" \
     23 		--localstatedir='/var/pthbs' \
     24 		"$@"
     25 
     26 }
     27 
     28 autotools_config_static() {
     29 	build_env_static
     30 	autotools_config "$@" --enable-static --disable-shared
     31 }
     32 
     33 build_env_static() {
     34 	export LD_LIBRARY_PATH="$pthbs_build_environment/library"
     35 	export CPATH="$pthbs_build_environment/include"
     36 	export LDFLAGS="-static -L$pthbs_build_environment/library $LDFLAGS"
     37 }
     38 
     39 check_static() {
     40 	local exe || true
     41 	exe=$pthbs_destdir'/versions'/$pthbs_package/$1
     42 	if ! test -f $exe; then
     43 		printf '%s\n' "Error: file '$1' doesn't exist!"
     44 		exit 1
     45 	fi
     46 	local interp_info || true
     47 	interp_info=$(readelf --string-dump=.interp "$exe") || exit $?
     48 	if test x '!=' "x$interp_info"; then
     49 		printf '%s\n' "Error: '$1' is a dynamic binary!"
     50 		exit 1
     51 	fi
     52 }
     53 
     54 prefix=/versions/$pthbs_package
     55 dest=${pthbs_destdir%/}${prefix}
     56 cd 'patchelf'
     57 
     58 ./bootstrap.sh
     59 autotools_config_static . --disable-nls
     60 
     61 make -j${JOBS:-1} -l$((1+${JOBS:-1}))
     62 
     63 make DESTDIR="$pthbs_destdir" install
     64 
     65 
     66 
     67 check_static command/patchelf
     68 
     69 
     70 cd "$pthbs_destdir/versions/$pthbs_package"
     71 find -type d -o -print | awk -F/ '
     72 BEGIN {
     73 	x["./command/patchelf"]=1
     74 	x["./man/man1/patchelf.1"]=1
     75 }
     76 
     77 function r1(s) {
     78 	sub("^[.]/[^/]*", ".", s)
     79 	return s
     80 }
     81 function s1(repl, s) {
     82 	sub("^[.]/[^/]*", "./"repl, s)
     83 	return s
     84 }
     85 function link(src) {
     86 	x[$0]=0
     87 	printf "%s\t%s\n", $0, src
     88 	printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr"
     89 }
     90 $1!="."{exit 1}
     91 
     92 
     93 $2 == "config" { link($0); next }
     94 $2 == "keys" { link($0); next }
     95 $2 == "zsh" { link($0); next }
     96 $2 == "env" { link($0); next }
     97 $2 == "command" { link($0); next }
     98 $2 == "bin" { link(s1("command", $0)); next }
     99 
    100 $2 == "library.so" { link($0); next }
    101 $2 == "library" { link($0); next }
    102 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next }
    103 $2 == "lib" && $NF ~ /\.so(\..*)?$/ { link(s1("library.so", $0)); next }
    104 
    105 $2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next }
    106 
    107 $2 == "man" { link($0); next }
    108 $2 == "info" { link($0); next }
    109 $2 == "doc" { link($0); next }
    110 $2 == "icons" { link($0); next }
    111 $2 == "terminfo" { link($0); next }
    112 $2 == "data" { link($0); next }
    113 $2 == "include" { link($0); next }
    114 
    115 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" }
    116 
    117 END {
    118 	for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" }
    119 	for(fname in x) {
    120 		if(x[fname]) {
    121 			printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr"
    122 			exit 3
    123 		}
    124 	}
    125 }' >.install-links.new
    126 mv .install-links.new .install-links
    127