# HG changeset patch # User Christian Mesh # Date 1337421542 18000 # Node ID a946ed77f7271774a2667d5e48c1da1798ebe7e5 # Parent 0cb21eb5cf205392f2484dcaa26fbd65c76292ba small clean diff -r 0cb21eb5cf20 -r a946ed77f727 lib/libspk.sh --- a/lib/libspk.sh Sat May 19 03:51:05 2012 -0500 +++ b/lib/libspk.sh Sat May 19 04:59:02 2012 -0500 @@ -83,6 +83,10 @@ cd - >/dev/null } +is_package_installed() { + [ -d "$installed/$1" ] +} + # Used by: list count_installed() { local count=$(ls $installed | wc -l) diff -r 0cb21eb5cf20 -r a946ed77f727 spk --- a/spk Sat May 19 03:51:05 2012 -0500 +++ b/spk Sat May 19 04:59:02 2012 -0500 @@ -120,13 +120,13 @@ check_root [ -d "$installed/$pkg" ] || continue if grep -qs ^${pkg}$ $blocked; then - echo -n "$(boldify $pkg) " - gettext "is already blocked"; newline + echo $(boldify $pkg) $(gettext "is already blocked") else gettext "Blocking package:"; echo -n " $pkg" echo $pkg >> $blocked log "Blocked package: $pkg" && status - fi && continue ;; + fi + continue ;; *\ --unblock\ *) check_root [ -d "$installed/$pkg" ] || continue @@ -135,11 +135,11 @@ sed -i /"^${pkg}$"/d $blocked log "Unblocked package: $pkg" && status else - echo -n "$(boldify $pkg) " - gettext "is not blocked"; newline - fi && continue ;; + echo $(boldify $pkg) $(gettext "is not blocked") + fi + continue ;; *\ --rm\ *) - [ -d "$installed/$pkg" ] || continue + is_package_installed $pkg || continue spk-rm $pkg --count=$count count=$(($count + 1)) continue ;; @@ -161,13 +161,14 @@ else colorize 36 $(gettext "Any upgrade log for:"; echo " $pkg") newline - fi && continue ;; + fi + continue ;; esac count=$(($count + 1)) [ "$count" == 1 ] && newline unset_receipt . $installed/$pkg/receipt - boldify "$(gettext "Package") $pkg" + boldify $(gettext "Package") $pkg separator gettext "Status :"; colorize 32 " installed" receipt_info @@ -186,13 +187,16 @@ esac count=$(($count + 1)) [ "$count" == 1 ] && newline - boldify "$(gettext "Package") $pkg" + boldify $(gettext "Package") $pkg separator gettext "Status :"; colorize 31 " not installed" - echo "$mirrored" | awk 'BEGIN { FS = "|" } ; { print \ - "Version :" $2 "\n" \ - "Short desc :" $3 "\n" \ - "Category :" $4 }' + IFS="|" + local mirror_version mirror_desc empty mirror_cat + echo "$mirrored" | read empty mirror_version mirror_desc empty mirror_cat + echo "Version :" $mirror_version + echo "Short desc :" $mirror_desc + echo "Category :" $mirror_cat + unset IFS separator && newline continue fi diff -r 0cb21eb5cf20 -r a946ed77f727 spk-add --- a/spk-add Sat May 19 03:51:05 2012 -0500 +++ b/spk-add Sat May 19 04:59:02 2012 -0500 @@ -34,7 +34,9 @@ } # Log install messages +# Parameters: package log_install() { + local pkg=$1 debug "log_install: $logdir/$pkg/install.log" mkdir -p $logdir/$pkg tee $logdir/$pkg/install.log @@ -85,12 +87,8 @@ gettext "Install missing dependencies" if ! confirm; then gettext "WARNING: Any dependencies installed"; newline - else - install_deps $package_name $DEPENDS fi - else install_deps $package_name $DEPENDS - fi else newline fi @@ -367,7 +365,7 @@ case "$pkg" in *.tazpkg|*.spk) count=$(($count + 1)) - install_local $pkg | log_install ;; + install_local $pkg | log_install $pkg;; *.deb|.rmp) echo "TODO: spk-convert then install" ;; *.*) gettext "WARNING: Not a valid package:"; echo " $pkg" ;; @@ -375,7 +373,7 @@ *) [ "$forced" ] || check_installed $pkg count=$(($count + 1)) - install_web $pkg | log_install ;; + install_web $pkg | log_install $pkg;; esac done diff -r 0cb21eb5cf20 -r a946ed77f727 spk-ls --- a/spk-ls Sat May 19 03:51:05 2012 -0500 +++ b/spk-ls Sat May 19 04:59:02 2012 -0500 @@ -73,8 +73,8 @@ separator read_pkgsdesc $extra/packages.desc separator - boldify $(echo -n "$(cat $extra/packages.$SUM | wc -l) " - gettext "packages in:"; echo " $(basename $extra)") + boldify $(echo -n $(cat $extra/packages.$SUM | wc -l)) + gettext "packages in:"; echo " $(basename $extra)" newline done exit 0 ;; @@ -83,7 +83,8 @@ cat $blocked else gettext "No blocked packages"; newline - fi && exit 0 ;; + fi + exit 0 ;; --short) newline boldify $(gettext "Installed packages") @@ -91,11 +92,12 @@ for pkg in $(ls -1 $installed) do . $installed/$pkg/receipt - echo -n "$(colorize 32 $pkg)"; indent 28 " $VERSION" + echo $(colorize 32 $pkg); indent 28 " $VERSION" done separator boldify $(count_installed) - newline && exit 0 ;; + newline + exit 0 ;; --*) continue ;; *) # List installed files by the package. @@ -115,18 +117,18 @@ cat $modifiers separator && newline else - echo -n "$(boldify $pkg) " - gettext "package was not modified"; newline + echo $(boldify $pkg) $(gettext "package was not modified") fi continue fi - boldify $(gettext "Installed files by"; echo " $pkg") + boldify $(gettext "Installed files by") $pkg separator cat $installed/$pkg/files.list separator - gettext "Installed files by"; echo -n " $pkg: " - colorize 32 "$nb" && newline - done && exit 0 ;; + echo $(gettext "Installed files by") $pkg: + colorize 32 $nb && newline + done + exit 0 ;; esac done @@ -137,7 +139,7 @@ count=0 newline -boldify "$(gettext "Installed packages")" +boldify $(gettext "Installed packages") separator for pkg in $installed/* do diff -r 0cb21eb5cf20 -r a946ed77f727 spk-mirror --- a/spk-mirror Sat May 19 03:51:05 2012 -0500 +++ b/spk-mirror Sat May 19 04:59:02 2012 -0500 @@ -65,8 +65,8 @@ local db=$1 debug "extra DB: $extradb/$db" nb=$(cat $extradb/$db/packages.$SUM 2>/dev/null | wc -l) - echo -n "Extra DB :"; boldify " $db" - echo -n "Extra URL :"; echo " $(cat $extradb/$db/mirror)" + echo "Extra DB : "$(boldify $db) + echo "Extra URL : "$(cat $extradb/$db/mirror) gettext "Packages :"; colorize 32 " $nb" } @@ -79,13 +79,14 @@ # Add PACKED_SIZE UNPACKED_SIZE to know packages size # before installing ??? --> actually done via packages.txt # - cat >> packages.desc << EOT -$PACKAGE | ${VERSION}$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE -EOT + + echo "$PACKAGE | ${VERSION}$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" \ + >> packages.desc + # packages.equiv is used by tazpkg install to check depends. touch packages.equiv for i in $PROVIDE; do - dest="" + unset dest echo $i | fgrep -q : && dest="${i#*:}:" if grep -qs ^${i%:*}= packages.equiv; then sed -i "s/^${i%:*}=/${i%:*}=${dest}$PACKAGE /" packages.equiv @@ -95,6 +96,7 @@ done # files.list provides a list of all packages files. cat $tmpdir/files.list | sed s/^/"$PACKAGE: \0"/ >> $pkgsdir/files.list + cd - > /dev/null } # @@ -261,7 +263,7 @@ echo "$pkgsdir/" > $db/mirror for list in packages.* do - gettext "Linking:"; echo -n " $list" + echo $(gettext "Linking:") $list ln -s $pkgsdir/$list $db/$list status done diff -r 0cb21eb5cf20 -r a946ed77f727 spk-rm --- a/spk-rm Sat May 19 03:51:05 2012 -0500 +++ b/spk-rm Sat May 19 04:59:02 2012 -0500 @@ -50,7 +50,7 @@ # Remove a single package remove() { altered="" - boldify $(gettext "Removing"; echo " $pkg") + boldify $(gettext "Removing") $pkg separator [ "$verbose" ] && echo "DB: $installed" @@ -59,7 +59,7 @@ [ -f $installed/$i/receipt ] || continue unset_receipt . $installed/$i/receipt - case " $(echo $DEPENDS) " in + case " $DEPENDS " in *\ $pkg\ *) altered="$altered $i" ;; esac done