spk rev 104

changed several tools to use lib functions
author Christian Mesh <meshca@clarkson.edu>
date Sat Jun 02 18:48:02 2012 -0500 (2012-06-02)
parents cab731b9a98c
children c27b19df240c
files lib/libspk.sh spk spk-rm spk-up
line diff
     1.1 --- a/lib/libspk.sh	Sat Jun 02 18:27:42 2012 -0500
     1.2 +++ b/lib/libspk.sh	Sat Jun 02 18:48:02 2012 -0500
     1.3 @@ -244,7 +244,7 @@
     1.4  # Usage: check_installed package
     1.5  check_installed() {
     1.6  	local name="$1"
     1.7 -	if [ -d "$installed/$name" ]; then
     1.8 +	if is_package_installed $name; then
     1.9  		echo $(boldify "$name") $(gettext "package is already installed")
    1.10  		[ "$forced" ] || rm -rf $tmpdir
    1.11  		continue
    1.12 @@ -258,14 +258,14 @@
    1.13  		if echo $i | fgrep -q : ; then
    1.14  			# format 'alternative:newname'
    1.15  			# if alternative is installed then substitute newname
    1.16 -			if [ -f $installed/${i%:*}/receipt ]; then
    1.17 +			if is_package_installed ${i%:*}; then
    1.18  				# substitute package dependancy
    1.19  				echo ${i#*:}
    1.20  				return
    1.21  			fi
    1.22  		else
    1.23  			# if alternative is installed then nothing to install
    1.24 -			if [ -f $installed/$i/receipt ]; then
    1.25 +			if is_package_installed $i/receipt; then
    1.26  				# substitute installed package
    1.27  				echo $i
    1.28  				return
    1.29 @@ -292,7 +292,7 @@
    1.30  		if [ ! -d "$installed/$pkg" ]; then
    1.31  			gettext "Missing:"; echo " $pkg"
    1.32  			deps=$(($deps+1))
    1.33 -		elif [ ! -f "$installed/$pkg/receipt" ]; then
    1.34 +		elif [ ! is_package_installed $pkg/receipt ]; then
    1.35  			gettext "WARNING: Dependency loop between:"; newline
    1.36  			echo "  $package --> $pkg"
    1.37  		fi
     2.1 --- a/spk	Sat Jun 02 18:27:42 2012 -0500
     2.2 +++ b/spk	Sat Jun 02 18:48:02 2012 -0500
     2.3 @@ -171,7 +171,7 @@
     2.4  		count=$(($count + 1))
     2.5  		[ "$count" == 1 ] && newline
     2.6  		unset_receipt
     2.7 -		. $installed/$pkg/receipt
     2.8 +		source_receipt $installed/$pkg/receipt
     2.9  		boldify $(gettext "Package") $pkg
    2.10  		separator
    2.11  		gettext "Status     :"; colorize 32 " installed"
     3.1 --- a/spk-rm	Sat Jun 02 18:27:42 2012 -0500
     3.2 +++ b/spk-rm	Sat Jun 02 18:48:02 2012 -0500
     3.3 @@ -56,7 +56,7 @@
     3.4  
     3.5  	# Reverse deps
     3.6  	for i in $(ls $installed); do
     3.7 -		[ -f $installed/$i/receipt ] || continue
     3.8 +		is_package_installed $i || continue
     3.9  		unset_receipt
    3.10  		source_receipt $installed/$i/receipt
    3.11  		case " $DEPENDS " in
    3.12 @@ -156,7 +156,7 @@
    3.13  		--*) continue
    3.14  	esac
    3.15  	# Be sure package is installed
    3.16 -	if [ ! -f "$installed/$pkg/receipt" ]; then
    3.17 +	if ! is_package_installed $pkg; then
    3.18  		echo -n "$(boldify $pkg) "
    3.19  		gettext "package is not installed"; newline
    3.20  		continue
     4.1 --- a/spk-up	Sat Jun 02 18:27:42 2012 -0500
     4.2 +++ b/spk-up	Sat Jun 02 18:48:02 2012 -0500
     4.3 @@ -50,7 +50,7 @@
     4.4  	newline
     4.5  	boldify $(gettext "Updating packages lists")
     4.6  	separator
     4.7 -	check="$extradb/*/mirror $PKGS_DB/mirror"
     4.8 +	local check="$extradb/*/mirror $PKGS_DB/mirror"
     4.9  	if [ "$mirror" ]; then
    4.10  		check=$extradb/$mirror/mirror
    4.11  		[ "$mirror" == "main" ] && check=$PKGS_DB/mirror
    4.12 @@ -133,7 +133,7 @@
    4.13  # Check if we have an upgrade for a package
    4.14  check_pkgup() {
    4.15  	unset_receipt
    4.16 -	. $pkg/receipt
    4.17 +	source_receipt $pkg/receipt
    4.18  	localdb=$extradb/local
    4.19  	sum=$(fgrep "  $PACKAGE-${VERSION}$EXTRAVERSION.tazpkg" \
    4.20  		$installed.$SUM | awk '{print $1}')
    4.21 @@ -196,10 +196,10 @@
    4.22  			system=no
    4.23  			check_root
    4.24  			[ "$count" == 0 ] && up_headers
    4.25 -			if [ -f "$installed/$pkg/receipt" ]; then
    4.26 +			if is_package_installed $pkg; then
    4.27  				count=$(($count +1))
    4.28  				cd $installed
    4.29 -				. $pkg/receipt
    4.30 +				source_receipt $pkg/receipt
    4.31  				check=$(check_pkgup)
    4.32  				if [ "$check" != "" ]; then
    4.33  					echo "$check"