spk rev 18
Some fixes to libspk.sh and spk-ls to use --root=
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Tue May 15 12:46:12 2012 +0200 (2012-05-15) |
parents | c4f1fc1c761a |
children | b9ca2ddbafa1 |
files | lib/libspk.sh spk-ls |
line diff
1.1 --- a/lib/libspk.sh Tue May 15 12:29:41 2012 +0200 1.2 +++ b/lib/libspk.sh Tue May 15 12:46:12 2012 +0200 1.3 @@ -21,6 +21,7 @@ 1.4 1.5 # 1.6 # Functions 1.7 +# 1.8 1.9 # Display receipt information. Expects a receipt to be sourced 1.10 receipt_info() { 1.11 @@ -43,7 +44,7 @@ 1.12 1.13 # Used by: list 1.14 count_installed() { 1.15 - local count=$(ls ${root}${installed} | wc -l) 1.16 + local count=$(ls $installed | wc -l) 1.17 gettext "Installed packages"; echo ": $count" 1.18 } 1.19 1.20 @@ -89,7 +90,7 @@ 1.21 # Parameters: package 1.22 check_for_installed_package() { 1.23 local name="$1" 1.24 - if [ -d "${root}${installed}/$name" ]; then 1.25 + if [ -d "$installed/$name" ]; then 1.26 newline 1.27 echo $name $(gettext "package is already installed.") 1.28 exit 0 1.29 @@ -104,14 +105,14 @@ 1.30 if echo $i | fgrep -q : ; then 1.31 # format 'alternative:newname' 1.32 # if alternative is installed then substitute newname 1.33 - if [ -f ${root}${installed}/${i%:*}/receipt ]; then 1.34 + if [ -f $installed/${i%:*}/receipt ]; then 1.35 # substitute package dependancy 1.36 echo ${i#*:} 1.37 return 1.38 fi 1.39 else 1.40 # if alternative is installed then nothing to install 1.41 - if [ -f ${root}${installed}/$i/receipt ]; then 1.42 + if [ -f $installed/$i/receipt ]; then 1.43 # substitute installed package 1.44 echo $i 1.45 return 1.46 @@ -135,10 +136,10 @@ 1.47 # Calculate missing dependencies 1.48 for pkgorg in $depends; do 1.49 local pkg=$(equivalent_pkg $pkgorg) 1.50 - if [ ! -d "${root}${installed}/$pkg" ]; then 1.51 + if [ ! -d "$installed/$pkg" ]; then 1.52 gettext "Missing: \$pkg"; newline 1.53 deps=$(($deps+1)) 1.54 - elif [ ! -f "${root}${installed}/$pkg/receipt" ]; then 1.55 + elif [ ! -f "$installed/$pkg/receipt" ]; then 1.56 gettext "WARNING Dependency loop between \$package and \$pkg."; newline 1.57 fi 1.58 done
2.1 --- a/spk-ls Tue May 15 12:29:41 2012 +0200 2.2 +++ b/spk-ls Tue May 15 12:46:12 2012 +0200 2.3 @@ -26,6 +26,7 @@ 2.4 --mirror $(gettext "List all the packages on mirror") 2.5 --blocked $(gettext "List all blocked packages") 2.6 --short ls: $(gettext "Short list of installed packages") 2.7 + --root $(gettext "Set the root file system path") 2.8 --debug $(gettext "Display some usefull debug information") 2.9 2.10 $(boldify $(gettext "Examples:")) 2.11 @@ -94,13 +95,18 @@ 2.12 # Parse all installed pkgs receipt. 2.13 # 2.14 2.15 +count=0 2.16 + 2.17 +newline 2.18 boldify "$(gettext "Installed packages")" 2.19 separator 2.20 for pkg in $installed/* 2.21 do 2.22 unset_receipt 2.23 . $pkg/receipt 2.24 - newline 2.25 + count=$(($count + 1)) 2.26 + [ "$count" != 1 ] && newline 2.27 + gettext "Package :"; echo " $PACKAGE" 2.28 receipt_info 2.29 done 2.30 separator