spk diff spk-rm @ rev 39

spk-rm handle modifiers, small changes and fixes
author Christophe Lincoln <pankso@slitaz.org>
date Wed May 16 01:19:38 2012 +0200 (2012-05-16)
parents 70c2d1ac2887
children 0a61f00e2373
line diff
     1.1 --- a/spk-rm	Tue May 15 23:32:17 2012 +0200
     1.2 +++ b/spk-rm	Wed May 16 01:19:38 2012 +0200
     1.3 @@ -50,7 +50,8 @@
     1.4  # Remove a single package
     1.5  remove() {
     1.6  	altered=""
     1.7 -	for i in $(cd $installed ; ls); do
     1.8 +	for i in $(ls $installed)
     1.9 +	do
    1.10  		[ -f $installed/$i/receipt ] || continue
    1.11  		unset_receipt
    1.12  		. $installed/$i/receipt
    1.13 @@ -61,35 +62,21 @@
    1.14  	unset_receipt
    1.15  	. $installed/$pkg/receipt
    1.16  
    1.17 -	if [ -n "$altered" ]; then
    1.18 -		gettext "The following packages depend on"; boldify " $PACKAGE:"
    1.19 +	# Reverse dep.
    1.20 +	if [ "$altered" ]; then
    1.21 +		gettext "The following packages depend on"; boldify " $PACKAGE"
    1.22  		for i in $altered; do
    1.23 -			echo "  $i"
    1.24 -		done
    1.25 -	fi
    1.26 -	refresh=$(cd $installed ; grep -sl ^$PACKAGE$ */modifiers)
    1.27 -	if [ -n "$refresh" ]; then
    1.28 -		gettext "The following packages have been modified by"
    1.29 -		boldify " $PACKAGE:"
    1.30 -		for i in $refresh; do
    1.31 -			echo "  ${i%/modifiers}"
    1.32 +			echo "    $i"
    1.33  		done
    1.34  	fi
    1.35  
    1.36 -	# Do we have packages depending on $pkg ?
    1.37 -	if [ "$altered" ]; then
    1.38 -		if [ "$confirm" ]; then
    1.39 -			gettext "Remove packages depending on:"; echo -n " $PACKAGE"
    1.40 -			if ! confirm; then
    1.41 -				gettext "Keeping packages depending on:"; echo " $PACKAGE"
    1.42 -				echo -e "\n" && continue
    1.43 -			fi
    1.44 +	# Reverse deps are displayed, confirm uninstall.
    1.45 +	if [ "$confirm" ]; then
    1.46 +		gettext "Confirm uninstallation of:"; echo -n " $pkg"
    1.47 +		if ! confirm; then
    1.48 +			gettext "Uninstallation cancelled"
    1.49 +			echo -e "\n" && continue
    1.50  		fi
    1.51 -		for i in $altered; do
    1.52 -			if [ -d "$installed/$i" ]; then
    1.53 -				spk-rm $i --root=$root
    1.54 -			fi
    1.55 -		done
    1.56  	fi
    1.57  
    1.58  	# Handle pre_remove
    1.59 @@ -135,21 +122,42 @@
    1.60  	status
    1.61  	sed -i "/ $PACKAGE-${VERSION}${EXTRAVERSION}$/d" $pkgsmd5 2> /dev/null
    1.62  
    1.63 -	# Mofified ?
    1.64 -	if [ "$refresh" ]; then
    1.65 +	separator && newline
    1.66 +
    1.67 +	# Do we have packages depending on $pkg to remove ?
    1.68 +	if [ "$altered" ]; then
    1.69  		if [ "$confirm" ]; then
    1.70 -			gettext "Reinstall packages modified by:"; echo " $PACKAGE"
    1.71 +			gettext "Remove packages depending on:"; echo -n " $PACKAGE"
    1.72 +			if ! confirm; then
    1.73 +				gettext "Keeping packages depending on:"; echo " $PACKAGE"
    1.74 +				newline && continue
    1.75 +			fi
    1.76 +		fi
    1.77 +		for i in $altered; do
    1.78 +			if [ -d "$installed/$i" ]; then
    1.79 +				spk-rm $i --root=$root
    1.80 +			fi
    1.81 +		done
    1.82 +	fi
    1.83 +
    1.84 +	# Handle mofified packages
    1.85 +	modified=$(cd $installed; grep -sl ^$pkg$ */modifiers)
    1.86 +	if [ "$modified" ]; then
    1.87 +		gettext "Following packages was modified by"; boldify " $pkg"
    1.88 +		for i in $modified; do
    1.89 +			echo "  ${i%/modifiers}"
    1.90 +			# Remove package from the modifiers list
    1.91 +			sed -i "/^${pkg}$/"d $installed/$i
    1.92 +		done
    1.93 +		if [ "$confirm" ]; then
    1.94 +			gettext "Reinstall packages modified by:"; echo -n " $PACKAGE"
    1.95  			if ! confirm; then
    1.96  				gettext "Keeping packages modified by:"; echo " $PACKAGE"
    1.97 -				echo -e "\n" && continue
    1.98 +				newline && continue
    1.99  			fi
   1.100  		fi
   1.101 -		for i in $refresh; do
   1.102 -			if [ $(wc -l < $installed/$i) -gt 1 ]; then
   1.103 -				gettext "For reinstallation check:"; echo " $installed/$i"
   1.104 -				continue
   1.105 -			fi
   1.106 -			rm -r $installed/$i
   1.107 +		# Reinstall modified packages
   1.108 +		for i in $modified; do
   1.109  			spk-add ${i%/modifiers} --forced --root=$root
   1.110  		done
   1.111  	fi
   1.112 @@ -187,16 +195,7 @@
   1.113  	boldify $(gettext "Removing"; echo " $pkg")
   1.114  	separator
   1.115  	[ "$verbose" ] && echo "DB: $installed"
   1.116 -	# Handle --confirm
   1.117 -	if [ "$confirm" ]; then
   1.118 -		gettext "Confirm uninstallation of"; echo -n " $pkg:"
   1.119 -		if ! confirm; then
   1.120 -			gettext "Uninstallation cancelled"
   1.121 -			echo -e "\n" && continue
   1.122 -		fi
   1.123 -	fi
   1.124  	remove
   1.125 -	separator
   1.126 -	echo "" && log "Removed package: $pkg"
   1.127 +	log "Removed package: $pkg"
   1.128  done
   1.129  exit 0