tazpkg annotate lib/tazpkgbox/list @ rev 317
Added tag 3.2.1 for changeset 55f7f7389343
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Feb 11 11:12:05 2010 +0100 (2010-02-11) |
parents | 3e0b726b512b |
children | 9a3121405428 |
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@300 | 16 PACKAGE=${PACKAGE%% *} |
pascal@300 | 17 if [ -d /var/lib/tazpkg/installed/$PACKAGE ]; then |
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@300 | 30 local cache |
pascal@300 | 31 cache=/var/lib/tazpkg/packages.installable_list.$CAT |
pascal@300 | 32 if [ -s $cache -a $cache -nt /var/lib/tazpkg/packages.desc \ |
pascal@300 | 33 -a $cache -nt /var/lib/tazpkg/installed ]; then |
pascal@300 | 34 cat $cache |
pascal@300 | 35 return |
pascal@300 | 36 fi |
pascal@130 | 37 IFS="|" |
pascal@187 | 38 cat /var/lib/tazpkg/packages.desc \ |
pascal@187 | 39 /var/lib/tazpkg/undigest/*/packages.desc 2> /dev/null | sort | \ |
pascal@315 | 40 while read PACKAGE VERSION SHORT_DESC CATEGORY; do |
pankso@231 | 41 # Check first for category for more speed. |
pankso@231 | 42 CATEGORY=${CATEGORY%| *} |
pascal@245 | 43 ICON=tazpkg |
pascal@315 | 44 [ $CAT == all -o $CATEGORY == " $CAT " ] || continue |
pascal@267 | 45 [ -d /var/lib/tazpkg/installed/${PACKAGE%% *} ] && continue |
pascal@245 | 46 grep -qs "^$PACKAGE" /var/lib/tazpkg/undigest/*/packages.desc && |
pascal@245 | 47 ICON=add |
pascal@245 | 48 echo "$ICON|$PACKAGE|$VERSION|$SHORT_DESC" |
pascal@300 | 49 done | tee $cache |
pascal@130 | 50 unset IFS |
pascal@130 | 51 } |
pascal@130 | 52 |
pascal@130 | 53 installed_list() |
pascal@130 | 54 { |
pascal@130 | 55 for pkg in /var/lib/tazpkg/installed/* |
pascal@130 | 56 do |
pascal@130 | 57 . $pkg/receipt |
pascal@245 | 58 ICON=tazpkg-installed |
pascal@300 | 59 [ $CAT == all -o $CATEGORY == $CAT ] || continue |
pascal@245 | 60 grep -qs "^$PACKAGE" /var/lib/tazpkg/undigest/*/packages.desc && |
pascal@245 | 61 ICON=add |
pascal@245 | 62 grep -qs "^$PACKAGE$" /var/lib/tazpkg/blocked-packages.list && |
pascal@245 | 63 ICON=stop |
pascal@245 | 64 echo "$ICON|$PACKAGE|$VERSION|$SHORT_DESC" |
pascal@130 | 65 done |
pascal@130 | 66 } |
pascal@130 | 67 |
pankso@231 | 68 all_list() |
pankso@231 | 69 { |
pascal@300 | 70 local cache |
pascal@300 | 71 cache=/var/lib/tazpkg/packages.all_list.$CAT |
pascal@300 | 72 if [ -s $cache -a $cache -nt /var/lib/tazpkg/packages.desc \ |
pascal@300 | 73 -a $cache -nt /var/lib/tazpkg/installed ]; then |
pascal@300 | 74 cat $cache |
pascal@300 | 75 return |
pascal@300 | 76 fi |
pascal@300 | 77 ( installable_list ; installed_list ) | sort -t \| -k 2 -u | tee $cache |
pankso@231 | 78 } |
pankso@231 | 79 |
pascal@178 | 80 blocked_list() |
pascal@178 | 81 { |
pascal@300 | 82 for pkg in $(cat /var/lib/tazpkg/blocked-packages.list 2> /dev/null); do |
pascal@300 | 83 [ -f /var/lib/tazpkg/installed/$pkg/receipt ] || continue |
pascal@300 | 84 . /var/lib/tazpkg/installed/$pkg/receipt |
pascal@300 | 85 AVAILABLE=$(grep -s "^$pkg " /var/lib/tazpkg/packages.desc \ |
pascal@300 | 86 /var/lib/tazpkg/undigest/*/packages.desc | awk '{ print $3 }') |
pascal@300 | 87 echo "stop|$PACKAGE|$VERSION (Available: $AVAILABLE)|$SHORT_DESC" |
pascal@178 | 88 done |
pascal@178 | 89 } |
pascal@178 | 90 |
pankso@81 | 91 case $1 in |
pankso@231 | 92 all) |
pankso@231 | 93 STATUS=`cat /tmp/tazpkgbox/status` |
pankso@231 | 94 case $STATUS in |
pankso@231 | 95 blocked) |
pankso@231 | 96 blocked_list ;; |
pankso@231 | 97 installed) |
pankso@231 | 98 CAT=`cat /tmp/tazpkgbox/category` |
pankso@231 | 99 installed_list ;; |
pankso@231 | 100 installable) |
pankso@231 | 101 CAT=`cat /tmp/tazpkgbox/category` |
pankso@231 | 102 installable_list ;; |
pankso@231 | 103 *) |
pankso@231 | 104 CAT=`cat /tmp/tazpkgbox/category` |
pankso@231 | 105 all_list ;; |
pankso@231 | 106 esac ;; |
pascal@187 | 107 undigest) |
pascal@187 | 108 set -- `cat /tmp/tazpkgbox/undigest-category` |
pascal@187 | 109 if [ "$1" == "all" -o "$1" == "" ]; then |
pascal@187 | 110 undigest_list $2 |
pascal@187 | 111 else |
pascal@187 | 112 undigest_list $2 | grep "$1" |
pascal@187 | 113 fi ;; |
pascal@178 | 114 blocked) |
pankso@231 | 115 blocked_list ;; |
pankso@81 | 116 *) |
pankso@231 | 117 echo "Usage: $0 [all|undigest|blocked]" ;; |
pankso@81 | 118 esac |
pankso@81 | 119 |
pankso@81 | 120 exit 0 |