mrrl

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

apk-tools (3314B)


      1 #!/usr/bin/env pthbs-build
      2 #+musl-cross-make.98979eb41109d371f19d0637d51116db18c7aeef61fbf804a68094c22a302a78
      3 #+gnu-make.ba8d7c64a23885182fc1c9dc0331d52adcdbc45df6000fb81e8e1dd3ee05694b
      4 #+busybox.ee3440974794767b833fd3299226771f170d3f8601cf225cb884f0a513db8ab3
      5 #+busybox-diffutils.c2ebcfcad050ad71b8e30322a463b5c009f254c7a42e95c627d32665e17134dc
      6 #+patch.05834624d74752d1cbe386cd61dbd0dd98d69aad7777828dcf07390ab8772d4b
      7 #+libressl.633500bb0c83790bc40476a011548bd124f73c708cd70ea1988c192fd90a8dad
      8 #+zstd.8b11bd81c450d61aa6a44ffd019654c590439df68ebd8987db4cdbbcf182d67c
      9 #+pkgconf-pkg-config.86f9c193f6ccc64cc2ac696a7e3a258f01b8d0c539312ae37c08ea2354332e90
     10 #@git:9d074efdc12bc41b5d24190595a5269a770e852a:apk-tools
     11 #@sha256:4b32a05f12c3d29befb210c88c415f7c7affd7e351b9e96b0cfde50773d22dbd:apk-tools.patch
     12 
     13 check_static() {
     14 	local exe || true
     15 	exe=$pthbs_destdir/'/home/ccx/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=/home/ccx/versions/$pthbs_package
     33 }
     34 def_dest() {
     35 	dest=${pthbs_destdir%/}//home/ccx/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 	CFLAGS=-O2 \
     44 	DESTDIR="$pthbs_destdir" \
     45 	SBINDIR="$prefix/command" \
     46 	CONFDIR="$prefix/etc/apk" \
     47 	MANDIR="$prefix/man" \
     48 	DOCDIR="$prefix/doc/apk" \
     49 	INCLUDEDIR="$prefix/include" \
     50 	LIBDIR="$prefix/library" \
     51 	PKGCONFIGDIR="$prefix/library/pkgconfig" \
     52 	install-static
     53 
     54 check_static command/apk.static
     55 
     56 cd "$pthbs_destdir/home/ccx/versions/$pthbs_package"
     57 find -type d -o -print | awk -F/ '
     58 BEGIN {
     59 	x["./command/apk.static"]=1
     60 	x["./library/libapk.a"]=1
     61 	x["./library/pkgconfig/apk.pc"]=1}
     62 
     63 function r1(s) {
     64 	sub("^[.]/[^/]*", ".", s)
     65 	return s
     66 }
     67 function s1(repl, s) {
     68 	sub("^[.]/[^/]*", "./"repl, s)
     69 	return s
     70 }
     71 function link(src) {
     72 	x[$0]=0
     73 	printf "%s\t%s\n", $0, src
     74 	printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr"
     75 }
     76 $1!="."{exit 1}
     77 
     78 
     79 $2 == "command" { link($0); next }
     80 $2 == "bin" { link(s1("command", $0)); next }
     81 
     82 $2 == "library.so" { link($0); next }
     83 $2 == "library" { link($0); next }
     84 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next }
     85 $2 == "lib" && $NF ~ /\.so(|\..*)$/ { link(s1("library.so", $0)); next }
     86 
     87 $2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next }
     88 
     89 $2 == "man" { link($0); next }
     90 $2 == "info" { link($0); next }
     91 $2 == "doc" { link($0); next }
     92 $2 == "icons" { link($0); next }
     93 $2 == "terminfo" { link($0); next }
     94 $2 == "data" { link($0); next }
     95 $2 == "include" { link($0); next }
     96 
     97 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" }
     98 
     99 END {
    100 	for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" }
    101 	for(fname in x) {
    102 		if(x[fname]) {
    103 			printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr"
    104 			exit 3
    105 		}
    106 	}
    107 }' >.install-links.new
    108 mv .install-links.new .install-links