mrrl

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

easyseccomp (4001B)


      1 #!/usr/bin/env pthbs-build
      2 #+musl-cross-make.98979eb41109d371f19d0637d51116db18c7aeef61fbf804a68094c22a302a78
      3 #+gnu-make.ba8d7c64a23885182fc1c9dc0331d52adcdbc45df6000fb81e8e1dd3ee05694b
      4 #+busybox.ee3440974794767b833fd3299226771f170d3f8601cf225cb884f0a513db8ab3
      5 #+busybox-diffutils.c2ebcfcad050ad71b8e30322a463b5c009f254c7a42e95c627d32665e17134dc
      6 #+m4.46e121f61e0af52abf876bf2688ecfe70eeb04185028d6adde0085e865fdfe75
      7 #+patch.05834624d74752d1cbe386cd61dbd0dd98d69aad7777828dcf07390ab8772d4b
      8 #+flex.322ebabc6eba6cdfd84b1b90f25790b8d917035872c2e6bb2f4c8e2f05eabcfd
      9 #+bison.1a189980b7909de4d49b57a4821f58147c2cc150fcd4227cb88b63342551a10f
     10 #+libseccomp.8b32056ea0458b22266d8fc1b3cce05c82d08282c40a1e56d00d15fa57cdc156
     11 #+error-standalone.664c98067651c547ed8252fefb7237335ee7b15aa7ea4a338ff8d65dc02a6c0e
     12 #+argp-standalone.67cb9dc5d68bacf213a32171dedea9b95c3651b603f91f1e757e583cb4f233c7
     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=/home/ccx/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/'/home/ccx/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/home/ccx/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