pthbs

Packaging Through Hashed Build Scripts
git clone https://ccx.te2000.cz/git/pthbs
Log | Files | Refs | Submodules | README

xbps (4811B)


      1 #!/usr/bin/env pthbs-build
      2 #+musl-cross-make.65f98305f5666435bf0c6b9ccedffae2179ff1b3286752756886f760cf7771d2
      3 #+gnu-make.782c9e6625fd7420e2cd38b847afed19db3b3844cae8a0426a0dbf73e10d78e5
      4 #+busybox.e60885fe93ee85c01831673bb29f0e62a64903f4ce3094e3dc35bc8ec8887ad9
      5 #+busybox-diffutils.4f5a07b29246414b77a7d71b103263af8f1249d75ddcbd9864e00def3d6feded
      6 #+m4.d61a4ef6e5ca207e24ed8bbbd9931e1e0ac2359ed5aae4e384b49d71401b4840
      7 #+libarchive.aa7013d03a07172e4ec536b685db4b899245f2188585c41da811a44171645026
      8 #+libressl.712d293b92e9b1beb4a8b5905c45ea20cab64e3ddd9796f9c2781577f04771ab
      9 #+pkgconf-pkg-config.2993a64b810b50b0fa289b8d8eaf614f6f1719d9f2473960b2cbf5856939b834
     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