cookutils rev 907

cook: add check_integrity(), fix install_package() to be compatible with receipts v2.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon May 29 01:54:22 2017 +0300 (2017-05-29)
parents dba59a5ecc00
children f439bf689ac8
files cook
line diff
     1.1 --- a/cook	Sat May 27 17:40:33 2017 +0300
     1.2 +++ b/cook	Mon May 29 01:54:22 2017 +0300
     1.3 @@ -538,6 +538,21 @@
     1.4  }
     1.5  
     1.6  
     1.7 +# Check source tarball integrity.
     1.8 +
     1.9 +check_integrity() {
    1.10 +	if [ -n  "$TARBALL_SHA1" ]; then
    1.11 +		echo "$TARBALL_SHA1  $SRC/$TARBALL"   | sha1sum -c   || exit 1
    1.12 +	fi
    1.13 +	if [ -n  "$TARBALL_SHA256" ]; then
    1.14 +		echo "$TARBALL_SHA256  $SRC/$TARBALL" | sha256sum -c || exit 1
    1.15 +	fi
    1.16 +	if [ -n  "$TARBALL_MD5" ]; then
    1.17 +		echo "$TARBALL_MD5  $SRC/$TARBALL"    | md5sum -c    || exit 1
    1.18 +	fi
    1.19 +}
    1.20 +
    1.21 +
    1.22  # The main cook function.
    1.23  
    1.24  cookit() {
    1.25 @@ -1056,7 +1071,23 @@
    1.26  }
    1.27  
    1.28  
    1.29 -# Install package on --install or update the chroot.
    1.30 +# Update chroot with freshly rebuilt package: keep env up-to-date.
    1.31 +
    1.32 +update_chroot() {
    1.33 +	for i in $pkg $SPLIT; do
    1.34 +		if [ -d "$root$INSTALLED/$i" ]; then
    1.35 +			. /etc/slitaz/cook.conf
    1.36 +			. $WOK/$pkg/taz/$i-$VERSION/receipt
    1.37 +			_ 'Updating %s chroot environment...' "$ARCH"
    1.38 +			_ 'Updating chroot: %s' "$i ($VERSION$EXTRAVERSION$arch)" | log
    1.39 +			cd $PKGS
    1.40 +			tazpkg install $i-$VERSION$EXTRAVERSION$arch.tazpkg --forced --root=$root
    1.41 +		fi
    1.42 +	done
    1.43 +}
    1.44 +
    1.45 +
    1.46 +# Install package on --inst or update the chroot.
    1.47  
    1.48  install_package() {
    1.49  	case "$ARCH" in
    1.50 @@ -1067,7 +1098,7 @@
    1.51  	# Install package if requested but skip install if target host doesn't
    1.52  	# match build system or it will break the build chroot.
    1.53  	build=$(echo $BUILD_SYSTEM | cut -d- -f1)
    1.54 -	if [ -n "$inst" ] && [ "$build" == "$ARCH" ]; then
    1.55 +	if [ -n "$inst" -a "$build" == "$ARCH" ]; then
    1.56  		if [ -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
    1.57  			cd $PKGS
    1.58  			tazpkg install $PACKAGE-$VERSION$EXTRAVERSION.tazpkg --forced
    1.59 @@ -1077,15 +1108,7 @@
    1.60  		fi
    1.61  	fi
    1.62  
    1.63 -	# Install package if part of the chroot to keep env up-to-date.
    1.64 -	if [ -d "$root$INSTALLED/$pkg" ]; then
    1.65 -		. /etc/slitaz/cook.conf
    1.66 -		. $WOK/$pkg/taz/$pkg-*/receipt
    1.67 -		_ 'Updating %s chroot environment...' "$ARCH"
    1.68 -		_ 'Updating chroot: %s' "$pkg ($VERSION$EXTRAVERSION$arch)" | log
    1.69 -		cd $PKGS
    1.70 -		tazpkg install $pkg-$VERSION$EXTRAVERSION$arch.tazpkg --forced --root=$root
    1.71 -	fi
    1.72 +	update_chroot
    1.73  }
    1.74  
    1.75  
    1.76 @@ -1767,6 +1790,7 @@
    1.77  		done
    1.78  
    1.79  		# Cook and pack or exit on error and log everything.
    1.80 +		check_integrity
    1.81  		cookit $@ 2>&1 | loglimit 50 > $LOGS/$pkg.log
    1.82  		remove_deps | tee -a $LOGS/$pkg.log
    1.83  		cookit_quality