cookutils rev 1027

cook: remove old package in /home/slitaz/packages and upgrade chroot package when $ARCH is used; provide overstriked "Failed" for prepared packages;
cook.site: remove redundant first part, fix ${sysconfdir} and ${docdir};
lighttpd/index.cgi: support for overstriked "Failed";
modules/compressor: strip_package(): consider *.dbg files (from glibc and gcc packages); make deterministic *.a archives in the simpler way.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Feb 02 00:51:10 2018 +0200 (2018-02-02)
parents c51331bcb617
children 01fbe9d46cb4
files cook cook.site lighttpd/index.cgi modules/compressor
line diff
     1.1 --- a/cook	Sat Jan 27 11:55:42 2018 +0200
     1.2 +++ b/cook	Fri Feb 02 00:51:10 2018 +0200
     1.3 @@ -1084,9 +1084,9 @@
     1.4  	# Find and remove old package only if "release checksum" has changed
     1.5  
     1.6  	if [ "$rsum" != "$rsumold" ]; then
     1.7 -		old_file=$(awk -F$'\t' -vname="$PACKAGE" '{
     1.8 -			if ($1 == name) printf("%s-%s.tazpkg", $1, $2);
     1.9 -			}' $pi)		# <name>-<version><extra_version>.tazpkg
    1.10 +		old_file=$(awk -F$'\t' -vname="$PACKAGE" -varch="$arch" '{
    1.11 +			if ($1 == name) printf("%s-%s%s.tazpkg", $1, $2, arch);
    1.12 +			}' $pi)		# <name>-<version><extra_version><-arch>.tazpkg
    1.13  		if [ -f "$PKGS/$old_file" ]; then
    1.14  			action 'Removing old package "%s"' "$old_file"
    1.15  			rm -f "$PKGS/$old_file"
    1.16 @@ -1181,7 +1181,7 @@
    1.17  			_ 'Updating %s chroot environment...' "$ARCH"
    1.18  			_ 'Updating chroot: %s' "$i ($VERSION$EXTRAVERSION$arch)" | log
    1.19  			cd $PKGS
    1.20 -			tazpkg install $PKGS/$i-$VERSION$EXTRAVERSION$arch.tazpkg --forced --root=$root
    1.21 +			tazpkg -i "$PKGS/$i-$VERSION$EXTRAVERSION$arch.tazpkg" --forced --root=$root
    1.22  		fi
    1.23  	done
    1.24  }
    1.25 @@ -1192,17 +1192,21 @@
    1.26  install_package() {
    1.27  	set_paths
    1.28  	case "$ARCH" in
    1.29 -		arm*|x86_64)
    1.30 +		arm*)
    1.31  			arch="-$ARCH"
    1.32 -			root="$CROSS_TREE/sysroot" ;;
    1.33 +			root="$CROSS_TREE/sysroot"
    1.34 +			;;
    1.35 +		x86_64)
    1.36 +			arch="-$ARCH"
    1.37 +			;;
    1.38  	esac
    1.39  	# Install package if requested but skip install if target host doesn't
    1.40  	# match build system or it will break the build chroot.
    1.41  	build=$(echo $BUILD_SYSTEM | cut -d- -f1)
    1.42  	if [ -n "$inst" -a "$build" == "$ARCH" ]; then
    1.43 -		if [ -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
    1.44 +		if [ -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION$arch.tazpkg" ]; then
    1.45  			cd $PKGS
    1.46 -			tazpkg install $PACKAGE-$VERSION$EXTRAVERSION.tazpkg --forced
    1.47 +			tazpkg -i "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION$arch.tazpkg" --forced
    1.48  		else
    1.49  			broken
    1.50  			die 'Unable to install package, build has failed.'
    1.51 @@ -1563,6 +1567,10 @@
    1.52  put_status() {
    1.53  	# $1: package, $2: status, one of 'Done', 'Failed'
    1.54  	sed -i "s|>$1</a>$|& [ $2 ]|" $activity
    1.55 +	if [ "$2" == 'Done' ]; then
    1.56 +		# overstrike all previous 'Failed' to indicate package is OK now
    1.57 +		sed -i "/>$1<\/a>/ s|\[ Failed \]|[ -Failed ]|" $activity
    1.58 +	fi
    1.59  }
    1.60  
    1.61  
     2.1 --- a/cook.site	Sat Jan 27 11:55:42 2018 +0200
     2.2 +++ b/cook.site	Fri Feb 02 00:51:10 2018 +0200
     2.3 @@ -4,24 +4,25 @@
     2.4  # handles CONFIG_SITE and will source this file automatically.
     2.5  #
     2.6  # If you want to use your own cook.site, you can use:
     2.7 -# export CONFIG_SITE=config.site in compile_rules of a receipt.
     2.8 +# export CONFIG_SITE=config.site in compile_rules() of a receipt.
     2.9  #
    2.10  
    2.11 -# Some old configure(s) use "${prefix}" instead of "${datarootdir}".
    2.12 -if echo "$localedir" | grep -q \${prefix}; then
    2.13 -	localedir=$( echo "$localedir" | sed 's/${prefix}/${datarootdir}/')
    2.14 -fi
    2.15 -if echo "$infodir" | grep -q \${prefix}; then
    2.16 -	infodir=$( echo "$infodir" | sed 's/${prefix}/${datarootdir}/')
    2.17 -fi
    2.18 -if echo "$mandir" | grep -q \${prefix}; then
    2.19 -	mandir=$( echo "$mandir" | sed 's/${prefix}/${datarootdir}/')
    2.20 -fi
    2.21 +# Find receipt (backward recursively from current dir)
    2.22 +receiptpath=$(realpath .)
    2.23 +until [ -z "$receiptpath" -o -e "$receiptpath/receipt" ]; do
    2.24 +	receiptpath="${receiptpath%/*}"
    2.25 +done
    2.26 +
    2.27  
    2.28  # Default options.
    2.29 -prefix=/usr
    2.30 -datarootdir=$prefix/share
    2.31 -datadir=$datadir
    2.32 -localedir=$datarootdir/locale
    2.33 -infodir=$datarootdir/info
    2.34 -mandir=$datarootdir/man
    2.35 +prefix="/usr"
    2.36 +sysconfdir="/etc"
    2.37 +localstatedir="/var"
    2.38 +datarootdir="$prefix/share"
    2.39 +datadir="$datarootdir"
    2.40 +infodir="$datarootdir/info"
    2.41 +localedir="$datarootdir/locale"
    2.42 +mandir="$datarootdir/man"
    2.43 +docdir="$datarootdir/doc/$(. $receiptpath/receipt; echo $PACKAGE-$VERSION)"
    2.44 +
    2.45 +unset receiptpath
     3.1 --- a/lighttpd/index.cgi	Sat Jan 27 11:55:42 2018 +0200
     3.2 +++ b/lighttpd/index.cgi	Fri Feb 02 00:51:10 2018 +0200
     3.3 @@ -871,6 +871,7 @@
     3.4  			tac $CACHE/$list | sed 's|cooker.cgi?pkg=||; s|%2B|+|g;
     3.5  				s|\[ Done|<span class="r c20">Done|;
     3.6  				s|\[ Failed|<span class="r c10">Failed|;
     3.7 +				s|\[ -Failed|<span class="r c10"><del>Failed</del>|;
     3.8  				s| \]|</span>|' | mktable $list
     3.9  			echo '</section>'
    3.10  		done
    3.11 @@ -1028,6 +1029,7 @@
    3.12  	tac $activity | head -n12 | sed 's|cooker.cgi?pkg=||;
    3.13  		s|\[ Done|<span class="r c20">Done|;
    3.14  		s|\[ Failed|<span class="r c10">Failed|;
    3.15 +		s|\[ -Failed|<span class="r c10"><del>Failed</del>|;
    3.16  		s| \]|</span>|;
    3.17  		s|%2B|\+|g' | \
    3.18  		section $activity 12 "Activity|More activity"
     4.1 --- a/modules/compressor	Sat Jan 27 11:55:42 2018 +0200
     4.2 +++ b/modules/compressor	Fri Feb 02 00:51:10 2018 +0200
     4.3 @@ -691,28 +691,35 @@
     4.4  	time0=$(get_time)
     4.5  	oldsize=$(sizes strip)
     4.6  
     4.7 -	# Strip executable files & shared libraries
     4.8 +
     4.9 +	# GNU strip (GNU Binutils)
    4.10 +	# -p --preserve-dates                 Copy modified/access timestamps to the output
    4.11 +	# -s --strip-all                      Remove all symbol and relocation information
    4.12 +	#    --strip-unneeded                 Remove all symbols not needed by relocations
    4.13 +	# -D --enable-deterministic-archives  Produce deterministic output when stripping archives
    4.14 +	# -g -S -d --strip-debug              Remove all debugging symbols & sections
    4.15 +
    4.16 +	# Strip executable files
    4.17  	while read i; do
    4.18 -		$STRIP -s "$i" 2>/dev/null
    4.19 +		$STRIP -ps "$i" 2>/dev/null
    4.20  	done <<EOT
    4.21 -$(find_elf EXEC; find_elf DYN)
    4.22 +$(find_elf EXEC)
    4.23 +EOT
    4.24 +
    4.25 +	# Strip shared libraries
    4.26 +	while read i; do
    4.27 +		case $i in
    4.28 +			*.dbg) ;; # skip library.so.*.dbg debugging symbols
    4.29 +			*) $STRIP -p --strip-unneeded "$i" 2>/dev/null;;
    4.30 +		esac
    4.31 +	done <<EOT
    4.32 +$(find_elf DYN)
    4.33  EOT
    4.34  
    4.35  	# Strip static libraries
    4.36 -	find $fs -name '*.a' -exec $STRIP -d '{}' 2>/dev/null \;
    4.37 +	# See also: https://wiki.debian.org/ReproducibleBuilds/TimestampsInStaticLibraries
    4.38 +	find $fs -name '*.a' -exec $STRIP -pdD '{}' 2>/dev/null \;
    4.39  
    4.40 -	# Nullify timestamps of files in ar archives
    4.41 -	# Skip empty 8-byte archives (hi, musl-libc package)
    4.42 -	# Using ar from binutils (ar from Busybox isn't enough) as ${TOOLPREFIX}ar
    4.43 -	whereami=$(pwd)
    4.44 -	find $fs -name '*.a' -type f -size +8c | \
    4.45 -	while read i; do
    4.46 -		tempdir=$(mktemp -d); cd $tempdir
    4.47 -		${TOOLPREFIX}ar -x $i; ${TOOLPREFIX}ar -crD $(basename $i) *
    4.48 -		mv -f $tempdir/$(basename $i) $i
    4.49 -		rm -rf $tempdir
    4.50 -	done
    4.51 -	cd $whereami; unset whereami
    4.52  
    4.53  	# Remove Python *.pyc and *.pyo
    4.54  	find $fs -type f \( -name '*.pyc' -o -name '*.pyo' \) -delete 2>/dev/null