tazpkg view lib/libtazpkgbox @ rev 350
Move all splited functions to libtazpkgbox (easier for translation)
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sun Jun 20 23:46:40 2010 +0200 (2010-06-20) |
parents | |
children | 4f41dee74425 |
line source
1 #!/bin/sh
2 #
3 # The libtazpkgbox - Libraries used by tazpkg GUI box.
4 # There is functions to list installed packages in a suitable format for
5 # GTK tree and list mirrored packages using the packages.desc file.
6 #
8 export LIB=/usr/lib/slitaz/libtazpkgbox
10 usage()
11 {
12 echo -e "\nTazpkgbox library\n
13 Usage : $0 [function] [pkg|args] [pkg]
14 Functions:
15 list-all List all packages
16 list-undigest List undigest packages
17 list-blocked List blocked packages
18 list-upgradeable List all upgradable packages
19 search-packages Search for packages
20 search-files Search for files
21 search-tags Search for TAGS
22 package-infos Display box with pkg information"
23 }
25 # List functions.
26 undigest_list()
27 {
28 IFS="|"
29 if [ -n "$1" -a "$1" != "all" ]; then
30 cat undigest/$1/packages.desc
31 else
32 cat undigest/*/packages.desc
33 fi 2> /dev/null | sort | while read PACKAGE VERSION SHORT_DESC; do
34 ICON=tazpkg
35 PACKAGE=${PACKAGE%% *}
36 if [ -d installed/$PACKAGE ]; then
37 [ "$2" == "installable" ] && continue
38 ICON=tazpkg-installed
39 if grep -qs "^$PACKAGE$" blocked-packages.list; then
40 ICON=stop
41 fi
42 else
43 [ "$2" == "installed" ] && continue
44 fi
45 [ "$2" == "blocked" -a "$ICON" != "stop" ] && continue
46 [ "$2" == "upgradeable" ] &&
47 ! grep -q ^$PACKAGE$ upgradeable-packages.list && continue
48 echo "$ICON|$PACKAGE|$VERSION|$SHORT_DESC"
49 done
50 unset IFS
51 }
53 installable_list()
54 {
55 local cache
56 cache=packages.installable_list.$CAT
57 if [ -s $cache -a $cache -nt packages.desc -a $cache -nt installed ]; then
58 cat $cache
59 return
60 fi
61 IFS="|"
62 cat packages.desc undigest/*/packages.desc 2> /dev/null | sort | \
63 while read PACKAGE VERSION SHORT_DESC CATEGORY; do
64 # Check first for category for more speed.
65 CATEGORY=${CATEGORY%| *}
66 ICON=tazpkg
67 [ $CAT == all -o $CATEGORY == " $CAT " ] || continue
68 [ -d installed/${PACKAGE%% *} ] && continue
69 grep -qs "^$PACKAGE" undigest/*/packages.desc && ICON=add
70 echo "$ICON|$PACKAGE|$VERSION|$SHORT_DESC"
71 done | tee $cache
72 unset IFS
73 }
75 installed_list()
76 {
77 for pkg in ${1}installed/*
78 do
79 [ -n "$1" -a -s installed/$(basename $pkg)/receipt ] && continue
80 . $pkg/receipt
81 ICON=tazpkg-installed
82 [ $CAT == all -o $CATEGORY == $CAT ] || continue
83 if [ -n "$1" -o -L $pkg ]; then
84 ICON=media-flash
85 else
86 grep -qs "^$PACKAGE" undigest/*/packages.desc && ICON=add
87 fi
88 grep -qs "^$PACKAGE$" blocked-packages.list && ICON=stop
89 echo "$ICON|$PACKAGE|$VERSION|$SHORT_DESC"
90 done
91 }
93 all_list()
94 {
95 local cache
96 cache=packages.all_list.$CAT
97 if [ -s $cache -a $cache -nt packages.desc -a $cache -nt installed ]; then
98 cat $cache
99 return
100 fi
101 ( installable_list ; installed_list ) | sort -t \| -k 2 -u | tee $cache
102 }
104 blocked_list()
105 {
106 ICON=tazpkg-installed
107 [ "$1" = "blocked" ] && ICON=stop
108 for pkg in $(cat $1-packages.list 2> /dev/null); do
109 [ -f installed/$pkg/receipt ] || continue
110 . installed/$pkg/receipt
111 [ $CAT == all -o $CATEGORY == $CAT ] || continue
112 AVAILABLE=$(grep -s "^$pkg " packages.desc \
113 undigest/*/packages.desc | awk '{ print $3 }')
114 echo "$ICON|$PACKAGE|$VERSION (Available: $AVAILABLE)|$SHORT_DESC"
115 done
116 }
118 # Search functions
120 clean_search()
121 {
122 # Clean preview results.
123 rm -f /tmp/tazpkgbox/search
124 touch /tmp/tazpkgbox/search
125 }
127 list_files()
128 {
129 sed 's/.\[[01]m//g' | awk 'BEGIN { show=0 } {
130 if (/^===/) show=1-show;
131 else if (/^Package/) pkg=$2;
132 else if ($0 != "" && show != 0) printf("%s %s\n",pkg,$0);
133 }' | while read pkg file; do
134 [ "$pkg" = "0" ] && continue
135 version=$(grep -hs "^$pkg " /var/lib/tazpkg/packages.desc \
136 /var/lib/tazpkg/undigest/*/packages.desc | awk '{ print $3 }')
137 if [ -d /var/lib/tazpkg/installed/$pkg ]; then
138 if [ -x $file ]; then
139 echo "exec|$pkg|$version|$file"
140 elif [ -f $file ]; then
141 echo "txt|$pkg|$version|$file"
142 elif [ -d $file ] ; then
143 echo "folder|$pkg|$version|$file"
144 else
145 # Missing installed file.
146 echo "dialog-warning|$pkg|$version|$file"
147 fi
148 else
149 echo "tazpkg|$pkg|$version|$file"
150 fi
151 done
152 }
154 list_package()
155 {
156 if [ -d /var/lib/tazpkg/installed/$1 ]; then
157 . /var/lib/tazpkg/installed/$1/receipt
158 echo "tazpkg-installed|$PACKAGE|$VERSION|$SHORT_DESC"
159 else
160 echo "tazpkg|$PACKAGE|$VERSION|$SHORT_DESC"
161 fi
162 }
164 search_package()
165 {
166 IFS="|"
167 cat /var/lib/tazpkg/packages.desc \
168 /var/lib/tazpkg/undigest/*/packages.desc 2> /dev/null | sort | \
169 while read PACKAGE VERSION SHORT_DESC; do
170 if echo "$PACKAGE $SHORT_DESC" | grep -iq "$SEARCH"; then
171 list_package ${PACKAGE%% *}
172 fi
173 done
174 unset IFS
175 }
177 case "$1" in
178 list-all)
179 cd /var/lib/tazpkg
180 CAT=`cat /tmp/tazpkgbox/category`
181 STATUS=`cat /tmp/tazpkgbox/status`
182 case $STATUS in
183 blocked|upgradeable)
184 blocked_list $STATUS;;
185 linkable)
186 [ -d fslink ] && installed_list \
187 $(readlink fslink)/var/lib/tazpkg/;;
188 installed)
189 installed_list ;;
190 installable)
191 installable_list ;;
192 *)
193 all_list ;;
194 esac ;;
195 list-undigest)
196 cd /var/lib/tazpkg
197 CAT=`cat /tmp/tazpkgbox/category`
198 set -- `cat /tmp/tazpkgbox/undigest-category`
199 if [ "$1" == "all" -o "$1" == "" ]; then
200 undigest_list $2 $3
201 else
202 undigest_list $2 $3 | grep "$1"
203 fi ;;
204 list-blocked|list-upgradeable)
205 cd /var/lib/tazpkg
206 CAT=`cat /tmp/tazpkgbox/category`
207 blocked_list $1 ;;
208 search-files)
209 # Search for files
210 clean_search
211 tazpkg search-file "$SEARCH" --mirror | list_files > \
212 /tmp/tazpkgbox/search ;;
213 search-packages)
214 clean_search
215 ( search_package ;
216 for i in $(grep ^$SEARCH= /var/lib/tazpkg/packages.equiv | \
217 cut -d= -f2); do
218 SEARCH=${i#*:}
219 search_package
220 done ) > /tmp/tazpkgbox/search ;;
221 search-tags)
222 clean_search
223 grep -ls TAGS /home/slitaz/wok/*/receipt | while read file; do
224 TAGS=""
225 . $file
226 case "$TAGS" in
227 *$SEARCH*) list_package $PACKAGE ;;
228 esac
229 done > /tmp/tazpkgbox/search ;;
230 package-infos)
231 # Dialog box to provide package info and actions
232 XTERM_OPTS="-geometry 80x16+120+120"
233 PKG=`cat /tmp/tazpkgbox/pkg | sed s/" "/""/g`
234 ROOT=/var/lib/tazpkg
235 if [ "$(cat /tmp/tazpkgbox/status)" = "linkable" ]; then
236 ROOT=$(readlink /var/lib/tazpkg/fslink)$ROOT
237 fi
238 TMP_DIR=/tmp/tazpkg-$$-$RANDOM
239 if [ "$2" = "sizes" ]; then
240 cat <<EOT
241 Dependancies for $3:
242 $(tazpkg depends $3)
244 Reverse dependancies for $3:
245 $(tazpkg rdepends $3)
246 EOT
247 exit 0
248 fi
249 if [ "$2" = "info" ]; then
250 RECEIPT=$ROOT/installed/$4/receipt
251 . $RECEIPT
252 case "$3" in
253 Web*) browser $WEB_SITE &;;
254 Tip*) browser http://hg.slitaz.org/wok/raw-file/tip/$4/receipt &;;
255 Siz*) xterm -T "$4 depends (q to quit)" -e "$0 sizes $4 | less";;
256 Upg*) xterm -T "$4 upgrade" -e "tazpkg get-install $4 --forced ; sleep 2";;
257 Hand*) browser $HANDBOOK_URL &;;
258 Sug*) $0 package-infos list_packages $SUGGESTED;;
259 Dep*) $0 package-infos list_packages $DEPENDS;;
260 Mod*) $0 package-infos list_packages $(xargs echo < $ROOT/installed/$3/modifiers);;
261 Con*) tazpkgbox list_config $4;;
262 Ver*) xterm -T "$4 receipt (q to quit)" -e "cat $RECEIPT | less";;
263 esac
264 exit 0
265 fi
267 if [ "$2" = "list_files" ]; then
268 CONF_FILES="$(tazpkg list-config $3 | awk "$AWK_FILTER")"
269 if [ -n "$CONF_FILES" ]; then
270 mkdir $TMP_DIR
271 zcat $ROOT/installed/$3/volatile.cpio.gz | \
272 ( cd $TMP_DIR ; cpio -id > /dev/null )
273 fi
274 cat $ROOT/installed/$3/files.list | grep ^/ | while read file; do
275 realfile="$file"
276 if [ "$(cat /tmp/tazpkgbox/status)" = "linkable" ]; then
277 realfile="$(readlink /var/lib/tazpkg/fslink)$file"
278 fi
279 echo -n "$(stat -c "%A|%U|%G|%s|$file|" "$realfile" || \
280 echo "File lost !||||$file|")"
281 if [ -L "$realfile" ]; then
282 echo -n "$(readlink "$realfile")"
283 elif [ -f "$file" ]; then
284 case "$CONF_FILES" in
285 *$file*)
286 if cmp $file $TMP_DIR$file > /dev/null 2>&1; then
287 echo -n "[configuration]"
288 else
289 echo -n "$(stat -c "[configuration: %.16y]" $file)"
290 fi;;
291 #* if [ "$(tazpkg check-file $file $2)" = "failure" ]; then
292 # echo -n "Invalid md5"
293 # fi;;
294 esac
295 fi
296 echo ""
297 done
298 [ -n "$CONF_FILES" ] && rm -rf $TMP_DIR
299 exit 0
300 fi
302 if [ "$2" = "list_files_mirror" ]; then
303 for i in /var/lib/tazpkg/files.list.lzma \
304 /var/lib/tazpkg/undigest/*/files.list.lzma ; do
305 [ -f $i ] || continue
306 unlzma -c $i
307 done | grep -- "^$3:" | awk '{ print substr($0,index($0,":")+2) }'
308 exit 0
309 fi
311 if [ "$2" = "list_packages" ]; then
312 PKG="$3"
313 if [ -n "$4" ]; then
314 shift
315 export LIST_PKGS='
316 <window title="Packages" icon-name="tazpkg">
317 <vbox>
318 <tree>
319 <width>600</width><height>160</height>
320 <label>Package|Version|Size|Description</label>
321 <variable>PKG</variable>
322 '
323 for i in "$@"; do
324 if [ -d $ROOT/installed/$i ]; then
325 . $ROOT/installed/$i/receipt
326 LIST_PKGS="$LIST_PKGS
327 <item icon=\"tazpkg\">$i|$VERSION|Installed|$SHORT_DESC</item>
328 "
329 else
330 RES=`grep -sh "^$i " \
331 /var/lib/tazpkg/packages.desc \
332 /var/lib/tazpkg/undigest/*/packages.desc`
333 PACKAGE=`echo "$RES" | cut -d "|" -f 1`
334 VERSION=`echo "$RES" | cut -d "|" -f 2`
335 SHORT_DESC=`echo "$RES" | cut -d "|" -f 3`
336 SIZE=`grep -sh -A 3 "^$(echo $PACKAGE)$" \
337 /var/lib/tazpkg/packages.txt \
338 /var/lib/tazpkg/undigest/*/packages.txt | \
339 tail -1 | sed 's/.*(\(.*\) .*/\1/'`
340 LIST_PKGS="$LIST_PKGS
341 <item icon=\"tazpkg\">$i|$VERSION|$SIZE|$SHORT_DESC</item>
342 "
343 fi
344 done
345 LIST_PKGS="$LIST_PKGS
346 <action>echo "\$PKG" > /tmp/tazpkgbox/pkg</action>
347 <action>$0 package-infos</action>
348 <action>refresh:PKG</action>
349 <action>refresh:PKG_STATS</action>
350 <action>refresh:CACHE_STATS</action>
351 </tree>
352 <hbox>
353 <button ok>
354 </button>
355 <button cancel>
356 <action type=\"closewindow\">LIST_PKGS</action>
357 </button>
358 </hbox>
359 </vbox>
360 </window>
361 "
362 eval `gtkdialog --center --program=LIST_PKGS`
363 [ "$EXIT" = "OK" ] || exit 0
364 fi
365 fi
367 export LIST_FILES="
368 <window title=\"$PKG files\" icon-name=\"system-file-manager\">
369 <vbox>
370 <tree exported_column=\"4\">
371 <variable>FILE</variable>
372 <width>600</width><height>160</height>
373 <label>Access | User | Group | Size | Name | Target</label>
374 <input> $0 package-infos list_files $PKG </input>
375 <action>tazpkg list-config $PKG | grep -q ^\$FILE$ && leafpad \$FILE</action>
376 </tree>
377 <hbox>
378 <button>
379 <input file icon=\"gtk-close\"></input>
380 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
381 </button>
382 </hbox>
383 </vbox>
384 </window>
385 "
387 export LIST_FILES_MIRROR="
388 <window title=\"$PKG files\" icon-name=\"system-file-manager\">
389 <vbox>
390 <tree>
391 <width>300</width><height>160</height>
392 <label>File Name</label>
393 <input> $0 package-infos list_files_mirror $PKG </input>
394 </tree>
395 <hbox>
396 <button>
397 <input file icon=\"gtk-close\"></input>
398 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
399 </button>
400 </hbox>
401 </vbox>
402 </window>
403 "
405 # Installed or not installed, that is the question!
406 if [ -d $ROOT/installed/$PKG ]; then
407 PACKED_SIZE=""
408 DEPENDS=""
409 MAINTAINER=""
410 BUGS=""
411 TAGS=""
412 . $ROOT/installed/$PKG/receipt
413 MAINTAINER=$(echo "$MAINTAINER" | sed 's/[<>|]/ /g')
414 upgrade_version="$(cat /var/lib/tazpkg/packages.desc \
415 /var/lib/tazpkg/undigest/*/packages.desc 2> /dev/null | \
416 awk "/^$PACKAGE / { print \$3 }" | head -1 )"
417 UPGRADE=""
418 if [ -n "$upgrade_version" ]; then
419 if [ "$upgrade_version" != "$VERSION" ]; then
420 UPGRADE="$upgrade_version"
421 else
422 cur_md5="$(awk "/ $PACKAGE-$VERSION/ { print \$1 }" \
423 $ROOT/installed.md5)"
424 new_md5="$(cat /var/lib/tazpkg/packages.md5 \
425 /var/lib/tazpkg/undigest/*/packages.md5 \
426 2> /dev/null | awk "/ $PACKAGE-$VERSION/ { print \$1 }")"
427 if [ -n "$cur_md5" -a -n "$new_md5" -a \
428 "$cur_md5" != "$new_md5" ]; then
429 UPGRADE="build"
430 fi
431 fi
432 fi
433 PACKAGE_INFOS="
434 <window title=\"Package: $PKG\" icon-name=\"package-x-generic\">
435 <vbox>
437 <tree>
438 <width>460</width><height>200</height>
439 <label>$PKG|$SHORT_DESC</label>
440 <variable>FIELD</variable>
441 <item icon=\"tazpkg\">Version: | $VERSION</item>
442 <item icon=\"tazpkg\">Category: | $CATEGORY</item>"
443 [ -n "$UPGRADE" ] && PACKAGE_INFOS="$PACKAGE_INFOS
444 <item icon=\"tazpkg\">Upgrade: | $(echo $UPGRADE)</item>"
445 [ -n "$DEPENDS" ] && PACKAGE_INFOS="$PACKAGE_INFOS
446 <item icon=\"tazpkg\">Depends: | $(echo $DEPENDS)</item>"
447 [ -n "$SUGGESTED" ] && PACKAGE_INFOS="$PACKAGE_INFOS
448 <item icon=\"tazpkg\">Suggested: | $(echo $SUGGESTED)</item>"
449 [ -n "$PACKED_SIZE" ] && PACKAGE_INFOS="$PACKAGE_INFOS
450 <item icon=\"tazpkg\">Size: | $PACKED_SIZE ($UNPACKED_SIZE installed)</item>"
451 [ -n "$MAINTAINER" ] && PACKAGE_INFOS="$PACKAGE_INFOS
452 <item icon=\"system-users\">Maintainer: | $MAINTAINER</item>"
453 [ -n "$BUGS" ] && PACKAGE_INFOS="$PACKAGE_INFOS
454 <item icon=\"important\">Bugs: | $BUGS</item>"
455 [ -n "$HANDBOOK_URL" ] && PACKAGE_INFOS="$PACKAGE_INFOS
456 <item icon=\"ascii\">Handbook: | $HANDBOOK_URL</item>"
457 [ -n "$TAGS" ] && PACKAGE_INFOS="$PACKAGE_INFOS
458 <item icon=\"tazpkg\">Tags: | $TAGS</item>"
459 [ -n "$CONFIG_FILES" ] && PACKAGE_INFOS="$PACKAGE_INFOS
460 <item icon=\"tazpkg\">Config files: | $CONFIG_FILES</item>"
461 [ -f $ROOT/installed/$PKG/modifiers ] &&
462 PACKAGE_INFOS="$PACKAGE_INFOS
463 <item icon=\"tazpkg\">Modified by: | $(xargs echo < $ROOT/installed/$PKG/modifiers)</item>"
464 PACKAGE_INFOS="$PACKAGE_INFOS
465 <item icon=\"applications-internet\">Website: | $WEB_SITE</item>
466 <item icon=\"help\">Tip: | double-click any item for more information</item>
467 <action> $0 package-infos info \"\$FIELD\" $PKG </action>
468 </tree>
470 <hbox>"
471 [ -s $ROOT/installed/$PACKAGE/description.txt ] &&
472 PACKAGE_INFOS="$PACKAGE_INFOS
473 <button>
474 <label>Description</label>
475 <input file icon=\"help\"></input>
476 <action>xterm -T \"$PKG description (q to quit)\" $XTERM_OPTS \
477 -e \"less $ROOT/installed/$PKG/description.txt\"</action>
478 </button>"
479 if [ ! -d /var/lib/tazpkg/fslink ]; then
480 [ ${PKG%%-*} = get -a ! -d $ROOT/installed/${PKG#get-} ] && PACKAGE_INFOS="$PACKAGE_INFOS
481 <button>
482 <label>Install</label>
483 <input file icon=\"go-next\"></input>
484 <action>xterm -T \"Install ${PKG#get-}\" $XTERM_OPTS -e \"\
485 $PKG; sleep 5\"</action>
486 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
487 </button>"
488 [ -n "$UPGRADE" ] && PACKAGE_INFOS="$PACKAGE_INFOS
489 <button>
490 <label>Upgrade</label>
491 <input file icon=\"go-next\"></input>
492 <action>xterm -T \"Install $PKG\" $XTERM_OPTS -e \"\
493 tazpkg get-install $PKG --forced ; sleep 5\"</action>
494 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
495 </button>"
496 grep -q post_install $ROOT/installed/$PKG/receipt && PACKAGE_INFOS="$PACKAGE_INFOS
497 <button>
498 <label>Reconfigure</label>
499 <input file icon=\"reload\"></input>
500 <action>xterm -T \"Reconfigure $PACKAGE\" $XTERM_OPTS -e \"\
501 tazpkg reconfigure $PACKAGE; sleep 2\"</action>
502 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
503 </button>"
504 if grep -qs ^$PKG$ /var/lib/tazpkg/blocked-packages.list; then
505 PACKAGE_INFOS="$PACKAGE_INFOS
506 <button>
507 <label>Unblock</label>
508 <input file icon=\"up\"></input>
509 <action>xterm -T \"Unblock $PACKAGE\" $XTERM_OPTS -e \"\
510 tazpkg unblock $PACKAGE; sleep 2\"</action>
511 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
512 </button>"
513 else
514 PACKAGE_INFOS="$PACKAGE_INFOS
515 <button>
516 <label>Block</label>
517 <input file icon=\"down\"></input>
518 <action>xterm -T \"Block $PACKAGE\" $XTERM_OPTS -e \"\
519 tazpkg block $PACKAGE; sleep 2\"</action>
520 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
521 </button>"
522 fi
523 fi
524 if [ "$(cat /tmp/tazpkgbox/status)" = "linkable" ]; then
525 PACKAGE_INFOS="$PACKAGE_INFOS
526 <button>
527 <label>Link</label>
528 <input file icon=\"edit-redo\"></input>
529 <action>xterm -T \"Link $PACKAGE\" $XTERM_OPTS -e \"\
530 tazpkg link $PACKAGE $(readlink /var/lib/tazpkg/fslink); sleep 2\"</action>
531 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
532 </button>"
533 elif [ ! -s $ROOT/installed/$PKG/modifiers ]; then
534 [ -L $ROOT/installed/$PKG ] || PACKAGE_INFOS="$PACKAGE_INFOS
535 <button>
536 <label>Repack</label>
537 <input file icon=\"edit-redo\"></input>
538 <action>xterm -T \"Repack $PACKAGE\" $XTERM_OPTS -e \"\
539 cd /var/cache/tazpkg; \
540 tazpkg repack $PACKAGE; sleep 2\"</action>
541 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
542 </button>
543 "
544 PACKAGE_INFOS="$PACKAGE_INFOS
545 <button>
546 <label>Remove</label>
547 <input file icon=\"edit-delete\"></input>
548 <action>xterm -T \"Remove $PACKAGE\" $XTERM_OPTS -e \"\
549 tazpkg remove $PACKAGE; sleep 2\"</action>
550 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
551 </button>
552 "
553 else
554 PACKAGE_INFOS="$PACKAGE_INFOS
555 <button>
556 <label>Re-install</label>
557 <input file icon=\"edit-redo\"></input>
558 <action>xterm -T \"Re-install $PACKAGE\" $XTERM_OPTS -e \"\
559 tazpkg get-install $PACKAGE --forced; sleep 2\"</action>
560 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
561 </button>
562 <button>
563 <label>Remove</label>
564 <input file icon=\"edit-delete\"></input>
565 <action>xterm -T \"Remove $PACKAGE\" $XTERM_OPTS -e \"\
566 tazpkg remove $PACKAGE; sleep 2\"</action>
567 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
568 </button>
569 "
570 fi
571 PACKAGE_INFOS="$PACKAGE_INFOS
572 <button>
573 <label>View Files</label>
574 <input file icon=\"tazpkg\"></input>
575 <action type=\"launch\">LIST_FILES</action>
576 </button>
577 <button>
578 <input file icon=\"gtk-close\"></input>
579 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
580 </button>
581 </hbox>
583 </vbox>
584 </window>
585 "
586 export PACKAGE_INFOS
587 else
588 RES=`grep -sh "^$PKG " /var/lib/tazpkg/packages.desc \
589 /var/lib/tazpkg/undigest/*/packages.desc`
590 PACKAGE=`echo "$RES" | cut -d "|" -f 1`
591 VERSION=`echo "$RES" | cut -d "|" -f 2`
592 SHORT_DESC=`echo "$RES" | cut -d "|" -f 3`
593 CATEGORY=`echo "$RES" | cut -d "|" -f 4`
594 WEB_SITE=`echo "$RES" | cut -d "|" -f 5`
595 SIZES=`grep -sh -A 3 "^$(echo $PACKAGE)$" /var/lib/tazpkg/packages.txt \
596 /var/lib/tazpkg/undigest/*/packages.txt | tail -1`
597 DEPENDS=""
598 SUGGESTED=""
599 MAINTAINER=""
600 BUGS=""
601 HANDBOOK_URL=""
602 TAGS=""
603 CONFIG_FILES=""
604 height=160
605 if [ -s /home/slitaz/wok/$PKG/receipt ]; then
606 . /home/slitaz/wok/$PKG/receipt
607 height=200
608 fi
609 PACKAGE_INFOS="
610 <window title=\"Package: $PACKAGE\" icon-name=\"package-x-generic\">
611 <vbox>
613 <tree>
614 <width>460</width><height>$height</height>
615 <label>$PKG|$SHORT_DESC</label>
616 <variable>FIELD2</variable>
617 <item icon=\"tazpkg\">Version: | $VERSION</item>
618 <item icon=\"tazpkg\">Category: | $CATEGORY</item>"
619 [ -n "$DEPENDS" ] && PACKAGE_INFOS="$PACKAGE_INFOS
620 <item icon=\"tazpkg\">Depends: | $(echo $DEPENDS)</item>"
621 [ -n "$SUGGESTED" ] && PACKAGE_INFOS="$PACKAGE_INFOS
622 <item icon=\"tazpkg\">Suggested: | $(echo $SUGGESTED)</item>"
623 [ -n "$SIZES" ] && PACKAGE_INFOS="$PACKAGE_INFOS
624 <item icon=\"tazpkg\">Size: | $SIZES</item>"
625 [ -n "$MAINTAINER" ] && PACKAGE_INFOS="$PACKAGE_INFOS
626 <item icon=\"system-users\">Maintainer: | $MAINTAINER</item>"
627 [ -n "$BUGS" ] && PACKAGE_INFOS="$PACKAGE_INFOS
628 <item icon=\"important\">Bugs: | $BUGS</item>"
629 [ -n "$HANDBOOK_URL" ] && PACKAGE_INFOS="$PACKAGE_INFOS
630 <item icon=\"ascii\">Handbook: | $HANDBOOK_URL</item>"
631 [ -n "$TAGS" ] && PACKAGE_INFOS="$PACKAGE_INFOS
632 <item icon=\"tazpkg\">Tags: | $TAGS</item>"
633 [ -n "$CONFIG_FILES" ] && PACKAGE_INFOS="$PACKAGE_INFOS
634 <item icon=\"tazpkg\">Config files: | $CONFIG_FILES</item>"
635 PACKAGE_INFOS="$PACKAGE_INFOS
636 <item icon=\"applications-internet\">Website: | $WEB_SITE</item>
637 <item icon=\"text-editor\">Receipt: | double-click to view receipt</item>
638 <action>case \$FIELD2 in Web*) browser $WEB_SITE &;; esac</action>
639 <action>case \$FIELD2 in Rec*) browser http://hg.slitaz.org/wok/raw-file/tip/$PACKAGE/receipt &;; esac</action>
641 </tree>
643 <hbox>"
644 [ ${PACKAGE%%-*} = get ] && PACKAGE_INFOS="$PACKAGE_INFOS
645 <checkbox>
646 <label>Auto exec</label>
647 <variable>AUTO_EXEC</variable>
648 <default>true</default>
649 </checkbox>"
650 PACKAGE_INFOS="$PACKAGE_INFOS
651 <checkbox>
652 <label>Auto install depends</label>
653 <variable>AUTO_DEPENDS</variable>
654 <default>true</default>
655 </checkbox>
656 <button>
657 <label>Install Package</label>
658 <input file icon=\"go-next\"></input>
659 <action>xterm -T \"Install $PACKAGE\" $XTERM_OPTS -e \"\
660 if [ x\$AUTO_DEPENDS != xtrue ]; then script -c \\\"tazpkg get-install $PACKAGE\\\" /var/log/tazpkg-install.log;\
661 else script -c \\\"yes y | tazpkg get-install $PACKAGE\\\" /var/log/tazpkg-install.log; fi; \
662 [ x\${AUTO_EXEC} = xtrue ] && $PACKAGE; \
663 sleep 2\"</action>
664 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
665 </button>
666 <button>
667 <label>Download</label>
668 <input file icon=\"go-next\"></input>
669 <action>xterm -T \"Get $PACKAGE\" $XTERM_OPTS -e \"\
670 cd /var/cache/tazpkg; tazpkg get $PACKAGE; sleep 2\"</action>
671 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
672 </button>
673 <button>
674 <label>View Files</label>
675 <input file icon=\"tazpkg\"></input>
676 <action type=\"launch\">LIST_FILES_MIRROR</action>
677 </button>
678 <button>
679 <input file icon=\"gtk-close\"></input>
680 <action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
681 </button>
682 </hbox>
684 </vbox>
685 </window>
686 "
687 export PACKAGE_INFOS
688 fi
689 gtkdialog --center --program=PACKAGE_INFOS ;;
691 *)
692 usage ;;
693 esac
695 exit 0