tazpkg view tazpkgbox @ rev 233

tazpkgbox: improved search tab and engine and add new tazpkg-installed icon
author Christophe Lincoln <pankso@slitaz.org>
date Wed Feb 25 22:03:25 2009 +0100 (2009-02-25)
parents dd48da6e9023
children e553dc92c647
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/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.
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>
236 <width>620</width><height>120</height>
237 <variable>RESULT</variable>
238 <label>Installed packages|Version|Description / File</label>
239 <input icon_column="0">cat /tmp/tazpkgbox/search</input>
240 <action>echo "$RESULT" > /tmp/tazpkgbox/pkg</action>
241 <action>$LIB/package_infos</action>
242 <action>$LIB/search</action>
243 <action>refresh:RESULT</action>
244 <action>refresh:PKG</action>
245 <action>refresh:PKG_STATS</action>
246 <action>refresh:CACHE_STATS</action>
247 </tree>
248 <hbox>
249 <entry>
250 <variable>SEARCH</variable>
251 </entry>
252 <button>
253 <label>Packages</label>
254 <input file icon="system-search"></input>
255 <action>$LIB/search packages</action>
256 <action>refresh:RESULT</action>
257 </button>
258 <button>
259 <label>Files</label>
260 <input file icon="system-search"></input>
261 <action>$LIB/search files</action>
262 <action>refresh:RESULT</action>
263 </button>
264 </hbox>
265 </vbox>
267 <vbox>
268 <tree>
269 <width>620</width><height>240</height>
270 <variable>DEV</variable>
271 <label>Package name|Version|Description</label>
272 <input>$LIB/list undigest</input>
273 <action>echo "$DEV" > /tmp/tazpkgbox/pkg</action>
274 <action>$LIB/package_infos</action>
275 <action>refresh:PKG</action>
276 <action>refresh:GETIT</action>
277 <action>refresh:PKG_STATS</action>
278 <action>refresh:CACHE_STATS</action>
279 </tree>
280 <hbox>
281 <button>
282 <label>Setup undigest mirrors</label>
283 <input file icon="go-next"></input>
284 <action type="launch">SETUP_UNDIGEST</action>
285 </button>
286 </hbox>
287 <hbox>
288 <text>
289 <label>"Undigest:"</label>
290 </text>
291 <combobox>
292 <variable>UNDIGEST_ENTRY</variable>
293 '
294 for i in all $(ls /var/lib/tazpkg/undigest 2> /dev/null); do
295 TAZPKG_DIALOG="$TAZPKG_DIALOG <item>$i</item> "
296 done
297 tmp=' </combobox>
298 <text>
299 <label>"Category:"</label>
300 </text>
301 <combobox>
302 <variable>UNDIGEST_CAT</variable>
303 <item>all</item>
304 <item>base-system</item>
305 <item>x-window</item>
306 <item>utilities</item>
307 <item>network</item>
308 <item>graphics</item>
309 <item>multimedia</item>
310 <item>office</item>
311 <item>development</item>
312 <item>system-tools</item>
313 <item>security</item>
314 <item>games</item>
315 <item>misc</item>
316 <item>meta</item>
317 <item>non-free</item>
318 </combobox>
319 <button>
320 <label>List</label>
321 <input file icon="reload"></input>
322 <action>echo "$UNDIGEST_CAT $UNDIGEST_ENTRY" > /tmp/tazpkgbox/undigest-category</action>
323 <action>refresh:DEV</action>
324 </button>
325 </hbox>
326 </vbox>
328 <vbox>
329 <frame Files and Cache directory>
330 <text use-markup="true" width-chars="60" wrap="false">
331 <label>"
332 Lists, mirror URL and installed packages: <b>/var/lib/tazpkg</b>
333 The cache directory is used to store downloaded or repacked packages.
334 "</label>
335 </text>
336 <hbox>
337 <entry editable="false">
338 <input>cd /var/cache/tazpkg; echo "Packages: `ls | wc -l`, size: `du -sh $PWD`"</input>
339 <variable>CACHE_STATS</variable>
340 </entry>
341 <button>
342 <label>Clean cache</label>
343 <input file icon="go-next"></input>
344 <action>rm -rf /var/cache/tazpkg/*</action>
345 <action>refresh:CACHE_STATS</action>
346 </button>
347 </hbox>
348 </frame>
349 <frame Mirror URL>
350 <hbox>
351 <entry>
352 <input>head -n 1 /var/lib/tazpkg/mirror</input>
353 <variable>MIRROR</variable>
354 </entry>
355 <button>
356 <label>Setup</label>
357 <input file icon="go-next"></input>
358 <action>echo "$MIRROR" > /var/lib/tazpkg/mirror</action>
359 <action>clear:MIRROR</action>
360 <action>refresh:MIRROR</action>
361 </button>
362 <button>
363 <label>Add</label>
364 <input file icon="gtk-add"></input>
365 <action>echo "$MIRROR" >> /var/lib/tazpkg/mirror</action>
366 <action>clear:MIRROR</action>
367 <action>refresh:MIRROR</action>
368 </button>
369 </hbox>
370 </frame>
371 <hbox>
372 <frame Journal>
373 <hbox>
374 <button>
375 <label>Show journal</label>
376 <input file icon="find"></input>
377 <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>
378 </button>
379 </hbox>
380 </frame>
381 <frame Configuration files>
382 <hbox>
383 <button>
384 <label>Repack config</label>
385 <input file icon="edit-redo"></input>
386 <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>
387 </button>
388 <button>
389 <label>Config Files</label>
390 <input file icon="tazpkg"></input>
391 <action type="launch">LIST_CONFIG_FILES</action>
392 </button>
393 </hbox>
394 </frame>
395 <frame Packages check>
396 <hbox>
397 <button>
398 <label>Quick check</label>
399 <input file icon="go-next"></input>
400 <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>
401 </button>
402 <button>
403 <label>Full check</label>
404 <input file icon="go-next"></input>
405 <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>
406 </button>
407 </hbox>
408 </frame>
409 </hbox>
410 </vbox>
412 </notebook>
414 <hbox>
415 <text wrap="false">
416 <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>
417 <variable>PKG_STATS</variable>
418 </text>
419 </hbox>
421 <hbox>
422 <button>
423 <label>Recharge lists</label>
424 <input file icon="system-software-update"></input>
425 <action>xterm -T "Recharge" -geometry 80x16+120+120 -e "tazpkg recharge; sleep 2" 2>/dev/null</action>
426 <action>refresh:DEV</action>
427 <action>refresh:GET</action>
428 <action>refresh:GETIT</action>
429 <action>refresh:PKG_STATS</action>
430 </button>
431 <button>
432 <label>Upgrade all</label>
433 <input file icon="system-software-update"></input>
434 <action>xterm -T "Package upgrade" -geometry 80x16+120+120 -e "tazpkg upgrade; sleep 2" 2>/dev/null</action>
435 <action>refresh:PKG</action>
436 <action>refresh:DEV</action>
437 <action>refresh:GET</action>
438 <action>refresh:GETIT</action>
439 <action>refresh:PKG_STATS</action>
440 <action>refresh:CACHE_STATS</action>
441 </button>
442 <button>
443 <label>Wok</label>
444 <input file icon="gtk-open"></input>
445 <action>firefox http://hg.slitaz.org/wok/file/</action>
446 </button>
447 <button help>
448 <label>Help</label>
449 <action type="launch">HELP</action>
450 </button>
451 <button>
452 <label>Exit</label>
453 <input file icon="exit"></input>
454 <action type="exit">Exit</action>
455 </button>
456 </hbox>
458 </vbox>
460 </window>
461 '
462 TAZPKG_DIALOG="$TAZPKG_DIALOG$tmp"
464 gtkdialog --center --program=TAZPKG_DIALOG >/dev/null
466 exit 0