certdata2pem (2829B)
1 #!/usr/bin/env pthbs-build 2 #+busybox.d2d7aa00eac6ec561a10d126b1866f22e226a1276307466251e80fd8a4a1ebc7 3 #+busybox-findutils.85b2328981df683d1ae7597eebdf3a332aa4241b936c0030fe3618cec1f4841a 4 #+busybox-awk.4c3f8cc249ba35f1206fcaf2979bcfd66d09b117eeea4e6a939024825a542496 5 #+musl-cross-make.e4735d8572f9b6654a7381ebdfbd62e665d1d1da5e06a56923e89274cc6a510f 6 #@sha256:064f7d41106cd9efa08b9e68cf049f44e3be55666bd2ab96d02c508293b8dce7:certdata2pem.c 7 8 9 # - build script start - 10 11 build_env_static() { 12 export LD_LIBRARY_PATH="$pthbs_build_environment/library" 13 export CPATH="$pthbs_build_environment/include" 14 export LDFLAGS="-static -L$pthbs_build_environment/library $LDFLAGS" 15 } 16 17 check_static() { 18 local exe || true 19 exe=$pthbs_destdir'/home/ccx/versions'/$pthbs_package/$1 20 if ! test -f $exe; then 21 printf '%s\n' "Error: file '$1' doesn't exist!" 22 exit 1 23 fi 24 local interp_info || true 25 interp_info=$(readelf --string-dump=.interp "$exe") || exit $? 26 if test x '!=' "x$interp_info"; then 27 printf '%s\n' "Error: '$1' is a dynamic binary!" 28 exit 1 29 fi 30 } 31 32 prefix=/home/ccx/versions/$pthbs_package 33 dest=${pthbs_destdir%/}${prefix} 34 cd '.' 35 name='certdata2pem' 36 37 CFLAGS="-D_GNU_SOURCE" 38 39 build_env_static 40 gcc ${CFLAGS} -o "$name" "$name.c" $LDFLAGS 41 42 install -d "$pthbs_destdir/$prefix/command" 43 install -m 755 "$name" "$pthbs_destdir/$prefix/command" 44 45 46 47 check_static "command/$name" 48 49 50 51 cd "$pthbs_destdir/home/ccx/versions/$pthbs_package" 52 find -type d -o -print | awk -F/ ' 53 BEGIN { 54 x["./command/certdata2pem"]=1 55 } 56 57 function r1(s) { 58 sub("^[.]/[^/]*", ".", s) 59 return s 60 } 61 function s1(repl, s) { 62 sub("^[.]/[^/]*", "./"repl, s) 63 return s 64 } 65 function link(src) { 66 x[$0]=0 67 printf "%s\t%s\n", $0, src 68 printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr" 69 } 70 $1!="."{exit 1} 71 72 73 $2 == "config" { link($0); next } 74 $2 == "keys" { link($0); next } 75 $2 == "zsh" { link($0); next } 76 $2 == "env" { link($0); next } 77 $2 == "command" { link($0); next } 78 $2 == "bin" { link(s1("command", $0)); next } 79 80 $2 == "library.so" { link($0); next } 81 $2 == "library" { link($0); next } 82 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next } 83 $2 == "lib" && $NF ~ /\.so(\..*)?$/ { link(s1("library.so", $0)); next } 84 85 $2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next } 86 87 $2 == "man" { link($0); next } 88 $2 == "info" { link($0); next } 89 $2 == "doc" { link($0); next } 90 $2 == "icons" { link($0); next } 91 $2 == "terminfo" { link($0); next } 92 $2 == "data" { link($0); next } 93 $2 == "include" { link($0); next } 94 95 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" } 96 97 END { 98 for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" } 99 for(fname in x) { 100 if(x[fname]) { 101 printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr" 102 exit 3 103 } 104 } 105 }' >.install-links.new 106 mv .install-links.new .install-links 107