cookutils rev 779

cook: don't hide tazpkg installing errors, use --quiet instead (thanks Pascal); use action(), title() and footer()
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Nov 30 01:49:08 2015 +0200 (2015-11-30)
parents b0c7e20fd844
children a2b90fc71cc9
files Makefile cook
line diff
     1.1 --- a/Makefile	Sun Nov 29 19:35:29 2015 +0100
     1.2 +++ b/Makefile	Mon Nov 30 01:49:08 2015 +0200
     1.3 @@ -77,7 +77,7 @@
     1.4  # i18n
     1.5  
     1.6  pot:
     1.7 -	xgettext -o po/cook.pot -k_ -k_n -k_p:1,2 -L Shell -cL10n \
     1.8 +	xgettext -o po/cook.pot -kaction -ktitle -k_ -k_n -k_p:1,2 -L Shell -cL10n \
     1.9  		--copyright-holder="SliTaz Association" \
    1.10  		--package-name="Cook" \
    1.11  		--package-version="$(VERSION)" \
     2.1 --- a/cook	Sun Nov 29 19:35:29 2015 +0100
     2.2 +++ b/cook	Mon Nov 30 01:49:08 2015 +0200
     2.3 @@ -10,6 +10,7 @@
     2.4  . /usr/lib/slitaz/libcook.sh
     2.5  
     2.6  VERSION="3.2"
     2.7 +export output=raw
     2.8  
     2.9  
    2.10  # Internationalization.
    2.11 @@ -389,7 +390,7 @@
    2.12  # Display debugging error info.
    2.13  
    2.14  debug_info() {
    2.15 -	newline; _ 'Debug information'; separator
    2.16 +	title 'Debug information'
    2.17  	# L10n: specify your format of date and time (to help: man date)
    2.18  	# L10n: not bad one is '+%x %R'
    2.19  	_ 'Cook date: %s' "$(date "$(_ '+%%F %%R')")"
    2.20 @@ -406,7 +407,7 @@
    2.21  	done > $LOGS/$pkg.log.debug_info 2>&1
    2.22  	cat $LOGS/$pkg.log.debug_info
    2.23  	rm -f $LOGS/$pkg.log.debug_info
    2.24 -	separator; newline
    2.25 +	footer
    2.26  }
    2.27  
    2.28  
    2.29 @@ -479,8 +480,8 @@
    2.30  	[ -d "$install/usr/share/applications" ] || return
    2.31  
    2.32  	if [ -n "$QA" -a -z "$(which desktop-file-validate)" ]; then
    2.33 -		_n 'Installing dep (web/cache): %s' 'desktop-file-utils-extra'
    2.34 -		tazpkg -gi desktop-file-utils-extra >/dev/null
    2.35 +		action 'Installing dep (web/cache): %s' 'desktop-file-utils-extra'
    2.36 +		tazpkg -gi desktop-file-utils-extra --quiet
    2.37  		status
    2.38  	fi
    2.39  
    2.40 @@ -515,7 +516,7 @@
    2.41  		arm*|x86_64) export STRIP="$HOST_SYSTEM-strip" ;;
    2.42  		*)           export STRIP='strip' ;;
    2.43  	esac
    2.44 -	_n 'Executing strip on all files...'
    2.45 +	action 'Executing strip on all files...'
    2.46  	for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games; do
    2.47  		if [ -d "$dir" ]; then
    2.48  			find $dir -type f -exec $STRIP -s '{}' 2>/dev/null \;
    2.49 @@ -526,14 +527,10 @@
    2.50  	status
    2.51  
    2.52  	# Remove Python .pyc and .pyo from packages.
    2.53 -	#_n 'Removing Python compiled files...'
    2.54  	find $fs -type f \( -name '*.pyc' -o -name '*.pyo' \) -delete 2>/dev/null
    2.55 -	#status
    2.56  
    2.57  	# Remove Perl perllocal.pod and .packlist from packages.
    2.58 -	#_n 'Removing Perl compiled files...'
    2.59  	find $fs -type f \( -name 'perllocal.pod' -o -name '.packlist' \) -delete 2>/dev/null
    2.60 -	#status
    2.61  }
    2.62  
    2.63  
    2.64 @@ -574,7 +571,7 @@
    2.65  # The main cook function.
    2.66  
    2.67  cookit() {
    2.68 -	_ 'Cook: %s' "$PACKAGE $VERSION"; separator
    2.69 +	title 'Cook: %s' "$PACKAGE $VERSION"
    2.70  	set_paths
    2.71  
    2.72  	# Handle cross-tools.
    2.73 @@ -711,14 +708,14 @@
    2.74  	cd $PKGS
    2.75  	for i in $(uniq $CACHE/installed.local); do
    2.76  		_ 'Installing dep (pkg/local): %s' "$i"
    2.77 -		tazpkg install $i --root=$root >/dev/null 2>/dev/null
    2.78 +		tazpkg install $i --root=$root --quiet
    2.79  	done
    2.80  
    2.81  	# Install web or cached packages (if mirror is set to $PKGS we only
    2.82  	# use local packages).
    2.83  	for i in $(uniq $CACHE/installed.web); do
    2.84  		_ 'Installing dep (web/cache): %s' "$i"
    2.85 -		tazpkg get-install $i --root=$root >/dev/null 2>/dev/null
    2.86 +		tazpkg get-install $i --root=$root --quiet
    2.87  	done
    2.88  
    2.89  	update_installed_cook_diff
    2.90 @@ -781,13 +778,13 @@
    2.91  		# QA: no compile_rules so no error, valid.
    2.92  		mkdir -p $install
    2.93  	fi
    2.94 -	separator; newline
    2.95 +	footer
    2.96  
    2.97  	# Execute testsuite.
    2.98  	if grep -q ^testsuite $receipt; then
    2.99 -		_ 'Running testsuite'; separator
   2.100 +		title 'Running testsuite'
   2.101  		testsuite $@ || exit 1
   2.102 -		separator; newline
   2.103 +		footer
   2.104  	fi
   2.105  
   2.106  	fix_desktop_files
   2.107 @@ -823,7 +820,7 @@
   2.108  		arm*|x86_64) arch="-$ARCH" ;;
   2.109  	esac
   2.110  
   2.111 -	_ 'Pack: %s' "$PACKAGE $VERSION$arch"; separator
   2.112 +	title 'Pack: %s' "$PACKAGE $VERSION$arch"
   2.113  
   2.114  	if grep -q ^genpkg_rules $receipt; then
   2.115  		_ 'Executing: %s' 'genpkg_rules'
   2.116 @@ -844,7 +841,7 @@
   2.117  	cd $taz
   2.118  	for file in receipt description.txt; do
   2.119  		[ ! -f "../$file" ] && continue
   2.120 -		_n 'Copying "%s"...' "$file"
   2.121 +		action 'Copying "%s"...' "$file"
   2.122  		cp -f ../$file $pack; chown 0.0 $pack/$file; status
   2.123  	done
   2.124  	copy_generic_files
   2.125 @@ -853,7 +850,7 @@
   2.126  	strip_package
   2.127  
   2.128  	# Create files.list with redirecting find output.
   2.129 -	_n 'Creating the list of files...'
   2.130 +	action 'Creating the list of files...'
   2.131  	cd $fs
   2.132  	find . -type f -print > ../files.list
   2.133  	find . -type l -print >> ../files.list
   2.134 @@ -861,7 +858,7 @@
   2.135  	status
   2.136  
   2.137  	# Md5sum of files.
   2.138 -	_n 'Creating md5sum of files...'
   2.139 +	action 'Creating md5sum of files...'
   2.140  	while read file; do
   2.141  		[ -L "fs$file" ] && continue
   2.142  		[ -f "fs$file" ] || continue
   2.143 @@ -876,7 +873,7 @@
   2.144  		2>/dev/null | awk 'END{ print $1 }')
   2.145  
   2.146  	# Build cpio archives.
   2.147 -	_n 'Compressing the FS...'
   2.148 +	action 'Compressing the FS...'
   2.149  	find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
   2.150  	rm -rf fs
   2.151  	status
   2.152 @@ -884,7 +881,7 @@
   2.153  	PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list md5sum description.txt \
   2.154  		2>/dev/null | awk 'END{ print $1 }')
   2.155  
   2.156 -	_n 'Updating receipt sizes...'
   2.157 +	action 'Updating receipt sizes...'
   2.158  	sed -i s/^PACKED_SIZE.*$// receipt
   2.159  	sed -i s/^UNPACKED_SIZE.*$// receipt
   2.160  	sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
   2.161 @@ -892,19 +889,19 @@
   2.162  
   2.163  	# Set extra version.
   2.164  	if [ -n "$EXTRAVERSION" ]; then
   2.165 -		_n 'Updating receipt EXTRAVERSION: %s' "$EXTRAVERSION"
   2.166 +		action 'Updating receipt EXTRAVERSION: %s' "$EXTRAVERSION"
   2.167  		sed -i s/^EXTRAVERSION.*$// receipt
   2.168  		sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
   2.169  		status
   2.170  	fi
   2.171  
   2.172  	# Compress.
   2.173 -	_n 'Creating full cpio archive...'
   2.174 +	action 'Creating full cpio archive...'
   2.175  	find . -print | cpio -o -H newc --quiet > \
   2.176  		../$PACKAGE-$VERSION$EXTRAVERSION$arch.tazpkg
   2.177  	status
   2.178  
   2.179 -	_n 'Restoring original package tree...'
   2.180 +	action 'Restoring original package tree...'
   2.181  	unlzma -c fs.cpio.lzma | cpio -idm --quiet
   2.182  	status
   2.183  
   2.184 @@ -913,14 +910,14 @@
   2.185  	# QA and give info.
   2.186  	tazpkg=$(ls *.tazpkg)
   2.187  	packit_quality
   2.188 -	separator; _ 'Package "%s" created' "$tazpkg"; newline
   2.189 +	footer "$(_ 'Package "%s" created' "$tazpkg")"
   2.190  }
   2.191  
   2.192  
   2.193  # Verify package quality and consistency.
   2.194  
   2.195  packit_quality() {
   2.196 -	#gettext "QA: checking for broken link..."
   2.197 +	#action 'QA: checking for broken link...'
   2.198  	#link=$(find $fs/usr -type l -follow)
   2.199  	#[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
   2.200  	#status
   2.201 @@ -932,7 +929,7 @@
   2.202  		exit 1
   2.203  	fi
   2.204  
   2.205 -	_n 'QA: checking for empty package...'
   2.206 +	action 'QA: checking for empty package...'
   2.207  	files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
   2.208  	if [ "$files" == 0 ] && [ "$CATEGORY" != 'meta' ]; then
   2.209  		newline; _ 'ERROR: empty package'
   2.210 @@ -943,13 +940,13 @@
   2.211  		old=$(ls $PKGS/$pkg-*.tazpkg 2>/dev/null | head -n1)
   2.212  		status
   2.213  		if [ -f "$old" ]; then
   2.214 -			_n 'Removing old package "%s"' "$(basename $old)"
   2.215 +			action 'Removing old package "%s"' "$(basename $old)"
   2.216  			rm -f $old; status
   2.217  		fi
   2.218  		mv -f $pkgdir/taz/$pkg-*.tazpkg $PKGS
   2.219  		sed -i /^${pkg}$/d $broken
   2.220 -		#gettext "Removing source tree..."
   2.221 -		#rm -f $WOK/$pkg/source && status
   2.222 +		#action 'Removing source tree...'
   2.223 +		#rm -f $WOK/$pkg/source; status
   2.224  	fi
   2.225  }
   2.226  
   2.227 @@ -1161,7 +1158,7 @@
   2.228  #
   2.229  
   2.230  get_dev_files() {
   2.231 -	_n 'Getting standard devel files...'
   2.232 +	action 'Getting standard devel files...'
   2.233  	mkdir -p $fs/usr/lib
   2.234  	cp -a $install/usr/lib/pkgconfig $fs/usr/lib
   2.235  	cp -a $install/usr/lib/*a $fs/usr/lib
   2.236 @@ -1183,7 +1180,7 @@
   2.237  		 usage ;;
   2.238  
   2.239  	list-wok)
   2.240 -		newline; _ 'List of %s packages in "%s"' "$ARCH" "$WOK"; separator
   2.241 +		title 'List of %s packages in "%s"' "$ARCH" "$WOK"
   2.242  		cd $WOK
   2.243  		if [ "$ARCH" != 'i486' ]; then
   2.244  			count=0
   2.245 @@ -1198,9 +1195,8 @@
   2.246  			count=$(ls | wc -l)
   2.247  			ls -1
   2.248  		fi
   2.249 -		separator
   2.250 -		_p '%s package' '%s packages' "$count" "$(colorize 32 "$count")"
   2.251 -		newline ;;
   2.252 +		footer "$(_p '%s package' '%s packages' "$count" "$(colorize 32 "$count")")"
   2.253 +		;;
   2.254  
   2.255  	activity)
   2.256  		cat $activity ;;
   2.257 @@ -1208,15 +1204,15 @@
   2.258  	search)
   2.259  		# Just a simple search function, we dont need more actually.
   2.260  		query="$2"
   2.261 -		newline; _ 'Search results for "%s"' "$query"; separator
   2.262 +		title 'Search results for "%s"' "$query"
   2.263  		cd $WOK; ls -1 | grep "$query"
   2.264 -		separator; newline ;;
   2.265 +		footer ;;
   2.266  
   2.267  	setup)
   2.268  		# Setup a build environment
   2.269  		check_root
   2.270  		_ 'Cook: setup environment' | log
   2.271 -		newline; _ 'Setting up your environment'; separator
   2.272 +		title 'Setting up your environment'
   2.273  		cd $SLITAZ
   2.274  		init_db_files
   2.275  		_ 'Checking for packages to install...'
   2.276 @@ -1255,7 +1251,7 @@
   2.277  		_ 'Setting permissions for group "%s"...' 'slitaz'
   2.278  		find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
   2.279  		find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
   2.280 -		separator; _ 'All done, ready to cook packages :-)'; newline ;;
   2.281 +		footer "$(_ 'All done, ready to cook packages :-)')" ;;
   2.282  
   2.283  	*-setup)
   2.284  		# Setup for cross compiling.
   2.285 @@ -1271,7 +1267,7 @@
   2.286  		done
   2.287  
   2.288  		_ 'Cook: setup %s cross environment' "$arch" | log
   2.289 -		newline; boldify $(_n 'Setting up your %s cross environment' "$arch"); separator
   2.290 +		title 'Setting up your %s cross environment' "$arch"
   2.291  		init_db_files
   2.292  		sed -i \
   2.293  			-e s"/ARCH=.*/ARCH=\"$arch\"/" \
   2.294 @@ -1326,7 +1322,7 @@
   2.295  			colorize 36 $(_ 'C compiler "%s" is missing' "$HOST_SYSTEM-gcc")
   2.296  			_ 'Run "%s" to cook a toolchain' 'cross compile'
   2.297  		fi
   2.298 -		separator; newline ;;
   2.299 +		footer ;;
   2.300  
   2.301  	test)
   2.302  		# Test a cook environment.
   2.303 @@ -1345,10 +1341,10 @@
   2.304  			exit 1
   2.305  		fi
   2.306  
   2.307 -		_n 'Creating folder "%s"' "$WOK/$pkg"
   2.308 +		action 'Creating folder "%s"' "$WOK/$pkg"
   2.309  		mkdir $WOK/$pkg; cd $WOK/$pkg; status
   2.310  
   2.311 -		_n 'Preparing the package receipt...'
   2.312 +		action 'Preparing the package receipt...'
   2.313  		cp $DATA/receipt .
   2.314  		sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
   2.315  		status; newline
   2.316 @@ -1388,19 +1384,19 @@
   2.317  
   2.318  				# Ask for a stuff dir.
   2.319  				confirm "$(_n 'Do you need a stuff directory? (y/N)')"
   2.320 -				if [ "$?" == 0 ]; then
   2.321 -					_n 'Creating the stuff directory...'
   2.322 +				if [ "$?" -eq 0 ]; then
   2.323 +					action 'Creating the stuff directory...'
   2.324  					mkdir $WOK/$pkg/stuff; status
   2.325  				fi
   2.326  
   2.327  				# Ask for a description file.
   2.328  				confirm "$(_n 'Are you going to write a description? (y/N)')"
   2.329 -				if [ "$?" == 0 ]; then
   2.330 -					_n 'Creating the "%s" file...' 'description.txt'
   2.331 +				if [ "$?" -eq 0 ]; then
   2.332 +					action 'Creating the "%s" file...' 'description.txt'
   2.333  					touch $WOK/$pkg/description.txt; status
   2.334  				fi
   2.335  
   2.336 -				separator; _ 'Receipt is ready to use.'; newline ;;
   2.337 +				footer "$(_ 'Receipt is ready to use.')" ;;
   2.338  		esac ;;
   2.339  
   2.340  	list)
   2.341 @@ -1424,20 +1420,20 @@
   2.342  
   2.343  	clean-wok)
   2.344  		check_root
   2.345 -		newline; _n 'Cleaning all packages files...'
   2.346 +		newline; action 'Cleaning all packages files...'
   2.347  		rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
   2.348  		status; newline ;;
   2.349  
   2.350  	clean-src)
   2.351  		check_root
   2.352 -		newline; _n 'Cleaning all packages sources...'
   2.353 +		newline; action 'Cleaning all packages sources...'
   2.354  		rm -rf $WOK/*/source
   2.355  		status; newline ;;
   2.356  
   2.357  	uncook)
   2.358  		cd $WOK
   2.359  		count=0
   2.360 -		newline; _ 'Checking for uncooked packages'; separator
   2.361 +		title 'Checking for uncooked packages'
   2.362  
   2.363  		for pkg in *; do
   2.364  			unset HOST_ARCH EXTRAVERSION
   2.365 @@ -1468,12 +1464,12 @@
   2.366  		done
   2.367  
   2.368  		if [ "$count" -gt "0" ]; then
   2.369 -			separator
   2.370 -			_p '%s uncooked package' '%s uncooked packages' "$count" "$(colorize 31 "$count")"
   2.371 +			footer "$(_p '%s uncooked package' '%s uncooked packages' "$count" "$(colorize 31 "$count")")"
   2.372  		else
   2.373  			_ 'All packages are cooked :-)'
   2.374 +			newline
   2.375  		fi
   2.376 -		newline ;;
   2.377 +		;;
   2.378  
   2.379  	pkgdb)
   2.380  		# Create suitable packages list for TazPKG and only for built packages
   2.381 @@ -1781,7 +1777,7 @@
   2.382  		# Handle --options
   2.383  		case "$2" in
   2.384  			--clean|-c)
   2.385 -				_n 'Cleaning "%s"' "$pkg"
   2.386 +				action 'Cleaning "%s"' "$pkg"
   2.387  				cd $WOK/$pkg; rm -rf install taz source
   2.388  				status; newline
   2.389  				exit 0 ;;
   2.390 @@ -1790,19 +1786,19 @@
   2.391  				inst='yes' ;;
   2.392  
   2.393  			--getsrc|-gs)
   2.394 -				_ 'Getting source for "%s"' "$pkg"; separator
   2.395 +				title 'Getting source for "%s"' "$pkg"
   2.396  				get_source
   2.397  				_ 'Tarball: %s' "$SRC/$TARBALL"; newline
   2.398  				exit 0 ;;
   2.399  
   2.400  			--block|-b)
   2.401 -				_n 'Blocking package "%s"' "$pkg"
   2.402 +				action 'Blocking package "%s"' "$pkg"
   2.403  				[ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
   2.404  				status; newline
   2.405  				exit 0 ;;
   2.406  
   2.407  			--unblock|-ub)
   2.408 -				_n 'Unblocking package "%s"' "$pkg"
   2.409 +				action 'Unblocking package "%s"' "$pkg"
   2.410  				sed -i "/^${pkg}$/"d $blocked
   2.411  				status; newline
   2.412  				exit 0 ;;
   2.413 @@ -1825,7 +1821,7 @@
   2.414  					exit 0
   2.415  				fi
   2.416  
   2.417 -				_ 'Checking depends'; separator
   2.418 +				title 'Checking depends'
   2.419  				lddlist='/tmp/lddlist'; touch $lddlist
   2.420  				missing='/var/cache/missing.file'
   2.421