tazpkg diff tazpkg @ rev 700

/etc/slitaz/slitaz.conf tells that $LOCALSTATE is an OLD variable and equals to $PKGS_DB, so change code.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu Dec 04 01:41:59 2014 +0200 (2014-12-04)
parents 1b791f0f9239
children 56a4afc8d5fa
line diff
     1.1 --- a/tazpkg	Thu Dec 04 01:23:47 2014 +0200
     1.2 +++ b/tazpkg	Thu Dec 04 01:41:59 2014 +0200
     1.3 @@ -112,9 +112,9 @@
     1.4  SAVE_CACHE_DIR="$CACHE_DIR"
     1.5  
     1.6  # Path to tazpkg used dir and configuration files
     1.7 -MIRROR=$LOCALSTATE/mirror
     1.8 -BLOCKED=$LOCALSTATE/blocked-packages.list
     1.9 -UP_LIST=$LOCALSTATE/packages.up
    1.10 +MIRROR=$PKGS_DB/mirror
    1.11 +BLOCKED=$PKGS_DB/blocked-packages.list
    1.12 +UP_LIST=$PKGS_DB/packages.up
    1.13  DEFAULT_MIRROR="$ONLINE_PKGS"
    1.14  
    1.15  
    1.16 @@ -225,9 +225,9 @@
    1.17  		check_dir $1$CACHE_DIR
    1.18  		check_dir $1$INSTALLED
    1.19  		check_dir $1$SLITAZ_LOGS
    1.20 -		if [ ! -f "$1$LOCALSTATE/mirror" ]; then
    1.21 -			echo "${DEFAULT_MIRROR%/}/" > $1$LOCALSTATE/mirror
    1.22 -			[ -n "$1" ] && cp $LOCALSTATE/packages.* $1$LOCALSTATE/
    1.23 +		if [ ! -f "$1$PKGS_DB/mirror" ]; then
    1.24 +			echo "${DEFAULT_MIRROR%/}/" > $1$PKGS_DB/mirror
    1.25 +			[ -n "$1" ] && cp $PKGS_DB/packages.* $1$PKGS_DB/
    1.26  		fi
    1.27  	fi
    1.28  }
    1.29 @@ -274,25 +274,25 @@
    1.30  }
    1.31  
    1.32  
    1.33 -# Get repositories priority using $LOCALSTATE/priority.
    1.34 +# Get repositories priority using $PKGS_DB/priority.
    1.35  # In this files, undigest are called by their name and main mirror
    1.36  # by main. Sort order: priority
    1.37  
    1.38  look_for_priority()
    1.39  {
    1.40 -	[ -s $LOCALSTATE/priority ] && priority=$(cat $LOCALSTATE/priority)
    1.41 -	for rep in main $(ls $LOCALSTATE/undigest 2>/dev/null); do
    1.42 -		if [ ! -s $LOCALSTATE/priority ] || \
    1.43 -			! grep -q ^$rep$ $LOCALSTATE/priority; then
    1.44 +	[ -s $PKGS_DB/priority ] && priority=$(cat $PKGS_DB/priority)
    1.45 +	for rep in main $(ls $PKGS_DB/undigest 2>/dev/null); do
    1.46 +		if [ ! -s $PKGS_DB/priority ] || \
    1.47 +			! grep -q ^$rep$ $PKGS_DB/priority; then
    1.48  			priority=$(echo -e "$priority\n$rep")
    1.49  		fi
    1.50  	done
    1.51  	priority=$(echo "$priority" | sed '/^$/d' | \
    1.52  		while read line; do
    1.53  		if [ "$line" = main ]; then
    1.54 -			echo $LOCALSTATE
    1.55 +			echo $PKGS_DB
    1.56  		else
    1.57 -			echo $LOCALSTATE/undigest/$line
    1.58 +			echo $PKGS_DB/undigest/$line
    1.59  		fi
    1.60  	done)
    1.61  }
    1.62 @@ -344,7 +344,7 @@
    1.63  
    1.64  check_for_packages_list()
    1.65  {
    1.66 -	list_path="$LOCALSTATE/packages.list"
    1.67 +	list_path="$PKGS_DB/packages.list"
    1.68  	if [ ! -f "$list_path" ]; then
    1.69  		if test $(id -u) = 0 ; then
    1.70  			tazpkg recharge
    1.71 @@ -364,7 +364,7 @@
    1.72  get_cache_dir()
    1.73  {
    1.74  	echo $rep > $tmp/rep
    1.75 -	if [ "$rep" = "$LOCALSTATE" ]; then
    1.76 +	if [ "$rep" = "$PKGS_DB" ]; then
    1.77  		CACHE_DIR="$SAVE_CACHE_DIR/$SLITAZ_RELEASE/packages"
    1.78  	elif [ "${rep%-incoming}" = "$rep" ]; then
    1.79  		CACHE_DIR="$SAVE_CACHE_DIR/${rep##*/}/packages"
    1.80 @@ -381,8 +381,8 @@
    1.81  
    1.82  equivalent_pkg()
    1.83  {
    1.84 -	for i in $(grep -hs "^$1=" $LOCALSTATE/packages.equiv \
    1.85 -		   $LOCALSTATE/undigest/*/packages.equiv | sed "s/^$1=//"); do
    1.86 +	for i in $(grep -hs "^$1=" $PKGS_DB/packages.equiv \
    1.87 +		   $PKGS_DB/undigest/*/packages.equiv | sed "s/^$1=//"); do
    1.88  		if echo $i | fgrep -q : ; then
    1.89  			# format 'alternative:newname'
    1.90  			# if alternative is installed then substitute newname
    1.91 @@ -491,7 +491,7 @@
    1.92  	local extra
    1.93  
    1.94  	[ "$1" = "Installed" ] && \
    1.95 -	extra=" - $(fgrep $PACKAGE-$VERSION $LOCALSTATE/installed.$SUM | awk '{ print $1 }')"
    1.96 +	extra=" - $(fgrep $PACKAGE-$VERSION $PKGS_DB/installed.$SUM | awk '{ print $1 }')"
    1.97  
    1.98  	[ -e $LOG ] || touch $LOG
    1.99  
   1.100 @@ -624,9 +624,9 @@
   1.101  		cp $TMP_DIR/files.list $ROOT$INSTALLED/$PACKAGE 2> /dev/null
   1.102  		rm -rf $TMP_DIR 2> /dev/null
   1.103  		sed -i "/ $(basename $PACKAGE_FILE)$/d" \
   1.104 -			$ROOT$LOCALSTATE/installed.$SUM 2> /dev/null
   1.105 +			$ROOT$PKGS_DB/installed.$SUM 2> /dev/null
   1.106  		cd $(dirname $PACKAGE_FILE)
   1.107 -		$CHECKSUM $(basename $PACKAGE_FILE) >> $ROOT$LOCALSTATE/installed.$SUM
   1.108 +		$CHECKSUM $(basename $PACKAGE_FILE) >> $ROOT$PKGS_DB/installed.$SUM
   1.109  	}
   1.110  
   1.111  	# Resolve package deps.
   1.112 @@ -635,7 +635,7 @@
   1.113  		install_deps $ROOT
   1.114  	fi
   1.115  	mkdir -p $TMP_DIR
   1.116 -	[ -n "$INSTALL_LIST" ] && echo "$PACKAGE_FILE" >> $ROOT$LOCALSTATE/$INSTALL_LIST-processed
   1.117 +	[ -n "$INSTALL_LIST" ] && echo "$PACKAGE_FILE" >> $ROOT$PKGS_DB/$INSTALL_LIST-processed
   1.118  
   1.119  	title 'Installation of: $PACKAGE'
   1.120  
   1.121 @@ -1005,7 +1005,7 @@
   1.122  				fi
   1.123  				# Install deps from the mirror.
   1.124  				if [ $found -eq 0 ]; then
   1.125 -					if [ ! -f "$LOCALSTATE/packages.list" ]; then
   1.126 +					if [ ! -f "$PKGS_DB/packages.list" ]; then
   1.127  						tazpkg recharge
   1.128  					fi
   1.129  					tazpkg get-install $pkg $root
   1.130 @@ -1058,11 +1058,11 @@
   1.131  	separator
   1.132  	num=0
   1.133  	BPATTERN="$(emsg "<b>$PATTERN</b>")"
   1.134 -	for i in $LOCALSTATE/packages.list $LOCALSTATE/undigest/*/packages.list; do
   1.135 +	for i in $PKGS_DB/packages.list $PKGS_DB/undigest/*/packages.list; do
   1.136  		grep -is "$PATTERN" $i | sed "s|$PATTERN|$BPATTERN|"
   1.137  		num=$(($num + `grep -is "$PATTERN" $i | wc -l`))
   1.138  	done
   1.139 -	if [ ! -f "$LOCALSTATE/packages.list" ]; then
   1.140 +	if [ ! -f "$PKGS_DB/packages.list" ]; then
   1.141  		newline
   1.142  		_ \
   1.143  "No 'packages.list' found to check for mirrored packages. For more results,
   1.144 @@ -1088,11 +1088,11 @@
   1.145  	_ 'Matching packages name with version and desc'
   1.146  	separator
   1.147  	num=0
   1.148 -	for i in $LOCALSTATE/packages.txt $LOCALSTATE/undigest/*/packages.txt; do
   1.149 +	for i in $PKGS_DB/packages.txt $PKGS_DB/undigest/*/packages.txt; do
   1.150  		grep -is -A 2 "^$PATTERN" $i
   1.151  		num=$(($num + `grep -is "^$PATTERN" $i | wc -l`))
   1.152  	done
   1.153 -	if [ ! -f "$LOCALSTATE/packages.txt" ]; then
   1.154 +	if [ ! -f "$PKGS_DB/packages.txt" ]; then
   1.155  		newline
   1.156  		_ \
   1.157  "No 'packages.txt' found to check for mirrored packages. For more results,
   1.158 @@ -1206,7 +1206,7 @@
   1.159  			*\ $i\ *) continue;;
   1.160  		esac
   1.161  		ALL_DEPS="$ALL_DEPS $i"
   1.162 -		[ -n "$2" ] && echo "$2$i ($(fgrep -A 3 $i $LOCALSTATE/packages.txt | \
   1.163 +		[ -n "$2" ] && echo "$2$i ($(fgrep -A 3 $i $PKGS_DB/packages.txt | \
   1.164  						tail -1 | sed 's/.*(\([^ ]*\).*/\1/'))"
   1.165  		[ -f $i/receipt ] || continue
   1.166  		DEPENDS=""
   1.167 @@ -1250,7 +1250,7 @@
   1.168  		echo -n $spc | sed 's/=/ /g'
   1.169  		echo -n $pkg
   1.170  		echo -n ' ('
   1.171 -		fgrep -A 3 $pkg $LOCALSTATE/packages.txt  | tail -1 | \
   1.172 +		fgrep -A 3 $pkg $PKGS_DB/packages.txt  | tail -1 | \
   1.173  			sed 's/.*(\([^ ]*\).*/\1)/'
   1.174  	done
   1.175  }
   1.176 @@ -1373,10 +1373,10 @@
   1.177  		check_for_packages_list
   1.178  		case $2 in
   1.179  			--diff)
   1.180 -				if [ -f "$LOCALSTATE/packages.diff" ]; then
   1.181 +				if [ -f "$PKGS_DB/packages.diff" ]; then
   1.182  					title 'Mirrored packages diff'
   1.183 -					cat $LOCALSTATE/packages.diff
   1.184 -					num=$(wc -l < $LOCALSTATE/packages.diff)
   1.185 +					cat $PKGS_DB/packages.diff
   1.186 +					num=$(wc -l < $PKGS_DB/packages.diff)
   1.187  					footer "$(eval_ngettext \
   1.188  						'$num new package listed on the mirror.' \
   1.189  						'$num new packages listed on the mirror.' $num)"
   1.190 @@ -1388,9 +1388,9 @@
   1.191  				fi; exit 0 ;;
   1.192  			--text|--txt|--raw|*)
   1.193  				title 'List of available packages on the mirror'
   1.194 -				cat $LOCALSTATE/packages.txt ;;
   1.195 +				cat $PKGS_DB/packages.txt ;;
   1.196  		esac
   1.197 -		pkgs=$(wc -l < $LOCALSTATE/packages.list)
   1.198 +		pkgs=$(wc -l < $PKGS_DB/packages.list)
   1.199  		num=$(emsg "<c 32>$pkgs</c>")
   1.200  		footer "$(eval_ngettext \
   1.201  			'$num package in the last recharged list.' \
   1.202 @@ -1420,8 +1420,8 @@
   1.203  		. $INSTALLED/$PACKAGE/receipt
   1.204  		title 'TazPKG information'
   1.205  		# Display localized short description
   1.206 -		if [ -e "$LOCALSTATE/packages-desc.$LANG" ]; then
   1.207 -			LOCDESC=$(grep -e "^$PACKAGE	" $LOCALSTATE/packages-desc.$LANG | cut -d'	' -f2)
   1.208 +		if [ -e "$PKGS_DB/packages-desc.$LANG" ]; then
   1.209 +			LOCDESC=$(grep -e "^$PACKAGE	" $PKGS_DB/packages-desc.$LANG | cut -d'	' -f2)
   1.210  			[ "x$LOCDESC" != "x" ] && SHORT_DESC="$LOCDESC"
   1.211  		fi
   1.212  		emsg "\
   1.213 @@ -1513,8 +1513,8 @@
   1.214  		if [ "$3" == "--mirror" ]; then
   1.215  
   1.216  			match=0
   1.217 -			for i in $LOCALSTATE/files.list.lzma \
   1.218 -				$LOCALSTATE/undigest/*/files.list.lzma; do
   1.219 +			for i in $PKGS_DB/files.list.lzma \
   1.220 +				$PKGS_DB/undigest/*/files.list.lzma; do
   1.221  				[ -f $i ] || continue
   1.222  				unlzma -c $i | grep -- ".*:.*$2" | awk '
   1.223  					BEGIN { last="" }
   1.224 @@ -1573,8 +1573,8 @@
   1.225  
   1.226  		# Search for a file on mirror and output only the package name
   1.227  		match=0
   1.228 -		for i in $LOCALSTATE/files.list.lzma \
   1.229 -				 $LOCALSTATE/undigest/*/files.list.lzma; do
   1.230 +		for i in $PKGS_DB/files.list.lzma \
   1.231 +				 $PKGS_DB/undigest/*/files.list.lzma; do
   1.232  				 [ -f $i ] || continue
   1.233  				unlzma -c $i | grep -- ".*:.*$2" | cut -d: -f1 | uniq | awk '{ print $1 }'
   1.234  				match=$(($match + `unlzma -c $i | grep -- ".*:.*$2" | cut -d: -f1 | uniq | wc -l`))
   1.235 @@ -1604,7 +1604,7 @@
   1.236  			if [ "$root" ]; then
   1.237  				CACHE_DIR=$root/$CACHE_DIR
   1.238  				SAVE_CACHE_DIR=$CACHE_DIR
   1.239 -				LOCALSTATE=$root/$LOCALSTATE
   1.240 +				PKGS_DB=$root/$PKGS_DB
   1.241  			else
   1.242  				echo "rootconfig needs --root= option used." >&2
   1.243  				exit 1
   1.244 @@ -1694,7 +1694,7 @@
   1.245  			newline
   1.246  			exit 0
   1.247  		fi
   1.248 -		rm $LOCALSTATE/mirror
   1.249 +		rm $PKGS_DB/mirror
   1.250  		echo "$RELEASE" > /etc/slitaz-release
   1.251  		tazpkg recharge && tazpkg upgrade
   1.252  
   1.253 @@ -1783,7 +1783,7 @@
   1.254  			status
   1.255  
   1.256  			sed -i "/ $PACKAGE-$VERSION$EXTRAVERSION$/d" \
   1.257 -				$LOCALSTATE/installed.$SUM 2> /dev/null
   1.258 +				$PKGS_DB/installed.$SUM 2> /dev/null
   1.259  
   1.260  			# Log this activity
   1.261  			log_pkg Removed
   1.262 @@ -2090,21 +2090,21 @@
   1.263  
   1.264  		ARG=$2
   1.265  		if [ "$root" ]; then
   1.266 -			LOCALSTATE=$root$LOCALSTATE
   1.267 +			PKGS_DB=$root$PKGS_DB
   1.268  			[ "${2#--}" != "$2" ] && ARG=$3
   1.269  		fi
   1.270  		if [ "$ARG" = main ]; then
   1.271 -			repository_to_recharge=$LOCALSTATE
   1.272 +			repository_to_recharge=$PKGS_DB
   1.273  		elif [ "$ARG" ]; then
   1.274 -			if [ -d "$LOCALSTATE/undigest/$ARG" ]; then
   1.275 -				repository_to_recharge=$LOCALSTATE/undigest/$ARG
   1.276 +			if [ -d "$PKGS_DB/undigest/$ARG" ]; then
   1.277 +				repository_to_recharge=$PKGS_DB/undigest/$ARG
   1.278  			else
   1.279 -				repo="$LOCALSTATE/undigest/$ARG"
   1.280 +				repo="$PKGS_DB/undigest/$ARG"
   1.281  				_ "\$repo doesn't exist." >&2
   1.282  				exit 1
   1.283  			fi
   1.284  		else
   1.285 -			repository_to_recharge="$LOCALSTATE $LOCALSTATE/undigest/*"
   1.286 +			repository_to_recharge="$PKGS_DB $PKGS_DB/undigest/*"
   1.287  		fi
   1.288  		for path in $repository_to_recharge; do
   1.289  			[ -f $path/mirror ] || continue
   1.290 @@ -2114,7 +2114,7 @@
   1.291  			[ -f ID ] && mv ID ID.bak
   1.292  			download_from "$(cat mirror)" ID >/dev/null 2>/dev/null
   1.293  			if [ -f ID ] && fgrep -q $(cat ID.bak 2>/dev/null || echo "null") ID; then
   1.294 -				if [ "$path" = "$LOCALSTATE" ]; then
   1.295 +				if [ "$path" = "$PKGS_DB" ]; then
   1.296  					repository_name=Main
   1.297  				else
   1.298  					base_path="$(basename $path)"
   1.299 @@ -2133,7 +2133,7 @@
   1.300  			fi
   1.301  
   1.302  			newline
   1.303 -			if [ "$path" != "$LOCALSTATE" ]; then
   1.304 +			if [ "$path" != "$PKGS_DB" ]; then
   1.305  				base_path="$(basename $path)"
   1.306  				_ 'Recharging undigest $base_path:'
   1.307  			fi
   1.308 @@ -2208,13 +2208,13 @@
   1.309  			esac
   1.310  		done
   1.311  		time=$(date +%s)
   1.312 -		installed_sum=$LOCALSTATE/installed.$SUM
   1.313 +		installed_sum=$PKGS_DB/installed.$SUM
   1.314  		look_for_priority
   1.315  		for repo in $priority; do
   1.316  			pkg_list=$repo/packages.list
   1.317  			mtime=$(find $pkg_list -mtime +7)
   1.318  			if [ "$mtime" ]; then
   1.319 -				if [ "$repo" = "$LOCALSTATE" ]; then
   1.320 +				if [ "$repo" = "$PKGS_DB" ]; then
   1.321  					repo_name=main
   1.322  				else
   1.323  					repo_name="${repo##*/}"
   1.324 @@ -2245,7 +2245,7 @@
   1.325  
   1.326  					emsg -n "$PACKAGE<i 28> $VERSION"
   1.327  
   1.328 -					# Skip pkgs listed in $LOCALSTATE/blocked-packages.list
   1.329 +					# Skip pkgs listed in $PKGS_DB/blocked-packages.list
   1.330  					if $(grep -qs "^$PACKAGE" $BLOCKED); then
   1.331  						blocked_count=$(($blocked_count + 1))
   1.332  						emsg "<i 48><c 31> $(_ 'Blocked')</c>"
   1.333 @@ -2482,7 +2482,7 @@
   1.334  			if [ "$root" ]; then
   1.335  				CACHE_DIR=$root/$CACHE_DIR
   1.336  				SAVE_CACHE_DIR=$CACHE_DIR
   1.337 -				LOCALSTATE=$root/$LOCALSTATE
   1.338 +				PKGS_DB=$root/$PKGS_DB
   1.339  			else
   1.340  				_ 'rootconfig needs --root= option used.' >&2
   1.341  				exit 1
   1.342 @@ -2527,7 +2527,7 @@
   1.343  			if [ "$root" ]; then
   1.344  				CACHE_DIR=$root/$CACHE_DIR
   1.345  				SAVE_CACHE_DIR=$CACHE_DIR
   1.346 -				LOCALSTATE=$root/$LOCALSTATE
   1.347 +				PKGS_DB=$root/$PKGS_DB
   1.348  			else
   1.349  				_ 'rootconfig needs --root= option used.' >&2
   1.350  				exit 1
   1.351 @@ -2575,7 +2575,7 @@
   1.352  			download $PACKAGE.tazpkg
   1.353  		fi
   1.354  		PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
   1.355 -		[ "$rootconfig" ] && LOCALSTATE=${LOCALSTATE#$root}
   1.356 +		[ "$rootconfig" ] && PKGS_DB=${PKGS_DB#$root}
   1.357  		install_package $ROOT
   1.358  		[ "$AUTOEXEC" != "no" ] && $PACKAGE $ROOT
   1.359  		update_desktop_database $ROOT
   1.360 @@ -2602,13 +2602,13 @@
   1.361  	list-undigest)
   1.362  		# list undigest URLs.
   1.363  		if [ "$2" = "--box" ]; then
   1.364 -			for i in $LOCALSTATE/undigest/*/mirror; do
   1.365 +			for i in $PKGS_DB/undigest/*/mirror; do
   1.366  				[ -f $i ] || continue
   1.367  				echo "$(basename $(dirname $i))|$(cat $i)"
   1.368  			done
   1.369  		else
   1.370  			title 'Current undigest(s)'
   1.371 -			for i in $LOCALSTATE/undigest/*/mirror; do
   1.372 +			for i in $PKGS_DB/undigest/*/mirror; do
   1.373  				if [ ! -f $i ]; then
   1.374  					_ 'No undigest mirror found.'
   1.375  					exit 1
   1.376 @@ -2623,13 +2623,13 @@
   1.377  		# remove undigest URL.
   1.378  		check_root $@
   1.379  		undigest="$2"
   1.380 -		if [ -d $LOCALSTATE/undigest/$2 ]; then
   1.381 +		if [ -d $PKGS_DB/undigest/$2 ]; then
   1.382  			confirm "$(_ 'Remove $undigest undigest? (y/N)')"
   1.383  			if [ $? = 0 ]; then
   1.384  				action 'Removing $undigest undigest...'
   1.385 -				rm -rf $LOCALSTATE/undigest/$2
   1.386 +				rm -rf $PKGS_DB/undigest/$2
   1.387  				status
   1.388 -				rmdir $LOCALSTATE/undigest 2> /dev/null
   1.389 +				rmdir $PKGS_DB/undigest 2> /dev/null
   1.390  			fi
   1.391  		else
   1.392  			_ 'Undigest $undigest not found'
   1.393 @@ -2640,25 +2640,25 @@
   1.394  		# Add undigest URL.
   1.395  		check_root $@
   1.396  		undigest=$2
   1.397 -		[ -d $LOCALSTATE/undigest ] || mkdir $LOCALSTATE/undigest
   1.398 +		[ -d $PKGS_DB/undigest ] || mkdir $PKGS_DB/undigest
   1.399  		if [ -z "$undigest" ]; then
   1.400  			i=1
   1.401 -			while [ -d $LOCALSTATE/undigest/$i ]; do
   1.402 +			while [ -d $PKGS_DB/undigest/$i ]; do
   1.403  				i=$(($i+1))
   1.404  			done
   1.405  			undigest=$i
   1.406  		fi
   1.407 -		if [ ! -d $LOCALSTATE/undigest/$undigest ]; then
   1.408 +		if [ ! -d $PKGS_DB/undigest/$undigest ]; then
   1.409  			_ 'Creating new undigest $undigest.'
   1.410 -			mkdir $LOCALSTATE/undigest/$undigest
   1.411 +			mkdir $PKGS_DB/undigest/$undigest
   1.412  		fi
   1.413 -		setup_mirror $LOCALSTATE/undigest/$undigest $3 ;;
   1.414 +		setup_mirror $PKGS_DB/undigest/$undigest $3 ;;
   1.415  
   1.416  
   1.417  	setup-mirror|-sm)
   1.418  		# Change mirror URL.
   1.419  		check_root $@
   1.420 -		setup_mirror $LOCALSTATE $2 ;;
   1.421 +		setup_mirror $PKGS_DB $2 ;;
   1.422  
   1.423  
   1.424  	reconfigure)