cookutils rev 8

Handle correctly installed/uninstalled build deps
author Christophe Lincoln <pankso@slitaz.org>
date Tue May 03 23:09:59 2011 +0200 (2011-05-03)
parents 604aa059dca2
children 02bf2a847c08
files cook
line diff
     1.1 --- a/cook	Tue May 03 22:33:50 2011 +0200
     1.2 +++ b/cook	Tue May 03 23:09:59 2011 +0200
     1.3 @@ -191,15 +191,21 @@
     1.4  	status
     1.5  }
     1.6  
     1.7 -# Verify package quality and consitensy.
     1.8 -packit_quality() {
     1.9 -	if grep -q ^ERROR $LOGS/$pkg.log; then
    1.10 -		exit 1
    1.11 -	fi
    1.12 -	if ! grep -q ^/ $WOK/$pkg/taz/$pkg-*/files.list; then
    1.13 -		echo -e "ERROR: empty package\n" | tee -a $LOGS/$pkg.log && exit 1
    1.14 -	else
    1.15 -		mv -f $WOK/$pkg/taz/$pkg-*.tazpkg $PKGS
    1.16 +# Remove installed deps.
    1.17 +remove_deps() {
    1.18 +	# Now remove installed build deps.
    1.19 +	deps=$(cat $CACHE/installed.diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
    1.20 +	nb=$(echo $deps | wc -l)
    1.21 +	if [ -s "$CACHE/installed.diff" ]; then
    1.22 +		gettext "Build dependencies to remove:"; echo " $nb"
    1.23 +		gettext "Removing:"
    1.24 +		for dep in $deps
    1.25 +		do
    1.26 +			echo -n " $dep"
    1.27 +			yes | tazpkg remove $dep >/dev/null
    1.28 +		done
    1.29 +		echo ""
    1.30 +		mv -f $CACHE/installed.diff $CACHE/installed.last.diff
    1.31  	fi
    1.32  }
    1.33  
    1.34 @@ -242,9 +248,11 @@
    1.35  		fi
    1.36  	done
    1.37  	ls -1 > $CACHE/installed.cook && cd $CACHE
    1.38 -	diff installed.list installed.cook | \
    1.39 -		grep ^+[a-zA-Z0-9] | sed s/^+// > installed.deps
    1.40 -	deps=$(cat installed.deps | wc -l)
    1.41 +	
    1.42 +	# If a cook failed deps are not remove since we exit 1.
    1.43 +	[ ! -s "installed.diff" ] && \
    1.44 +		diff installed.list installed.cook > installed.diff
    1.45 +	deps=$(cat installed.diff | grep ^+[a-zA-Z0-9] | wc -l)
    1.46  
    1.47  	# Get source tarball and make sure we have source dir named:
    1.48  	# $PACKAGE-$VERSION to be standard in receipts. Her we use tar.lzma
    1.49 @@ -275,15 +283,6 @@
    1.50  			"\nERROR: genpkg_rules failed\n" | \
    1.51  			tee -a $LOGS/$pkg.log && exit 1 )
    1.52  	fi
    1.53 -
    1.54 -	# Now remove installed build deps.
    1.55 -	if [ "$deps" -gt 0 ]; then
    1.56 -		gettext "Removing build dependencies:"; echo " $deps"
    1.57 -		for dep in $(cat $CACHE/installed.deps)
    1.58 -		do
    1.59 -			yes | tazpkg remove $dep >/dev/null
    1.60 -		done
    1.61 -	fi
    1.62  	separator && echo ""
    1.63  }
    1.64  
    1.65 @@ -293,7 +292,7 @@
    1.66  		exit 1
    1.67  	fi
    1.68  	if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then
    1.69 -		echo -e "ERROR: cook failed\n" | \
    1.70 +		echo -e "\nERROR: cook failed\n" | \
    1.71  			tee -a $LOGS/$pkg.log && exit 1
    1.72  	fi
    1.73  }
    1.74 @@ -317,6 +316,18 @@
    1.75  	separator && echo ""
    1.76  }
    1.77  
    1.78 +# Verify package quality and consitensy.
    1.79 +packit_quality() {
    1.80 +	if grep -q ^ERROR $LOGS/$pkg.log; then
    1.81 +		exit 1
    1.82 +	fi
    1.83 +	if ! grep -q ^/ $WOK/$pkg/taz/$pkg-*/files.list; then
    1.84 +		echo -e "ERROR: empty package\n" | tee -a $LOGS/$pkg.log && exit 1
    1.85 +	else
    1.86 +		mv -f $WOK/$pkg/taz/$pkg-*.tazpkg $PKGS
    1.87 +	fi
    1.88 +}
    1.89 +
    1.90  #
    1.91  # Commands
    1.92  #
    1.93 @@ -471,6 +482,7 @@
    1.94  
    1.95  		# Cook and pack or exit on error and log everything.
    1.96  		cookit | tee $LOGS/$pkg.log
    1.97 +		remove_deps
    1.98  		cookit_quality
    1.99  		packit | tee -a $LOGS/$pkg.log
   1.100  		clean_log