spk rev 69
Update to use new colorize
author | Christian Mesh <meshca@clarkson.edu> |
---|---|
date | Sat May 19 03:51:05 2012 -0500 (2012-05-19) |
parents | d1790128faac |
children | a946ed77f727 |
files | lib/libspk.sh spk spk-add spk-ls spk-mirror spk-rm testsuite.sh |
line diff
1.1 --- a/lib/libspk.sh Fri May 18 21:24:30 2012 +0200 1.2 +++ b/lib/libspk.sh Sat May 19 03:51:05 2012 -0500 1.3 @@ -53,10 +53,10 @@ 1.4 cat $list | while read package version desc category 1.5 do 1.6 if [ "$short" ]; then 1.7 - echo -n "$(colorize "$package" 32)"; indent 28 " $version" 1.8 + echo -n "$(colorize 32 "$package")"; indent 28 " $version" 1.9 else 1.10 newline 1.11 - gettext "Package :"; colorize " $package" 32 1.12 + gettext "Package :"; colorize 32 " $package" 1.13 gettext "Version :"; echo "$version" 1.14 gettext "Short desc :"; echo "$desc" 1.15 fi 1.16 @@ -148,13 +148,13 @@ 1.17 if [ -f "$uri/$file" ]; then 1.18 [ "$verbose" ] && echo "URI: $uri/" 1.19 gettext "Using local mirror:"; boldify " $file" 1.20 - [ "$verbose" ] && (gettext "Copying file to:"; colorize " $pwd" 34) 1.21 + [ "$verbose" ] && (gettext "Copying file to:"; colorize 34 " $pwd") 1.22 cp -f $uri/$file $pwd 1.23 cd $pwd && return 0 1.24 fi 1.25 # In cache ? Root can use --cache to set destdir. 1.26 if [ -f "$CACHE_DIR/$file" ]; then 1.27 - gettext "Using cache:"; colorize " ${file%.tazpkg}" 34 1.28 + gettext "Using cache:"; colorize 34 " ${file%.tazpkg}" 1.29 return 0 1.30 else 1.31 [ "$verbose" ] && echo "URL: $uri/" 1.32 @@ -164,7 +164,7 @@ 1.33 gettext "Using extra mirror:" 1.34 fi 1.35 boldify " $file" 1.36 - [ "$verbose" ] && (gettext "Destination:"; colorize " $pwd" 34) 1.37 + [ "$verbose" ] && (gettext "Destination:"; colorize 34 " $pwd") 1.38 if [ -f "$pwd/$file" ]; then 1.39 echo "File exist: $pwd/$file" && return 0 1.40 fi 1.41 @@ -175,7 +175,7 @@ 1.42 fi 1.43 # Be sure the file was fetched. 1.44 if [ ! -f "$pwd/$file" ] || [ ! -f "$CACHE_DIR/$file" ]; then 1.45 - gettext "ERROR: Missing file:"; colorize " $file" 31 1.46 + gettext "ERROR: Missing file:"; colorize 31 " $file" 1.47 newline && exit 1 1.48 fi 1.49 } 1.50 @@ -256,7 +256,7 @@ 1.51 fi 1.52 done 1.53 1.54 - gettext "Missing dependencies:"; echo " $(colorize "$deps" 34)" 1.55 + gettext "Missing dependencies:"; echo " $(colorize 34 "$deps")" 1.56 1.57 # Return true if missing deps 1.58 [ "$deps" != "0" ]
2.1 --- a/spk Fri May 18 21:24:30 2012 +0200 2.2 +++ b/spk Sat May 19 03:51:05 2012 -0500 2.3 @@ -120,7 +120,7 @@ 2.4 check_root 2.5 [ -d "$installed/$pkg" ] || continue 2.6 if grep -qs ^${pkg}$ $blocked; then 2.7 - echo -n "$(boldify "$pkg") " 2.8 + echo -n "$(boldify $pkg) " 2.9 gettext "is already blocked"; newline 2.10 else 2.11 gettext "Blocking package:"; echo -n " $pkg" 2.12 @@ -135,7 +135,7 @@ 2.13 sed -i /"^${pkg}$"/d $blocked 2.14 log "Unblocked package: $pkg" && status 2.15 else 2.16 - echo -n "$(boldify "$pkg") " 2.17 + echo -n "$(boldify $pkg) " 2.18 gettext "is not blocked"; newline 2.19 fi && continue ;; 2.20 *\ --rm\ *) 2.21 @@ -148,18 +148,18 @@ 2.22 if [ -f "$logdir/$pkg/install.log" ]; then 2.23 count=$(($count + 1)) 2.24 [ "$count" == "1" ] && newline 2.25 - colorize "$(gettext "Install log for:"; echo " $pkg")" 36 2.26 + colorize 36 $(gettext "Install log for:"; echo " $pkg") 2.27 separator 2.28 cat $logdir/$pkg/install.log 2.29 else 2.30 gettext "Any install log for:"; boldify " $pkg" 2.31 fi 2.32 if [ -f "$logdir/$pkg/up.log" ]; then 2.33 - colorize "$(gettext "Upgrade log for:"; echo " $pkg")" 36 2.34 + colorize 36 $(gettext "Upgrade log for:"; echo " $pkg") 2.35 separator 2.36 cat $logdir/$pkg/up.log 2.37 else 2.38 - colorize "$(gettext "Any upgrade log for:"; echo " $pkg")" 36 2.39 + colorize 36 $(gettext "Any upgrade log for:"; echo " $pkg") 2.40 newline 2.41 fi && continue ;; 2.42 esac 2.43 @@ -169,7 +169,7 @@ 2.44 . $installed/$pkg/receipt 2.45 boldify "$(gettext "Package") $pkg" 2.46 separator 2.47 - gettext "Status :"; colorize " installed" 32 2.48 + gettext "Status :"; colorize 32 " installed" 2.49 receipt_info 2.50 separator && newline 2.51 continue 2.52 @@ -188,7 +188,7 @@ 2.53 [ "$count" == 1 ] && newline 2.54 boldify "$(gettext "Package") $pkg" 2.55 separator 2.56 - gettext "Status :"; colorize " not installed" 31 2.57 + gettext "Status :"; colorize 31 " not installed" 2.58 echo "$mirrored" | awk 'BEGIN { FS = "|" } ; { print \ 2.59 "Version :" $2 "\n" \ 2.60 "Short desc :" $3 "\n" \
3.1 --- a/spk-add Fri May 18 21:24:30 2012 +0200 3.2 +++ b/spk-add Sat May 19 03:51:05 2012 -0500 3.3 @@ -153,7 +153,7 @@ 3.4 [ "$package_name" == "$name" ] && continue 2 3.5 count=$(($count +1)) 3.6 [ "$count" == "1" ] && gettext "Modified package:"; \ 3.7 - colorize " $name" 31 3.8 + colorize 31 " $name" 3.9 gettext "Overwriting file:"; echo " $file" 3.10 # If confirm is set, ask to remove. Do we want that ? 3.11 # If gawk is installed for example we will never remove Busybox 3.12 @@ -381,7 +381,7 @@ 3.13 3.14 # Show all new counted packages in verbose mode 3.15 if [ "$verbose" ]; then 3.16 - gettext "Handled packages:"; colorize " $count" 34 3.17 + gettext "Handled packages:"; colorize 34 " $count" 3.18 fi 3.19 3.20 exit 0
4.1 --- a/spk-ls Fri May 18 21:24:30 2012 +0200 4.2 +++ b/spk-ls Sat May 19 03:51:05 2012 -0500 4.3 @@ -54,7 +54,7 @@ 4.4 exit 0 ;; 4.5 --mirror) 4.6 newline 4.7 - boldify "$(gettext "Mirror") $(cat $mirrorurl)" 4.8 + boldify $(gettext "Mirror") $(cat $mirrorurl) 4.9 read_pkgsdesc $pkgsdesc 4.10 separator 4.11 boldify $(count_mirrored) 4.12 @@ -64,10 +64,10 @@ 4.13 for extra in $extradb/* 4.14 do 4.15 newline 4.16 - boldify "$(gettext "Extra mirror")" 4.17 + boldify $(gettext "Extra mirror") 4.18 if [ ! -f "$extra/packages.desc" ]; then 4.19 echo "URL: $(cat $extra/mirror)" 4.20 - gettext "Missing:"; colorize " packages.desc" 31 4.21 + gettext "Missing:"; colorize 31" packages.desc" 4.22 continue 4.23 fi 4.24 separator 4.25 @@ -82,16 +82,16 @@ 4.26 if [ -s "$blocked" ]; then 4.27 cat $blocked 4.28 else 4.29 - gettext "No blocked packages"; echo "" 4.30 + gettext "No blocked packages"; newline 4.31 fi && exit 0 ;; 4.32 --short) 4.33 newline 4.34 - boldify "$(gettext "Installed packages")" 4.35 + boldify $(gettext "Installed packages") 4.36 separator 4.37 for pkg in $(ls -1 $installed) 4.38 do 4.39 . $installed/$pkg/receipt 4.40 - echo -n "$(colorize "$pkg" 32)"; indent 28 " $VERSION" 4.41 + echo -n "$(colorize 32 $pkg)"; indent 28 " $VERSION" 4.42 done 4.43 separator 4.44 boldify $(count_installed) 4.45 @@ -110,12 +110,12 @@ 4.46 if [ "$modifiers" ]; then 4.47 modifiers=$installed/$pkg/modifiers 4.48 if [ -f "$modifiers" ]; then 4.49 - boldify "$(gettext "Modifiers for") $pkg" 4.50 + boldify $(gettext "Modifiers for") $pkg 4.51 separator 4.52 cat $modifiers 4.53 separator && newline 4.54 else 4.55 - echo -n "$(boldify "$pkg") " 4.56 + echo -n "$(boldify $pkg) " 4.57 gettext "package was not modified"; newline 4.58 fi 4.59 continue 4.60 @@ -125,7 +125,7 @@ 4.61 cat $installed/$pkg/files.list 4.62 separator 4.63 gettext "Installed files by"; echo -n " $pkg: " 4.64 - colorize "$nb" 32 && newline 4.65 + colorize 32 "$nb" && newline 4.66 done && exit 0 ;; 4.67 esac 4.68 done 4.69 @@ -145,7 +145,7 @@ 4.70 . $pkg/receipt 4.71 count=$(($count + 1)) 4.72 [ "$count" != 1 ] && newline 4.73 - gettext "Package :"; colorize " $PACKAGE" 32 4.74 + gettext "Package :"; colorize 32 " $PACKAGE" 4.75 receipt_info 4.76 done 4.77 separator
5.1 --- a/spk-mirror Fri May 18 21:24:30 2012 +0200 5.2 +++ b/spk-mirror Sat May 19 03:51:05 2012 -0500 5.3 @@ -46,7 +46,7 @@ 5.4 gettext "Checking file:"; echo -n " $file" 5.5 if ! wget -q -s -T 6 ${1}${list} 2>/dev/null; then 5.6 newline 5.7 - gettext "Unable to reach:"; colorize " $file" 31 5.8 + gettext "Unable to reach:"; colorize 31 " $file" 5.9 newline && return 1 5.10 fi 5.11 status 5.12 @@ -67,7 +67,7 @@ 5.13 nb=$(cat $extradb/$db/packages.$SUM 2>/dev/null | wc -l) 5.14 echo -n "Extra DB :"; boldify " $db" 5.15 echo -n "Extra URL :"; echo " $(cat $extradb/$db/mirror)" 5.16 - gettext "Packages :"; colorize " $nb" 32 5.17 + gettext "Packages :"; colorize 32 " $nb" 5.18 } 5.19 5.20 # Add a package to packages.* lists 5.21 @@ -119,13 +119,13 @@ 5.22 boldify " $(cat $mirrorurl)" 5.23 if [ -f "$mirrors" ]; then 5.24 nb=$(cat $mirrors | wc -l) 5.25 - gettext "Mirrors :"; colorize " $nb " $excolor 5.26 + gettext "Mirrors :"; colorize $excolor " $nb " 5.27 fi 5.28 if [ -d "$extradb" ]; then 5.29 extra=$(ls $extradb | wc -l) 5.30 fi 5.31 [ "$extra" != 0 ] || excolor=31 5.32 - gettext "Extra :"; colorize " $extra" $excolor 5.33 + gettext "Extra :"; colorize $excolor " $extra" 5.34 separator 5.35 newline 5.36 if [ "$list" ]; then 5.37 @@ -163,10 +163,10 @@ 5.38 extra_db 5.39 if [ -d "$extradb/$db" ]; then 5.40 gettext "Removing extra mirror:" 5.41 - echo -n " $(boldify "$db")" 5.42 + echo -n " $(boldify $db)" 5.43 rm -rf $extradb/$db && status 5.44 else 5.45 - gettext "Not an extra mirror:"; colorize " $db" 31 5.46 + gettext "Not an extra mirror:"; colorize 31 " $db" 5.47 fi 5.48 newline && continue 5.49 fi 5.50 @@ -180,7 +180,7 @@ 5.51 i486) arch="/" ;; 5.52 esac 5.53 url=${url}packages/${SLITAZ_RELEASE}${arch} 5.54 - echo "URL: $(boldify "$url")" 5.55 + echo "URL: $(boldify $url)" 5.56 echo "$url" > $mirrorurl 5.57 newline && continue 5.58 fi 5.59 @@ -192,7 +192,7 @@ 5.60 else 5.61 boldify $(gettext "Enabling: extra mirror") 5.62 separator 5.63 - echo "URL: $(boldify "$url")" 5.64 + echo "URL: $(boldify $url)" 5.65 if ! check_mirror $url; then 5.66 continue 5.67 fi 5.68 @@ -214,7 +214,7 @@ 5.69 fi 5.70 newline 5.71 gettext "Directory:"; boldify " $pkgsdir" 5.72 - gettext "Packages :"; colorize " $nb" 32 5.73 + gettext "Packages :"; colorize 32 " $nb" 5.74 cd $pkgsdir 5.75 if [ ! "$nodb" ]; then 5.76 time=$(date +%s) 5.77 @@ -247,7 +247,7 @@ 5.78 time=$(($(date +%s) - $time)) 5.79 echo -n "$nb " 5.80 gettext "packages added in" 5.81 - echo " ${time}s ($(date "+%Y%m%d %H:%M"))" 5.82 + echo " ${time}s ("$(date "+%Y%m%d %H:%M")")" 5.83 fi 5.84 newline 5.85 # Handle --extra: Use local repo as extra mirror with symlinks 5.86 @@ -279,7 +279,7 @@ 5.87 newline && continue 5.88 fi 5.89 gettext "Can't handle:" 5.90 - colorize " $url" 31 && newline ;; 5.91 + colorize 31 " $url"; newline ;; 5.92 esac 5.93 done 5.94
6.1 --- a/spk-rm Fri May 18 21:24:30 2012 +0200 6.2 +++ b/spk-rm Sat May 19 03:51:05 2012 -0500 6.3 @@ -67,9 +67,9 @@ 6.4 . $installed/$pkg/receipt 6.5 6.6 if [ "$altered" ]; then 6.7 - gettext "The following packages depend on"; colorize " $pkg" 31 6.8 + gettext "The following packages depend on"; colorize 31 " $pkg" 6.9 for i in $altered; do 6.10 - echo " $(colorize "$i" 32)" 6.11 + echo " $(colorize 32 $i)" 6.12 done 6.13 fi 6.14 6.15 @@ -169,7 +169,7 @@ 6.16 6.17 # Show all new counted packages in verbose mode 6.18 if [ "$verbose" ]; then 6.19 - gettext "Removed packages:"; colorize " $count" 34 6.20 + gettext "Removed packages:"; colorize 34 " $count" 6.21 fi 6.22 6.23 exit 0
7.1 --- a/testsuite.sh Fri May 18 21:24:30 2012 +0200 7.2 +++ b/testsuite.sh Sat May 19 03:51:05 2012 -0500 7.3 @@ -11,8 +11,8 @@ 7.4 #./spk-rm bc 7.5 7.6 # Check libspk.sh functions usage. 7.7 -echo -n "$(boldify "Checking: libspk.sh functions")" 7.8 -indent 34 "$(colorize $(grep "[a-z]() {" lib/libspk.sh | wc -l) 32)" 7.9 +echo -n $(boldify "Checking: libspk.sh functions") 7.10 +indent 34 $(colorize 32 $(grep "[a-z]() {" lib/libspk.sh | wc -l)) 7.11 separator 7.12 grep "[a-z]() {" lib/libspk.sh | while read line 7.13 do