spk rev 65

Less verbose on extract but show package size, add comments to download() and enbale --quiet mode
author Christophe Lincoln <pankso@slitaz.org>
date Fri May 18 03:48:08 2012 +0200 (2012-05-18)
parents fb6acdd2617c
children 63fb720dc777
files lib/libspk.sh spk-archive
line diff
     1.1 --- a/lib/libspk.sh	Fri May 18 03:19:51 2012 +0200
     1.2 +++ b/lib/libspk.sh	Fri May 18 03:48:08 2012 +0200
     1.3 @@ -105,18 +105,27 @@
     1.4  
     1.5  # Download a file trying all mirrors
     1.6  # Parameters: package/file
     1.7 +#
     1.8 +# We should do much better here, give priority to extra, then try
     1.9 +# main mirror, then try others official mirrors. The case $file is
    1.10 +# not needed since we use same URL for list or packages.
    1.11 +#
    1.12  download() {
    1.13 -	local package=$1
    1.14 +	local file=$1
    1.15  	local mirror="$(cat $mirrorurl)"
    1.16 -	case "$package" in
    1.17 +	[ "$quiet" ] && local quiet="-q"
    1.18 +	case "$file" in
    1.19  		*.tazpkg)
    1.20 -			echo "${mirror%/}/$package"
    1.21 -			wget -c ${mirror%/}/$package ;;
    1.22 +			[ "$quiet" ] || echo "URL: ${mirror%/}/"
    1.23 +			gettext "Downloading:"; boldify " $file"
    1.24 +			wget $quiet -c ${mirror%/}/$file
    1.25 +			if [ ! -f "$file" ]; then
    1.26 +				gettext "ERROR: Missing package:"; boldify "$package"
    1.27 +				newline && exit 1
    1.28 +			fi ;;
    1.29 +		ID|packages.*|files.list.lzma)
    1.30 +			echo "TODO" ;;
    1.31  	esac
    1.32 -	if [ ! -f "$package" ]; then
    1.33 -		gettext "ERROR: Missing package $package"; newline
    1.34 -		newline && exit 1
    1.35 -	fi
    1.36  }
    1.37  
    1.38  # Assume package name is valid
     2.1 --- a/spk-archive	Fri May 18 03:19:51 2012 +0200
     2.2 +++ b/spk-archive	Fri May 18 03:48:08 2012 +0200
     2.3 @@ -32,14 +32,11 @@
     2.4  extract_package() {
     2.5  	local package_file=$1
     2.6  	local package_name=$(package_name $package_file)
     2.7 -
     2.8 -	gettext "Extracting:"; echo " $package_name... "
     2.9 +	local size=$(du -sh $package_file | awk '{print $1}')
    2.10 +	gettext "Extracting"; echo -n " $package_name: $size"
    2.11  	cpio -idm --quiet < ${package_file##*/} && rm -f ${package_file##*/}
    2.12 +	unlzma -c fs.cpio.lzma | cpio -idm --quiet && rm fs.cpio.lzma
    2.13  	status
    2.14 -
    2.15 -	[ "$verbose" ] && gettext "Extracting the pseudo fs... "
    2.16 -	unlzma -c fs.cpio.lzma | cpio -idm --quiet && rm fs.cpio.lzma
    2.17 -	[ "$verbose" ] && status
    2.18  }
    2.19  
    2.20  # Extract .tazpkg cpio archive into a directory.