applyuidgid-caps (3015B)
1 #!/usr/bin/env pthbs-build 2 #+busybox.d2d7aa00eac6ec561a10d126b1866f22e226a1276307466251e80fd8a4a1ebc7 3 #+busybox-findutils.85b2328981df683d1ae7597eebdf3a332aa4241b936c0030fe3618cec1f4841a 4 #+busybox-awk.4c3f8cc249ba35f1206fcaf2979bcfd66d09b117eeea4e6a939024825a542496 5 #+musl-cross-make.e4735d8572f9b6654a7381ebdfbd62e665d1d1da5e06a56923e89274cc6a510f 6 #+skalibs.d3e22646f4396d3d4a8a4c95b19356b3590bcbf747a89cb9733aa3826e0612a0 7 #+libcap.5567968eac18a668a85c2ae4ab116db560fdbe3b56d170d8ada7d192aa7f3f96 8 #@sha256:818a5ad7061ab1a740a5c2e7d7d8cdcc7be7e84e3f04b479731cf94ff1f1d093:applyuidgid-caps.c 9 10 11 # - build script start - 12 13 build_env_static() { 14 export LD_LIBRARY_PATH="$pthbs_build_environment/library" 15 export CPATH="$pthbs_build_environment/include" 16 export LDFLAGS="-static -L$pthbs_build_environment/library $LDFLAGS" 17 } 18 19 check_static() { 20 local exe || true 21 exe=$pthbs_destdir'/home/ccx/versions'/$pthbs_package/$1 22 if ! test -f $exe; then 23 printf '%s\n' "Error: file '$1' doesn't exist!" 24 exit 1 25 fi 26 local interp_info || true 27 interp_info=$(readelf --string-dump=.interp "$exe") || exit $? 28 if test x '!=' "x$interp_info"; then 29 printf '%s\n' "Error: '$1' is a dynamic binary!" 30 exit 1 31 fi 32 } 33 34 prefix=/home/ccx/versions/$pthbs_package 35 dest=${pthbs_destdir%/}${prefix} 36 cd '.' 37 name='applyuidgid-caps' 38 39 CFLAGS="-D_GNU_SOURCE" 40 LDFLAGS="-lskarnet -lcap" 41 42 build_env_static 43 gcc ${CFLAGS} -o "$name" "$name.c" $LDFLAGS 44 45 install -d "$pthbs_destdir/$prefix/command" 46 install -m 755 "$name" "$pthbs_destdir/$prefix/command" 47 48 49 50 check_static "command/$name" 51 52 53 54 cd "$pthbs_destdir/home/ccx/versions/$pthbs_package" 55 find -type d -o -print | awk -F/ ' 56 BEGIN { 57 x["./command/applyuidgid-caps"]=1} 58 59 function r1(s) { 60 sub("^[.]/[^/]*", ".", s) 61 return s 62 } 63 function s1(repl, s) { 64 sub("^[.]/[^/]*", "./"repl, s) 65 return s 66 } 67 function link(src) { 68 x[$0]=0 69 printf "%s\t%s\n", $0, src 70 printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr" 71 } 72 $1!="."{exit 1} 73 74 75 $2 == "config" { link($0); next } 76 $2 == "keys" { link($0); next } 77 $2 == "zsh" { link($0); next } 78 $2 == "env" { link($0); next } 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 109