tazpkg rev 876

modules getenv, get, install: provide --quiet option (don't display service messages, show errors only)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Nov 30 01:45:37 2015 +0200 (2015-11-30)
parents e2e188861988
children a458663ae7d4
files modules/get modules/getenv modules/install
line diff
     1.1 --- a/modules/get	Sat Nov 28 13:46:13 2015 +0200
     1.2 +++ b/modules/get	Mon Nov 30 01:45:37 2015 +0200
     1.3 @@ -159,7 +159,7 @@
     1.4  		if [ -f 'packages.info' ]; then
     1.5  			awk -F$'\t' -vp="$1" '$1==p{exit 1}' packages.info
     1.6  			if [ "$?" -eq 1 ]; then
     1.7 -				_ 'Package "%s" already in the cache' "$1" >&2
     1.8 +				[ -z "$quiet" ] && _ 'Package "%s" already in the cache' "$1" >&2
     1.9  				echo -n "$(pwd)/"
    1.10  				awk -F$'\t' -vp="$1" '$1==p{printf "%s-%s.tazpkg\n", $1, $2; exit}' packages.info
    1.11  				exit 0
    1.12 @@ -283,7 +283,7 @@
    1.13  virtual_pkg() {
    1.14  	# input:  $1 virtual package name
    1.15  	#         $2 repository db directory
    1.16 -	# outout: display possible package name
    1.17 +	# output: display possible package name
    1.18  
    1.19  	local i
    1.20  	for i in $(grep -hs "^$1=" "$2/packages.equiv" | sed "s/^$1=//"); do
    1.21 @@ -351,11 +351,11 @@
    1.22  
    1.23  	# Check if package already downloaded
    1.24  	if [ -f "$namever.tazpkg" ]; then
    1.25 -		[ -z "$nocache" ] && _ 'Package "%s" already in the cache' "$namever" >&2
    1.26 +		[ -z "$nocache" -a -z "$quiet" ] && _ 'Package "%s" already in the cache' "$namever" >&2
    1.27  
    1.28  		# Check if downloading complete, resume it not complete
    1.29  		if ! tail -c 2k "$namever.tazpkg" | fgrep -q '00000000TRAILER'; then
    1.30 -			_ 'Continuing package "%s" download' "$namever" >&2
    1.31 +			[ -z "$quiet" ] && _ 'Continuing package "%s" download' "$namever" >&2
    1.32  			download_from "$(cat "$rep/mirror")" "$namever.tazpkg"
    1.33  		fi
    1.34  	else
     2.1 --- a/modules/getenv	Sat Nov 28 13:46:13 2015 +0200
     2.2 +++ b/modules/getenv	Mon Nov 30 01:45:37 2015 +0200
     2.3 @@ -192,4 +192,33 @@
     2.4  
     2.5  CUR_DIR="$(pwd)"
     2.6  
     2.7 +
     2.8 +# Quiet functions
     2.9 +
    2.10 +saved_action=''
    2.11 +qaction() {
    2.12 +	saved_action="$1"
    2.13 +	[ -z "$quiet" ] && action "$1";
    2.14 +}
    2.15 +
    2.16 +qstatus() {
    2.17 +	local ret_code=$?
    2.18 +	if [ -z "$quiet" ]; then
    2.19 +		test "$ret_code" -eq 0; status
    2.20 +	elif [ "$ret_code" -ne 0 ]; then
    2.21 +		# Show both action and it's status in the silent mode if error
    2.22 +		action "$saved_action"
    2.23 +		test 1 -eq 2; status
    2.24 +	fi
    2.25 +}
    2.26 +
    2.27 +qtitle() {
    2.28 +	[ -z "$quiet" ] && title "$@";
    2.29 +}
    2.30 +
    2.31 +qfooter() {
    2.32 +	[ -z "$quiet" ] && footer "$@";
    2.33 +}
    2.34 +
    2.35 +
    2.36  debug '-- end getenv --'
     3.1 --- a/modules/install	Sat Nov 28 13:46:13 2015 +0200
     3.2 +++ b/modules/install	Mon Nov 30 01:45:37 2015 +0200
     3.3 @@ -188,7 +188,7 @@
     3.4  extract_package() {
     3.5  	# input: $1 - path to package to be extracted; package should be in the current dir
     3.6  	# ROOT INDEPENDENT
     3.7 -	action 'Extracting package...'
     3.8 +	qaction 'Extracting package...'
     3.9  
    3.10  	# Extract "outer layer": cpio; remove the original package file
    3.11  	cpio -idm --quiet < "$1" && rm -f "$1"
    3.12 @@ -202,7 +202,7 @@
    3.13  		zcat fs.cpio.gz | cpio -idm --quiet && rm fs.cpio.gz
    3.14  	fi
    3.15  
    3.16 -	status
    3.17 +	qstatus
    3.18  }
    3.19  
    3.20  
    3.21 @@ -248,12 +248,12 @@
    3.22  call_pre_install() {
    3.23  	local tmp
    3.24  	if grep -q '^pre_install()' "$1"; then
    3.25 -		action 'Execute pre-install commands...'
    3.26 +		qaction 'Execute pre-install commands...'
    3.27  		tmp="$(mktemp)"
    3.28  		cp "$1" "$tmp"
    3.29  		sed -i 's|$1/*$INSTALLED|$INSTALLED|g' "$tmp"
    3.30  		( . "$tmp"; pre_install "$root" )
    3.31 -		status
    3.32 +		qstatus
    3.33  		rm "$tmp"
    3.34  	fi
    3.35  
    3.36 @@ -262,12 +262,12 @@
    3.37  call_post_install() {
    3.38  	local tmp
    3.39  	if grep -q '^post_install()' "$1"; then
    3.40 -		action 'Execute post-install commands...'
    3.41 +		qaction 'Execute post-install commands...'
    3.42  		tmp="$(mktemp)"
    3.43  		cp "$1" "$tmp"
    3.44  		sed -i 's|$1/*$INSTALLED|$INSTALLED|g' "$tmp"
    3.45  		( . "$tmp"; post_install "$root" )
    3.46 -		status
    3.47 +		qstatus
    3.48  		rm "$tmp"
    3.49  	fi
    3.50  }
    3.51 @@ -332,17 +332,19 @@
    3.52  	#[ -n "$INSTALL_LIST" ] && echo "$PACKAGE_FILE" >> "$PKGS_DB/$INSTALL_LIST-processed"
    3.53  
    3.54  	if [ -n "$sequence" ]; then
    3.55 -		title 'Installation of package "%s" (%s)' "$PACKAGE" "$sequence"
    3.56 +		qtitle 'Installation of package "%s" (%s)' "$PACKAGE" "$sequence"
    3.57  	else
    3.58 -		title 'Installation of package "%s"' "$PACKAGE"
    3.59 +		qtitle 'Installation of package "%s"' "$PACKAGE"
    3.60  	fi
    3.61  
    3.62 -	print_short_description "$PACKAGE"
    3.63 -	separator '-'
    3.64 +	if [ -z "$quiet" ]; then
    3.65 +		print_short_description "$PACKAGE"
    3.66 +		separator '-'
    3.67 +	fi
    3.68  
    3.69 -	action 'Copying package...'
    3.70 +	qaction 'Copying package...'
    3.71  	cp "$PACKAGE_FILE" "$TMP_DIR"
    3.72 -	status
    3.73 +	qstatus
    3.74  
    3.75  	cd "$TMP_DIR"
    3.76  	extract_package "$(basename "$PACKAGE_FILE")"
    3.77 @@ -370,7 +372,7 @@
    3.78  
    3.79  
    3.80  	# Remember modified packages
    3.81 -	action 'Remember modified packages...'
    3.82 +	qaction 'Remember modified packages...'
    3.83  	{
    3.84  		check=false
    3.85  		# TODO: why '[' the special?
    3.86 @@ -416,7 +418,7 @@
    3.87  		fi
    3.88  		echo "$PACKAGE" >> "$dir/modifiers"
    3.89  	done
    3.90 -	status
    3.91 +	qstatus
    3.92  
    3.93  
    3.94  	cd "$TMP_DIR"
    3.95 @@ -432,7 +434,7 @@
    3.96  
    3.97  	if [ -n "$CONFIG_FILES" ]; then
    3.98  		# Save "official" configuration files
    3.99 -		action 'Saving configuration files...'
   3.100 +		qaction 'Saving configuration files...'
   3.101  		debug "\n"
   3.102  
   3.103  		cd fs
   3.104 @@ -458,12 +460,12 @@
   3.105  			done
   3.106  		fi
   3.107  		# always '[ Done ]' status, unless '--newconf' is passed or not
   3.108 -		:; status
   3.109 +		:; qstatus
   3.110  	fi
   3.111  
   3.112  
   3.113  	if [ -n "$(ls fs/* 2>/dev/null)" ]; then
   3.114 -		action 'Installing package...'
   3.115 +		qaction 'Installing package...'
   3.116  
   3.117  		debug '\n  resolving destination links in source'
   3.118  		IFS=$'\n'
   3.119 @@ -478,12 +480,12 @@
   3.120  
   3.121  		debug '  copying folders and files to destination'
   3.122  		cp -af fs/* "$root/"
   3.123 -		status
   3.124 +		qstatus
   3.125  	fi
   3.126  
   3.127  
   3.128  	if [ -s files2remove.list ]; then
   3.129 -		action 'Removing old files...'
   3.130 +		qaction 'Removing old files...'
   3.131  		while read file; do
   3.132  			dir="$root$file"
   3.133  			# Remove specified file
   3.134 @@ -494,15 +496,14 @@
   3.135  				rmdir "$dir" 2>/dev/null || break
   3.136  			done
   3.137  		done < files2remove.list
   3.138 -		true
   3.139 -		status
   3.140 +		:; qstatus
   3.141  	fi
   3.142  
   3.143  
   3.144  	# Remove the temporary random directory.
   3.145 -	action "Removing all tmp files..."
   3.146 +	qaction "Removing all tmp files..."
   3.147  	cd ..; rm -rf "$TMP_DIR"
   3.148 -	status
   3.149 +	qstatus
   3.150  
   3.151  
   3.152  	# Post install commands
   3.153 @@ -525,7 +526,7 @@
   3.154  	fgrep -q /lib/modules "$fl" && ukrnl='yes'
   3.155  
   3.156  	if [ -n "$udesk$umime$uicon$uschm$upixb$ukrnl" ]; then
   3.157 -		action 'Update system databases...'
   3.158 +		qaction 'Update system databases...'
   3.159  		upd=1
   3.160  	fi
   3.161  
   3.162 @@ -542,7 +543,7 @@
   3.163  	# packages 'busybox', 'kmod', 'depmod'
   3.164  	[ -n "$ukrnl" ] && grep '/lib/modules' "$fl" | cut -d'/' -f4 | uniq | xargs chroot "$root/" /sbin/depmod -a
   3.165  
   3.166 -	[ "$upd" -eq 1 ] && status
   3.167 +	[ "$upd" -eq 1 ] && qstatus
   3.168  
   3.169  
   3.170  
   3.171 @@ -563,7 +564,7 @@
   3.172  	sort "$ii" > "$TEMP_FILE"; mv -f "$TEMP_FILE" "$ii"; chmod a+r "$ii"; unset ii
   3.173  
   3.174  	cd "$CUR_DIR"
   3.175 -	footer "$(_ 'Package "%s" (%s) is installed.' "$PACKAGE" "$VERSION$EXTRAVERSION")"
   3.176 +	qfooter "$(_ 'Package "%s" (%s) is installed.' "$PACKAGE" "$VERSION$EXTRAVERSION")"
   3.177  
   3.178  	# Log this activity
   3.179  	log_pkg Installed