tazpkg diff tazpkg @ rev 598
tazpkg: improve up output and small clean
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Thu May 24 13:36:35 2012 +0200 (2012-05-24) |
parents | 269735758815 |
children | eb1a1a0d392a |
line diff
1.1 --- a/tazpkg Wed May 23 12:54:35 2012 +0000 1.2 +++ b/tazpkg Thu May 24 13:36:35 2012 +0200 1.3 @@ -1,7 +1,7 @@ 1.4 #!/bin/sh 1.5 # Tazpkg - Tiny autonomous zone packages manager. 1.6 # 1.7 -# This is a lightwight packages manager for *.tazpkg files written in SHell 1.8 +# This is a lightwight packages manager for *.tazpkg files written in SHell 1.9 # script. It works well with Busybox ash shell and bash. Tazpkg lets you 1.10 # list, install, remove, download or get information about a package. You can 1.11 # use 'tazpkg usage' to get a list of commands with short descriptions. Tazpkg 1.12 @@ -34,7 +34,7 @@ 1.13 COMMAND=$1 1.14 PACKAGE=${2%/} 1.15 PACKAGE_DIR="$(cd $(dirname $PACKAGE 2>/dev/null) 2>/dev/null; pwd)" 1.16 -[ -n "$PACKAGE" ] && 1.17 +[ -n "$PACKAGE" ] && 1.18 PACKAGE_FILE="$PACKAGE_DIR/${PACKAGE##*/}" 1.19 if [ -f "$PACKAGE" ]; then 1.20 # Set pkg basename for install, extract 1.21 @@ -159,7 +159,7 @@ 1.22 check_for_package_on_cmdline() 1.23 { 1.24 if [ -z "$PACKAGE" ]; then 1.25 - echo "" 1.26 + echo "" 1.27 gettext "Please specify a package name on the command line."; echo 1.28 echo "" 1.29 exit 0 1.30 @@ -302,7 +302,7 @@ 1.31 # get a virtual package from packages.equiv 1.32 virtual_pkg() 1.33 { 1.34 - for i in $(for rep in $priority; do 1.35 + for i in $(for rep in $priority; do 1.36 grep -hs "^$1=" $rep/packages.equiv 1.37 done | sed "s/^$1=//"); do 1.38 if echo $i | fgrep -q : ; then 1.39 @@ -330,10 +330,10 @@ 1.40 sed 's/^ *//') 1.41 [ "$pkg" ] && pkg=$(grep -sh "^$1-$pkg" \ 1.42 $rep/packages.list | head -1) 1.43 - 1.44 + 1.45 # Allow user to call a package with his version number. 1.46 [ "$pkg" ] || pkg=$(grep -sh "^$1$" $rep/packages.list | head -1) 1.47 - 1.48 + 1.49 [ "$pkg" ] || pkg=$(grep -sh "^$1-[0-9]" \ 1.50 $rep/packages.list | head -1) 1.51 [ "$pkg" ] || pkg=$(grep -sh "^$1-.[\.0-9]" \ 1.52 @@ -442,7 +442,7 @@ 1.53 { 1.54 # Avoid dirname errors by checking for argument. 1.55 [ "$1" ] || return 1.56 - 1.57 + 1.58 local dir 1.59 rm -f $1 2>/dev/null 1.60 dir="$1" 1.61 @@ -536,8 +536,8 @@ 1.62 [ -d "$ROOT$i" ] && continue 1.63 echo "- $i" 1.64 check=true 1.65 - done ; 1.66 - $check && for i in *; do 1.67 + done ; 1.68 + $check && for i in *; do 1.69 [ "$i" == "$PACKAGE" ] && continue 1.70 [ -s $i/files.list ] || continue 1.71 awk "{ printf \"$i %s\\n\",\$1 }" < $i/files.list 1.72 @@ -712,7 +712,7 @@ 1.73 fi 1.74 } 1.75 1.76 -# Install all missing deps. Auto install or ask user then install all missing 1.77 +# Install all missing deps. Auto install or ask user then install all missing 1.78 # deps from local dir, cdrom, media or from the mirror. In case we want to 1.79 # install packages from local, we need a packages.list to find the version. 1.80 install_deps() 1.81 @@ -927,10 +927,10 @@ 1.82 install_flavor() 1.83 { 1.84 check_root 1.85 - 1.86 + 1.87 # Get repositories priority list. 1.88 look_for_priority 1.89 - 1.90 + 1.91 FLAVOR=$1 1.92 ARG=$2 1.93 mkdir -p $TMP_DIR 1.94 @@ -1433,10 +1433,10 @@ 1.95 misc) gettext "misc" ;; 1.96 meta) gettext "meta" ;; 1.97 non-free) gettext "non-free" ;; 1.98 - 1.99 + 1.100 # Support custom categories by keeping them untranslated. 1.101 *) echo "$1" ;; 1.102 - 1.103 + 1.104 esac 1.105 } 1.106 1.107 @@ -1457,12 +1457,12 @@ 1.108 `gettext "misc"`) echo "misc" ;; 1.109 `gettext "meta"`) echo "meta" ;; 1.110 `gettext "non-free"`) echo "non-free" ;; 1.111 - 1.112 + 1.113 # If category is not one of those translated in native language, 1.114 # keep it untranslated. This allows both native and english 1.115 # language support. This also supports custom categories. 1.116 *) echo "$1" ;; 1.117 - 1.118 + 1.119 esac 1.120 } 1.121 1.122 @@ -1714,7 +1714,7 @@ 1.123 echo "" 1.124 echo -e "\033[1m`gettext \"Search result for file\"`\033[0m $2" 1.125 separator 1.126 - 1.127 + 1.128 if [ "$3" == "--mirror" ]; then 1.129 1.130 match=0 1.131 @@ -1762,7 +1762,7 @@ 1.132 eval_gettext "\$match file(s) found for: \$pkg"; echo 1.133 echo "" 1.134 fi ;; 1.135 - search-pkgname) 1.136 + search-pkgname) 1.137 # Search for a package name 1.138 if [ -z "$2" ]; then 1.139 echo "" 1.140 @@ -1774,7 +1774,7 @@ 1.141 echo "" 1.142 echo -e "\033[1m`gettext \"Search result for file\"`\033[0m $2" 1.143 separator 1.144 - 1.145 + 1.146 # Search for a file on mirror and output only the package name 1.147 match=0 1.148 for i in $LOCALSTATE/files.list.lzma \ 1.149 @@ -1799,7 +1799,7 @@ 1.150 check_root 1.151 check_for_package_on_cmdline 1.152 check_for_package_file 1.153 - 1.154 + 1.155 [ "$root" ] && ROOT="$root" && check_base_dir "$root" 1.156 [ "$list" ] && INSTALL_LIST="$list" 1.157 if [ "$rootconfig" ]; then 1.158 @@ -1822,8 +1822,8 @@ 1.159 fi 1.160 install_package $ROOT 1.161 update_desktop_database $ROOT 1.162 - update_mime_database $ROOT 1.163 - update_icon_database $ROOT 1.164 + update_mime_database $ROOT 1.165 + update_icon_database $ROOT 1.166 compile_glib_schemas $ROOT ;; 1.167 install-list|get-install-list) 1.168 # Install a set of packages from a list. 1.169 @@ -1905,8 +1905,8 @@ 1.170 # Remove packages. 1.171 check_root 1.172 check_for_package_on_cmdline 1.173 - 1.174 - [ "$root" ] && ROOT="$root" 1.175 + 1.176 + [ "$root" ] && ROOT="$root" 1.177 if [ ! -f "$ROOT$INSTALLED/$PACKAGE/receipt" ]; then 1.178 echo "" 1.179 eval_gettext "\$PACKAGE is not installed."; echo 1.180 @@ -2268,7 +2268,7 @@ 1.181 # must have only the choosen main mirror. 1.182 # 1.183 check_root 1.184 - 1.185 + 1.186 ARG=$2 1.187 if [ "$root" ]; then 1.188 LOCALSTATE=$root$LOCALSTATE 1.189 @@ -2285,11 +2285,11 @@ 1.190 fi 1.191 else 1.192 repository_to_recharge="$LOCALSTATE $LOCALSTATE/undigest/*" 1.193 - fi 1.194 + fi 1.195 for path in $repository_to_recharge; do 1.196 [ -f $path/mirror ] || continue 1.197 cd $path 1.198 - 1.199 + 1.200 # Quietly check if recharging is needed. 1.201 [ -f ID ] && mv ID ID.bak 1.202 download_from "$(cat mirror)" ID >/dev/null 2>/dev/null 1.203 @@ -2310,7 +2310,7 @@ 1.204 cat ID.bak > ID 1.205 rm ID.bak 1.206 fi 1.207 - 1.208 + 1.209 echo "" 1.210 if [ "$path" != "$LOCALSTATE" ]; then 1.211 echo -e "`gettext \"Recharging undigest\"` $(basename $path):" 1.212 @@ -2330,9 +2330,9 @@ 1.213 for i in desc md5 txt list equiv; do 1.214 download_from "$(cat mirror)" packages.$i 1.215 done 1.216 - download_from "$(cat mirror)" files.list.lzma 1.217 + download_from "$(cat mirror)" files.list.lzma 1.218 download_from "$(sed 's|packages/.*||' < mirror)" mirrors 1.219 - 1.220 + 1.221 if [ -f "packages.list.bak" ]; then 1.222 diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff 1.223 sed -i s/+// packages.diff 1.224 @@ -2365,7 +2365,7 @@ 1.225 # upgradeable out-of-date. This new way is much, much more faster! 1.226 # Look into installed packages and get data from receipt, it is fast 1.227 # and easy to handle vars after using only md5sum to compare packages 1.228 - # 1.229 + # 1.230 # Options available for the command: up 1.231 if [ "$COMMAND" == "--help-up" ]; then 1.232 usage_up 1.233 @@ -2382,6 +2382,7 @@ 1.234 install="n" ;; 1.235 esac 1.236 done 1.237 + time=$(date +%s) 1.238 installed_sum=$LOCALSTATE/installed.$SUM 1.239 look_for_priority 1.240 for repo in $priority; do 1.241 @@ -2397,10 +2398,10 @@ 1.242 tazpkg recharge $repo_name 1.243 fi 1.244 done 1.245 - echo -en "\n\033[1m" 1.246 - gettext "Package" 1.247 - echo -en "\033[26G " && gettext "Update type" 1.248 - echo -e "\033[0m" 1.249 + newline 1.250 + boldify $(gettext "Package") \ 1.251 + $(echo -n $(indent 28 $(gettext "Version"))) \ 1.252 + $(echo -n $(indent 48 $(gettext "Status"))) 1.253 separator 1.254 cd $INSTALLED 1.255 echo "" > $UP_LIST 1.256 @@ -2421,19 +2422,22 @@ 1.257 # in this one. 1.258 grep -q ^$PACKAGE- $pkg_list || continue 1.259 1.260 + echo -n "$PACKAGE" 1.261 + echo -n $(indent 28 "$VERSION") 1.262 + 1.263 # Skip pkgs listed in $LOCALSTATE/blocked-packages.list 1.264 if $(grep -qs "^$PACKAGE" $BLOCKED); then 1.265 - blocked_count=$(($blocked_count+1)) 1.266 + blocked_count=$(($blocked_count + 1)) 1.267 + colorize 31 $(indent 48 $(gettext "Blocked")) 1.268 break 1.269 fi 1.270 - 1.271 + 1.272 new=$(grep "^$PACKAGE |" $pkg_desc | awk '{print $3}') 1.273 + 1.274 if [ "$VERSION" == "$new" ]; then 1.275 - echo -n "$PACKAGE" 1.276 - echo -e "\\033[26G `gettext \"New build :\"` $md5" 1.277 + colorize 34 $(indent 48 $(gettext "New build")) 1.278 else 1.279 - echo -n "$PACKAGE" 1.280 - echo -e "\\033[26G `gettext \"New version :\"` $new" 1.281 + colorize 32 $(indent 48 $(gettext "New version") $new) 1.282 fi 1.283 echo "$PACKAGE" >> $UP_LIST 1.284 break 1.285 @@ -2443,16 +2447,20 @@ 1.286 sed -i /^$/d $UP_LIST 1.287 upnb=$(cat $UP_LIST | wc -l) 1.288 pkgs=$(ls | wc -l) 1.289 + time=$(($(date +%s) - $time)) 1.290 if [ "$upnb" = 0 ]; then 1.291 install="n" 1.292 gettext -e "System is up-to-date...\n\n" 1.293 - else 1.294 - separator 1.295 + fi 1.296 + separator 1.297 + echo -n "$pkgs "; gettext "installed packages scanned in"; echo " ${time}s" 1.298 + newline 1.299 + if [ "$upnb" != 0 ]; then 1.300 echo -en "\033[1m" 1.301 if [ "$blocked_count" -gt 0 ]; then 1.302 blocks=`eval_gettext " (\$blocked_count blocked)"` 1.303 fi 1.304 - eval_gettext "You have \$upnb available upgrades\$blocks on \$pkgs installed packages" 1.305 + eval_gettext "You have \$upnb available upgrades\$blocks" 1.306 echo -e "\033[0m\n" 1.307 fi 1.308 # Pkgs to upgrade ? Skip, let install them all or ask user 1.309 @@ -2503,10 +2511,10 @@ 1.310 check) 1.311 # Check installed packages set. 1.312 check_root 1.313 - 1.314 + 1.315 # Get repositories priority list. 1.316 look_for_priority 1.317 - 1.318 + 1.319 cd $INSTALLED 1.320 for PACKAGE in `ls`; do 1.321 if [ ! -f $PACKAGE/receipt ]; then 1.322 @@ -2631,7 +2639,7 @@ 1.323 check_root 1.324 check_for_package_on_cmdline 1.325 check_for_packages_list 1.326 - 1.327 + 1.328 [ "$root" ] && ROOT="$root" && check_base_dir "$root" 1.329 if [ "$rootconfig" ]; then 1.330 if [ "$root" ]; then 1.331 @@ -2643,10 +2651,10 @@ 1.332 exit 1 1.333 fi 1.334 fi 1.335 - 1.336 + 1.337 # Get repositories priority list. 1.338 look_for_priority 1.339 - 1.340 + 1.341 CURRENT_DIR=$PWD 1.342 check_for_package_in_list 1.343 cd $CACHE_DIR 1.344 @@ -2672,7 +2680,7 @@ 1.345 check_root 1.346 check_for_package_on_cmdline 1.347 check_for_packages_list 1.348 - 1.349 + 1.350 DO_CHECK="" 1.351 [ "$forced" ] && DO_CHECK=no 1.352 [ "$root" ] && ROOT="$root" && check_base_dir "$root" 1.353 @@ -2726,8 +2734,8 @@ 1.354 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg 1.355 [ "$rootconfig" ] && LOCALSTATE=${LOCALSTATE#$root} 1.356 install_package $ROOT 1.357 - [ "$AUTOEXEC" != "no" ] && $PACKAGE $ROOT 1.358 - update_desktop_database $ROOT 1.359 + [ "$AUTOEXEC" != "no" ] && $PACKAGE $ROOT 1.360 + update_desktop_database $ROOT 1.361 update_mime_database $ROOT ;; 1.362 clean-cache|-cc) 1.363 # Remove all downloaded packages. 1.364 @@ -2879,7 +2887,7 @@ 1.365 convert|-c) 1.366 # convert misc package format to .tazpkg 1.367 check_for_package_file 1.368 - [ -n "$TARGET_DIR" -a -s "$TARGET_DIR/files.list.lzma" ] && 1.369 + [ -n "$TARGET_DIR" -a -s "$TARGET_DIR/files.list.lzma" ] && 1.370 TMPLOCALSTATE="$TARGET_DIR" 1.371 if [ "$(dd if=$PACKAGE_FILE bs=8 count=1 skip=1 2> /dev/null)" \ 1.372 == "debian-b" ]; then