mrrl

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

easyseccomp (3974B)


      1 #!/usr/bin/env pthbs-build
      2 #+musl-cross-make.d0431fc0def788be03da43136972361827de52c8e6f0a6f3890dc57fe32e8ecc
      3 #+gnu-make.444e811a68f4f16724e21354b710fad3592e53a2dbf7c0c78658f3d4e7c8e465
      4 #+busybox.f4ef3d511c029095beda8d21dd48f7730bec63fb09792ca951402d6620338089
      5 #+busybox-diffutils.4a0933977737282afcd82b39d435b50946a700fe13472d24e4580a41fa852123
      6 #+m4.3cffaef6909a65493ddc9aba4c53f77dc594ff5ab8b58c57acaa34c654b09ff3
      7 #+patch.9d8b2c370a0ccf6e5ad48c27070ff1da2d30d41327fd5711a76cf570b34ae523
      8 #+flex.42bdab01fb2083e92a4417d5fb289c468b9a1a5b8092904b965455b74559262f
      9 #+bison.d9992ea20119a82e24982f67479e65e94ec0fdc686f024f0ed04e87c83a00ef0
     10 #+libseccomp.cf3861629089b6a01e1499bd0296161802ff4978c7adde69cff19c5c5a568902
     11 #+error-standalone.b756d86efb93b61ab49683dd2614413fc0a0c66fed3026f238ab32a725257ab2
     12 #+argp-standalone.1704fb243241c32274e2f78dafafa0ad18e2c26456742441ebd3e5dda8bc7d0b
     13 #@git:94422be00da71ff44c8ad1fe3455587c62ca29d3:easyseccomp
     14 #@untar::sha256:1b44a63d415c48ac68d210951fec8d4761d3522f3d82d53182e66fabe5e2f2cd:easyseccomp
     15 #@sha256:eec15ac67403946e9d988d485f11764cf313b4798efe01d40f951ff521a23d10:easyseccomp_fix_includes.patch
     16 
     17 build_env_static() {
     18 	export LD_LIBRARY_PATH="$pthbs_build_environment/library"
     19 	export CPATH="$pthbs_build_environment/include"
     20 	export LDFLAGS="-static -L$pthbs_build_environment/library $LDFLAGS"
     21 }
     22 autotools_config() {
     23 	prefix=/versions/$pthbs_package
     24 	./configure -C \
     25 		--prefix="$prefix" \
     26 		--build="$(${CC:-gcc} -dumpmachine)" \
     27 		--bindir="$prefix/command" \
     28 		--sbindir="$prefix/command" \
     29 		--infodir="$prefix/info" \
     30 		--localedir="$prefix/locale" \
     31 		--mandir="$prefix/man" \
     32 		--libdir="$prefix/library" \
     33 		--docdir="$prefix/doc/easyseccomp" \
     34 		--datadir="$prefix/data" \
     35 		--datarootdir="$prefix/data" \
     36 		--localstatedir='/var/pthbs' \
     37 		"$@"
     38 
     39 }
     40 
     41 autotools() {
     42 	cd "$1"
     43 	shift
     44 	autotools_config "$@"
     45 	make -j${JOBS:-1} -l$((1+${JOBS:-1}))
     46 	make DESTDIR="$pthbs_destdir" install
     47 }
     48 
     49 autotools_static() {
     50 	build_env_static
     51 	autotools "$@" --enable-static --disable-shared
     52 }
     53 check_static() {
     54 	local exe || true
     55 	exe=$pthbs_destdir/'/versions'/$pthbs_package/$1
     56 	if ! test -f $exe; then
     57 		printf '%s\n' "Error: file '$1' doesn't exist!"
     58 		exit 1
     59 	fi
     60 	interp_info=$(readelf --string-dump=.interp "$exe") || exit $?
     61 	if test x '!=' "x$interp_info"; then
     62 		printf '%s\n' "Error: '$1' is a dynamic binary!"
     63 		exit 1
     64 	fi
     65 }
     66 
     67 
     68 cd easyseccomp
     69 patch -p1 <../easyseccomp_fix_includes.patch
     70 touch Makefile.in configure
     71 build_env_static
     72 autotools_config --enable-seccomp
     73 make -j1 V=1 DESTDIR="$pthbs_destdir" LIBS="-lseccomp -lerror -largp" install
     74 check_static command/easyseccomp
     75 
     76 
     77 
     78 cd "$pthbs_destdir/versions/$pthbs_package"
     79 find -type d -o -print | awk -F/ '
     80 BEGIN {
     81 	x["./command/seccomp-run"]=1
     82 	x["./command/easyseccomp"]=1
     83 }
     84 
     85 function r1(s) {
     86 	sub("^[.]/[^/]*", ".", s)
     87 	return s
     88 }
     89 function s1(repl, s) {
     90 	sub("^[.]/[^/]*", "./"repl, s)
     91 	return s
     92 }
     93 function link(src) {
     94 	x[$0]=0
     95 	printf "%s\t%s\n", $0, src
     96 	printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr"
     97 }
     98 $1!="."{exit 1}
     99 
    100 
    101 $2 == "command" { link($0); next }
    102 $2 == "bin" { link(s1("command", $0)); next }
    103 
    104 $2 == "library.so" { link($0); next }
    105 $2 == "library" { link($0); next }
    106 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next }
    107 $2 == "lib" && $NF ~ /\.so(|\..*)$/ { link(s1("library.so", $0)); next }
    108 
    109 $2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next }
    110 
    111 $2 == "man" { link($0); next }
    112 $2 == "info" { link($0); next }
    113 $2 == "doc" { link($0); next }
    114 $2 == "icons" { link($0); next }
    115 $2 == "terminfo" { link($0); next }
    116 $2 == "data" { link($0); next }
    117 $2 == "include" { link($0); next }
    118 
    119 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" }
    120 
    121 END {
    122 	for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" }
    123 	for(fname in x) {
    124 		if(x[fname]) {
    125 			printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr"
    126 			exit 3
    127 		}
    128 	}
    129 }' >.install-links.new
    130 mv .install-links.new .install-links