tazpkg rev 503

tazpkg: remove old upgrade and upgradeable code
author Christophe Lincoln <pankso@slitaz.org>
date Thu Jun 02 03:25:52 2011 +0200 (2011-06-02)
parents 59604130cb72
children 99e76d407f79
files tazpkg
line diff
     1.1 --- a/tazpkg	Thu Jun 02 03:13:20 2011 +0200
     1.2 +++ b/tazpkg	Thu Jun 02 03:25:52 2011 +0200
     1.3 @@ -111,8 +111,6 @@
     1.4    repack           `gettext \"Create a package archive from an installed package.\"`
     1.5    repack-config    `gettext \"Create a package archive with configuration files.\"`
     1.6    recompress       `gettext \"Rebuild a package with a better compression ratio.\"`
     1.7 -  upgrade          `gettext \"Upgrade one or all installed package(s) (obsolete).\"`
     1.8 -  upgradeable      `gettext \"Build upgradeable packages list quickly. (buggy)\"`
     1.9    block|unblock    `gettext \"Block an installed package version or unblock it for upgrade.\"`
    1.10    get              `gettext \"Download a package into the current directory.\"`
    1.11    get-install      `gettext \"Download and install a package from the mirror.\"`
    1.12 @@ -1437,14 +1435,11 @@
    1.13  		Y) gettext "Y" ;;
    1.14  		n) gettext "n" ;;
    1.15  		N) gettext "N" ;;
    1.16 -		
    1.17  		# Support other cases but keep them untranslated.
    1.18  		*) echo "$1" ;;
    1.19 -		
    1.20  	esac
    1.21  }
    1.22  
    1.23 -
    1.24  ###################
    1.25  # Tazpkg commands #
    1.26  ###################
    1.27 @@ -1452,7 +1447,6 @@
    1.28  case "$COMMAND" in
    1.29  	list)
    1.30  		# List all installed packages or a specific category.
    1.31 -		#
    1.32  		if [ "$2" = "blocked" ]; then
    1.33  			echo ""
    1.34  			echo -e "\033[1m`gettext \"Blocked packages\"`\033[0m"
    1.35 @@ -1590,7 +1584,6 @@
    1.36  		echo "" ;;
    1.37  	list-files)
    1.38  		# List files installed with the package.
    1.39 -		#
    1.40  		check_for_package_on_cmdline
    1.41  		check_for_receipt
    1.42  		echo ""
    1.43 @@ -1603,7 +1596,6 @@
    1.44  		echo "" ;;
    1.45  	info)
    1.46  		# Information about package.
    1.47 -		#
    1.48  		check_for_package_on_cmdline
    1.49  		check_for_receipt
    1.50  		EXTRAVERSION=""
    1.51 @@ -1649,7 +1641,6 @@
    1.52  		fi ;;
    1.53  	search)
    1.54  		# Search for a package by pattern or name.
    1.55 -		#
    1.56  		PATTERN="$2"
    1.57  		if [ -z "$PATTERN" ]; then
    1.58  			echo ""
    1.59 @@ -1675,7 +1666,6 @@
    1.60  		esac ;;
    1.61  	search-file)
    1.62  		# Search for a file by pattern or name in all files.list.
    1.63 -		#
    1.64  		if [ -z "$2" ]; then
    1.65  			echo ""
    1.66  			gettext "Please specify a pattern or file name to search for."; echo
    1.67 @@ -1747,7 +1737,7 @@
    1.68  		echo -e "\033[1m`gettext \"Search result for file\"`\033[0m $2"
    1.69  		separator
    1.70  		
    1.71 -	 # Search for a file on mirror and output only the package name
    1.72 +		# Search for a file on mirror and output only the package name
    1.73  		match=0
    1.74  		for i in $LOCALSTATE/files.list.lzma \
    1.75  				 $LOCALSTATE/undigest/*/files.list.lzma; do
    1.76 @@ -1768,7 +1758,6 @@
    1.77  		;;
    1.78  	install)
    1.79  		# Install .tazpkg packages.
    1.80 -		#
    1.81  		check_root
    1.82  		check_for_package_on_cmdline
    1.83  		check_for_package_file
    1.84 @@ -1801,7 +1790,6 @@
    1.85  		update_mime_database $ROOT ;;
    1.86  	install-list|get-install-list)
    1.87  		# Install a set of packages from a list.
    1.88 -		#
    1.89  		check_root
    1.90  		if [ -z "$2" ]; then
    1.91  			echo ""
    1.92 @@ -1849,15 +1837,12 @@
    1.93  		rm -f $2-processed ;;
    1.94  	add-flavor)
    1.95  		# Install a set of packages from a flavor.
    1.96 -		#
    1.97  		install_flavor $2 ;;
    1.98  	install-flavor)
    1.99  		# Install a set of packages from a flavor and purge other ones.
   1.100 -		#
   1.101  		install_flavor $2 --purge ;;
   1.102  	set-release)
   1.103  		# Change curent release and upgrade packages.
   1.104 -		#
   1.105  		RELEASE=$2
   1.106  		if [ -z "$RELEASE" ]; then
   1.107  			echo ""
   1.108 @@ -1881,7 +1866,6 @@
   1.109  		done ;;
   1.110  	remove)
   1.111  		# Remove packages.
   1.112 -		#
   1.113  		check_root
   1.114  		check_for_package_on_cmdline
   1.115  		get_options_list="root auto"
   1.116 @@ -2004,7 +1988,6 @@
   1.117  		echo "" ;;
   1.118  	extract)
   1.119  		# Extract .tazpkg cpio archive into a directory.
   1.120 -		#
   1.121  		check_for_package_on_cmdline
   1.122  		check_for_package_file
   1.123  		echo ""
   1.124 @@ -2028,7 +2011,6 @@
   1.125  		echo "" ;;
   1.126  	recompress)
   1.127  		# Recompress .tazpkg cpio archive with lzma.
   1.128 -		#
   1.129  		check_for_package_on_cmdline
   1.130  		check_for_package_file
   1.131  		echo ""
   1.132 @@ -2054,7 +2036,6 @@
   1.133  		rm -rf $TMP_DIR ;;
   1.134  	list-config)
   1.135  		# List configuration files installed.
   1.136 -		#
   1.137  		if [ "$2" = "--box" ]; then
   1.138  			mkdir -p $TMP_DIR && cd $TMP_DIR
   1.139  			FILES="$INSTALLED/*/volatile.cpio.gz"
   1.140 @@ -2089,7 +2070,6 @@
   1.141  		fi ;;
   1.142  	repack-config)
   1.143  		# Create SliTaz package archive from configuration files.
   1.144 -		#
   1.145  		mkdir -p $TMP_DIR && cd $TMP_DIR
   1.146  		CONFIG_VERSION=1.0
   1.147  		mkdir config-$CONFIG_VERSION
   1.148 @@ -2125,7 +2105,6 @@
   1.149  		;;
   1.150  	repack)
   1.151  		# Create SliTaz package archive from an installed package.
   1.152 -		#
   1.153  		check_for_package_on_cmdline
   1.154  		check_for_receipt
   1.155  		EXTRAVERSION=""
   1.156 @@ -2193,7 +2172,6 @@
   1.157  		echo "" ;;
   1.158  	pack)
   1.159  		# Create SliTaz package archive using cpio and gzip.
   1.160 -		#
   1.161  		check_for_package_on_cmdline
   1.162  		cd $PACKAGE
   1.163  		if [ ! -f "receipt" ]; then
   1.164 @@ -2249,7 +2227,6 @@
   1.165  		fi ;;
   1.166  	recharge)
   1.167  		# Recharge packages.list from a mirror.
   1.168 -		#
   1.169  		check_root
   1.170  		get_options_list="root forced list rootconfig"
   1.171  		get_options
   1.172 @@ -2357,7 +2334,7 @@
   1.173  			echo ""
   1.174  			fi
   1.175  		done ;;
   1.176 -	up)
   1.177 +	up|upgrade)
   1.178  		#
   1.179  		# This is the new way to upgrade packages making 'upgrade' and
   1.180  		# upgradeable out-of-date. This new way is much, much more faster!
   1.181 @@ -2453,170 +2430,8 @@
   1.182  			esac
   1.183  		fi
   1.184  		echo "" ;;
   1.185 -	upgradeable)
   1.186 -		# Build upgradeable-packages.list quickly.
   1.187 -		#
   1.188 -		check_root
   1.189 -		cd $LOCALSTATE
   1.190 -		while read md5 file ; do
   1.191 -			fgrep -qs "$md5  $file" packages.md5 && continue
   1.192 -			for i in 1 2 3 4 5; do
   1.193 -				file=${file%-*}
   1.194 -				[ -d installed/$file ] || continue
   1.195 -				echo $file
   1.196 -				break
   1.197 -			done
   1.198 -		done < installed.md5 > upgradeable-packages.list.tmp
   1.199 -		uniq upgradeable-packages.list.tmp upgradeable-packages.list ;;
   1.200 -	upgrade)
   1.201 -		# Upgrade all installed packages with the new version from the mirror.
   1.202 -		#
   1.203 -		check_root
   1.204 -		check_for_packages_list
   1.205 -		
   1.206 -		# Get repositories priority list.
   1.207 -		look_for_priority
   1.208 -		
   1.209 -		cd $LOCALSTATE
   1.210 -		# Touch the blocked pkgs list to avoid errors and remove any old
   1.211 -		# upgrade list.
   1.212 -		touch blocked-packages.list
   1.213 -		rm -f upgradeable-packages.list
   1.214 -		echo ""
   1.215 -		echo -e "\033[1m`gettext \"Available upgrades\"`\033[0m"
   1.216 -		separator
   1.217 -		echo ""
   1.218 -		# Some packages must be installed first
   1.219 -		FIRST_CLASS_PACKAGE=" glibc-base slitaz-base-files slitaz-boot-scripts "
   1.220 -		if [ -n "$PACKAGE_FILE" -a -d "$INSTALLED/$PACKAGE_FILE" ]; then
   1.221 -			ALL=$INSTALLED/$PACKAGE_FILE
   1.222 -		else
   1.223 -			ALL="$(ls -d $INSTALLED/*)"
   1.224 -		fi
   1.225 -		for pkg in $ALL
   1.226 -		do
   1.227 -			[ -f $pkg/receipt ] || continue
   1.228 -			EXTRAVERSION=""
   1.229 -			. $pkg/receipt
   1.230 -			# Display package name to show that Tazpkg is working...
   1.231 -			echo -en "\\033[0G                                         "
   1.232 -			echo -en "\\033[0G$PACKAGE"
   1.233 -			# Skip specified pkgs listed in $LOCALSTATE/blocked-packages.list
   1.234 -			if grep -qs "^$PACKAGE" $BLOCKED; then
   1.235 -				blocked=$(($blocked+1))
   1.236 -			else
   1.237 -				# Check if the installed package is in the current list (other
   1.238 -				# mirror or local).
   1.239 -				NEW_PACKAGE=$(get_package_filename $PACKAGE)
   1.240 -
   1.241 -				if [ -n "$NEW_PACKAGE" ]; then
   1.242 -					# Set new pkg and version for future comparison
   1.243 -					NEW_VERSION=`echo $NEW_PACKAGE | sed s/$PACKAGE-/''/`
   1.244 -					# Change '-' and 'pre' to points.
   1.245 -					NEW_VERSION=`echo $NEW_VERSION | sed s/'-'/'.'/`
   1.246 -					VERSION=`echo $VERSION | sed s/'-'/'.'/`$EXTRAVERSION
   1.247 -					NEW_VERSION=`echo $NEW_VERSION | sed s/'pre'/'.'/`
   1.248 -					VERSION=`echo $VERSION | sed s/'pre'/'.'/`
   1.249 -					NEW_VERSION=`echo $NEW_VERSION | sed 's/[A-Z]\.//'`
   1.250 -					VERSION=`echo $VERSION | sed 's/[A-Z]\.//'`
   1.251 -					# Compare version. Upgrades are only available for official
   1.252 -					# packages, so we control the mirror and it should be ok if
   1.253 -					# we just check for equality.
   1.254 -					RELEASE=""
   1.255 -					if [ -f installed.md5 -a -f packages.md5 ]; then
   1.256 -						current_md5=$(fgrep -s "  $PACKAGE-$VERSION" installed.md5 | awk '{ print $1 }')
   1.257 -						new_md5=$(fgrep -hs "  $PACKAGE-$VERSION" packages.md5 undigest/*/packages.md5 | head -1 | awk '{ print $1 }')
   1.258 -						[ -n "$current_md5" ] && [ -n "$new_md5" ] &&
   1.259 -						[ "$current_md5" != "$new_md5" ] && RELEASE=$(gettext "build")
   1.260 -					fi
   1.261 -					if [ "$VERSION" != "$NEW_VERSION" -o -n "$RELEASE" ]; then
   1.262 -						# Version seems different. Check for major, minor or
   1.263 -						# revision
   1.264 -						PKG_MAJOR=`echo ${VERSION%_*} | cut -f1 -d"."`
   1.265 -						NEW_MAJOR=`echo ${NEW_VERSION%_*} | cut -f1 -d"."`
   1.266 -						PKG_MINOR=`echo ${VERSION%_*} | cut -f2 -d"."`
   1.267 -						NEW_MINOR=`echo ${NEW_VERSION%_*} | cut -f2 -d"."`
   1.268 -						# Minor
   1.269 -						if [ "$NEW_MINOR" -gt "$PKG_MINOR" ] 2> /dev/null; then
   1.270 -							RELEASE=$(gettext "minor")
   1.271 -						fi
   1.272 -						if [ "$NEW_MINOR" -lt "$PKG_MINOR" ] 2> /dev/null; then
   1.273 -							RELEASE=$(gettext "WARNING")
   1.274 -							FIXE=yes
   1.275 -						fi
   1.276 -						# Major
   1.277 -						if [ "$NEW_MAJOR" -gt "$PKG_MAJOR" ] 2> /dev/null; then
   1.278 -							RELEASE=$(gettext "major")
   1.279 -							FIXE=""
   1.280 -						fi
   1.281 -						if [ "$NEW_MAJOR" -lt "$PKG_MAJOR" ] 2> /dev/null; then
   1.282 -							RELEASE=$(gettext "WARNING")
   1.283 -							FIXE=yes
   1.284 -						fi
   1.285 -						# Default to revision.
   1.286 -						if [ -z $RELEASE ]; then
   1.287 -							RELEASE=$(gettext "revision")
   1.288 -						fi
   1.289 -						# Pkg name is already displayed by the check process.
   1.290 -						echo -en "\033[24G $VERSION"
   1.291 -						echo -en "\033[38G --->"
   1.292 -						echo -en "\033[43G $NEW_VERSION"
   1.293 -						echo -en "\033[58G `translate_category $CATEGORY`"
   1.294 -						echo -e "\033[72G $RELEASE"
   1.295 -						up=$(($up+1))
   1.296 -						echo "$PACKAGE" >> upgradeable-packages.list
   1.297 -						case "$FIRST_CLASS_PACKAGE" in
   1.298 -						*\ $PACKAGE\ *) echo "$PACKAGE" >> upgradeable-packages.list$$;;
   1.299 -						esac
   1.300 -						unset RELEASE
   1.301 -					fi
   1.302 -					packages=$(($packages+1))
   1.303 -				fi
   1.304 -			fi
   1.305 -		done
   1.306 -		if [ -z $blocked ]; then
   1.307 -			blocked=0
   1.308 -		fi
   1.309 -		# Clean last checked package and display summary.
   1.310 -		if [ ! "$up" = "" ]; then
   1.311 -			echo -e "\\033[0G                                         "
   1.312 -			separator
   1.313 -			eval_gettext "\$packages installed and listed packages to consider, \$up to upgrade, \$blocked blocked."; echo
   1.314 -			echo ""
   1.315 -		else
   1.316 -			echo -e "\\033[0G`gettext \"System is up-to-date.\"`                    "
   1.317 -			echo ""
   1.318 -			separator
   1.319 -			eval_gettext "\$packages installed and listed packages to consider, 0 to upgrade, \$blocked blocked."; echo
   1.320 -			echo ""
   1.321 -			exit 0
   1.322 -		fi
   1.323 -		# What to do if major or minor version is smaller.
   1.324 -		if [ "$FIXE" == "yes" ]; then
   1.325 -			gettext \
   1.326 -"WARNING ---> Installed package seems more recent than the mirrored
   1.327 -one. You can block packages using the command : 'tazpkg block package'.
   1.328 -Or upgrade packages at your own risk."
   1.329 -			echo ""
   1.330 -		fi
   1.331 -		# Ask for upgrade, it can be done another time.
   1.332 -		gettext "Upgrade now"
   1.333 -		echo -n " (`translate_querry y`/`translate_querry N`) ? "
   1.334 -		read answer
   1.335 -		if [ ! "$answer" = "$(translate_querry y)" ]; then
   1.336 -			echo ""
   1.337 -			gettext "Exiting. No package upgraded."; echo
   1.338 -			echo ""
   1.339 -			exit 0
   1.340 -		fi
   1.341 -		# If answer is yes (y). Install all new versions.
   1.342 -		cat upgradeable-packages.list >> upgradeable-packages.list$$
   1.343 -		mv -f upgradeable-packages.list$$ upgradeable-packages.list
   1.344 -		yes y | tazpkg get-install-list upgradeable-packages.list --forced
   1.345 -		rm -f upgradeable-packages.list ;;
   1.346  	bugs)
   1.347  		# Show known bugs in package(s)
   1.348 -		#
   1.349  		cd $INSTALLED
   1.350  		shift
   1.351  		LIST=$@
   1.352 @@ -2638,7 +2453,6 @@
   1.353  		echo "$MSG" ;;
   1.354  	check)
   1.355  		# Check installed packages set.
   1.356 -		#
   1.357  		check_root
   1.358  		
   1.359  		# Get repositories priority list.
   1.360 @@ -2728,7 +2542,6 @@
   1.361  		gettext "Check completed."; echo ;;
   1.362  	block)
   1.363  		# Add a pkg name to the list of blocked packages.
   1.364 -		#
   1.365  		check_root
   1.366  		check_for_package_on_cmdline
   1.367  		echo ""
   1.368 @@ -2747,7 +2560,6 @@
   1.369  		echo "" ;;
   1.370  	unblock)
   1.371  		# Remove a pkg name from the list of blocked packages.
   1.372 -		#
   1.373  		check_root
   1.374  		check_for_package_on_cmdline
   1.375  		echo ""
   1.376 @@ -2767,7 +2579,6 @@
   1.377  		echo "" ;;
   1.378  	get)
   1.379  		# Downlowd a package with wget.
   1.380 -		#
   1.381  		check_root
   1.382  		check_for_package_on_cmdline
   1.383  		check_for_packages_list
   1.384 @@ -2812,7 +2623,6 @@
   1.385  		;;
   1.386  	get-install)
   1.387  		# Download and install a package.
   1.388 -		#
   1.389  		check_root
   1.390  		check_for_package_on_cmdline
   1.391  		check_for_packages_list
   1.392 @@ -2878,7 +2688,6 @@
   1.393  		update_mime_database $ROOT ;;
   1.394  	clean-cache)
   1.395  		# Remove all downloaded packages.
   1.396 -		#
   1.397  		check_root
   1.398  		files=$(find $CACHE_DIR -name *.tazpkg | wc -l)
   1.399  		echo ""
   1.400 @@ -2890,7 +2699,6 @@
   1.401  		eval_gettext "\$files file(s) removed from cache."; echo -e "\n" ;;
   1.402  	list-undigest)
   1.403  		# list undigest URLs.
   1.404 -		#
   1.405  		if [ "$2" = "--box" ]; then
   1.406  			for i in $LOCALSTATE/undigest/*/mirror; do
   1.407  				[ -f $i ] || continue
   1.408 @@ -2911,7 +2719,6 @@
   1.409  		fi ;;
   1.410  	remove-undigest)
   1.411  		# remove undigest URL.
   1.412 -		#
   1.413  		check_root
   1.414  		undigest="$2"
   1.415  		if [ -d $LOCALSTATE/undigest/$2 ]; then
   1.416 @@ -2929,7 +2736,6 @@
   1.417  		fi ;;
   1.418  	add-undigest|setup-undigest)
   1.419  		# Add undigest URL.
   1.420 -		#
   1.421  		check_root
   1.422  		undigest=$2
   1.423  		[ -d $LOCALSTATE/undigest ] || mkdir $LOCALSTATE/undigest
   1.424 @@ -2947,12 +2753,10 @@
   1.425  		setup_mirror $LOCALSTATE/undigest/$undigest $3 ;;
   1.426  	setup-mirror)
   1.427  		# Change mirror URL.
   1.428 -		#
   1.429  		check_root
   1.430  		setup_mirror $LOCALSTATE $2 ;;
   1.431  	reconfigure)
   1.432  		# Replay post_install from receipt
   1.433 -		#
   1.434  		check_for_package_on_cmdline
   1.435  		check_root
   1.436  		ROOT=""
   1.437 @@ -2986,7 +2790,6 @@
   1.438  		fi ;;
   1.439  	shell)
   1.440  		# Tazpkg SHell
   1.441 -		#
   1.442  		if test $(id -u) = 0 ; then
   1.443  			PROMPT="\\033[1;33mtazpkg\\033[0;39m# "
   1.444  		else