tazpkg view tazpkgbox @ rev 319

show upgradeable packages
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Feb 22 23:57:19 2010 +0100 (2010-02-22)
parents 55f7f7389343
children 317b65f3d2a0
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 </combobox>
300 <text>
301 <label>"Category:"</label>
302 </text>
303 <combobox>
304 <variable>CAT</variable>
305 <item>all</item>
306 <item>base-system</item>
307 <item>x-window</item>
308 <item>utilities</item>
309 <item>network</item>
310 <item>graphics</item>
311 <item>multimedia</item>
312 <item>office</item>
313 <item>development</item>
314 <item>system-tools</item>
315 <item>security</item>
316 <item>games</item>
317 <item>misc</item>
318 <item>meta</item>
319 <item>non-free</item>
320 </combobox>
321 <button>
322 <label>List</label>
323 <input file icon="reload"></input>
324 <action>echo "$CAT" > /tmp/tazpkgbox/category</action>
325 <action>echo "$STATUS" > /tmp/tazpkgbox/status</action>
326 <action>refresh:PKG</action>
327 </button>
328 </hbox>
329 </vbox>
331 <vbox>
332 <tree>
333 <width>620</width><height>120</height>
334 <variable>RESULT</variable>
335 <label>Packages Name|Version|Description / File</label>
336 <input icon_column="0">cat /tmp/tazpkgbox/search</input>
337 <action>echo "$RESULT" > /tmp/tazpkgbox/pkg</action>
338 <action>$LIB/package_infos</action>
339 <action>$LIB/search packages</action>
340 <action>refresh:RESULT</action>
341 <action>refresh:PKG</action>
342 <action>refresh:PKG_STATS</action>
343 <action>refresh:CACHE_STATS</action>
344 </tree>
345 <hbox>
346 <entry>
347 <variable>SEARCH</variable>
348 </entry>
349 <button>
350 <label>Packages</label>
351 <input file icon="system-search"></input>
352 <action>$LIB/search packages</action>
353 <action>refresh:RESULT</action>
354 </button>
355 <button>
356 <label>Files</label>
357 <input file icon="system-search"></input>
358 <action>$LIB/search files</action>
359 <action>refresh:RESULT</action>
360 </button>
361 '
362 tmp='
363 <button>
364 <label>Tags</label>
365 <input file icon="system-search"></input>
366 <action>$LIB/search tags</action>
367 <action>refresh:RESULT</action>
368 </button>
369 '
370 [ -d /home/slitaz/wok ] && TAZPKG_DIALOG="$TAZPKG_DIALOG $tmp"
371 tmp='
372 </hbox>
373 </vbox>
375 <vbox>
376 <tree>
377 <width>620</width><height>240</height>
378 <variable>DEV</variable>
379 <label>Name|Version|Description</label>
380 <input icon_column="0">$LIB/list undigest</input>
381 <action>echo "$DEV" > /tmp/tazpkgbox/pkg</action>
382 <action>$LIB/package_infos</action>
383 <action>refresh:PKG</action>
384 <action>refresh:PKG_STATS</action>
385 <action>refresh:CACHE_STATS</action>
386 </tree>
387 <hbox>
388 <button>
389 <label>Setup undigest mirrors</label>
390 <input file icon="go-next"></input>
391 <action type="launch">SETUP_UNDIGEST</action>
392 </button>
393 </hbox>
394 <hbox>
395 <text>
396 <label>"Undigest:"</label>
397 </text>
398 <combobox>
399 <variable>UNDIGEST_ENTRY</variable>
400 '
401 TAZPKG_DIALOG="$TAZPKG_DIALOG $tmp"
402 for i in all $(ls /var/lib/tazpkg/undigest 2> /dev/null); do
403 TAZPKG_DIALOG="$TAZPKG_DIALOG <item>$i</item> "
404 done
405 tmp=' </combobox>
406 <text>
407 <label>"Category:"</label>
408 </text>
409 <combobox>
410 <variable>UNDIGEST_CAT</variable>
411 <item>all</item>
412 <item>base-system</item>
413 <item>x-window</item>
414 <item>utilities</item>
415 <item>network</item>
416 <item>graphics</item>
417 <item>multimedia</item>
418 <item>office</item>
419 <item>development</item>
420 <item>system-tools</item>
421 <item>security</item>
422 <item>games</item>
423 <item>misc</item>
424 <item>meta</item>
425 <item>non-free</item>
426 </combobox>
427 <button>
428 <label>List</label>
429 <input file icon="reload"></input>
430 <action>echo "$UNDIGEST_CAT $UNDIGEST_ENTRY" > /tmp/tazpkgbox/undigest-category</action>
431 <action>refresh:DEV</action>
432 </button>
433 </hbox>
434 </vbox>
436 <vbox>
437 <frame Files and Cache directory>
438 <text use-markup="true" width-chars="60" wrap="false">
439 <label>"
440 Lists, mirror URL and installed packages: <b>/var/lib/tazpkg</b>
441 The cache directory is used to store downloaded or repacked packages.
442 "</label>
443 </text>
444 <hbox>
445 <entry editable="false">
446 <input>cd /var/cache/tazpkg; echo "Packages: `ls | wc -l`, size: `du -sh $PWD`"</input>
447 <variable>CACHE_STATS</variable>
448 </entry>
449 <button>
450 <label>Clean cache</label>
451 <input file icon="go-next"></input>
452 <action>rm -rf /var/cache/tazpkg/*</action>
453 <action>refresh:CACHE_STATS</action>
454 </button>
455 </hbox>
456 </frame>
457 <frame Mirror URL>
458 <hbox>
459 <entry>
460 <input>head -n 1 /var/lib/tazpkg/mirror</input>
461 <variable>MIRROR</variable>
462 </entry>
463 <button>
464 <label>Setup</label>
465 <input file icon="go-next"></input>
466 <action>echo "$MIRROR" > /var/lib/tazpkg/mirror</action>
467 <action>clear:MIRROR</action>
468 <action>refresh:MIRROR</action>
469 </button>
470 <button>
471 <label>Add</label>
472 <input file icon="gtk-add"></input>
473 <action>echo "$MIRROR" >> /var/lib/tazpkg/mirror</action>
474 <action>clear:MIRROR</action>
475 <action>refresh:MIRROR</action>
476 </button>
477 <button>
478 <input file icon="media-cdrom"></input>
479 <label>DVD</label>
480 <action type="launch">SETUP_DVD</action>
481 </button>
482 </hbox>
483 </frame>
484 <hbox>
485 <frame Journal>
486 <hbox>
487 <button>
488 <label>Show journal</label>
489 <input file icon="find"></input>
490 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -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>
491 </button>
492 </hbox>
493 </frame>
494 <frame Configuration files>
495 <hbox>
496 <button>
497 <label>Repack config</label>
498 <input file icon="edit-redo"></input>
499 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -T "Repack configs" -geometry 80x25+120+120 -e "tazpkg repack-config ; sleep 5" 2> /dev/null</action>
500 </button>
501 <button>
502 <label>Config Files</label>
503 <input file icon="tazpkg"></input>
504 <action type="launch">LIST_CONFIG_FILES</action>
505 </button>
506 </hbox>
507 </frame>
508 <frame Packages check>
509 <hbox>
510 <button>
511 <label>Quick check</label>
512 <input file icon="go-next"></input>
513 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -T "Check packages (q to quit)" -geometry 80x25+120+120 -e "tazpkg check | less " 2> /dev/null</action>
514 </button>
515 <button>
516 <label>Full check</label>
517 <input file icon="go-next"></input>
518 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -T "Check packages (q to quit)" -geometry 80x25+120+120 -e "tazpkg check --full | less " 2> /dev/null</action>
519 </button>
520 </hbox>
521 </frame>
522 </hbox>
523 </vbox>
525 </notebook>
527 <hbox>
528 <text wrap="false" width-chars="82">
529 <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>
530 <variable>PKG_STATS</variable>
531 </text>
532 </hbox>
534 <hbox>
535 <button>
536 <label>Recharge lists</label>
537 <input file icon="system-software-update"></input>
538 <action>xterm -T "Recharge" -geometry 80x16+120+120 -e "tazpkg recharge ; tazpkg upgradeable" 2>/dev/null</action>
539 <action>refresh:DEV</action>
540 <action>refresh:PKG</action>
541 <action>refresh:PKG_STATS</action>
542 <action>refresh:CACHE_STATS</action>
543 </button>
544 <button>
545 <label>Upgrade all</label>
546 <input file icon="system-software-update"></input>
547 <action>xterm -T "Package upgrade" -geometry 80x16+120+120 -e "tazpkg upgrade; sleep 2" 2>/dev/null</action>
548 <action>refresh:PKG</action>
549 <action>refresh:DEV</action>
550 <action>refresh:PKG_STATS</action>
551 <action>refresh:CACHE_STATS</action>
552 </button>
553 <button>
554 <label>Wok</label>
555 <input file icon="gtk-open"></input>
556 <action>firefox http://hg.slitaz.org/wok/file/</action>
557 </button>
558 <button help>
559 <label>Help</label>
560 <action type="launch">HELP</action>
561 </button>
562 <button>
563 <label>Exit</label>
564 <input file icon="exit"></input>
565 <action type="exit">Exit</action>
566 </button>
567 </hbox>
569 </vbox>
571 </window>
572 '
573 TAZPKG_DIALOG="$TAZPKG_DIALOG$tmp"
575 gtkdialog --center --program=TAZPKG_DIALOG >/dev/null
577 exit 0