apk-tools (3264B)
1 #!/usr/bin/env pthbs-build 2 #+musl-cross-make.757bcca6771cad3395ae302e0fdc835ebf5b4a965c08e30d758e6149b0bacbcd 3 #+gnu-make.529116171fecc2bdac7c70e109d28270d765379c8a52cf7c3ea7453195bbf42b 4 #+busybox.3664b94c09ea6d35ce73985026762c142829e53fed4a38541af3afb00c37dd4a 5 #+busybox-diffutils.a22698424a7618572314d3da6953bf6652138ec492d3a0d01c37072f74adefc4 6 #+patch.29275f81d7ca08a0126c5f1029bc3a8cae04b9baf9d40d84d697bda1ffc872c1 7 #+libressl.dc3d77c147487b10dba1c94c97c776418f4c5d798583f17754b647912ff70066 8 #+zstd.934aa8762e5bafa2364861a6dac405b0521953ab98c893363578431396344cc8 9 #+pkgconf-pkg-config.00b5dde2db59264dcdcc0fba6f3952da3a4320bcf523fc7751d0e9dd34fe6294 10 #@git:4cfb907282ede4b7f52f2514fbf96c60e1cad441:apk-tools 11 #@sha256:921442b5f5bd0070caeb9c27137e63b804e634a2f5a2d69a82145362b2055b33:apk-tools.patch 12 13 check_static() { 14 local exe || true 15 exe=$pthbs_destdir/'/versions'/$pthbs_package/$1 16 if ! test -f $exe; then 17 printf '%s\n' "Error: file '$1' doesn't exist!" 18 exit 1 19 fi 20 interp_info=$(readelf --string-dump=.interp "$exe") || exit $? 21 if test x '!=' "x$interp_info"; then 22 printf '%s\n' "Error: '$1' is a dynamic binary!" 23 exit 1 24 fi 25 } 26 build_env_static() { 27 export LD_LIBRARY_PATH="$pthbs_build_environment/library" 28 export CPATH="$pthbs_build_environment/include" 29 export LDFLAGS="-static -L$pthbs_build_environment/library $LDFLAGS" 30 } 31 def_prefix() { 32 prefix=/versions/$pthbs_package 33 } 34 def_dest() { 35 dest=${pthbs_destdir%/}//versions/$pthbs_package 36 } 37 38 build_env_static 39 def_prefix 40 cd apk-tools 41 patch -p1 <../apk-tools.patch 42 make -j${JOBS:-1} -l$((1+${JOBS:-1})) STATIC=y LUA=no V=1 \ 43 DESTDIR="$pthbs_destdir" \ 44 SBINDIR="$prefix/command" \ 45 CONFDIR="$prefix/etc/apk" \ 46 MANDIR="$prefix/man" \ 47 DOCDIR="$prefix/doc/apk" \ 48 INCLUDEDIR="$prefix/include" \ 49 LIBDIR="$prefix/library" \ 50 PKGCONFIGDIR="$prefix/library/pkgconfig" \ 51 install-static 52 53 check_static command/apk.static 54 55 cd "$pthbs_destdir/versions/$pthbs_package" 56 find -type d -o -print | awk -F/ ' 57 BEGIN { 58 x["./command/apk.static"]=1 59 x["./library/libapk.a"]=1 60 x["./library/pkgconfig/apk.pc"]=1} 61 62 function r1(s) { 63 sub("^[.]/[^/]*", ".", s) 64 return s 65 } 66 function s1(repl, s) { 67 sub("^[.]/[^/]*", "./"repl, s) 68 return s 69 } 70 function link(src) { 71 x[$0]=0 72 printf "%s\t%s\n", $0, src 73 printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr" 74 } 75 $1!="."{exit 1} 76 77 78 $2 == "command" { link($0); next } 79 $2 == "bin" { link(s1("command", $0)); next } 80 81 $2 == "library.so" { link($0); next } 82 $2 == "library" { link($0); next } 83 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next } 84 $2 == "lib" && $NF ~ /\.so(|\..*)$/ { link(s1("library.so", $0)); next } 85 86 $2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next } 87 88 $2 == "man" { link($0); next } 89 $2 == "info" { link($0); next } 90 $2 == "doc" { link($0); next } 91 $2 == "icons" { link($0); next } 92 $2 == "terminfo" { link($0); next } 93 $2 == "data" { link($0); next } 94 $2 == "include" { link($0); next } 95 96 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" } 97 98 END { 99 for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" } 100 for(fname in x) { 101 if(x[fname]) { 102 printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr" 103 exit 3 104 } 105 } 106 }' >.install-links.new 107 mv .install-links.new .install-links