tazpkg rev 970

Modules "get" and "install": fix cookmode again
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Nov 26 18:53:08 2018 +0200 (12 months ago)
parents f40de1e052aa
children d2dc3d5ed06d
files modules/get modules/install
line diff
     1.1 --- a/modules/get	Mon Nov 26 14:59:03 2018 +0200
     1.2 +++ b/modules/get	Mon Nov 26 18:53:08 2018 +0200
     1.3 @@ -160,8 +160,8 @@
     1.4  		[ ! -e 'packages.info' -a ! -e "packages-$SLITAZ_ARCH.info" ] &&
     1.5  			tazpkg mkdb "$extra_cache" --root='' --forced >/dev/null
     1.6  
     1.7 -		pi='packages.info'
     1.8 -		[ -e "$pi" ] || pi="packages-$SLITAZ_ARCH.info"
     1.9 +		pi="packages-$SLITAZ_ARCH.info"
    1.10 +		[ -e "$pi" ] || pi='packages.info'
    1.11  
    1.12  		if [ -e "$pi" ]; then
    1.13  			awk -F$'\t' -vp="$1" '$1==p{exit 1}' $pi
    1.14 @@ -295,7 +295,11 @@
    1.15  virtual_name() {
    1.16  	# input:  $1 virtual package name
    1.17  	#         $2 repository db directory
    1.18 -	local i
    1.19 +	local i pi
    1.20 +
    1.21 +	pi="$2/packages-$SLITAZ_ARCH.info"
    1.22 +	[ -e "$pi" ] || pi="$2/packages.info"
    1.23 +
    1.24  	unset IFS
    1.25  	for i in $(grep -hs "^$1=" "$2/packages.equiv" | sed "s/^$1=//"); do
    1.26  		if echo $i | fgrep -q : ; then
    1.27 @@ -306,7 +310,7 @@
    1.28  				echo ${i#*:}
    1.29  				return
    1.30  			fi
    1.31 -		elif ! grep -q "^$1	" "$2/packages.info" || [ -f "$INSTALLED/$i/receipt" ]; then
    1.32 +		elif ! grep -q "^$1	" "$pi" || [ -f "$INSTALLED/$i/receipt" ]; then
    1.33  			# unconditional substitution
    1.34  			echo $i
    1.35  			return
    1.36 @@ -320,12 +324,16 @@
    1.37  	# input:  $1 virtual package name
    1.38  	#         $2 repository db directory
    1.39  	# output: display possible package name
    1.40 +	local pi
    1.41  
    1.42  	debug "\nvirtual_pkg('$1', '$2')"
    1.43  
    1.44 +	pi="$2/packages-$SLITAZ_ARCH.info"
    1.45 +	[ -e "$pi" ] || pi="$2/packages.info"
    1.46 +
    1.47  	if [ "$tazpkg_command" != 'get-install' ]; then
    1.48  		# 'get' command: download any package
    1.49 -		if [ -z "$(awk -F$'\t' -vp="$1" '{if ($1 == p) print p}' "$2/packages.info")" ]; then
    1.50 +		if [ -z "$(awk -F$'\t' -vp="$1" '{if ($1 == p) print p}' "$pi")" ]; then
    1.51  			# This package does not exist in the list, it may be a virtual package
    1.52  			virtual_name "$1" "$2"
    1.53  		else
    1.54 @@ -351,17 +359,16 @@
    1.55  
    1.56  	IFS=$'\n'
    1.57  	for rep in $PRIORITY; do
    1.58 -		pi="$rep/packages.info"
    1.59 -		[ ! -e "$pi" ] && pi="$rep/packages-$SLITAZ_ARCH.info"
    1.60 -		[ ! -e "$pi" ] && continue
    1.61 +		pi="$rep/packages-$SLITAZ_ARCH.info"
    1.62 +		[ -e "$pi" ] || pi="$rep/packages.info"
    1.63 +		[ -e "$pi" ] || continue
    1.64  
    1.65  		# If found, output string "<name>-<ver>"
    1.66  		namever=$(awk -F$'\t' -vpkg="$(virtual_pkg "$1" "$rep")" \
    1.67  			'$1==pkg || $1"-"$2==pkg {printf "%s-%s", $1, $2; exit}' "$pi")
    1.68  
    1.69  		pkgfile="$namever-$SLITAZ_ARCH.tazpkg"
    1.70 -		[ -e "$pkgfile" ] ||
    1.71 -		pkgfile="$namever-any.tazpkg"
    1.72 +		[ -e "$pkgfile" ] || pkgfile="$namever-any.tazpkg"
    1.73  
    1.74  		if [ -n "$namever" ]; then
    1.75  			pkgsum=$(awk -vfile="$pkgfile" '{if($2==file)print $1}' $rep/packages.md5)
    1.76 @@ -436,12 +443,12 @@
    1.77  	# output: full path to the found package
    1.78  	# ROOT NOT USED
    1.79  
    1.80 -	local PKGS='/home/slitaz/packages' found='0'
    1.81 +	local PKGS='/home/slitaz/packages' found='0' i
    1.82  	[ -e "/etc/slitaz/cook.conf" ] && . /etc/slitaz/cook.conf
    1.83  
    1.84  	# Find local package
    1.85 -	pi="$PKGS/packages.info"
    1.86 -	[ -e "$pi" ] || pi="$PKGS/packages-$SLITAZ_ARCH.info"
    1.87 +	pi="$PKGS/packages-$SLITAZ_ARCH.info"
    1.88 +	[ -e "$pi" ] || pi="$PKGS/packages.info"
    1.89  
    1.90  	namever="$(awk -F$'\t' -vpkg="$1" '{
    1.91  		if ($1 == pkg) { printf("%s-%s", $1, $2); exit; }
    1.92 @@ -453,18 +460,16 @@
    1.93  		if (index(" " $10 " ", " " pkg " ")) { printf("%s-%s", $1, $2); exit; }
    1.94  	}' $pi)"
    1.95  
    1.96 -	if [ -n "$namever" ]; then
    1.97 -		pkgfile=$(find "$PKGS" -name "$namever-$SLITAZ_ARCH.tazpkg")
    1.98 -		[ -n "$pkgfile" ] ||
    1.99 -		pkgfile=$(find "$PKGS" -name "$namever-any.tazpkg")
   1.100 -	fi
   1.101 +	for i in $SLITAZ_ARCH any; do
   1.102 +		pkgfile="$PKGS/$namever-$i.tazpkg"
   1.103 +		if [ -e "$pkgfile" ]; then
   1.104 +			echo "$pkgfile"
   1.105 +			return
   1.106 +		fi
   1.107 +	done
   1.108  
   1.109 -	if [ -n "$pkgfile" -a -f "$pkgfile" ]; then
   1.110 -		echo "$pkgfile"
   1.111 -	else
   1.112 -		# Proceed to get package as usual (non-local)
   1.113 -		get_pkg "$1"
   1.114 -	fi
   1.115 +	# Proceed to get package as usual (non-local)
   1.116 +	get_pkg "$1"
   1.117  }
   1.118  
   1.119  
     2.1 --- a/modules/install	Mon Nov 26 14:59:03 2018 +0200
     2.2 +++ b/modules/install	Mon Nov 26 18:53:08 2018 +0200
     2.3 @@ -46,11 +46,12 @@
     2.4  	if [ -n "$local" ]; then
     2.5  		# Search for virtual packages
     2.6  		if [ -n "$cookmode" ]; then
     2.7 -			pi='/home/slitaz/packages/packages.info'
     2.8 -			[ -e "$pi" ] || pi="/home/slitaz/packages/packages-$SLITAZ_ARCH.info"
     2.9 +			pi="/home/slitaz/packages/packages-$SLITAZ_ARCH.info"
    2.10 +			[ -e "$pi" ] || pi='/home/slitaz/packages/packages.info'
    2.11  		else
    2.12  			pi="$(dirname "$2")/packages.info"
    2.13  		fi
    2.14 +
    2.15  		[ -f "$pi" ] &&
    2.16  		out=$(awk -F$'\t' -vpkg="$1" '{
    2.17  			# if package name or provided package name matched
    2.18 @@ -183,8 +184,10 @@
    2.19  			if [ -n "$local" ]; then
    2.20  				[ -z "$quiet" ] && _ 'Checking if package "%s" exists in local list...' "$pkg"
    2.21  				[ -n "$cookmode" ] && dir='/home/slitaz/packages'
    2.22 -				pi="$dir/packages.info"
    2.23 -				[ -e "$pi" ] || pi="$dir/packages-$SLITAZ_ARCH.info"
    2.24 +
    2.25 +				pi="$dir/packages-$SLITAZ_ARCH.info"
    2.26 +				[ -e "$pi" ] || pi="$dir/packages.info"
    2.27 +
    2.28  				# Find local package
    2.29  				if [ -f "$pi" ]; then
    2.30  					# Packages database exists (should be everfresh!)
    2.31 @@ -200,13 +203,18 @@
    2.32  						if (index(" " $10 " ", " " pkg " ")) { printf("%s-%s", $1, $2); exit; }
    2.33  					}' "$pi")		# <namever> = <package_name>-<package_version>
    2.34  
    2.35 -					# Package file may be in form <namever>.tazpkg or <namever>-<arch>.tazpkg, so find one
    2.36 -					[ -n "$namever" ] && pkgfile=$(find "$dir" -name "$namever*.tazpkg")
    2.37 +					# Package file may be in form <namever>-<arch>.tazpkg or <namever>-any.tazpkg, so find one
    2.38 +					if [ -n "$namever" ]; then
    2.39 +						pkgfile=$(find "$dir" -name "$namever-$SLITAZ_ARCH.tazpkg")
    2.40 +						[ -n "$pkgfile" ] ||
    2.41 +						pkgfile=$(find "$dir" -name "$namever-any.tazpkg")
    2.42 +					fi
    2.43 +
    2.44  					[ -n "$pkgfile" ] && found='1'
    2.45  				else
    2.46  					# Packages DB missing, proceed to sniff packages
    2.47  					tempd="$(mktemp -d)"; cd "$tempd"
    2.48 -					for pkgfile in $dir/$pkg-*.tazpkg; do
    2.49 +					for pkgfile in $dir/$pkg-*-$SLITAZ_ARCH.tazpkg $dir/$pkg-*-any.tazpkg; do
    2.50  						[ -e "$pkgfile" ] || continue
    2.51  						# Extract receipt from each matched package
    2.52  						cpio -F "$pkgfile" -i receipt >/dev/null 2>&1
    2.53 @@ -274,11 +282,9 @@
    2.54  
    2.55  	# Try to find short description for mirrored package
    2.56  	if [ -z "$short_desc" ]; then
    2.57 -		if [ -e "$PKGS_DB/packages.info" ]; then
    2.58 -			pi="$PKGS_DB/packages.info"
    2.59 -		else
    2.60 -			"$PKGS_DB/packages-$SLITAZ_ARCH.info"
    2.61 -		fi
    2.62 +		pi="$PKGS_DB/packages-$SLITAZ_ARCH.info"
    2.63 +		[ -e "$pi" ] || pi="$PKGS_DB/packages.info"
    2.64 +
    2.65  		short_desc=$(awk -F$'\t' -vp="$1" '$1==p{print $4; exit}' "$pi")
    2.66  	fi
    2.67