tazpkg rev 261

tazpkg: install virtual packages
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon May 25 16:08:24 2009 +0200 (2009-05-25)
parents d867115ab926
children a041e442f730
files tazpkg
line diff
     1.1 --- a/tazpkg	Mon May 11 15:20:14 2009 +0200
     1.2 +++ b/tazpkg	Mon May 25 16:08:24 2009 +0200
     1.3 @@ -228,7 +228,7 @@
     1.4  	fi
     1.5  }
     1.6  
     1.7 -# get package from packages.equiv
     1.8 +# get an already installed package from packages.equiv
     1.9  equivalent_pkg()
    1.10  {
    1.11  	for i in $(grep -hs "^$1=" $LOCALSTATE/packages.equiv \
    1.12 @@ -254,6 +254,27 @@
    1.13  	echo $1
    1.14  }
    1.15  
    1.16 +# get a virtual package from packages.equiv
    1.17 +virtual_pkg()
    1.18 +{
    1.19 +	for i in $(grep -hs "^$1=" $LOCALSTATE/packages.equiv \
    1.20 +		   $LOCALSTATE/undigest/*/packages.equiv | sed "s/^$1=//"); do
    1.21 +		if echo $i | grep -q : ; then
    1.22 +			# format 'alternative:newname'
    1.23 +			# if alternative is installed then substitute newname
    1.24 +			if [ -f $2$INSTALLED/${i%:*}/receipt ]; then
    1.25 +				# substitute package dependancy
    1.26 +				echo ${i#*:}
    1.27 +				return
    1.28 +			fi
    1.29 +		else
    1.30 +			# if alternative is installed then nothing to install
    1.31 +			echo $i
    1.32 +			return
    1.33 +		fi
    1.34 +	done
    1.35 +}
    1.36 +
    1.37  # Get package filename available on the mirror
    1.38  get_package_filename()
    1.39  {
    1.40 @@ -273,7 +294,7 @@
    1.41  	if [ -z "$pkg" ]; then
    1.42  		# Check for vitual package
    1.43  		local equiv
    1.44 -		equiv=$(equivalent_pkg $1 virtual)
    1.45 +		equiv=$(virtual_pkg $1)
    1.46  		if [ "$equiv" != "$1" ]; then
    1.47  			PACKAGE=$equiv
    1.48  			get_package_filename $PACKAGE