tazpkg rev 226

tazpkg may download virtual packages
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Feb 19 06:48:26 2009 +0000 (2009-02-19)
parents 1fddc0f5ac50
children e3aebbd89277
files tazpkg
line diff
     1.1 --- a/tazpkg	Wed Feb 18 17:36:57 2009 +0000
     1.2 +++ b/tazpkg	Thu Feb 19 06:48:26 2009 +0000
     1.3 @@ -228,6 +228,32 @@
     1.4  	fi
     1.5  }
     1.6  
     1.7 +# get package from packages.equiv
     1.8 +equivalent_pkg()
     1.9 +{
    1.10 +	for i in $(grep -hs "^$1=" $LOCALSTATE/packages.equiv \
    1.11 +		   $LOCALSTATE/undigest/*/packages.equiv | sed "s/^$1=//"); do
    1.12 +		if echo $i | grep -q : ; then
    1.13 +			# format 'alternative:newname'
    1.14 +			# if alternative is installed then substitute newname
    1.15 +			if [ -f $2$INSTALLED/${i%:*}/receipt ]; then
    1.16 +				# substitute package dependancy
    1.17 +				echo ${i#*:}
    1.18 +				return
    1.19 +			fi
    1.20 +		else
    1.21 +			# if alternative is installed then nothing to install
    1.22 +			if [ -f $2$INSTALLED/$i/receipt -o -n "$2" ]; then
    1.23 +				# substitute installed package
    1.24 +				echo $i
    1.25 +				return
    1.26 +			fi
    1.27 +		fi
    1.28 +	done
    1.29 +	# if not found in packages.equiv then no substitution
    1.30 +	echo $1
    1.31 +}
    1.32 +
    1.33  # Get package filename available on the mirror
    1.34  get_package_filename()
    1.35  {
    1.36 @@ -244,6 +270,16 @@
    1.37  	[ -n "$pkg" ] || pkg=$(grep -sh "^$1-.[\.0-9]" \
    1.38  		$LOCALSTATE/packages.list \
    1.39  		$LOCALSTATE/undigest/*/packages.list | head -1)
    1.40 +	if [ -z "$pkg" ]; then
    1.41 +		# Check for vitual package
    1.42 +		local equiv
    1.43 +		equiv=$(equivalent_pkg $1 virtual)
    1.44 +		if [ "$equiv" != "$1" ]; then
    1.45 +			PACKAGE=$equiv
    1.46 +			get_package_filename $PACKAGE
    1.47 +			return
    1.48 +		fi
    1.49 +	fi
    1.50  	echo $pkg
    1.51  }
    1.52  
    1.53 @@ -464,32 +500,6 @@
    1.54  	done
    1.55  }
    1.56  
    1.57 -# get package from packages.equiv
    1.58 -equivalent_pkg()
    1.59 -{
    1.60 -	for i in $(grep -hs "^$1=" $LOCALSTATE/packages.equiv \
    1.61 -		   $LOCALSTATE/undigest/*/packages.equiv | sed "s/^$1=//"); do
    1.62 -		if echo $i | grep -q : ; then
    1.63 -			# format 'alternative:newname'
    1.64 -			# if alternative is installed then substitute newname
    1.65 -			if [ -f $2$INSTALLED/${i%:*}/receipt ]; then
    1.66 -				# substitute package dependancy
    1.67 -				echo ${i#*:}
    1.68 -				return
    1.69 -			fi
    1.70 -		else
    1.71 -			# if alternative is installed then nothing to install
    1.72 -			if [ -f $2$INSTALLED/$i/receipt ]; then
    1.73 -				# substitute installed package
    1.74 -				echo $i
    1.75 -				return
    1.76 -			fi
    1.77 -		fi
    1.78 -	done
    1.79 -	# if not found in packages.equiv then no substitution
    1.80 -	echo $1
    1.81 -}
    1.82 -
    1.83  # Check for missing deps listed in a receipt packages.
    1.84  check_for_deps()
    1.85  {