mrrl

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

apk-tools (3264B)


      1 #!/usr/bin/env pthbs-build
      2 #+musl-cross-make.675bc960d97b88b341ba4c64ea1b10f6afd9c9f0394ed84ca848768c5e1b646c
      3 #+gnu-make.152d99fd58e3130b4bd4d23833643ca418555a0560e88962cd8a28ffcd9a9ab7
      4 #+busybox.7818e9d6df97d97317c8fcdf404811731aa0c5c3ab7eb6aec00c9652b6da511c
      5 #+busybox-diffutils.3579038707d7520c09339ee4fc3b67ef03caeeaf8fff3b6f93c51ace141a4393
      6 #+patch.7eea774dc5402ab08569b8a038980075864cade9b04048a89bc70f65a54bd72e
      7 #+libressl.c6f4193f35d146e0af36bfb69d8f4a9be69da9ea0b9cb80b05ddd617ea12cece
      8 #+zstd.23993b39184b62e1b1f11ee2d7337b1c808131e9fedec765911badae185afbaf
      9 #+pkgconf-pkg-config.4c1feadf205ba11eec4f487eee4e6b0bdc8601f0975f332c70272cc56e2e3c42
     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