# HG changeset patch # User Christophe Lincoln # Date 1337078772 -7200 # Node ID e5d4c5d3ccf4bdbffc354c7a646ee97eec947735 # Parent c4f1fc1c761a2586a755b5460eb3e068f06c5e85 Some fixes to libspk.sh and spk-ls to use --root= diff -r c4f1fc1c761a -r e5d4c5d3ccf4 lib/libspk.sh --- a/lib/libspk.sh Tue May 15 12:29:41 2012 +0200 +++ b/lib/libspk.sh Tue May 15 12:46:12 2012 +0200 @@ -21,6 +21,7 @@ # # Functions +# # Display receipt information. Expects a receipt to be sourced receipt_info() { @@ -43,7 +44,7 @@ # Used by: list count_installed() { - local count=$(ls ${root}${installed} | wc -l) + local count=$(ls $installed | wc -l) gettext "Installed packages"; echo ": $count" } @@ -89,7 +90,7 @@ # Parameters: package check_for_installed_package() { local name="$1" - if [ -d "${root}${installed}/$name" ]; then + if [ -d "$installed/$name" ]; then newline echo $name $(gettext "package is already installed.") exit 0 @@ -104,14 +105,14 @@ if echo $i | fgrep -q : ; then # format 'alternative:newname' # if alternative is installed then substitute newname - if [ -f ${root}${installed}/${i%:*}/receipt ]; then + if [ -f $installed/${i%:*}/receipt ]; then # substitute package dependancy echo ${i#*:} return fi else # if alternative is installed then nothing to install - if [ -f ${root}${installed}/$i/receipt ]; then + if [ -f $installed/$i/receipt ]; then # substitute installed package echo $i return @@ -135,10 +136,10 @@ # Calculate missing dependencies for pkgorg in $depends; do local pkg=$(equivalent_pkg $pkgorg) - if [ ! -d "${root}${installed}/$pkg" ]; then + if [ ! -d "$installed/$pkg" ]; then gettext "Missing: \$pkg"; newline deps=$(($deps+1)) - elif [ ! -f "${root}${installed}/$pkg/receipt" ]; then + elif [ ! -f "$installed/$pkg/receipt" ]; then gettext "WARNING Dependency loop between \$package and \$pkg."; newline fi done diff -r c4f1fc1c761a -r e5d4c5d3ccf4 spk-ls --- a/spk-ls Tue May 15 12:29:41 2012 +0200 +++ b/spk-ls Tue May 15 12:46:12 2012 +0200 @@ -26,6 +26,7 @@ --mirror $(gettext "List all the packages on mirror") --blocked $(gettext "List all blocked packages") --short ls: $(gettext "Short list of installed packages") + --root $(gettext "Set the root file system path") --debug $(gettext "Display some usefull debug information") $(boldify $(gettext "Examples:")) @@ -94,13 +95,18 @@ # Parse all installed pkgs receipt. # +count=0 + +newline boldify "$(gettext "Installed packages")" separator for pkg in $installed/* do unset_receipt . $pkg/receipt - newline + count=$(($count + 1)) + [ "$count" != 1 ] && newline + gettext "Package :"; echo " $PACKAGE" receipt_info done separator