tazpkg rev 949

modules/get, modules/install: use "release checksum" too, as defined in packages.info field #9.
Checksum from packages.md5 used in verifying downloaded package file, while checksum in packages.info[$9] used in updates checking.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu Jul 20 22:40:46 2017 +0300 (2017-07-20)
parents 99722514f5fe
children 4802158453e1
files modules/get modules/install
line diff
     1.1 --- a/modules/get	Thu Jun 08 14:47:02 2017 +0300
     1.2 +++ b/modules/get	Thu Jul 20 22:40:46 2017 +0300
     1.3 @@ -348,11 +348,11 @@
     1.4  	IFS=$'\n'
     1.5  	for rep in $PRIORITY; do
     1.6  		[ ! -f "$rep/packages.info" ] && continue
     1.7 -		# If found, output string "<name>-<ver>:<sum>"
     1.8 -		line=$(awk -F$'\t' -vpkg="$(virtual_pkg "$1" "$rep")" \
     1.9 -			'$1==pkg || $1"-"$2==pkg {printf "%s-%s:%s", $1, $2, $9; exit}' "$rep/packages.info")
    1.10 -		if [ -n "$line" ]; then
    1.11 -			namever=${line%:*}; pkgsum=${line#*:}
    1.12 +		# If found, output string "<name>-<ver>"
    1.13 +		namever=$(awk -F$'\t' -vpkg="$(virtual_pkg "$1" "$rep")" \
    1.14 +			'$1==pkg || $1"-"$2==pkg {printf "%s-%s", $1, $2; exit}' "$rep/packages.info")
    1.15 +		if [ -n "$namever" ]; then
    1.16 +			pkgsum=$(awk -vfile="$namever.tazpkg" '{if($2==file)print $1}' $rep/packages.md5)
    1.17  			break
    1.18  		fi
    1.19  	done
    1.20 @@ -360,7 +360,7 @@
    1.21  
    1.22  	debug "  rep='$rep'\n  namever='$namever'\n  pkgsum='$pkgsum'"
    1.23  
    1.24 -	if [ -z "$line" ]; then
    1.25 +	if [ -z "$namever" ]; then
    1.26  		_ 'Unable to find package "%s" in the mirrored packages list.' "$1" >&2
    1.27  		# Retry with "get-package"; prevent looping with 'redo'
    1.28  		if [ "$2" != 'redo' ]; then
     2.1 --- a/modules/install	Thu Jun 08 14:47:02 2017 +0300
     2.2 +++ b/modules/install	Thu Jul 20 22:40:46 2017 +0300
     2.3 @@ -615,20 +615,34 @@
     2.4  
     2.5  
     2.6  
     2.7 -	# Update installed.info
     2.8 +	# Update installed.info ----------------------------------------------------
     2.9  	SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
    2.10 +
    2.11  	# Remove newlines from some receipts
    2.12  	DEPENDS=$(echo $DEPENDS)
    2.13 -	PKG_SUM="$(fgrep " $PACKAGE-$VERSION$EXTRAVERSION.tazpkg" "$PKGS_DB/installed.$SUM" | cut -d' ' -f1)"
    2.14 +
    2.15 +	# Calculate "release checksum": md5sum of file containing md5sums of:
    2.16 +	# a) all files, b) receipt, and c) description.txt.
    2.17 +	rsumf=$(mktemp)
    2.18 +	cp $INSTALLED/$PACKAGE/md5sum $rsumf
    2.19 +	md5sum $INSTALLED/$PACKAGE/receipt | sed 's| [^ ]*/| |' >> $rsumf
    2.20 +	[ -e "$INSTALLED/$PACKAGE/description.txt" ] &&
    2.21 +		md5sum $INSTALLED/$PACKAGE/description.txt | sed 's| [^ ]*/| |' >> $rsumf
    2.22 +	RSUM=$(md5sum $rsumf | awk '{print $1}')
    2.23 +	rm $rsumf
    2.24 +
    2.25  	ii="$PKGS_DB/installed.info"
    2.26 +
    2.27  	# Remove old entry
    2.28  	sed -i "/^$PACKAGE	/d" "$ii"
    2.29 +
    2.30  	cat >> "$ii" <<EOT
    2.31 -$PACKAGE	$VERSION$EXTRAVERSION	$CATEGORY	$SHORT_DESC	$WEB_SITE	$TAGS	$SIZES	$DEPENDS	$PKG_SUM
    2.32 +$PACKAGE	$VERSION$EXTRAVERSION	$CATEGORY	$SHORT_DESC	$WEB_SITE	$TAGS	$SIZES	$DEPENDS	$RSUM
    2.33  EOT
    2.34 -	#awk -F$'\t' -vp="$PACKAGE" '$1==p' "$PKGS_DB/packages.info" > $ii
    2.35 +
    2.36  	TEMP_FILE="$(mktemp)"
    2.37  	sort "$ii" > "$TEMP_FILE"; mv -f "$TEMP_FILE" "$ii"; chmod a+r "$ii"; unset ii
    2.38 +	# --------------------------------------------------------------------------
    2.39  
    2.40  	cd "$CUR_DIR"
    2.41  	footer "$(_ 'Package "%s" (%s) is installed.' "$PACKAGE" "$VERSION$EXTRAVERSION")"