pthbs

Packaging Through Hashed Build Scripts
git clone https://ccx.te2000.cz/git/pthbs
Log | Files | Refs | Submodules | README

patchelf:bootstrap (2798B)


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