tazpkg rev 407

Fix: /var/lib/tazpkg is now properly created when using --root and check of installed packages now works properly
author Antoine Bodin <gokhlayeh@slitaz.org>
date Tue Jan 25 00:14:07 2011 +0100 (2011-01-25)
parents bed335284b2e
children 05010d8d951b
files tazpkg
line diff
     1.1 --- a/tazpkg	Tue Jan 25 00:01:48 2011 +0100
     1.2 +++ b/tazpkg	Tue Jan 25 00:14:07 2011 +0100
     1.3 @@ -62,13 +62,17 @@
     1.4  
     1.5  # Check if the directories and files used by Tazpkg
     1.6  # exist. If not and user is root we create them.
     1.7 -if test $(id -u) = 0 ; then
     1.8 -	check_dir $CACHE_DIR
     1.9 -	check_dir $INSTALLED
    1.10 -	if [ ! -f "$LOCALSTATE/mirror" ]; then
    1.11 -		echo "$DEFAULT_MIRROR" > $LOCALSTATE/mirror
    1.12 +check_base_dir()
    1.13 +{
    1.14 +	if test $(id -u) = 0 ; then
    1.15 +		check_dir $1$CACHE_DIR
    1.16 +		check_dir $1$INSTALLED
    1.17 +		if [ ! -f "$1$LOCALSTATE/mirror" ]; then
    1.18 +			echo "$DEFAULT_MIRROR" > $1$LOCALSTATE/mirror
    1.19 +		fi
    1.20  	fi
    1.21 -fi
    1.22 +}
    1.23 +check_base_dir
    1.24  
    1.25  ####################
    1.26  # Script functions #
    1.27 @@ -182,9 +186,9 @@
    1.28  # Get package name in a directory
    1.29  package_fullname_in_dir()
    1.30  {
    1.31 -	[ -f $2$1/receipt ] || return
    1.32 +	[ -f $1/receipt ] || return
    1.33  	EXTRAVERSION=""
    1.34 -	. $2$1/receipt
    1.35 +	. $1/receipt
    1.36  	echo $PACKAGE-$VERSION$EXTRAVERSION
    1.37  }
    1.38  
    1.39 @@ -193,7 +197,7 @@
    1.40  {
    1.41  	for i in $2$INSTALLED/${1%%-*}*; do
    1.42  		[ -d $i ] || continue
    1.43 -		if [ "$1" = "$(package_fullname_in_dir $i $2)" ]; then
    1.44 +		if [ "$1" = "$(package_fullname_in_dir $i)" ]; then
    1.45  			echo $i
    1.46  			return
    1.47  		fi
    1.48 @@ -1735,7 +1739,7 @@
    1.49  		# Check if forced install.
    1.50  		DO_CHECK="yes"
    1.51  		[ "$forced" ] && DO_CHECK=no
    1.52 -		[ "$root" ] && ROOT="$root"
    1.53 +		[ "$root" ] && ROOT="$root" && check_dir "$root"
    1.54  		[ "$list" ] && INSTALL_LIST="$list"
    1.55  		if [ "$DO_CHECK" = "yes" ]; then
    1.56  			check_for_installed_package $ROOT
    1.57 @@ -2602,7 +2606,7 @@
    1.58  		
    1.59  		DO_CHECK=""
    1.60  		[ "$forced" ] && DO_CHECK=no
    1.61 -		[ "$root" ] && ROOT="$root"
    1.62 +		[ "$root" ] && ROOT="$root" && check_dir "$root"
    1.63  		[ "$list" ] && INSTALL_LIST="$list"
    1.64  		AUTOEXEC="no"
    1.65  		if ! check_for_package_in_list check; then