libcap (3279B)
1 #!/usr/bin/env pthbs-build 2 #+musl-cross-make.757bcca6771cad3395ae302e0fdc835ebf5b4a965c08e30d758e6149b0bacbcd 3 #+gnu-make.529116171fecc2bdac7c70e109d28270d765379c8a52cf7c3ea7453195bbf42b 4 #+busybox.3664b94c09ea6d35ce73985026762c142829e53fed4a38541af3afb00c37dd4a 5 #+busybox-diffutils.a22698424a7618572314d3da6953bf6652138ec492d3a0d01c37072f74adefc4 6 #+pkgconf-pkg-config.00b5dde2db59264dcdcc0fba6f3952da3a4320bcf523fc7751d0e9dd34fe6294 7 #@untar:-J:sha256:f311f8f3dad84699d0566d1d6f7ec943a9298b28f714cae3c931dfd57492d7eb:. 8 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 def_prefix 34 LDFLAGS=--static 35 build_env_static 36 37 cd libcap-2.69 38 sed -i '1 s|^#!/bin/bash|#!/bin/sh|' progs/*.sh 39 make \ 40 DESTDIR="$pthbs_destdir" \ 41 SHARED=no DYNAMIC=no LIBCSTATIC=yes \ 42 prefix="$prefix" \ 43 exec_prefix="$prefix" \ 44 lib_prefix="$prefix" \ 45 inc_prefix="$prefix" \ 46 man_prefix="$prefix/share" \ 47 MANDIR="$prefix/man" \ 48 sbin=command \ 49 SBINDIR="$prefix/command" \ 50 INCDIR="$prefix/include" \ 51 lib=library \ 52 LIBDIR="$prefix/library" \ 53 PKGCONFIGDIR="$prefix/library/pkgconfig" \ 54 CAPSH_SHELL="'-DSHELL=\"$(which sh)\"'" \ 55 LDFLAGS="$LDFLAGS" \ 56 all install 57 58 check_static command/capsh 59 check_static command/getcap 60 check_static command/setcap 61 check_static command/getpcaps 62 63 64 cd "$pthbs_destdir/versions/$pthbs_package" 65 find -type d -o -print | awk -F/ ' 66 BEGIN { 67 x["./command/capsh"]=1 68 x["./command/getcap"]=1 69 x["./command/setcap"]=1 70 x["./command/getpcaps"]=1 71 x["./library/libcap.a"]=1 72 } 73 74 function r1(s) { 75 sub("^[.]/[^/]*", ".", s) 76 return s 77 } 78 function s1(repl, s) { 79 sub("^[.]/[^/]*", "./"repl, s) 80 return s 81 } 82 function link(src) { 83 x[$0]=0 84 printf "%s\t%s\n", $0, src 85 printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr" 86 } 87 $1!="."{exit 1} 88 89 90 $2 == "command" { link($0); next } 91 $2 == "bin" { link(s1("command", $0)); next } 92 93 $2 == "library.so" { link($0); next } 94 $2 == "library" { link($0); next } 95 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next } 96 $2 == "lib" && $NF ~ /\.so(|\..*)$/ { link(s1("library.so", $0)); next } 97 98 $2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next } 99 100 $2 == "man" { link($0); next } 101 $2 == "info" { link($0); next } 102 $2 == "doc" { link($0); next } 103 $2 == "icons" { link($0); next } 104 $2 == "terminfo" { link($0); next } 105 $2 == "data" { link($0); next } 106 $2 == "include" { link($0); next } 107 108 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" } 109 110 END { 111 for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" } 112 for(fname in x) { 113 if(x[fname]) { 114 printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr" 115 exit 3 116 } 117 } 118 }' >.install-links.new 119 mv .install-links.new .install-links