tazpkg view tazpkgbox @ rev 231

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