tazpkg view tazpkgbox @ rev 334

tazpkgbox: some improvements to gui
author Rohit Joshi <jozee@slitaz.org>
date Fri Mar 19 11:23:01 2010 +0000 (2010-03-19)
parents cd4d52716080
children d6183a5cf8c4
line source
1 #!/bin/sh
2 #
3 # GTKdialog interface to SliTaz Packages Manager aka Tazpkg. Notes:
4 # Notebook tab are vbox, tabs are used to indent and functions are
5 # split and found in $LIB.
6 #
7 # (C) GNU gpl v3 - SliTaz GNU/Linux 2010.
8 #
9 VERSION=3.2.1
11 # Functions path.
12 export LIB=/usr/lib/slitaz/tazpkgbox
14 # Tazpkgbox is only for root.
15 if test $(id -u) != 0 ; then
16 exec subox tazpkgbox
17 exit 0
18 fi
20 # We need at least a mirror URL.
21 if [ ! -f /var/lib/tazpkg/mirror ]; then
22 tazpkg >/dev/null
23 fi
25 RELEASE=$(cat /etc/slitaz-release)
26 case "$1" in
27 dliso)
28 echo "Downloading packages-$RELEASE.iso into $2..."
29 cd $2
30 for i in $(cat /var/lib/tazpkg/mirror) ; do
31 wget ${i%packages*}/iso/$RELEASE/packages-$RELEASE.iso && break
32 done
33 exit 0;;
34 instiso)
35 PKGSIGN="LABEL=\"packages-$RELEASE\" TYPE=\"iso9660\""
36 PKGDEV=$(blkid $2 | grep "$PKGSIGN" | cut -d: -f1)
37 [ -z "$PKGDEV$2" -a -L /dev/cdrom ] && PKGDEV=$(blkid /dev/cdrom | grep "$PKGSIGN" | cut -d: -f1)
38 if [ -n "$PKGDEV" ]; then
39 mkdir /packages 2> /dev/null
40 mount -t iso9660 -o ro $PKGDEV /packages
41 /packages/install.sh
42 fi
43 exit 0;;
44 esac
45 # Tmp dir and files used to get pkgs info on the fly. Clean also
46 # lists and searches for files to load less data and have a faster start.
47 mkdir -p /tmp/tazpkgbox
48 echo "all" > /tmp/tazpkgbox/status
49 echo "all" > /tmp/tazpkgbox/category
50 echo "all" > /tmp/tazpkgbox/undigest-category
51 echo "" > /tmp/tazpkgbox/search
53 # English/French help dialog.
54 export HELP='
55 <window title="Tazpkgbox Help" icon-name="help">
56 <vbox>
57 <text use-markup="true" width-chars="54">
58 <label>"
59 <b>Tazpkgbox - Packages Manager Help</b>"
60 </label>
61 </text>
63 <frame English>
64 <text wrap="false">
65 <label>"
66 Tazpkgbox is a simple and easy to use interface to the SliTaz
67 package manager - aka Tazpkg. You can install, remove, repack or
68 get packages by double-clicking on the package item. A Search engine
69 lets you find and install new applications in a few mouse clicks."
70 </label>
71 </text>
72 </frame>
74 <frame Français>
75 <text wrap="false">
76 <label>"
77 Tazpkgbox est une interface graphique au gestionnaire de paquet
78 de Slitaz aka Tazpkg. Simple et facile à utiliser, vous pouvez
79 installer, télécharger ou supprimer des paquets en double-cliquant
80 sur sa ligne. La fonction de recherche permet de facilement trouver
81 et installer des logiciels ou fichiers."
82 </label>
83 </text>
84 </frame>
86 <hbox>
87 <button ok>
88 <action type="closewindow">HELP</action>
89 </button>
90 </hbox>
91 </vbox>
92 </window>
93 '
95 FILES="$2"
96 [ "$1" = "list_config" ] || FILES=""
98 export SETUP_DVD="
99 <window title=\"Packages archive\" icon-name=\"media-cdrom\">
100 <vbox>
101 <text use-markup=\"true\" width-chars=\"54\">
102 <label>\"
103 <b>Tazpkgbox - Packages Archive Manager</b>\"
104 </label>
105 </text>
106 <frame English>
107 <text wrap=\"false\">
108 <label>\"
109 An ISO image with all $(cat /etc/slitaz-release) packages is available on Slitaz mirrors.
110 You can burn it onto a DVD or install it on an USB key and each
111 package becomes installable without an Internet connection.\"
112 </label>
113 </text>
114 </frame>
116 <frame Français>
117 <text wrap=\"false\">
118 <label>\"
119 Une image ISO installable sur clé USB ou gravable sur DVD est
120 disponible sur les mirroirs Slitaz. Elle contient tous les paquets
121 de la version $(cat /etc/slitaz-release) pour pouvoir installer des paquets sans
122 connexion Internet.\"
123 </label>
124 </text>
125 </frame>
126 <frame>
127 <hbox>
128 <text use-markup=\"true\">
129 <label>\"<b>ISO image : </b>\"</label>
130 </text>
131 <entry>
132 <variable>PKGISO</variable>
133 </entry>
134 <button>
135 <input file stock=\"gtk-open\"></input>
136 <action type=\"fileselect\">PKGISO</action>
137 </button>
138 <button>
139 <label>Install ISO</label>
140 <input file icon=\"go-jump\"></input>
141 <action>xterm -T \"Install ISO\" -geometry 80x16+120+120 -e \"tazpkgbox instiso \$PKGISO; sleep 2\" 2>/dev/null</action>
142 <action>refresh:PKG</action>
143 <action>refresh:PKG_STATS</action>
144 <action>refresh:CACHE_STATS</action>
145 </button>
146 </hbox>
147 </frame>
148 <hbox>
149 <button>
150 <label>Download ISO</label>
151 <input file icon=\"system-software-update\"></input>
152 <action>xterm -T \"Download ISO\" -geometry 80x16+120+120 -e \"tazpkgbox dliso /tmp; sleep 2\" 2>/dev/null</action>
153 </button>
154 <button>
155 <input file icon=\"media-cdrom\"></input>
156 <label>Burn DVD</label>
157 <action>burnbox</action>
158 </button>
159 <button>
160 <label>Install DVD/USB key</label>
161 <input file icon=\"go-jump\"></input>
162 <action>xterm -T \"Install DVD/USB key\" -geometry 80x16+120+120 -e \"tazpkgbox instiso; sleep 2\" 2>/dev/null</action>
163 <action>refresh:PKG</action>
164 <action>refresh:PKG_STATS</action>
165 <action>refresh:CACHE_STATS</action>
166 </button>
167 <button>
168 <input file icon=\"gtk-close\"></input>
169 <action type=\"closewindow\">SETUP_DVD</action>
170 </button>
171 </hbox>
172 </vbox>
173 </window>
174 "
176 export LIST_CONFIG_FILES="
177 <window title=\"configuration files\" icon-name=\"system-file-manager\">
178 <vbox>
179 <tree exported_column=\"5\">
180 <width>560</width><height>160</height>
181 <variable>CONF_FILE</variable>
182 <label>Access | User | Group | Size | Update Date | Name</label>
183 <input>tazpkg list-config --box $FILES</input>
184 <action>leafpad \$CONF_FILE</action>
185 </tree>
186 <hbox>
187 <text wrap=\"false\">
188 <label>
189 \"Only files with Update Date have been modified after package installation\"
190 </label>
191 </text>
192 <button>
193 <input file icon=\"gtk-close\"></input>
194 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
195 </button>
196 </hbox>
197 </vbox>
198 </window>
199 "
200 if [ "$1" = "list_config" ]; then
201 gtkdialog --center --program=LIST_CONFIG_FILES >/dev/null
202 exit 0
203 fi
205 export SETUP_UNDIGEST='
206 <window title="undigest mirrors" icon-name="tazpkg">
207 <vbox>
208 <tree>
209 <width>560</width><height>160</height>
210 <variable>UNDIGEST_LIST</variable>
211 <label>Name | URL</label>
212 <input>tazpkg list-undigest --box</input>
213 <action>xterm -T "Remove undigest" -geometry 80x16+120+120 -e "tazpkg remove-undigest $UNDIGEST_LIST; sleep 2"</action>
214 </tree>
215 <hbox>
216 <text>
217 <label>URL:</label>
218 </text>
219 <entry>
220 <variable>UNDIGEST_URL</variable>
221 </entry>
222 </hbox>
223 <hbox>
224 <text>
225 <label>Name:</label>
226 </text>
227 <entry>
228 <variable>UNDIGEST_NAME</variable>
229 </entry>
230 <button>
231 <label>Add</label>
232 <input file icon="gtk-add"></input>
233 <action>tazpkg add-undigest "$UNDIGEST_NAME" $UNDIGEST_URL</action>
234 <action>refresh:UNDIGEST_LIST</action>
235 </button>
236 <button>
237 <label>Remove</label>
238 <input file icon="gtk-remove"></input>
239 <action>xterm -T "Remove undigest" -geometry 80x16+120+120 -e "tazpkg remove-undigest $UNDIGEST_NAME; sleep 2"</action>
240 <action>refresh:UNDIGEST_LIST</action>
241 </button>
242 <button>
243 <label>Update</label>
244 <input file icon="reload"></input>
245 <action>tazpkg setup-undigest "$UNDIGEST_NAME" $UNDIGEST_URL</action>
246 <action>refresh:UNDIGEST_LIST</action>
247 </button>
248 <button>
249 <input file icon="gtk-close"></input>
250 <action type="closewindow">SETUP_UNDIGEST</action>
251 </button>
252 </hbox>
253 </vbox>
254 </window>
255 '
257 # Scan notification
258 desktopbox notify "Scanning packages database" 6 &
260 # Main dialog
261 export TAZPKG_DIALOG='
262 <window title="SliTaz Packages Manager" icon-name="package-x-generic">
263 <vbox>
265 <hbox>
266 <text use-markup="true">
267 <label>"<b>Packages Manager</b>"</label>
268 </text>
269 <pixmap>
270 <input file>/usr/share/pixmaps/tazpkg.png</input>
271 </pixmap>
272 </hbox>
274 <notebook labels="Packages|Search|Undigest|Configuration">
276 <vbox>
277 <tree>
278 <width>620</width><height>240</height>
279 <variable>PKG</variable>
280 <label>Name|Version|Description</label>
281 <input icon_column="0">$LIB/list all</input>
282 <action>echo "$PKG" > /tmp/tazpkgbox/pkg</action>
283 <action>$LIB/package_infos</action>
284 <action>refresh:PKG</action>
285 <action>refresh:PKG_STATS</action>
286 <action>refresh:CACHE_STATS</action>
287 </tree>
288 <hbox>
289 <text>
290 <label>"Status:"</label>
291 </text>
292 <combobox>
293 <variable>STATUS</variable>
294 <item>all</item>
295 <item>installed</item>
296 <item>installable</item>
297 <item>blocked</item>
298 <item>upgradeable</item>
299 <item>linkable</item>
300 </combobox>
301 <text>
302 <label>"Category:"</label>
303 </text>
304 <combobox>
305 <variable>CAT</variable>
306 <item>all</item>
307 <item>base-system</item>
308 <item>x-window</item>
309 <item>utilities</item>
310 <item>network</item>
311 <item>graphics</item>
312 <item>multimedia</item>
313 <item>office</item>
314 <item>development</item>
315 <item>system-tools</item>
316 <item>security</item>
317 <item>games</item>
318 <item>misc</item>
319 <item>meta</item>
320 <item>non-free</item>
321 </combobox>
322 <button>
323 <label>List Packages</label>
324 <input file icon="reload"></input>
325 <action>echo "$CAT" > /tmp/tazpkgbox/category</action>
326 <action>echo "$STATUS" > /tmp/tazpkgbox/status</action>
327 <action>refresh:PKG</action>
328 </button>
329 </hbox>
330 </vbox>
332 <vbox>
333 <tree>
334 <width>620</width><height>120</height>
335 <variable>RESULT</variable>
336 <label>Packages Name|Version|Description / File</label>
337 <input icon_column="0">cat /tmp/tazpkgbox/search</input>
338 <action>echo "$RESULT" > /tmp/tazpkgbox/pkg</action>
339 <action>$LIB/package_infos</action>
340 <action>$LIB/search packages</action>
341 <action>refresh:RESULT</action>
342 <action>refresh:PKG</action>
343 <action>refresh:PKG_STATS</action>
344 <action>refresh:CACHE_STATS</action>
345 </tree>
346 <hbox>
347 <text>
348 <label>" Search: "</label>
349 </text>
350 <entry>
351 <variable>SEARCH</variable>
352 </entry>
353 <button>
354 <label>Packages/Description</label>
355 <input file icon="system-search"></input>
356 <action>$LIB/search packages</action>
357 <action>refresh:RESULT</action>
358 </button>
359 <button>
360 <label>Files</label>
361 <input file icon="system-search"></input>
362 <action>$LIB/search files</action>
363 <action>refresh:RESULT</action>
364 </button>
365 '
366 tmp='
367 <button>
368 <label>Tags</label>
369 <input file icon="system-search"></input>
370 <action>$LIB/search tags</action>
371 <action>refresh:RESULT</action>
372 </button>
373 '
374 [ -d /home/slitaz/wok ] && TAZPKG_DIALOG="$TAZPKG_DIALOG $tmp"
375 tmp='
376 </hbox>
377 </vbox>
379 <vbox>
380 <tree>
381 <width>620</width><height>240</height>
382 <variable>DEV</variable>
383 <label>Name|Version|Description</label>
384 <input icon_column="0">$LIB/list undigest</input>
385 <action>echo "$DEV" > /tmp/tazpkgbox/pkg</action>
386 <action>$LIB/package_infos</action>
387 <action>refresh:PKG</action>
388 <action>refresh:PKG_STATS</action>
389 <action>refresh:CACHE_STATS</action>
390 </tree>
392 <hbox>
394 <button>
395 <label>Setup/Add undigest mirrors</label>
396 <input file icon="go-next"></input>
397 <action type="launch">SETUP_UNDIGEST</action>
398 </button>
399 </hbox>
400 <frame List packages on undigest mirrors>
401 <hbox>
402 <text>
403 <label>"Undigest:"</label>
404 </text>
405 <combobox>
406 <variable>UNDIGEST_ENTRY</variable>
407 '
408 TAZPKG_DIALOG="$TAZPKG_DIALOG $tmp"
409 for i in all $(ls /var/lib/tazpkg/undigest 2> /dev/null); do
410 TAZPKG_DIALOG="$TAZPKG_DIALOG <item>$i</item> "
411 done
412 tmp=' </combobox>
414 <text>
415 <label>"Status:"</label>
416 </text>
417 <combobox>
418 <variable>UNDIGEST_STATUS</variable>
419 <item>all</item>
420 <item>installed</item>
421 <item>installable</item>
422 <item>blocked</item>
423 <item>upgradeable</item>
424 </combobox>
425 </hbox>
426 <hbox>
427 <text>
428 <label>"Category:"</label>
429 </text>
430 <combobox>
431 <variable>UNDIGEST_CAT</variable>
432 <item>all</item>
433 <item>base-system</item>
434 <item>x-window</item>
435 <item>utilities</item>
436 <item>network</item>
437 <item>graphics</item>
438 <item>multimedia</item>
439 <item>office</item>
440 <item>development</item>
441 <item>system-tools</item>
442 <item>security</item>
443 <item>games</item>
444 <item>misc</item>
445 <item>meta</item>
446 <item>non-free</item>
447 </combobox>
448 <text>
449 <label>" "</label>
450 </text>
451 <button>
452 <label>" List Packages "</label>
453 <input file icon="reload"></input>
454 <action>echo "$UNDIGEST_CAT $UNDIGEST_ENTRY $UNDIGEST_STATUS" > /tmp/tazpkgbox/undigest-category</action>
455 <action>refresh:DEV</action>
456 </button>
457 </hbox>
458 </frame>
460 </vbox>
462 <vbox>
463 <frame Files and Cache directory>
464 <text use-markup="true" width-chars="60" wrap="false">
465 <label>"
466 Lists, mirror URL and installed packages: <b>/var/lib/tazpkg</b>
467 The cache directory is used to store downloaded or repacked packages.
468 "</label>
469 </text>
470 <hbox>
471 <entry editable="false">
472 <input>cd /var/cache/tazpkg; echo "Packages: `ls | wc -l`, size: `du -sh $PWD`"</input>
473 <variable>CACHE_STATS</variable>
474 </entry>
475 <button>
476 <label>Clean cache</label>
477 <input file icon="go-next"></input>
478 <action>rm -rf /var/cache/tazpkg/*</action>
479 <action>refresh:CACHE_STATS</action>
480 </button>
481 </hbox>
482 </frame>
483 <frame Filesystem link (to install packages as a soft link from another mounted Slitaz)>
484 <hbox>
485 <entry>
486 <input>readlink /var/lib/tazpkg/fslink</input>
487 <variable>FSLINK</variable>
488 </entry>
489 <button>
490 <label>Setup</label>
491 <input file icon="go-next"></input>
492 <action>rm -f /var/lib/tazpkg/fslink ; [ "$FSLINK" != "/" -a -d $FSLINK/var/lib/tazpkg ] && ln -s $FSLINK /var/lib/tazpkg/fslink</action>
493 <action>clear:FSLINK</action>
494 <action>refresh:FSLINK</action>
495 </button>
496 <button>
497 <label>Mountbox</label>
498 <input file icon="media-flash"></input>
499 <action>mountbox</action>
500 </button>
501 </hbox>
502 </frame>
503 <hbox>
504 <frame Mirror URL>
505 <hbox>
506 <entry>
507 <input>head -n 1 /var/lib/tazpkg/mirror</input>
508 <variable>MIRROR</variable>
509 </entry>
510 <button>
511 <label>Setup</label>
512 <input file icon="go-next"></input>
513 <action>echo "$MIRROR" > /var/lib/tazpkg/mirror</action>
514 <action>clear:MIRROR</action>
515 <action>refresh:MIRROR</action>
516 </button>
517 <button>
518 <label>Add</label>
519 <input file icon="gtk-add"></input>
520 <action>echo "$MIRROR" >> /var/lib/tazpkg/mirror</action>
521 <action>clear:MIRROR</action>
522 <action>refresh:MIRROR</action>
523 </button>
524 </hbox>
525 </frame>
526 <frame Mirror Packages>
527 <hbox>
528 <button>
529 <input file icon="media-cdrom"></input>
530 <label>DVD Box</label>
531 <action type="launch">SETUP_DVD</action>
532 </button>
533 </hbox>
534 </frame>
535 </hbox>
536 <hbox>
537 <frame Install Logs>
538 <hbox>
539 <button>
540 <label>View Logs</label>
541 <input file icon="find"></input>
542 <action>xterm -fa MiscFixed -fs 11 -T "$(ls -l /var/log/tazpkg.log | while read mod links user grep remain ; do echo $remain ; done) (q to quit)" -geometry 80x25+120+120 -e "cat /var/log/tazpkg.log | less"</action>
543 </button>
544 </hbox>
545 </frame>
546 <frame Configuration files>
547 <hbox>
548 <button>
549 <label>Repack config</label>
550 <input file icon="edit-redo"></input>
551 <action>xterm -fa MiscFixed -fs 11 -T "Repack configs" -geometry 80x25+120+120 -e "tazpkg repack-config ; sleep 5" 2> /dev/null</action>
552 </button>
553 <button>
554 <label>View Files</label>
555 <input file icon="tazpkg"></input>
556 <action type="launch">LIST_CONFIG_FILES</action>
557 </button>
558 </hbox>
559 </frame>
560 <frame Packages check>
561 <hbox>
562 <button>
563 <label>Quick check</label>
564 <input file icon="system-search"></input>
565 <action>xterm -fa MiscFixed -fs 11 -T "Check packages (q to quit)" -geometry 80x25+120+120 -e "tazpkg check | less " 2> /dev/null</action>
566 </button>
567 <button>
568 <label>Full check</label>
569 <input file icon="system-search"></input>
570 <action>xterm -fa MiscFixed -fs 11 -T "Check packages (q to quit)" -geometry 80x25+120+120 -e "tazpkg check --full | less " 2> /dev/null</action>
571 </button>
572 </hbox>
573 </frame>
574 </hbox>
575 </vbox>
577 </notebook>
579 <hbox>
580 <text wrap="false" width-chars="82">
581 <input>installed=`ls /var/lib/tazpkg/installed | wc -l`; mirrored=`cat /var/lib/tazpkg/packages.list | wc -l`; undigest=`cat /var/lib/tazpkg/undigest/*/packages.list 2> /dev/null | wc -l`; blocked=`cat /var/lib/tazpkg/blocked-packages.list 2> /dev/null | wc -l`; installable=$(($mirrored + $undigest - $installed)); [ $installable -lt 0 ] && installable=0; echo -n "Packages statistics: $installed installed, $blocked blocked, $installable installable, $undigest undigest, $mirrored mirrored, `cat /var/lib/tazpkg/upgradeable-packages.list 2> /dev/null | wc -l` to upgrade "</input>
582 <variable>PKG_STATS</variable>
583 </text>
584 </hbox>
586 <hbox>
587 <button>
588 <label>Recharge lists</label>
589 <input file icon="system-software-update"></input>
590 <action>xterm -T "Recharge" -geometry 80x16+120+120 -e "tazpkg recharge ; tazpkg upgradeable" 2>/dev/null</action>
591 <action>refresh:DEV</action>
592 <action>refresh:PKG</action>
593 <action>refresh:PKG_STATS</action>
594 <action>refresh:CACHE_STATS</action>
595 </button>
596 <button>
597 <label>Upgrade all</label>
598 <input file icon="system-software-update"></input>
599 <action>xterm -T "Package upgrade" -geometry 80x16+120+120 -e "tazpkg upgrade; sleep 2" 2>/dev/null</action>
600 <action>refresh:PKG</action>
601 <action>refresh:DEV</action>
602 <action>refresh:PKG_STATS</action>
603 <action>refresh:CACHE_STATS</action>
604 </button>
605 <button>
606 <label> View Wok</label>
607 <input file icon="gtk-open"></input>
608 <action>browser http://hg.slitaz.org/wok/file/</action>
609 </button>
610 <button help>
611 <label>Help</label>
612 <action type="launch">HELP</action>
613 </button>
614 <button>
615 <label>Exit</label>
616 <input file icon="exit"></input>
617 <action type="exit">Exit</action>
618 </button>
619 </hbox>
621 </vbox>
623 </window>
624 '
625 TAZPKG_DIALOG="$TAZPKG_DIALOG$tmp"
627 gtkdialog --center --program=TAZPKG_DIALOG >/dev/null
629 exit 0