mrrl

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

apk-tools (3571B)


      1 #!/usr/bin/env pthbs-build
      2 #+busybox.539513a18a06a21e4660004fea30f3658959c5c7f54488b66b5fee7120b0c27c
      3 #+busybox-findutils.3ba95afbbde5f39d6a3c0b17d82ff2e5350904cf19dd40acdf1c60ed126d3bda
      4 #+busybox-awk.4ac003d165540d0084cd08c1386f136343851ef344ac5ff844769b058049d859
      5 #+musl-cross-make.ef7f483eefcad5b8f2d6c8329e61a0acaca7864b88e9521cb839392c62f45676
      6 #+gnu-make.6c204d453a2d9b4e29dd7b9f93fc7c5a928284402b8646493cf72004f748753c
      7 #+busybox-diffutils.b820ef7a40bea977a2bf740425ae15b2d9a21097bcf3a2f5ec77c21782b9deb8
      8 #+patch.c713f3aa67a288e6bb986c0545f22f7e63211a00383bac354bba563b8320da95
      9 #+libressl.e97bfa759fd72f50d85a4acf6095ffc27a96a40b443e951c1024d7f5afe898e9
     10 #+zstd.bbfd2dca53c37a5aebdd65f7ffb17acdeeca6a6eabea214449e1729754748c25
     11 #+pkgconf-pkg-config.2176b62d5271a766426ccdf60171dc4c8ceeec26f0b0f69683e11e035de4e96d
     12 #@sha256:4b32a05f12c3d29befb210c88c415f7c7affd7e351b9e96b0cfde50773d22dbd:apk-tools.patch
     13 #@git:9d074efdc12bc41b5d24190595a5269a770e852a:apk-tools
     14 
     15 
     16 # - build script start -
     17 
     18 build_env_static() {
     19 	export LD_LIBRARY_PATH="$pthbs_build_environment/library"
     20 	export CPATH="$pthbs_build_environment/include"
     21 	export LDFLAGS="-static -L$pthbs_build_environment/library $LDFLAGS"
     22 }
     23 
     24 check_static() {
     25 	local exe || true
     26 	exe=$pthbs_destdir'/versions'/$pthbs_package/$1
     27 	if ! test -f $exe; then
     28 		printf '%s\n' "Error: file '$1' doesn't exist!"
     29 		exit 1
     30 	fi
     31 	local interp_info || true
     32 	interp_info=$(readelf --string-dump=.interp "$exe") || exit $?
     33 	if test x '!=' "x$interp_info"; then
     34 		printf '%s\n' "Error: '$1' is a dynamic binary!"
     35 		exit 1
     36 	fi
     37 }
     38 
     39 prefix=/versions/$pthbs_package
     40 dest=${pthbs_destdir%/}${prefix}
     41 cd 'apk-tools'
     42 patch -p1 <../apk-tools.patch
     43 
     44 
     45 build_env_static
     46 
     47 make -j${JOBS:-1} -l$((1+${JOBS:-1})) STATIC=y LUA=no V=1 \
     48 	CFLAGS=-O2 \
     49 	DESTDIR="$pthbs_destdir" \
     50 	SBINDIR="$prefix/command" \
     51 	CONFDIR="$prefix/etc/apk" \
     52 	MANDIR="$prefix/man" \
     53 	DOCDIR="$prefix/doc/apk" \
     54 	INCLUDEDIR="$prefix/include" \
     55 	LIBDIR="$prefix/library" \
     56 	PKGCONFIGDIR="$prefix/library/pkgconfig" \
     57 	install-static
     58 
     59 check_static command/apk.static
     60 
     61 
     62 cd "$pthbs_destdir/versions/$pthbs_package"
     63 find -type d -o -print | awk -F/ '
     64 BEGIN {
     65 	x["./command/apk.static"]=1
     66 	x["./library/libapk.a"]=1
     67 	x["./library/pkgconfig/apk.pc"]=1
     68 }
     69 
     70 function r1(s) {
     71 	sub("^[.]/[^/]*", ".", s)
     72 	return s
     73 }
     74 function s1(repl, s) {
     75 	sub("^[.]/[^/]*", "./"repl, s)
     76 	return s
     77 }
     78 function link(src) {
     79 	x[$0]=0
     80 	printf "%s\t%s\n", $0, src
     81 	printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr"
     82 }
     83 $1!="."{exit 1}
     84 
     85 
     86 $2 == "config" { link($0); next }
     87 $2 == "keys" { link($0); next }
     88 $2 == "zsh" { link($0); next }
     89 $2 == "env" { link($0); next }
     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
    120