spk rev 32

A bunch of fix to add an lib
author Christophe Lincoln <pankso@slitaz.org>
date Tue May 15 20:32:41 2012 +0200 (2012-05-15)
parents ea3c01346d05
children fca271e55b69
files lib/libspk.sh spk-add spk-archive spk-rm
line diff
     1.1 --- a/lib/libspk.sh	Tue May 15 19:40:29 2012 +0200
     1.2 +++ b/lib/libspk.sh	Tue May 15 20:32:41 2012 +0200
     1.3 @@ -14,7 +14,7 @@
     1.4  mirrorurl="${root}${PKGS_DB}/mirror"
     1.5  installed="${root}${PKGS_DB}/installed"
     1.6  pkgsdesc="${root}${PKGS_DB}/packages.desc"
     1.7 -pkgsmd5="${root}${PKGS_DB}/packages.md5"
     1.8 +pkgsmd5="${root}${PKGS_DB}/packages.$SUM"
     1.9  # ????do we need packages.equiv????
    1.10  blocked="${root}${PKGS_DB}/blocked.list"
    1.11  activity="${root}${PKGS_DB}/activity"
     2.1 --- a/spk-add	Tue May 15 19:40:29 2012 +0200
     2.2 +++ b/spk-add	Tue May 15 20:32:41 2012 +0200
     2.3 @@ -6,7 +6,8 @@
     2.4  # Copyright (C) SliTaz GNU/Linux - BSD License
     2.5  # Author: See AUTHORS files
     2.6  #
     2.7 -. /usr/lib/slitaz/libspk.sh
     2.8 +#. /usr/lib/slitaz/libspk.sh
     2.9 +. lib/libspk.sh
    2.10  
    2.11  # Set to / for now until we add installing to chroot support
    2.12  # Could we update tools so they do not need this?
    2.13 @@ -89,10 +90,9 @@
    2.14  
    2.15  	# Add package checksum to pkgsmd5
    2.16  	sed -i "/ $(basename $package_dir)$/d" $pkgsmd5 2> /dev/null
    2.17 -	oldpwd=$(pwd)
    2.18  	cd $(dirname $package_file) || exit 1
    2.19  	$CHECKSUM $(basename $package_file) >> $pkgsmd5
    2.20 -	cd $oldpwd
    2.21 +	cd - >/dev/null
    2.22  
    2.23  	# Resolve package deps.
    2.24  	if missing_deps $package_name $DEPENDS; then
    2.25 @@ -115,9 +115,10 @@
    2.26  	# Get files to remove if upgrading
    2.27  	local files_to_remove
    2.28  	if [ -f $package_dir/files.list ]; then
    2.29 -		for file in $($package_dir/files.list); do
    2.30 +		for file in $(cat $package_dir/files.list)
    2.31 +		do
    2.32  			grep -q "^$(echo $file | grepesc)$" $TMP_DIR/files.list && continue
    2.33 -			local modifiers=$(cat $package_dir/modifiers 2> /dev/null;\
    2.34 +			local modifiers=$(cat $package_dir/modifiers 2> /dev/null; \
    2.35  							  fgrep -sl $package_dir */modifiers | cut -d/ -f1)
    2.36  			for i in modifiers; do
    2.37  				grep -qs "^$(echo $file | grepesc)$" $i/files.list && continue 2
    2.38 @@ -138,13 +139,13 @@
    2.39  
    2.40  	# Check possibly modified files against other packages file.list
    2.41  	if $check; then
    2.42 -		for pkg in $INSTALLED/*; do
    2.43 +		for pkg in $installed/*; do
    2.44  		  	[ "$pkg" == "$package_name" ] && continue
    2.45  		  	[ -s $pkg/files.list ] || continue
    2.46  
    2.47  		  	for file in $file_list; do
    2.48  		  		# $package_name wants to install $file which is already
    2.49 -		  		# Installed from $pkg
    2.50 +		  		# installed from $pkg
    2.51  				if grep -q ^$file$ $pkg/files.list; then
    2.52  					# Tell $pkg that $package_name is going to overwrite some of its files
    2.53  					if [ -s "$pkg/volatile.cpio.gz" ]; then
    2.54 @@ -191,15 +192,18 @@
    2.55  	fi
    2.56  
    2.57  	# Merge ROOT_FS with Package FS
    2.58 -	eval_gettext "Installing \$package_name... "
    2.59 +	gettext "Installing"; echo -n " $package_name..."
    2.60  	cp -a fs/* $ROOT/
    2.61  	status
    2.62  
    2.63  	# Remove old config files
    2.64 -	if [ -n $files_to_remove ]; then
    2.65 -		eval_gettext "Removing old \$package_name... "
    2.66 +	if [ "$files_to_remove" ]; then
    2.67 +		gettext "Removing old"; echo -n " $package_name..."
    2.68  		for file in $files_to_remove; do
    2.69 -			remove_with_path $ROOT$file
    2.70 +			if [ "$verbose" ]; then
    2.71 +				gettext "Removing:"; echo " ${root}${file}"
    2.72 +			fi
    2.73 +			remove_with_path ${root}${file}
    2.74  		done
    2.75  		status
    2.76  	fi
    2.77 @@ -245,12 +249,6 @@
    2.78  install_local() {
    2.79  	package_file="$1"
    2.80  	check_valid_tazpkg $package_file
    2.81 -
    2.82 -	# Check if forced install.
    2.83 -	if ! [ "$forced" ]; then
    2.84 -		check_installed $(package_name $package_file)
    2.85 -	fi
    2.86 -
    2.87  	install_package $package_file
    2.88  	update_databases
    2.89  }
    2.90 @@ -275,11 +273,6 @@
    2.91  	# package_full=Package-Version
    2.92  	local package_full=$(full_package $package_name)
    2.93  
    2.94 -	# Check if forced install.
    2.95 -	if ! [ "$forced" ]; then
    2.96 -		check_installed $package_name
    2.97 -	fi
    2.98 -
    2.99  	cd $CACHE_DIR > /dev/null
   2.100  	if [ -f "$package_full.tazpkg" ]; then
   2.101  		echo -n "$(colorize "$package_full" 34)"; echo ": $CACHE_DIR)"
     3.1 --- a/spk-archive	Tue May 15 19:40:29 2012 +0200
     3.2 +++ b/spk-archive	Tue May 15 20:32:41 2012 +0200
     3.3 @@ -39,12 +39,7 @@
     3.4  	status
     3.5  
     3.6  	gettext "Extracting the pseudo fs... "
     3.7 -	if [ -f fs.cpio.lzma ]; then
     3.8 -		echo -n "(lzma) "
     3.9 -		unlzma -c fs.cpio.lzma | cpio -idm --quiet && rm fs.cpio.lzma
    3.10 -	elif [ -f fs.cpio.gz ]; then
    3.11 -		zcat fs.cpio.gz | cpio -idm --quiet && rm fs.cpio.gz
    3.12 -	fi
    3.13 +	unlzma -c fs.cpio.lzma | cpio -idm --quiet && rm fs.cpio.lzma
    3.14  	status
    3.15  }
    3.16  
     4.1 --- a/spk-rm	Tue May 15 19:40:29 2012 +0200
     4.2 +++ b/spk-rm	Tue May 15 20:32:41 2012 +0200
     4.3 @@ -62,14 +62,15 @@
     4.4  	. $installed/$pkg/receipt
     4.5  
     4.6  	if [ -n "$altered" ]; then
     4.7 -		eval_gettext "The following packages depend on \$PACKAGE:"; echo
     4.8 +		gettext "The following packages depend on"; boldify " $PACKAGE:"
     4.9  		for i in $altered; do
    4.10  			echo "  $i"
    4.11  		done
    4.12  	fi
    4.13  	refresh=$(cd $installed ; grep -sl ^$PACKAGE$ */modifiers)
    4.14  	if [ -n "$refresh" ]; then
    4.15 -		eval_gettext "The following packages have been modified by \$PACKAGE:"; echo
    4.16 +		gettext "The following packages have been modified by"
    4.17 +		boldify " $PACKAGE:"
    4.18  		for i in $refresh; do
    4.19  			echo "  ${i%/modifiers}"
    4.20  		done
    4.21 @@ -87,7 +88,7 @@
    4.22  		for i in $altered; do
    4.23  			if [ -d "$installed/$i" ]; then
    4.24  				# TODO: use spk-rm
    4.25 -				echo "tazpkg remove $i --root=$root"
    4.26 +				echo "spk-rm $i --root=$root"
    4.27  			fi
    4.28  		done
    4.29  	fi
    4.30 @@ -101,9 +102,9 @@
    4.31  	gettext "Removing all installed files..."
    4.32  	[ "$verbose" ] && newline
    4.33  	if [ -f $installed/$PACKAGE/modifiers ]; then
    4.34 -	    for file in `cat $installed/$PACKAGE/files.list`
    4.35 +	    for file in $(cat $installed/$PACKAGE/files.list)
    4.36  	    do
    4.37 -			for mod in `cat $installed/$PACKAGE/modifiers`
    4.38 +			for mod in $(cat $installed/$PACKAGE/modifiers)
    4.39  			do
    4.40  				[ -f $installed/$mod/files.list ] && \
    4.41  					[ $(grep "^$(echo $file | grepesc)$" $installed/$mod/files.list | wc -l) -gt 1 ] \
    4.42 @@ -115,7 +116,9 @@
    4.43  	else
    4.44  		for file in $(cat $installed/$PACKAGE/files.list)
    4.45  		do
    4.46 -			[ "$verbose" ] && (gettext "Removing:"; echo -n " ${root}${file}")
    4.47 +			if [ "$verbose" ]; then
    4.48 +				gettext "Removing:"; echo -n " ${root}${file}"
    4.49 +			fi
    4.50  			remove_file ${root}${file}
    4.51  			[ "$verbose" ] && status
    4.52  		done
    4.53 @@ -131,8 +134,7 @@
    4.54  	gettext "Removing package receipt..."
    4.55  	rm -rf $installed/$PACKAGE
    4.56  	status
    4.57 -	sed -i "/ $PACKAGE-$VERSION$EXTRAVERSION$/d" \
    4.58 -		${root}${PKGS_DB}/installed.$SUM 2> /dev/null
    4.59 +	sed -i "/ $PACKAGE-${VERSION}${EXTRAVERSION}$/d" $pkgsmd5 2> /dev/null
    4.60  
    4.61  	# Mofified ?
    4.62  	if [ "$refresh" ]; then
    4.63 @@ -150,7 +152,7 @@
    4.64  			fi
    4.65  			# TODO: use spk-add
    4.66  			rm -r $installed/$i
    4.67 -			tazpkg -gi ${i%/modifiers} --forced --root=$root
    4.68 +			spk-add ${i%/modifiers} --forced --root=$root
    4.69  		done
    4.70  	fi
    4.71  }