xbps (4811B)
1 #!/usr/bin/env pthbs-build 2 #+musl-cross-make.757bcca6771cad3395ae302e0fdc835ebf5b4a965c08e30d758e6149b0bacbcd 3 #+gnu-make.529116171fecc2bdac7c70e109d28270d765379c8a52cf7c3ea7453195bbf42b 4 #+busybox.3664b94c09ea6d35ce73985026762c142829e53fed4a38541af3afb00c37dd4a 5 #+busybox-diffutils.a22698424a7618572314d3da6953bf6652138ec492d3a0d01c37072f74adefc4 6 #+m4.b78d93922dc9dbf43dd31037c98271490db5d6d1919b69b12122cf55fa1fb515 7 #+libarchive.bf1723109cb84ebe3d74c5aeb171127881d0dca7682c580364dc33a81b578937 8 #+libressl.dc3d77c147487b10dba1c94c97c776418f4c5d798583f17754b647912ff70066 9 #+pkgconf-pkg-config.00b5dde2db59264dcdcc0fba6f3952da3a4320bcf523fc7751d0e9dd34fe6294 10 #@untar:-z:sha256:a6607e83fcd654a0ae846d729e43fefd8da9a61323e91430f884caf895b4f59b:. 11 12 build_env_static() { 13 export LD_LIBRARY_PATH="$pthbs_build_environment/library" 14 export CPATH="$pthbs_build_environment/include" 15 export LDFLAGS="-static -L$pthbs_build_environment/library $LDFLAGS" 16 } 17 autotools_config() { 18 prefix=/versions/$pthbs_package 19 ./configure -C \ 20 --prefix="$prefix" \ 21 --build="$(${CC:-gcc} -dumpmachine)" \ 22 --bindir="$prefix/command" \ 23 --sbindir="$prefix/command" \ 24 --infodir="$prefix/info" \ 25 --localedir="$prefix/locale" \ 26 --mandir="$prefix/man" \ 27 --libdir="$prefix/library" \ 28 --docdir="$prefix/doc/xbps" \ 29 --datadir="$prefix/data" \ 30 --datarootdir="$prefix/data" \ 31 --localstatedir='/var/pthbs' \ 32 "$@" 33 34 } 35 36 autotools() { 37 cd "$1" 38 shift 39 autotools_config "$@" 40 make -j${JOBS:-1} -l$((1+${JOBS:-1})) 41 make DESTDIR="$pthbs_destdir" install 42 } 43 44 autotools_static() { 45 build_env_static 46 autotools "$@" --enable-static --disable-shared 47 } 48 check_static() { 49 local exe || true 50 exe=$pthbs_destdir/'/versions'/$pthbs_package/$1 51 if ! test -f $exe; then 52 printf '%s\n' "Error: file '$1' doesn't exist!" 53 exit 1 54 fi 55 interp_info=$(readelf --string-dump=.interp "$exe") || exit $? 56 if test x '!=' "x$interp_info"; then 57 printf '%s\n' "Error: '$1' is a dynamic binary!" 58 exit 1 59 fi 60 } 61 62 def_prefix() { 63 prefix=/versions/$pthbs_package 64 } 65 def_dest() { 66 dest=${pthbs_destdir%/}//versions/$pthbs_package 67 } 68 69 export LDFLAGS=--static 70 export CPPFLAGS="-D_GNU_SOURCE -DSTDC_HEADERS" 71 build_env_static 72 def_dest 73 def_prefix 74 75 cd xbps-0.59.2 76 find lib bin -name '*.c' -exec sed -iEe '/^[\t ]*#[\t ]*define[\t ]+_GNU_SOURCE/d' '{}' \; 77 find lib bin -name '*.c' -exec sed -iEe '/#.*_GNU_SOURCE/d' '{}' \; 78 ./configure --verbose \ 79 --prefix="$prefix" \ 80 --build="$(${CC:-gcc} -dumpmachine)" \ 81 --datadir="$prefix" \ 82 --bindir="$prefix/command" \ 83 --infodir="$prefix/info" \ 84 --mandir="$prefix/man" \ 85 --libdir="$prefix/library" \ 86 --localstatedir=/var \ 87 --enable-static 88 89 make -j${JOBS:-1} -l$((1+${JOBS:-1})) -C include 90 make -j${JOBS:-1} -l$((1+${JOBS:-1})) -C lib libxbps.a 91 install -d "$dest/library" 92 install -m 644 lib/libxbps.a "$dest/library" 93 install -d "$dest/command" 94 for cmd in xbps-alternatives xbps-create xbps-dgraph xbps-install xbps-pkgdb xbps-query xbps-reconfigure xbps-remove xbps-rindex xbps-uhelper xbps-checkvers xbps-fbulk xbps-digest xbps-fetch xbps-uchroot xbps-uunshare; do 95 make -j${JOBS:-1} -l$((1+${JOBS:-1})) -C "bin/$cmd" "$cmd.static" 96 install -m 755 "bin/$cmd/$cmd.static" "$pthbs_destdir/$prefix/command" 97 done 98 make -j${JOBS:-1} -l$((1+${JOBS:-1})) -C data 99 make -j${JOBS:-1} -l$((1+${JOBS:-1})) -C data install DESTDIR="$pthbs_destdir" 100 101 check_static command/xbps-install.static 102 mkdir -p "$dest/keys" 103 mv -v "$pthbs_destdir/var/db/xbps/keys" "$dest/keys/void" 104 105 106 107 cd "$pthbs_destdir/versions/$pthbs_package" 108 find -type d -o -print | awk -F/ ' 109 BEGIN { 110 x["./command/xbps-install.static"]=1} 111 112 function r1(s) { 113 sub("^[.]/[^/]*", ".", s) 114 return s 115 } 116 function s1(repl, s) { 117 sub("^[.]/[^/]*", "./"repl, s) 118 return s 119 } 120 function link(src) { 121 x[$0]=0 122 printf "%s\t%s\n", $0, src 123 printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr" 124 } 125 $1!="."{exit 1} 126 127 128 $2 == "keys" { link($0); next } 129 $2 == "command" { link($0); next } 130 $2 == "bin" { link(s1("command", $0)); next } 131 132 $2 == "library.so" { link($0); next } 133 $2 == "library" { link($0); next } 134 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next } 135 $2 == "lib" && $NF ~ /\.so(|\..*)$/ { link(s1("library.so", $0)); next } 136 137 $2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next } 138 139 $2 == "man" { link($0); next } 140 $2 == "info" { link($0); next } 141 $2 == "doc" { link($0); next } 142 $2 == "icons" { link($0); next } 143 $2 == "terminfo" { link($0); next } 144 $2 == "data" { link($0); next } 145 $2 == "include" { link($0); next } 146 147 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" } 148 149 END { 150 for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" } 151 for(fname in x) { 152 if(x[fname]) { 153 printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr" 154 exit 3 155 } 156 } 157 }' >.install-links.new 158 mv .install-links.new .install-links