pthbs

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

pthbs-install (1631B)


      1 #!/bin/sh -e
      2 test -z "$pthbs_xtrace" || set -x
      3 if test -z "$pthbs_versions"; then
      4 	echo >&2 "ERROR: pthbs_versions is undefined"
      5 	exit 2
      6 elif ! test -d "$pthbs_versions"; then
      7 	echo >&2 "ERROR: pthbs_versions '$pthbs_versions' is not directory"
      8 	exit 1
      9 fi
     10 
     11 test "$#" -eq 2 || exit 2
     12 
     13 pthbs_destdir="$1"
     14 pthbs_package="$2"
     15 
     16 if ! test -f "$pthbs_destdir/${pthbs_versions%/}/$pthbs_package/.install-links"; then
     17 	echo >&2 "ERROR: link file not found"
     18 	exit 1
     19 fi
     20 
     21 if test -n "$pthbs_install_uid"; then
     22 	chown -R "$pthbs_install_uid:$pthbs_install_gid" "$pthbs_destdir/${pthbs_versions%/}/$pthbs_package"
     23 fi
     24 chmod -R ugo-w "$pthbs_destdir/${pthbs_versions%/}/$pthbs_package"
     25 pthbs-digest-tree >"$pthbs_destdir/pthbs-digest" "$pthbs_destdir/${pthbs_versions%/}/$pthbs_package/" || exit $?
     26 mv "$pthbs_destdir/pthbs-digest" "$pthbs_destdir/${pthbs_versions%/}/$pthbs_package/.pthbs-digest" || exit $?
     27 
     28 if test -e "$pthbs_versions/$pthbs_package"; then
     29 	if ! diff -u "$pthbs_versions/$pthbs_package" "$pthbs_destdir/${pthbs_versions%/}/$pthbs_package/.pthbs-digest"; then
     30 		echo >&2 "ERROR: digest file mismatch - packages with same buildhash differ"
     31 		exit 3
     32 	fi
     33 	N=1
     34 	while test -e "$pthbs_versions/$pthbs_package.$N"; do
     35 		N=$(1+$N)
     36 	done
     37 	echo >&2 "INFO: replacing previous package"
     38 	mv "$pthbs_versions/$pthbs_package" "$pthbs_versions/$pthbs_package.$N"
     39 	# remove dangling links
     40 	find "$pthbs_versions" -type l ! -exec test -e {} \; -exec rm -v {} +
     41 fi
     42 
     43 mv "$pthbs_destdir/${pthbs_versions%/}/$pthbs_package" "$pthbs_versions/$pthbs_package"
     44 find "$pthbs_destdir" -type d -o -exec printf 'WARNING: stray file in destdir: %s\n' '{}' +