tazpkg rev 971

modules/get: fix plain mode and cookmode again
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Nov 26 20:27:56 2018 +0200 (2018-11-26)
parents f079c87ba419
children 9d683c983e2e
files modules/get
line diff
     1.1 --- a/modules/get	Mon Nov 26 18:53:08 2018 +0200
     1.2 +++ b/modules/get	Mon Nov 26 20:27:56 2018 +0200
     1.3 @@ -363,23 +363,29 @@
     1.4  		[ -e "$pi" ] || pi="$rep/packages.info"
     1.5  		[ -e "$pi" ] || continue
     1.6  
     1.7 -		# If found, output string "<name>-<ver>"
     1.8 -		namever=$(awk -F$'\t' -vpkg="$(virtual_pkg "$1" "$rep")" \
     1.9 -			'$1==pkg || $1"-"$2==pkg {printf "%s-%s", $1, $2; exit}' "$pi")
    1.10 +		# If found, output string "<name>-<ver>-<arch>.tazpkg"
    1.11 +		# Field #11 may be:
    1.12 +		#  - empty (old format): treat as arch-dependent, use $SLITAZ_ARCH
    1.13 +		#  - 0: arch-independent (*-any.tazpkg)
    1.14 +		#  - 3: 32-bit \ just use $SLITAZ_ARCH in both cases -
    1.15 +		#  - 6: 64-bit / there's no 32-bit package in 64-bit repo
    1.16 +		pkgfile=$(awk -F$'\t' -vpkg="$(virtual_pkg "$1" "$rep")" -varch="$SLITAZ_ARCH" '
    1.17 +			$1==pkg || $1"-"$2==pkg {
    1.18 +				a = ($11 == "0") ? "any" : arch;
    1.19 +				printf("%s-%s-%s.tazpkg", $1, $2, a);
    1.20 +				exit
    1.21 +			}' "$pi")
    1.22  
    1.23 -		pkgfile="$namever-$SLITAZ_ARCH.tazpkg"
    1.24 -		[ -e "$pkgfile" ] || pkgfile="$namever-any.tazpkg"
    1.25 -
    1.26 -		if [ -n "$namever" ]; then
    1.27 +		if [ -n "$pkgfile" ]; then
    1.28  			pkgsum=$(awk -vfile="$pkgfile" '{if($2==file)print $1}' $rep/packages.md5)
    1.29  			break
    1.30  		fi
    1.31  	done
    1.32  	unset IFS
    1.33  
    1.34 -	debug "  rep='$rep'\n  namever='$namever'\n  pkgfile='$pkgfile'\n  pkgsum='$pkgsum'"
    1.35 +	debug "  rep='$rep'\n  pkgfile='$pkgfile'\n  pkgsum='$pkgsum'"
    1.36  
    1.37 -	if [ -z "$namever" ]; then
    1.38 +	if [ -z "$pkgfile" ]; then
    1.39  		_ 'Unable to find package "%s" in the mirrored packages list.' "$1" >&2
    1.40  		# Retry with "get-package"; prevent looping with 'redo'
    1.41  		if [ "$2" != 'redo' ]; then
    1.42 @@ -401,11 +407,11 @@
    1.43  
    1.44  	# Check if package already downloaded
    1.45  	if [ -f "$pkgfile" ]; then
    1.46 -		[ -z "$nocache" -a -z "$quiet" ] && _ 'Package "%s" already in the cache' "$namever" >&2
    1.47 +		[ -z "$nocache" -a -z "$quiet" ] && _ 'Package "%s" already in the cache' "$pkgfile" >&2
    1.48  
    1.49  		# Check if downloading complete, resume if not complete
    1.50  		if ! tail -c 2k "$pkgfile" | fgrep -q '00000000TRAILER'; then
    1.51 -			[ -z "$quiet" ] && _ 'Continuing package "%s" download' "$namever" >&2
    1.52 +			[ -z "$quiet" ] && _ 'Continuing package "%s" download' "$pkgfile" >&2
    1.53  			download_from "$(cat "$rep/mirror")" "$pkgfile"
    1.54  		fi
    1.55  	else
    1.56 @@ -450,26 +456,30 @@
    1.57  	pi="$PKGS/packages-$SLITAZ_ARCH.info"
    1.58  	[ -e "$pi" ] || pi="$PKGS/packages.info"
    1.59  
    1.60 -	namever="$(awk -F$'\t' -vpkg="$1" '{
    1.61 -		if ($1 == pkg) { printf("%s-%s", $1, $2); exit; }
    1.62 +	pkgfile="$(awk -F$'\t' -vpkg="$1" -varch="$SLITAZ_ARCH" '{
    1.63 +		if ($1 == pkg) {
    1.64 +			a = ($11 == "0") ? "any" : arch;
    1.65 +			printf("%s-%s-%s.tazpkg", $1, $2, a);
    1.66 +			exit;
    1.67 +		}
    1.68  	}' $pi)"
    1.69  
    1.70  	# Find local provided package
    1.71 -	[ -n "$namever" ] ||
    1.72 -	namever="$(awk -F$'\t' -vpkg="$1" '{
    1.73 -		if (index(" " $10 " ", " " pkg " ")) { printf("%s-%s", $1, $2); exit; }
    1.74 +	[ -n "$pkgfile" ] ||
    1.75 +	pkgfile="$(awk -F$'\t' -vpkg="$1" -varch="$SLITAZ_ARCH" '{
    1.76 +		if (index(" " $10 " ", " " pkg " ")) {
    1.77 +			a = ($11 == "0") ? "any" : arch;
    1.78 +			printf("%s-%s-%s.tazpkg", $1, $2, a);
    1.79 +			exit;
    1.80 +		}
    1.81  	}' $pi)"
    1.82  
    1.83 -	for i in $SLITAZ_ARCH any; do
    1.84 -		pkgfile="$PKGS/$namever-$i.tazpkg"
    1.85 -		if [ -e "$pkgfile" ]; then
    1.86 -			echo "$pkgfile"
    1.87 -			return
    1.88 -		fi
    1.89 -	done
    1.90 -
    1.91 -	# Proceed to get package as usual (non-local)
    1.92 -	get_pkg "$1"
    1.93 +	if [ -e "$PKGS/$pkgfile" ]; then
    1.94 +		echo "$PKGS/$pkgfile"
    1.95 +	else
    1.96 +		# Proceed to get package as usual (non-local)
    1.97 +		get_pkg "$1"
    1.98 +	fi
    1.99  }
   1.100  
   1.101