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