tazpkg rev 190

tazpkg: search package file name in package.txt
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Oct 28 19:35:11 2008 +0000 (2008-10-28)
parents 6a18ba183660
children f58f1abdbbe6
files tazpkg
line diff
     1.1 --- a/tazpkg	Tue Oct 28 12:32:30 2008 +0000
     1.2 +++ b/tazpkg	Tue Oct 28 19:35:11 2008 +0000
     1.3 @@ -56,7 +56,6 @@
     1.4  INSTALLED=$LOCALSTATE/installed
     1.5  CACHE_DIR=/var/cache/tazpkg
     1.6  MIRROR=$LOCALSTATE/mirror
     1.7 -PACKAGES_LIST=$LOCALSTATE/packages.list
     1.8  BLOCKED=$LOCALSTATE/blocked-packages.list
     1.9  DEFAULT_MIRROR="http://mirror.slitaz.org/packages/`cat /etc/slitaz-release`/"
    1.10  INSTALL_LIST=""
    1.11 @@ -227,18 +226,33 @@
    1.12  	fi
    1.13  }
    1.14  
    1.15 +# Get package filename available on the mirror
    1.16 +get_package_filename()
    1.17 +{
    1.18 +	local pkg
    1.19 +	pkg=$(grep -A 1 -sh "^$1$" $LOCALSTATE/packages.txt \
    1.20 +		$LOCALSTATE/undigest/*/packages.txt | tail -1)
    1.21 +	pkg=$(echo $pkg)
    1.22 +	[ -n "$pkg" ] && pkg=$(grep -sh "^$1-$pkg" \
    1.23 +		$LOCALSTATE/packages.list \
    1.24 +		$LOCALSTATE/undigest/*/packages.list | head -1)
    1.25 +	[ -n "$pkg" ] || pkg=$(grep -sh "^$1-[0-9]" \
    1.26 +		$LOCALSTATE/packages.list \
    1.27 +		$LOCALSTATE/undigest/*/packages.list | head -1)
    1.28 +	[ -n "$pkg" ] || pkg=$(grep -sh "^$1-.[\.0-9]" \
    1.29 +		$LOCALSTATE/packages.list \
    1.30 +		$LOCALSTATE/undigest/*/packages.list | head -1)
    1.31 +	echo $pkg
    1.32 +}
    1.33 +
    1.34  # Check for a package in packages.list. Used by get and get-install to grep
    1.35  # package basename.
    1.36  check_for_package_in_list()
    1.37  {
    1.38 -	local pkg
    1.39 -	pkg=$(grep -sh "^$PACKAGE-[0-9]" $LOCALSTATE/packages.list \
    1.40 -		$LOCALSTATE/undigest/*/packages.list | head -1)
    1.41 -	[ -n "$pkg" ] || pkg=$(grep -sh "^$PACKAGE-.[\.0-9]" \
    1.42 -		$LOCALSTATE/packages.list \
    1.43 -		$LOCALSTATE/undigest/*/packages.list | head -1)
    1.44 -	if [ -n "$pkg" ]; then
    1.45 -		PACKAGE=$pkg
    1.46 +	local filename
    1.47 +	filename=$(get_package_filename $PACKAGE)
    1.48 +	if [ -n "$filename" ]; then
    1.49 +		PACKAGE=$filename
    1.50  	else
    1.51  		echo -e "\nUnable to find : $PACKAGE in the mirrored packages list.\n"
    1.52  		exit 0
    1.53 @@ -1270,10 +1284,14 @@
    1.54  			mkdir -p $TMP_DIR && cd $TMP_DIR
    1.55  			for i in $INSTALLED/*/volatile.cpio.gz; do 
    1.56  				zcat $i | cpio -id > /dev/null
    1.57 -				find * -type f | while read file; do
    1.58 +				find * -type f 2>/dev/null | while read file; do
    1.59 +					if [ ! -e /$file ]; then
    1.60 +					echo -n "|--|--|--|File lost"
    1.61 +					else
    1.62  					echo -n "$(stat -c "%A|%U|%G|%s|" /$file)"
    1.63  					cmp $file /$file > /dev/null 2>&1 || \
    1.64  						echo -n "$(stat -c "%.16y" /$file)"
    1.65 +					fi
    1.66  					echo "|/$file"
    1.67  				done
    1.68  				rm -rf *
    1.69 @@ -1535,8 +1553,7 @@
    1.70  			else
    1.71  				# Check if the installed package is in the current list (other
    1.72  				# mirror or local).
    1.73 -				NEW_PACKAGE=$(grep "^$PACKAGE-[0-9]" packages.list | head -1)
    1.74 -				[ -n "$NEW_PACKAGE" ] || NEW_PACKAGE=$(grep "^$PACKAGE-.[\.0-9]" packages.list | head -1)
    1.75 +				NEW_PACKAGE=$(get_package_filename $PACKAGE)
    1.76  
    1.77  				if [ -n "$NEW_PACKAGE" ]; then
    1.78  					# Set new pkg and version for futur comparaison