tazpkg view lib/tazpkgbox/list @ rev 347

Add tazpkg french translation (not yet complet)
author Christophe Lincoln <pankso@slitaz.org>
date Sun Jun 20 19:42:10 2010 +0200 (2010-06-20)
parents 317b65f3d2a0
children
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 undigest/$1/packages.desc
12 else
13 cat 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 installed/$PACKAGE ]; then
18 [ "$2" == "installable" ] && continue
19 ICON=tazpkg-installed
20 if grep -qs "^$PACKAGE$" blocked-packages.list; then
21 ICON=stop
22 fi
23 else
24 [ "$2" == "installed" ] && continue
25 fi
26 [ "$2" == "blocked" -a "$ICON" != "stop" ] && continue
27 [ "$2" == "upgradeable" ] &&
28 ! grep -q ^$PACKAGE$ upgradeable-packages.list && continue
29 echo "$ICON|$PACKAGE|$VERSION|$SHORT_DESC"
30 done
31 unset IFS
32 }
34 installable_list()
35 {
36 local cache
37 cache=packages.installable_list.$CAT
38 if [ -s $cache -a $cache -nt packages.desc -a $cache -nt installed ]; then
39 cat $cache
40 return
41 fi
42 IFS="|"
43 cat packages.desc undigest/*/packages.desc 2> /dev/null | sort | \
44 while read PACKAGE VERSION SHORT_DESC CATEGORY; do
45 # Check first for category for more speed.
46 CATEGORY=${CATEGORY%| *}
47 ICON=tazpkg
48 [ $CAT == all -o $CATEGORY == " $CAT " ] || continue
49 [ -d installed/${PACKAGE%% *} ] && continue
50 grep -qs "^$PACKAGE" undigest/*/packages.desc && ICON=add
51 echo "$ICON|$PACKAGE|$VERSION|$SHORT_DESC"
52 done | tee $cache
53 unset IFS
54 }
56 installed_list()
57 {
58 for pkg in ${1}installed/*
59 do
60 [ -n "$1" -a -s installed/$(basename $pkg)/receipt ] && continue
61 . $pkg/receipt
62 ICON=tazpkg-installed
63 [ $CAT == all -o $CATEGORY == $CAT ] || continue
64 if [ -n "$1" -o -L $pkg ]; then
65 ICON=media-flash
66 else
67 grep -qs "^$PACKAGE" undigest/*/packages.desc && ICON=add
68 fi
69 grep -qs "^$PACKAGE$" blocked-packages.list && ICON=stop
70 echo "$ICON|$PACKAGE|$VERSION|$SHORT_DESC"
71 done
72 }
74 all_list()
75 {
76 local cache
77 cache=packages.all_list.$CAT
78 if [ -s $cache -a $cache -nt packages.desc -a $cache -nt installed ]; then
79 cat $cache
80 return
81 fi
82 ( installable_list ; installed_list ) | sort -t \| -k 2 -u | tee $cache
83 }
85 blocked_list()
86 {
87 ICON=tazpkg-installed
88 [ "$1" = "blocked" ] && ICON=stop
89 for pkg in $(cat $1-packages.list 2> /dev/null); do
90 [ -f installed/$pkg/receipt ] || continue
91 . installed/$pkg/receipt
92 [ $CAT == all -o $CATEGORY == $CAT ] || continue
93 AVAILABLE=$(grep -s "^$pkg " packages.desc \
94 undigest/*/packages.desc | awk '{ print $3 }')
95 echo "$ICON|$PACKAGE|$VERSION (Available: $AVAILABLE)|$SHORT_DESC"
96 done
97 }
99 cd /var/lib/tazpkg
100 CAT=`cat /tmp/tazpkgbox/category`
101 case $1 in
102 all)
103 STATUS=`cat /tmp/tazpkgbox/status`
104 case $STATUS in
105 blocked|upgradeable)
106 blocked_list $STATUS;;
107 linkable)
108 [ -d fslink ] && installed_list \
109 $(readlink fslink)/var/lib/tazpkg/;;
110 installed)
111 installed_list ;;
112 installable)
113 installable_list ;;
114 *)
115 all_list ;;
116 esac ;;
117 undigest)
118 set -- `cat /tmp/tazpkgbox/undigest-category`
119 if [ "$1" == "all" -o "$1" == "" ]; then
120 undigest_list $2 $3
121 else
122 undigest_list $2 $3 | grep "$1"
123 fi ;;
124 blocked|upgradeable)
125 blocked_list $1;;
126 *)
127 echo "Usage: $0 [all|undigest|blocked|upgradeable]" ;;
128 esac
130 exit 0