tazpkg annotate lib/tazpkgbox/list @ rev 267
tazpkgbox: show installed, non-mirror packages for Status=all
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon May 25 21:36:28 2009 +0200 (2009-05-25) |
parents | fe0931b59be1 |
children | 3e0b726b512b |
rev | line source |
---|---|
pankso@81 | 1 #!/bin/sh |
pankso@81 | 2 # |
pankso@81 | 3 # List installed packages in a suitable format for GTK tree. |
pankso@81 | 4 # List mirrored packages using the packages.desc file. |
pankso@81 | 5 # |
pankso@81 | 6 |
pascal@187 | 7 undigest_list() |
pascal@187 | 8 { |
pascal@187 | 9 IFS="|" |
pascal@213 | 10 if [ -n "$1" -a "$1" != "all" ]; then |
pascal@187 | 11 cat /var/lib/tazpkg/undigest/$1/packages.desc |
pascal@187 | 12 else |
pascal@187 | 13 cat /var/lib/tazpkg/undigest/*/packages.desc |
pascal@187 | 14 fi 2> /dev/null | sort | while read PACKAGE VERSION SHORT_DESC; do |
pascal@243 | 15 ICON=tazpkg |
pascal@243 | 16 if [ -d /var/lib/tazpkg/installed/${PACKAGE%% *} ]; then |
pascal@243 | 17 . /var/lib/tazpkg/installed/${PACKAGE%% *}/receipt |
pascal@243 | 18 ICON=tazpkg-installed |
pascal@244 | 19 if grep -qs "^$PACKAGE$" /var/lib/tazpkg/blocked-packages.list; then |
pascal@244 | 20 ICON=stop |
pascal@244 | 21 fi |
pascal@243 | 22 fi |
pascal@243 | 23 echo "$ICON|$PACKAGE|$VERSION|$SHORT_DESC" |
pascal@187 | 24 done |
pascal@187 | 25 unset IFS |
pascal@187 | 26 } |
pascal@187 | 27 |
pascal@130 | 28 installable_list() |
pascal@130 | 29 { |
pascal@130 | 30 IFS="|" |
pascal@187 | 31 cat /var/lib/tazpkg/packages.desc \ |
pascal@187 | 32 /var/lib/tazpkg/undigest/*/packages.desc 2> /dev/null | sort | \ |
pascal@130 | 33 while read PACKAGE VERSION SHORT_DESC; do |
pankso@231 | 34 # Check first for category for more speed. |
pankso@231 | 35 CATEGORY=${CATEGORY%| *} |
pascal@245 | 36 ICON=tazpkg |
pascal@267 | 37 [ "$CAT" == "all" -o "$CATEGORY" == "$CAT" ] || continue |
pascal@267 | 38 [ -d /var/lib/tazpkg/installed/${PACKAGE%% *} ] && continue |
pascal@245 | 39 grep -qs "^$PACKAGE" /var/lib/tazpkg/undigest/*/packages.desc && |
pascal@245 | 40 ICON=add |
pascal@245 | 41 echo "$ICON|$PACKAGE|$VERSION|$SHORT_DESC" |
pascal@187 | 42 done |
pascal@130 | 43 unset IFS |
pascal@130 | 44 } |
pascal@130 | 45 |
pascal@130 | 46 installed_list() |
pascal@130 | 47 { |
pascal@130 | 48 for pkg in /var/lib/tazpkg/installed/* |
pascal@130 | 49 do |
pascal@130 | 50 . $pkg/receipt |
pascal@245 | 51 ICON=tazpkg-installed |
pascal@245 | 52 [ "$CAT" == "all" -o "$CATEGORY" == "$CAT" ] || continue |
pascal@245 | 53 grep -qs "^$PACKAGE" /var/lib/tazpkg/undigest/*/packages.desc && |
pascal@245 | 54 ICON=add |
pascal@245 | 55 grep -qs "^$PACKAGE$" /var/lib/tazpkg/blocked-packages.list && |
pascal@245 | 56 ICON=stop |
pascal@245 | 57 echo "$ICON|$PACKAGE|$VERSION|$SHORT_DESC" |
pascal@130 | 58 done |
pascal@130 | 59 } |
pascal@130 | 60 |
pankso@231 | 61 all_list() |
pankso@231 | 62 { |
pascal@267 | 63 ( installable_list ; installed_list ) | sort -t \| -k 2 -u |
pankso@231 | 64 } |
pankso@231 | 65 |
pascal@178 | 66 blocked_list() |
pascal@178 | 67 { |
pascal@178 | 68 for pkg in /var/lib/tazpkg/installed/* |
pascal@178 | 69 do |
pascal@178 | 70 . $pkg/receipt |
pascal@178 | 71 if grep -qs "^$(basename $pkg)$" /var/lib/tazpkg/blocked-packages.list; then |
pascal@245 | 72 AVAILABLE=$(grep -s "^$(basename $pkg) " /var/lib/tazpkg/packages.desc /var/lib/tazpkg/undigest/*/packages.desc | awk '{ print $3 }') |
pankso@231 | 73 echo "stop|$PACKAGE|$VERSION (Available: $AVAILABLE)|$SHORT_DESC" |
pascal@178 | 74 fi |
pascal@178 | 75 done |
pascal@178 | 76 } |
pascal@178 | 77 |
pankso@81 | 78 case $1 in |
pankso@231 | 79 all) |
pankso@231 | 80 STATUS=`cat /tmp/tazpkgbox/status` |
pankso@231 | 81 case $STATUS in |
pankso@231 | 82 blocked) |
pankso@231 | 83 blocked_list ;; |
pankso@231 | 84 installed) |
pankso@231 | 85 CAT=`cat /tmp/tazpkgbox/category` |
pankso@231 | 86 installed_list ;; |
pankso@231 | 87 installable) |
pankso@231 | 88 CAT=`cat /tmp/tazpkgbox/category` |
pankso@231 | 89 installable_list ;; |
pankso@231 | 90 *) |
pankso@231 | 91 CAT=`cat /tmp/tazpkgbox/category` |
pankso@231 | 92 all_list ;; |
pankso@231 | 93 esac ;; |
pascal@187 | 94 undigest) |
pascal@187 | 95 set -- `cat /tmp/tazpkgbox/undigest-category` |
pascal@187 | 96 if [ "$1" == "all" -o "$1" == "" ]; then |
pascal@187 | 97 undigest_list $2 |
pascal@187 | 98 else |
pascal@187 | 99 undigest_list $2 | grep "$1" |
pascal@187 | 100 fi ;; |
pascal@178 | 101 blocked) |
pankso@231 | 102 blocked_list ;; |
pankso@81 | 103 *) |
pankso@231 | 104 echo "Usage: $0 [all|undigest|blocked]" ;; |
pankso@81 | 105 esac |
pankso@81 | 106 |
pankso@81 | 107 exit 0 |