tazpkg view tazpkgbox @ rev 238

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