tazpkg view lib/tazpkgbox/package_infos @ rev 211

tazpkgbox: show depends/rdepends tree
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Nov 24 11:41:43 2008 +0000 (2008-11-24)
parents 7c00ac97d6bf
children 39ff491d6b0c
line source
1 #!/bin/sh
2 #
3 # Dialog box to provide package info and actions
4 #
6 XTERM_OPTS="-geometry 80x16+120+120"
8 PKG=`cat /tmp/tazpkgbox/pkg | sed s/" "/""/g`
9 TMP_DIR=/tmp/tazpkg-$$-$RANDOM
11 if [ "$1" = "sizes" ]; then
12 cat <<EOT
13 Dependancies for $2:
14 $(tazpkg depends $2)
16 Reverse dependancies for $2:
17 $(tazpkg rdepends $2)
18 EOT
19 exit 0
20 fi
21 if [ "$1" = "info" ]; then
22 RECEIPT=/var/lib/tazpkg/installed/$3/receipt
23 . $RECEIPT
24 case "$2" in
25 Web*) firefox $WEB_SITE &;;
26 Siz*) xterm -T "$3 depends (q to quit)" -e "$0 sizes $3 | less";;
27 Hand*) firefox $HANDBOOK_URL &;;
28 Sug*) $0 list_packages $SUGGESTED;;
29 Dep*) $0 list_packages $DEPENDS;;
30 Mod*) $0 list_packages $(xargs echo < /var/lib/tazpkg/installed/$3/modifiers);;
31 Con*) tazpkgbox list_config $3;;
32 Ver*) xterm -T "$3 receipt (q to quit)" -e "cat $RECEIPT | less";;
33 esac
34 exit 0
35 fi
37 if [ "$1" = "list_files" ]; then
38 AWK_FILTER='BEGIN { ls=0 } { if (/^===/) ls=1-ls; else if (ls) print; }'
39 CONF_FILES="$(tazpkg list-config $2 | awk "$AWK_FILTER")"
40 if [ -n "$CONF_FILES" ]; then
41 mkdir $TMP_DIR
42 zcat /var/lib/tazpkg/installed/$2/volatile.cpio.gz | \
43 ( cd $TMP_DIR ; cpio -id > /dev/null )
44 fi
45 tazpkg list-files $2 | awk "$AWK_FILTER" | while read file; do
46 echo -n "$(stat -c "%A|%U|%G|%s|%n|" "$file" || \
47 echo "File lost !||||$file|")"
48 if [ -L "$file" ]; then
49 echo -n "$(readlink "$file")"
50 elif [ -f "$file" ]; then
51 case "$CONF_FILES" in
52 *$file*)
53 if cmp $file $TMP_DIR$file > /dev/null 2>&1; then
54 echo -n "[configuration]"
55 else
56 echo -n "$(stat -c "[configuration: %.16y]" $file)"
57 fi;;
58 #* if [ "$(tazpkg check-file $file $2)" = "failure" ]; then
59 # echo -n "Invalid md5"
60 # fi;;
61 esac
62 fi
63 echo ""
64 done
65 [ -n "$CONF_FILES" ] && rm -rf $TMP_DIR
66 exit 0
67 fi
69 if [ "$1" = "list_files_mirror" ]; then
70 for i in /var/lib/tazpkg/files.list.lzma \
71 /var/lib/tazpkg/undigest/*/files.list.lzma ; do
72 [ -f $i ] || continue
73 unlzma -c $i
74 done | grep -- "^$2:" | awk '{ print substr($0,index($0,":")+2) }'
75 exit 0
76 fi
78 if [ "$1" = "list_packages" ]; then
79 PKG="$2"
80 if [ -n "$3" ]; then
81 shift
82 export LIST_PKGS='
83 <window title="Packages" icon-name="tazpkg">
84 <vbox>
85 <tree>
86 <width>600</width><height>160</height>
87 <label>Package|Version|Size|Description</label>
88 <variable>PKG</variable>
89 '
90 for i in "$@"; do
91 if [ -d /var/lib/tazpkg/installed/$i ]; then
92 . /var/lib/tazpkg/installed/$i/receipt
93 LIST_PKGS="$LIST_PKGS
94 <item icon=\"tazpkg\">$i|$VERSION|Installed|$SHORT_DESC</item>
95 "
96 else
97 RES=`grep -sh "^$i " \
98 /var/lib/tazpkg/packages.desc \
99 /var/lib/tazpkg/undigest/*/packages.desc`
100 PACKAGE=`echo "$RES" | cut -d "|" -f 1`
101 VERSION=`echo "$RES" | cut -d "|" -f 2`
102 SHORT_DESC=`echo "$RES" | cut -d "|" -f 3`
103 SIZE=`grep -sh -A 3 "^$(echo $PACKAGE)$" \
104 /var/lib/tazpkg/packages.txt \
105 /var/lib/tazpkg/undigest/*/packages.txt | \
106 tail -1 | sed 's/.*(\(.*\) .*/\1/'`
107 LIST_PKGS="$LIST_PKGS
108 <item icon=\"tazpkg\">$i|$VERSION|$SIZE|$SHORT_DESC</item>
109 "
110 fi
111 done
112 LIST_PKGS="$LIST_PKGS
113 <action>echo "\$PKG" > /tmp/tazpkgbox/pkg</action>
114 <action>/usr/lib/slitaz/tazpkgbox/package_infos</action>
115 <action>refresh:PKG</action>
116 <action>refresh:PKG_STATS</action>
117 <action>refresh:CACHE_STATS</action>
118 </tree>
119 <hbox>
120 <button ok>
121 </button>
122 <button cancel>
123 <action type=\"closewindow\">LIST_PKGS</action>
124 </button>
125 </hbox>
126 </vbox>
127 </window>
128 "
129 eval `gtkdialog --center --program=LIST_PKGS`
130 [ "$EXIT" = "OK" ] || exit 0
131 fi
132 fi
134 export LIST_FILES="
135 <window title=\"$PKG files\" icon-name=\"system-file-manager\">
136 <vbox>
137 <tree exported_column=\"4\">
138 <variable>FILE</variable>
139 <width>600</width><height>160</height>
140 <label>Access | User | Group | Size | Name | Target</label>
141 <input> $0 list_files $PKG </input>
142 <action>tazpkg list-config $PKG | grep -q ^\$FILE$ && leafpad \$FILE</action>
143 </tree>
144 <hbox>
145 <button>
146 <input file icon=\"gtk-close\"></input>
147 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
148 </button>
149 </hbox>
150 </vbox>
151 </window>
152 "
154 export LIST_FILES_MIRROR="
155 <window title=\"$PKG files\" icon-name=\"system-file-manager\">
156 <vbox>
157 <tree>
158 <width>300</width><height>160</height>
159 <label>File Name</label>
160 <input> $0 list_files_mirror $PKG </input>
161 </tree>
162 <hbox>
163 <button>
164 <input file icon=\"gtk-close\"></input>
165 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
166 </button>
167 </hbox>
168 </vbox>
169 </window>
170 "
172 # Installed or not installed, that the question.
173 if [ -d /var/lib/tazpkg/installed/$PKG ]; then
174 PACKED_SIZE=""
175 DEPENDS=""
176 MAINTAINER=""
177 BUGS=""
178 . /var/lib/tazpkg/installed/$PKG/receipt
179 MAINTAINER=$(echo "$MAINTAINER" | sed 's/[<>|]/ /g')
180 PACKAGE_INFOS="
181 <window title=\"Package: $PKG\" icon-name=\"package-x-generic\">
182 <vbox>
184 <tree>
185 <width>460</width><height>200</height>
186 <label>$PKG|$SHORT_DESC</label>
187 <variable>FIELD</variable>
188 <item icon=\"tazpkg\">Version: | $VERSION</item>
189 <item icon=\"tazpkg\">Category: | $CATEGORY</item>"
190 [ -n "$DEPENDS" ] && PACKAGE_INFOS="$PACKAGE_INFOS
191 <item icon=\"tazpkg\">Depends: | $(echo $DEPENDS)</item>"
192 [ -n "$SUGGESTED" ] && PACKAGE_INFOS="$PACKAGE_INFOS
193 <item icon=\"tazpkg\">Suggested: | $(echo $SUGGESTED)</item>"
194 [ -n "$PACKED_SIZE" ] && PACKAGE_INFOS="$PACKAGE_INFOS
195 <item icon=\"tazpkg\">Size: | $PACKED_SIZE ($UNPACKED_SIZE installed)</item>"
196 [ -n "$MAINTAINER" ] && PACKAGE_INFOS="$PACKAGE_INFOS
197 <item icon=\"system-users\">Maintainer: | $MAINTAINER</item>"
198 [ -n "$BUGS" ] && PACKAGE_INFOS="$PACKAGE_INFOS
199 <item icon=\"important\">Bugs: | $BUGS</item>"
200 [ -n "$HANDBOOK_URL" ] && PACKAGE_INFOS="$PACKAGE_INFOS
201 <item icon=\"ascii\">Handbook: | $HANDBOOK_URL</item>"
202 [ -n "$CONFIG_FILES" ] && PACKAGE_INFOS="$PACKAGE_INFOS
203 <item icon=\"tazpkg\">Config files: | $CONFIG_FILES</item>"
204 [ -f /var/lib/tazpkg/installed/$PKG/modifiers ] &&
205 PACKAGE_INFOS="$PACKAGE_INFOS
206 <item icon=\"tazpkg\">Modified by: | $(xargs echo < /var/lib/tazpkg/installed/$PKG/modifiers)</item>"
207 PACKAGE_INFOS="$PACKAGE_INFOS
208 <item icon=\"applications-internet\">Web site: | $WEB_SITE</item>
209 <action> $0 info \"\$FIELD\" $PKG </action>
210 </tree>
212 <hbox>"
213 [ ${PKG%%-*} = get -a ! -d /var/lib/tazpkg/installed/${PKG#get-} ] && PACKAGE_INFOS="$PACKAGE_INFOS
214 <button>
215 <label>Install</label>
216 <input file icon=\"go-next\"></input>
217 <action>xterm -T \"Install ${PKG#get-}\" $XTERM_OPTS -e \"\
218 $PKG; sleep 5\"</action>
219 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
220 </button>"
221 grep -q post_install /var/lib/tazpkg/installed/$PKG/receipt && PACKAGE_INFOS="$PACKAGE_INFOS
222 <button>
223 <label>Reconfigure</label>
224 <input file icon=\"reload\"></input>
225 <action>xterm -T \"Reconfigure $PACKAGE\" $XTERM_OPTS -e \"\
226 tazpkg reconfigure $PACKAGE; sleep 2\"</action>
227 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
228 </button>"
229 if grep -qs ^$PKG$ /var/lib/tazpkg/blocked-packages.list; then
230 PACKAGE_INFOS="$PACKAGE_INFOS
231 <button>
232 <label>Unblock</label>
233 <input file icon=\"up\"></input>
234 <action>xterm -T \"Unblock $PACKAGE\" $XTERM_OPTS -e \"\
235 tazpkg unblock $PACKAGE; sleep 2\"</action>
236 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
237 </button>"
238 else
239 PACKAGE_INFOS="$PACKAGE_INFOS
240 <button>
241 <label>Block</label>
242 <input file icon=\"down\"></input>
243 <action>xterm -T \"Block $PACKAGE\" $XTERM_OPTS -e \"\
244 tazpkg block $PACKAGE; sleep 2\"</action>
245 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
246 </button>"
247 fi
248 PACKAGE_INFOS="$PACKAGE_INFOS
249 <button>
250 <label>Remove</label>
251 <input file icon=\"edit-delete\"></input>
252 <action>xterm -T \"Remove $PACKAGE\" $XTERM_OPTS -e \"\
253 tazpkg remove $PACKAGE; sleep 2\"</action>
254 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
255 </button>
256 <button>
257 <label>Repack</label>
258 <input file icon=\"edit-redo\"></input>
259 <action>xterm -T \"Repack $PACKAGE\" $XTERM_OPTS -e \"\
260 cd /var/cache/tazpkg; \
261 tazpkg repack $PACKAGE; sleep 2\"</action>
262 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
263 </button>
264 <button>
265 <label>Files</label>
266 <input file icon=\"tazpkg\"></input>
267 <action type=\"launch\">LIST_FILES</action>
268 </button>
269 <button>
270 <input file icon=\"gtk-close\"></input>
271 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
272 </button>
273 </hbox>
275 </vbox>
276 </window>
277 "
278 export PACKAGE_INFOS
279 else
280 RES=`grep -sh "^$PKG " /var/lib/tazpkg/packages.desc \
281 /var/lib/tazpkg/undigest/*/packages.desc`
282 PACKAGE=`echo "$RES" | cut -d "|" -f 1`
283 VERSION=`echo "$RES" | cut -d "|" -f 2`
284 SHORT_DESC=`echo "$RES" | cut -d "|" -f 3`
285 CATEGORY=`echo "$RES" | cut -d "|" -f 4`
286 WEB_SITE=`echo "$RES" | cut -d "|" -f 5`
287 SIZES=`grep -sh -A 3 "^$(echo $PACKAGE)$" /var/lib/tazpkg/packages.txt \
288 /var/lib/tazpkg/undigest/*/packages.txt | tail -1`
289 PACKAGE_INFOS="
290 <window title=\"Package: $PACKAGE\" icon-name=\"package-x-generic\">
291 <vbox>
293 <tree>
294 <width>460</width><height>160</height>
295 <label>$PKG|$SHORT_DESC</label>
296 <variable>FIELD2</variable>
297 <item icon=\"tazpkg\">Name: | $PACKAGE</item>
298 <item icon=\"tazpkg\">Version: | $VERSION</item>
299 <item icon=\"tazpkg\">Category: | $CATEGORY</item>"
300 [ -n "$SIZES" ] && PACKAGE_INFOS="$PACKAGE_INFOS
301 <item icon=\"tazpkg\">Size: | $SIZES</item>"
302 PACKAGE_INFOS="$PACKAGE_INFOS
303 <item icon=\"applications-internet\">Web site: | $WEB_SITE</item>
304 <action>case \$FIELD2 in Web*) firefox $WEB_SITE &;; esac</action>
305 </tree>
307 <hbox>"
308 [ ${PACKAGE%%-*} = get ] && PACKAGE_INFOS="$PACKAGE_INFOS
309 <checkbox>
310 <label>Auto exec</label>
311 <variable>AUTO_EXEC</variable>
312 <default>true</default>
313 </checkbox>"
314 PACKAGE_INFOS="$PACKAGE_INFOS
315 <checkbox>
316 <label>Auto install depends</label>
317 <variable>AUTO_DEPENDS</variable>
318 <default>true</default>
319 </checkbox>
320 <button>
321 <label>Get-install</label>
322 <input file icon=\"go-next\"></input>
323 <action>xterm -T \"Install $PACKAGE\" $XTERM_OPTS -e \"\
324 if [ x\$AUTO_DEPENDS != xtrue ]; then script -c \\\"tazpkg get-install $PACKAGE\\\" /var/log/tazpkg-install.log;\
325 else script -c \\\"yes y | tazpkg get-install $PACKAGE\\\" /var/log/tazpkg-install.log; fi; \
326 [ x\${AUTO_EXEC} = xtrue ] && $PACKAGE; \
327 sleep 2\"</action>
328 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
329 </button>
330 <button>
331 <label>Get</label>
332 <input file icon=\"go-next\"></input>
333 <action>xterm -T \"Get $PACKAGE\" $XTERM_OPTS -e \"\
334 cd /var/cache/tazpkg; tazpkg get $PACKAGE; sleep 2\"</action>
335 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
336 </button>
337 <button>
338 <label>Files</label>
339 <input file icon=\"tazpkg\"></input>
340 <action type=\"launch\">LIST_FILES_MIRROR</action>
341 </button>
342 <button>
343 <input file icon=\"gtk-close\"></input>
344 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
345 </button>
346 </hbox>
348 </vbox>
349 </window>
350 "
351 export PACKAGE_INFOS
352 fi
354 gtkdialog --center --program=PACKAGE_INFOS
356 exit 0