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