tazpkg view oldstuff/libtazpkgbox @ rev 955

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