spk rev 26

spk-add: make id busybox ash compatible and fix libspk.sh as well
author Christophe Lincoln <pankso@slitaz.org>
date Tue May 15 18:17:27 2012 +0200 (2012-05-15)
parents 3cca155b72a7
children eb8149264a44
files lib/libspk.sh spk-add spk-archive
line diff
     1.1 --- a/lib/libspk.sh	Tue May 15 17:52:37 2012 +0200
     1.2 +++ b/lib/libspk.sh	Tue May 15 18:17:27 2012 +0200
     1.3 @@ -46,9 +46,9 @@
     1.4  extract_receipt() {
     1.5  	local dir="$1"
     1.6  	local file="$2"
     1.7 -	pushd "$dir" > /dev/null
     1.8 +	cd "$dir"
     1.9  	{ cpio --quiet -i receipt > /dev/null 2>&1; } < $file
    1.10 -	popd > /dev/null
    1.11 +	cd - >/dev/null
    1.12  }
    1.13  
    1.14  # Used by: list
    1.15 @@ -100,8 +100,7 @@
    1.16  check_for_installed_package() {
    1.17  	local name="$1"
    1.18  	if [ -d "$installed/$name" ]; then
    1.19 -		newline
    1.20 -		echo $name $(gettext "package is already installed.")
    1.21 +		echo $(boldify "$name") $(gettext "package is already installed.")
    1.22  		exit 0
    1.23  	fi
    1.24  }
     2.1 --- a/spk-add	Tue May 15 17:52:37 2012 +0200
     2.2 +++ b/spk-add	Tue May 15 18:17:27 2012 +0200
     2.3 @@ -60,11 +60,12 @@
     2.4  #	touch $package_dir/modifiers
     2.5  #	touch $package_dir/files.list
     2.6  
     2.7 -	# add package checksum to pkgsmd5
     2.8 +	# Add package checksum to pkgsmd5
     2.9  	sed -i "/ $(basename $package_dir)$/d" $pkgsmd5 2> /dev/null
    2.10 -	pushd $(dirname $package_file) > /dev/null
    2.11 -		$CHECKSUM $(basename $package_file) >> $pkgsmd5
    2.12 -	popd > /dev/null
    2.13 +	oldpwd=$(pwd)
    2.14 +	cd $(dirname $package_file) || exit 1
    2.15 +	$CHECKSUM $(basename $package_file) >> $pkgsmd5
    2.16 +	cd $oldpwd
    2.17  
    2.18  	# Resolve package deps.
    2.19  	if missing_deps $package_name $DEPENDS; then
    2.20 @@ -79,10 +80,10 @@
    2.21  	status
    2.22  
    2.23  	# Extract Package
    2.24 -	pushd $TMP_DIR > /dev/null
    2.25 -		rm receipt
    2.26 -		spk-archive extract $package_file
    2.27 -	popd > /dev/null
    2.28 +	cd $TMP_DIR || exit 1
    2.29 +	rm receipt
    2.30 +	spk-archive extract $package_file
    2.31 +	cd - >/dev/null
    2.32  
    2.33  	# Get files to remove if upgrading
    2.34  	local files_to_remove
    2.35 @@ -130,52 +131,52 @@
    2.36  		done
    2.37  	fi
    2.38  
    2.39 -	pushd $TMP_DIR > /dev/null
    2.40 -		cp receipt files.list $package_dir
    2.41 -		# Copy the description if found.
    2.42 -		[ -f "description.txt" ] && cp description.txt $package_dir
    2.43 +	cd $TMP_DIR || exit 1
    2.44 +	cp receipt files.list $package_dir
    2.45 +	# Copy the description if found.
    2.46 +	[ -f "description.txt" ] && cp description.txt $package_dir
    2.47  
    2.48 -		# Pre install commands.
    2.49 -		if grep -q ^pre_install $package_dir/receipt; then
    2.50 -			pre_install $ROOT
    2.51 -		fi
    2.52 +	# Pre install commands.
    2.53 +	if grep -q ^pre_install $package_dir/receipt; then
    2.54 +		pre_install $ROOT
    2.55 +	fi
    2.56  
    2.57 -		# Handle Config Files from receipt
    2.58 -		if [ -n "$CONFIG_FILES" ]; then
    2.59 -			pushd $fs > /dev/null
    2.60 -				# save 'official' configuration files
    2.61 -				eval_gettext "Saving configuration files for \$package_name... "
    2.62 +	# Handle Config Files from receipt
    2.63 +	if [ -n "$CONFIG_FILES" ]; then
    2.64 +		cd $fs || exit 1
    2.65 +		# save 'official' configuration files
    2.66 +		eval_gettext "Saving configuration files for \$package_name... "
    2.67  
    2.68 -				local confs
    2.69 -				for i in $CONFIG_FILES; do
    2.70 -					confs="$confs $(find ${i#/} -type f 2> /dev/null)"
    2.71 -				done
    2.72 +		local confs
    2.73 +		for i in $CONFIG_FILES; do
    2.74 +			confs="$confs $(find ${i#/} -type f 2> /dev/null)"
    2.75 +		done
    2.76  
    2.77 -				echo $confs | cpio -o -H newc --quiet | gzip -9 > $package_dir/volatile.cpio.gz
    2.78 +		echo $confs | cpio -o -H newc --quiet | gzip -9 > $package_dir/volatile.cpio.gz
    2.79  
    2.80 -				# keep user configuration files
    2.81 -				for conf_file in $confs; do
    2.82 -					[ -e $conf_file ] || continue
    2.83 -					cp -a $conf_file fs/$conf_file
    2.84 -				done
    2.85 -				status
    2.86 -			popd > /dev/null
    2.87 -		fi
    2.88 +		# keep user configuration files
    2.89 +		for conf_file in $confs; do
    2.90 +			[ -e $conf_file ] || continue
    2.91 +			cp -a $conf_file fs/$conf_file
    2.92 +		done
    2.93 +		status
    2.94 +		cd - >/dev/null
    2.95 +	fi
    2.96  
    2.97 -		# Merge ROOT_FS with Package FS
    2.98 -		eval_gettext "Installing \$package_name... "
    2.99 -		cp -a fs/* $ROOT/
   2.100 +	# Merge ROOT_FS with Package FS
   2.101 +	eval_gettext "Installing \$package_name... "
   2.102 +	cp -a fs/* $ROOT/
   2.103 +	status
   2.104 +
   2.105 +	# Remove old config files
   2.106 +	if [ -n $files_to_remove ]; then
   2.107 +		eval_gettext "Removing old \$package_name... "
   2.108 +		for file in $files_to_remove; do
   2.109 +			remove_with_path $ROOT$file
   2.110 +		done
   2.111  		status
   2.112 -
   2.113 -		# Remove old config files
   2.114 -		if [ -n $files_to_remove ]; then
   2.115 -			eval_gettext "Removing old \$package_name... "
   2.116 -			for file in $files_to_remove; do
   2.117 -				remove_with_path $ROOT$file
   2.118 -			done
   2.119 -			status
   2.120 -		fi
   2.121 -	popd > /dev/null
   2.122 +	fi
   2.123 +	cd - >/dev/null
   2.124  
   2.125  	# Remove the temporary directory.
   2.126  	gettext "Removing all tmp files... "
   2.127 @@ -250,7 +251,7 @@
   2.128  
   2.129  	# Check if package is mirrored
   2.130  	if ! is_package_mirrored $package_name; then
   2.131 -		gettext "Could not find \$package_name in repositories"; newline
   2.132 +		gettext "Could not find package on mirror:"; echo " $package_name"
   2.133  		exit 1
   2.134  	fi
   2.135  
   2.136 @@ -262,25 +263,24 @@
   2.137  		check_for_installed_package $package_name
   2.138  	fi
   2.139  
   2.140 -	pushd $CACHE_DIR > /dev/null
   2.141 -		if [ -f "$package_full.tazpkg" ]; then
   2.142 -			eval_gettext "\$package_full is already in the cache : \$CACHE_DIR"; newline
   2.143 -			# Check package download was finished
   2.144 -			if ! tail -c 2k $package_full.tazpkg | fgrep -q 00000000TRAILER; then
   2.145 -				eval_gettext "Continuing \$package_name download"; newline
   2.146 -				download "$package_full.tazpkg"
   2.147 -			fi
   2.148 +	cd $CACHE_DIR > /dev/null
   2.149 +	if [ -f "$package_full.tazpkg" ]; then
   2.150 +		eval_gettext "\$package_full is already in the cache : \$CACHE_DIR"; newline
   2.151 +		# Check package download was finished
   2.152 +		if ! tail -c 2k $package_full.tazpkg | fgrep -q 00000000TRAILER; then
   2.153 +			eval_gettext "Continuing \$package_name download"; newline
   2.154 +			download "$package_full.tazpkg"
   2.155 +		fi
   2.156  
   2.157 -			# Check that the package has the correct checksum
   2.158 +		# Check that the package has the correct checksum
   2.159  #			if [ "$($CHECKSUM $package_full.tazpkg)" != "$(fgrep \"  $package_full.tazpkg\" $pkgsmd5)" ]; then
   2.160  #				rm -f $package.tazpkg
   2.161  #				download "$package_full.tazpkg"
   2.162  #			fi
   2.163 -		else
   2.164 -			newline
   2.165 -			download "$package_full.tazpkg"
   2.166 -		fi
   2.167 -	popd > /dev/null
   2.168 +	else
   2.169 +		newline
   2.170 +		download "$package_full.tazpkg"
   2.171 +	fi
   2.172  
   2.173  	install_package "$CACHE_DIR/$package_full.tazpkg"
   2.174  
     3.1 --- a/spk-archive	Tue May 15 17:52:37 2012 +0200
     3.2 +++ b/spk-archive	Tue May 15 18:17:27 2012 +0200
     3.3 @@ -1,4 +1,4 @@
     3.4 -#!/bin/sh
     3.5 +#!/bin/bash
     3.6  #
     3.7  # Spk-Archive - SliTaz Package Archive Manager
     3.8  #
     3.9 @@ -11,7 +11,7 @@
    3.10  
    3.11  usage() {
    3.12  	name=$(basename $0)
    3.13 -	cat << EOT 
    3.14 +	cat << EOT
    3.15  
    3.16  $(boldify $(gettext "Usage:")) $name [command] package
    3.17  
    3.18 @@ -33,11 +33,11 @@
    3.19  extract_package() {
    3.20  	local package_file=$1
    3.21  	local package_name=$(package_name $package_file)
    3.22 -	
    3.23 +
    3.24  	eval_gettext "Extracting \$package_name... "
    3.25  	cpio -idm --quiet < ${package_file##*/} && rm -f ${package_file##*/}
    3.26  	status
    3.27 -	
    3.28 +
    3.29  	gettext "Extracting the pseudo fs... "
    3.30  	if [ -f fs.cpio.lzma ]; then
    3.31  		echo -n "(lzma) "
    3.32 @@ -53,10 +53,10 @@
    3.33  extract() {
    3.34  	local package_file=$1
    3.35  	local target_dir=$2
    3.36 -	
    3.37 +
    3.38  	# validate the file
    3.39  	check_valid_tazpkg $package_file
    3.40 -	
    3.41 +
    3.42  	# find the package name
    3.43  	local package_name=$(package_name $package_file)
    3.44  
    3.45 @@ -64,11 +64,11 @@
    3.46  	local dest_dir=$(pwd)/$package_name
    3.47  	[ -n "$target_dir" ] && dest_dir=$target_dir/$package_name
    3.48  	mkdir -p $dest_dir
    3.49 -	
    3.50 +
    3.51  	newline
    3.52  	echo $(boldify $(gettext "Extracting:")) $package_name
    3.53  	separator
    3.54 -	
    3.55 +
    3.56  	gettext "Copying original package..."
    3.57  	cp $package_file $dest_dir
    3.58  	status
    3.59 @@ -83,37 +83,37 @@
    3.60  # Recompress .tazpkg cpio archive with lzma.
    3.61  # Parameters: package_file
    3.62  recompress() {
    3.63 -	local package_file=$1	
    3.64 +	local package_file=$1
    3.65  	valid_tazpkg $package_file
    3.66 -	
    3.67 +
    3.68  	local package_name=$(package_name $package_file)
    3.69 -	
    3.70 +
    3.71  	newline
    3.72  	echo $(boldify $(gettext "Recompressing:")) $package_name
    3.73  	separator
    3.74 -	
    3.75 +
    3.76  	mkdir -p $TMP_DIR
    3.77 -	
    3.78 +
    3.79  	gettext "Copying original package..."
    3.80  	cp $package_file $TMP_DIR
    3.81  	status
    3.82 -	
    3.83 +
    3.84  	pushd $TMP_DIR > /dev/null
    3.85  		extract_package $package_file
    3.86 -	
    3.87 +
    3.88  		gettext "Recompressing the fs... "
    3.89  		find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
    3.90  		rm -rf fs
    3.91  		status
    3.92  	popd > /dev/null
    3.93 -	
    3.94 +
    3.95  	gettext "Creating new package... "
    3.96  	find $TMP_DIR -print | cpio -o -H newc --quiet > \
    3.97  		$(basename $package_file).$$ && mv -f \
    3.98  		$(basename $package_file).$$ \
    3.99  		$(basename $package_file)
   3.100  	status
   3.101 -	
   3.102 +
   3.103  	rm -rf $TMP_DIR
   3.104  }
   3.105  
   3.106 @@ -147,7 +147,7 @@
   3.107  		echo -e "$MISSING"
   3.108  		exit 1
   3.109  	fi
   3.110 -	mkdir -p $TMP_DIR 
   3.111 +	mkdir -p $TMP_DIR
   3.112  	pushd $TMP_DIR > /dev/null
   3.113  	FILES="fs.cpio.lzma\n"
   3.114  	for i in $(ls $INSTALLED/$PACKAGE) ; do
   3.115 @@ -237,7 +237,7 @@
   3.116  		echo "$(bold Packing :) $PACKAGE"
   3.117  		separator
   3.118  		# Create files.list with redirecting find outpout.
   3.119 -		gettext "Creating the list of files..." 
   3.120 +		gettext "Creating the list of files..."
   3.121  		pushd fs
   3.122  		find . -type f -print > ../files.list
   3.123  		find . -type l -print >> ../files.list