tazpkg view tazpkgbox @ rev 230

tazpkgbox: Major improvement (all list in the same tab + icons)
author Christophe Lincoln <pankso@slitaz.org>
date Sat Feb 21 22:06:40 2009 +0100 (2009-02-21)
parents 5c0e601b47d3
children 1956016c0998
line source
1 #!/bin/sh
2 #
3 # GTKdialog interface to SliTaz Packages Manager aka Tazpkg. Functions
4 # path: /usr/lib/slitaz/tazpkgbox. Notes: Notebook tab are vbox, tab are
5 # used to indent.
6 #
7 # (C) GNU gpl v3 - SliTaz GNU/Linux 2009.
8 #
9 VERSION=2.6
11 # Tazpkgbox is only for root.
12 if test $(id -u) != 0 ; then
13 exec subox tazpkgbox
14 exit 0
15 fi
17 export LIB=$PWD/lib/tazpkgbox
19 # We need at least a mirror URL.
20 if [ ! -f /var/lib/tazpkg/mirror ]; then
21 tazpkg >/dev/null
22 fi
24 # Tmp dir and files used to get pkgs infos on the fly. Clean also
25 # list and search files to load less data and have a faster start.
26 mkdir -p /tmp/tazpkgbox
27 echo "all" > /tmp/tazpkgbox/status
28 echo "all" > /tmp/tazpkgbox/category
29 echo "all" > /tmp/tazpkgbox/undigest-category
30 echo "" > /tmp/tazpkgbox/search-installed
31 echo "" > /tmp/tazpkgbox/search-mirrored
33 # English/French help dialod.
34 export HELP='
35 <window title="Tazpkgbox Help" icon-name="help">
36 <vbox>
37 <text use-markup="true" width-chars="54">
38 <label>"
39 <b>Tazpkgbox - Packages Manager Help</b>"
40 </label>
41 </text>
43 <frame English>
44 <text wrap="false">
45 <label>"
46 Tazpkgbox is a simple and easy to use interface to the SliTaz
47 package manager - aka Tazpkg. You can install, remove, repack or
48 get packages by double-clicking on the package item. A Search engine
49 lets you find and install new applications in a few mouse clicks.
51 Downloaded and repacked packages are stored in: /var/cache/tazpkg"
52 </label>
53 </text>
54 </frame>
56 <frame Français>
57 <text wrap="false">
58 <label>"
59 Tazpkgbox est une interface graphique au gestionnaire de paquet
60 de Slitaz aka Tazpkg. Simple et facile à utiliser, vous pouvez
61 installer, télécharger ou supprimer des paquet en double-cliquant
62 sur sa ligne. Les paquets téléchargés ou recréés sont stocké
63 dans: /var/cache/tazpkg"
64 </label>
65 </text>
66 </frame>
68 <hbox>
69 <button ok>
70 <action type="closewindow">HELP</action>
71 </button>
72 </hbox>
73 </vbox>
74 </window>
75 '
77 FILES="$2"
78 [ "$1" = "list_config" ] || FILES=""
79 export LIST_CONFIG_FILES="
80 <window title=\"configuration files\" icon-name=\"system-file-manager\">
81 <vbox>
82 <tree exported_column=\"5\">
83 <width>560</width><height>160</height>
84 <variable>CONF_FILE</variable>
85 <label>Access | User | Group | Size | Update Date | Name</label>
86 <input>tazpkg list-config --box $FILES</input>
87 <action>leafpad \$CONF_FILE</action>
88 </tree>
89 <hbox>
90 <text wrap=\"false\">
91 <label>
92 \"Only files with Update Date have been modified after package installation\"
93 </label>
94 </text>
95 <button>
96 <input file icon=\"gtk-close\"></input>
97 <action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
98 </button>
99 </hbox>
100 </vbox>
101 </window>
102 "
103 if [ "$1" = "list_config" ]; then
104 gtkdialog --center --program=LIST_CONFIG_FILES >/dev/null
105 exit 0
106 fi
108 export SETUP_UNDIGEST='
109 <window title="undigest mirrors" icon-name="tazpkg">
110 <vbox>
111 <tree>
112 <width>560</width><height>160</height>
113 <variable>UNDIGEST_LIST</variable>
114 <label>Name | URL</label>
115 <input>tazpkg list-undigest --box</input>
116 <action>xterm -T "Remove undigest" -geometry 80x16+120+120 -e "tazpkg remove-undigest $UNDIGEST_LIST; sleep 2"</action>
117 </tree>
118 <hbox>
119 <text>
120 <label>URL:</label>
121 </text>
122 <entry>
123 <variable>UNDIGEST_URL</variable>
124 </entry>
125 </hbox>
126 <hbox>
127 <text>
128 <label>Name:</label>
129 </text>
130 <entry>
131 <variable>UNDIGEST_NAME</variable>
132 </entry>
133 <button>
134 <label>Add</label>
135 <input file icon="gtk-add"></input>
136 <action>tazpkg add-undigest "$UNDIGEST_NAME" $UNDIGEST_URL</action>
137 <action>refresh:UNDIGEST_LIST</action>
138 </button>
139 <button>
140 <label>Remove</label>
141 <input file icon="gtk-remove"></input>
142 <action>xterm -T "Remove undigest" -geometry 80x16+120+120 -e "tazpkg remove-undigest $UNDIGEST_NAME; sleep 2"</action>
143 <action>refresh:UNDIGEST_LIST</action>
144 </button>
145 <button>
146 <label>Update</label>
147 <input file icon="reload"></input>
148 <action>tazpkg setup-undigest "$UNDIGEST_NAME" $UNDIGEST_URL</action>
149 <action>refresh:UNDIGEST_LIST</action>
150 </button>
151 <button>
152 <input file icon="gtk-close"></input>
153 <action type="closewindow">SETUP_UNDIGEST</action>
154 </button>
155 </hbox>
156 </vbox>
157 </window>
158 '
160 # Scan notifycation
161 desktopbox notify "Scanning packages database" 6 &
163 # Main dialog
164 export TAZPKG_DIALOG='
165 <window title="SliTaz Packages Manager" icon-name="package-x-generic">
166 <vbox>
168 <hbox>
169 <text use-markup="true">
170 <label>"<b>Packages Manager</b>"</label>
171 </text>
172 <pixmap>
173 <input file>/usr/share/pixmaps/tazpkg.png</input>
174 </pixmap>
175 </hbox>
177 <notebook labels="Packages list|Search|Undigest|Configuration">
179 <vbox>
180 <tree>
181 <width>620</width><height>240</height>
182 <variable>PKG</variable>
183 <label>Name|Version|Description</label>
184 <input icon_column="0">$LIB/list all</input>
185 <action>echo "$PKG" > /tmp/tazpkgbox/pkg</action>
186 <action>$LIB/package_infos</action>
187 <action>refresh:PKG</action>
188 <action>refresh:GETIT</action>
189 <action>refresh:PKG_STATS</action>
190 <action>refresh:CACHE_STATS</action>
191 </tree>
192 <hbox>
193 <text>
194 <label>"Status:"</label>
195 </text>
196 <combobox>
197 <variable>STATUS</variable>
198 <item>all</item>
199 <item>installed</item>
200 <item>installable</item>
201 <item>blocked</item>
202 </combobox>
203 <text>
204 <label>"Category:"</label>
205 </text>
206 <combobox>
207 <variable>CAT</variable>
208 <item>all</item>
209 <item>base-system</item>
210 <item>x-window</item>
211 <item>utilities</item>
212 <item>network</item>
213 <item>graphics</item>
214 <item>multimedia</item>
215 <item>office</item>
216 <item>development</item>
217 <item>system-tools</item>
218 <item>security</item>
219 <item>games</item>
220 <item>misc</item>
221 <item>meta</item>
222 <item>non-free</item>
223 </combobox>
224 <button>
225 <label>List</label>
226 <input file icon="reload"></input>
227 <action>echo "$CAT" > /tmp/tazpkgbox/category</action>
228 <action>echo "$STATUS" > /tmp/tazpkgbox/status</action>
229 <action>refresh:PKG</action>
230 </button>
231 </hbox>
232 </vbox>
234 <vbox>
235 <tree icon="tazpkg">
236 <width>620</width><height>120</height>
237 <variable>RESULT_INSTALLED</variable>
238 <label>Installed packages|Version|Description / File</label>
239 <input>cat /tmp/tazpkgbox/search-installed</input>
240 <action>echo "$RESULT_INSTALLED" > /tmp/tazpkgbox/pkg</action>
241 <action>$LIB/package_infos</action>
242 <action>$LIB/search</action>
243 <action>refresh:RESULT_INSTALLED</action>
244 <action>refresh:PKG</action>
245 <action>refresh:PKG_STATS</action>
246 <action>refresh:CACHE_STATS</action>
247 </tree>
248 <tree icon="tazpkg">
249 <width>620</width><height>120</height>
250 <variable>RESULT_MIRROR</variable>
251 <label>Mirrored packages|Version|Description / File</label>
252 <input>cat /tmp/tazpkgbox/search-mirrored</input>
253 <action>echo "$RESULT_MIRROR" > /tmp/tazpkgbox/pkg</action>
254 <action>$LIB/package_infos</action>
255 <action>$LIB/search</action>
256 <action>refresh:RESULT_INSTALLED</action>
257 <action>refresh:PKG</action>
258 <action>refresh:PKG_STATS</action>
259 <action>refresh:CACHE_STATS</action>
260 </tree>
261 <hbox>
262 <entry>
263 <variable>SEARCH</variable>
264 </entry>
265 <button>
266 <label>Search Packages</label>
267 <input file icon="system-search"></input>
268 <action>$LIB/search</action>
269 <action>refresh:RESULT_INSTALLED</action>
270 <action>refresh:RESULT_MIRROR</action>
271 </button>
272 <button>
273 <label>Search Files</label>
274 <input file icon="system-search"></input>
275 <action>$LIB/search --files</action>
276 <action>refresh:RESULT_INSTALLED</action>
277 <action>refresh:RESULT_MIRROR</action>
278 </button>
279 </hbox>
280 </vbox>
282 <vbox>
283 <tree>
284 <width>620</width><height>240</height>
285 <variable>DEV</variable>
286 <label>Package name|Version|Description</label>
287 <input>$LIB/list undigest</input>
288 <action>echo "$DEV" > /tmp/tazpkgbox/pkg</action>
289 <action>$LIB/package_infos</action>
290 <action>refresh:PKG</action>
291 <action>refresh:GETIT</action>
292 <action>refresh:PKG_STATS</action>
293 <action>refresh:CACHE_STATS</action>
294 </tree>
295 <hbox>
296 <button>
297 <label>Setup undigest mirrors</label>
298 <input file icon="go-next"></input>
299 <action type="launch">SETUP_UNDIGEST</action>
300 </button>
301 </hbox>
302 <hbox>
303 <text>
304 <label>"Undigest:"</label>
305 </text>
306 <combobox>
307 <variable>UNDIGEST_ENTRY</variable>
308 '
309 for i in all $(ls /var/lib/tazpkg/undigest 2> /dev/null); do
310 TAZPKG_DIALOG="$TAZPKG_DIALOG <item>$i</item> "
311 done
312 tmp=' </combobox>
313 <text>
314 <label>"Category:"</label>
315 </text>
316 <combobox>
317 <variable>UNDIGEST_CAT</variable>
318 <item>all</item>
319 <item>base-system</item>
320 <item>x-window</item>
321 <item>utilities</item>
322 <item>network</item>
323 <item>graphics</item>
324 <item>multimedia</item>
325 <item>office</item>
326 <item>development</item>
327 <item>system-tools</item>
328 <item>security</item>
329 <item>games</item>
330 <item>misc</item>
331 <item>meta</item>
332 <item>non-free</item>
333 </combobox>
334 <button>
335 <label>List</label>
336 <input file icon="reload"></input>
337 <action>echo "$UNDIGEST_CAT $UNDIGEST_ENTRY" > /tmp/tazpkgbox/undigest-category</action>
338 <action>refresh:DEV</action>
339 </button>
340 </hbox>
341 </vbox>
343 <vbox>
344 <frame Files and Cache directory>
345 <text use-markup="true" width-chars="60" wrap="false">
346 <label>"
347 Lists, mirror URL and installed packages: <b>/var/lib/tazpkg</b>
348 The cache directory is used to store downloaded or repacked packages.
349 "</label>
350 </text>
351 <hbox>
352 <entry editable="false">
353 <input>cd /var/cache/tazpkg; echo "Packages: `ls | wc -l`, size: `du -sh $PWD`"</input>
354 <variable>CACHE_STATS</variable>
355 </entry>
356 <button>
357 <label>Clean cache</label>
358 <input file icon="go-next"></input>
359 <action>rm -rf /var/cache/tazpkg/*</action>
360 <action>refresh:CACHE_STATS</action>
361 </button>
362 </hbox>
363 </frame>
364 <frame Mirror URL>
365 <hbox>
366 <entry>
367 <input>head -n 1 /var/lib/tazpkg/mirror</input>
368 <variable>MIRROR</variable>
369 </entry>
370 <button>
371 <label>Setup</label>
372 <input file icon="go-next"></input>
373 <action>echo "$MIRROR" > /var/lib/tazpkg/mirror</action>
374 <action>clear:MIRROR</action>
375 <action>refresh:MIRROR</action>
376 </button>
377 <button>
378 <label>Add</label>
379 <input file icon="gtk-add"></input>
380 <action>echo "$MIRROR" >> /var/lib/tazpkg/mirror</action>
381 <action>clear:MIRROR</action>
382 <action>refresh:MIRROR</action>
383 </button>
384 </hbox>
385 </frame>
386 <hbox>
387 <frame Journal>
388 <hbox>
389 <button>
390 <label>Show journal</label>
391 <input file icon="find"></input>
392 <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>
393 </button>
394 </hbox>
395 </frame>
396 <frame Configuration files>
397 <hbox>
398 <button>
399 <label>Repack config</label>
400 <input file icon="edit-redo"></input>
401 <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>
402 </button>
403 <button>
404 <label>Config Files</label>
405 <input file icon="tazpkg"></input>
406 <action type="launch">LIST_CONFIG_FILES</action>
407 </button>
408 </hbox>
409 </frame>
410 <frame Packages check>
411 <hbox>
412 <button>
413 <label>Quick check</label>
414 <input file icon="go-next"></input>
415 <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>
416 </button>
417 <button>
418 <label>Full check</label>
419 <input file icon="go-next"></input>
420 <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>
421 </button>
422 </hbox>
423 </frame>
424 </hbox>
425 </vbox>
427 </notebook>
429 <hbox>
430 <text wrap="false">
431 <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 "Packages statistics: $installed installed, $blocked blocked, $installable installable, $undigest undigest, $mirrored mirrored, `cat /var/lib/tazpkg/upgradable-packages.list 2> /dev/null | wc -l` to upgrade "</input>
432 <variable>PKG_STATS</variable>
433 </text>
434 </hbox>
436 <hbox>
437 <button>
438 <label>Recharge lists</label>
439 <input file icon="system-software-update"></input>
440 <action>xterm -T "Recharge" -geometry 80x16+120+120 -e "tazpkg recharge; sleep 2" 2>/dev/null</action>
441 <action>refresh:DEV</action>
442 <action>refresh:GET</action>
443 <action>refresh:GETIT</action>
444 <action>refresh:PKG_STATS</action>
445 </button>
446 <button>
447 <label>Upgrade all</label>
448 <input file icon="system-software-update"></input>
449 <action>xterm -T "Package upgrade" -geometry 80x16+120+120 -e "tazpkg upgrade; sleep 2" 2>/dev/null</action>
450 <action>refresh:PKG</action>
451 <action>refresh:DEV</action>
452 <action>refresh:GET</action>
453 <action>refresh:GETIT</action>
454 <action>refresh:PKG_STATS</action>
455 <action>refresh:CACHE_STATS</action>
456 </button>
457 <button>
458 <label>Wok</label>
459 <input file icon="gtk-open"></input>
460 <action>firefox http://hg.slitaz.org/wok/file/</action>
461 </button>
462 <button help>
463 <label>Help</label>
464 <action type="launch">HELP</action>
465 </button>
466 <button>
467 <label>Exit</label>
468 <input file icon="exit"></input>
469 <action type="exit">Exit</action>
470 </button>
471 </hbox>
473 </vbox>
475 </window>
476 '
477 TAZPKG_DIALOG="$TAZPKG_DIALOG$tmp"
479 gtkdialog --center --program=TAZPKG_DIALOG >/dev/null
481 exit 0