tazlito view tazlitobox @ rev 184

tazlitobox: typos
author Paul Issott <paul@slitaz.org>
date Wed Oct 20 20:51:57 2010 +0000 (2010-10-20)
parents c7cb09008f4b
children b8347b934dc4
line source
1 #!/bin/sh
2 #
3 # Gtkdialog box for Tazlito - SliTaz Live Tool.
4 # Tabs are used for ident ans all action should go into functions to
5 # separate GUI and commands.
6 #
7 # (C) GNU gpl v3 - SliTaz GNU/Linux 2010.
8 #
9 VERSION=3.0
11 export BIN=$0
13 # Check if user is root.
14 check_root()
15 {
16 if test $(id -u) != 0 ; then
17 echo -e "
18 You must be root to run `basename $0`. Please type 'su' and
19 root password to become super-user.\n"
20 exit 0
21 fi
22 }
24 # We need to parse flavors.list for GTK tree.
25 list_flavors()
26 {
27 tazlito list-flavors | grep ^[a-z] | while read line
28 do
29 info=`echo -n $line | awk '{print $1 " " $2 " " $3}'`
30 printinfo=`echo -n $line | awk '{print $1 "|" $2 "|" $3}'`
31 echo "$printinfo|`echo $line | sed s/\"$info\"//`"
32 done
33 }
35 recharge_list()
36 {
37 xterm -geometry 90x14 \
38 -title "list-flavors --recharge" \
39 -e "tazlito list-flavors --recharge | grep ^[a-z] && sleep 2"
40 }
42 # When using gen-liveflavor, gen-flavor or gen-distro, user can put some
43 # addfiles copied into the rootfs.
44 addfiles_action()
45 {
46 cd /home/slitaz
47 mkdir -p distro/addfiles/rootfs/usr/share/images
48 mkdir -p distro/addfiles/rootcd
49 file-manager distro/addfiles &
50 }
52 writeiso_action()
53 {
54 xterm -geometry 80x16 \
55 -title "writeiso" \
56 -e "tazlito writeiso $COMPRESSION"
57 }
59 gen_liveflavor_action()
60 {
61 cd /home/slitaz
62 sed -i "s/ISO_NAME=.*/ISO_NAME=\"slitaz-$GEN_LIVEFLAVOR_NAME\"/" \
63 /etc/tazlito/tazlito.conf
64 xterm -geometry 80x16 \
65 -title "gen-liveflavor" \
66 -e "tazlito gen-liveflavor $GEN_LIVEFLAVOR_NAME && echo -e \"----\nENTER to continue...\" && read close"
67 }
69 clean_distro_action()
70 {
71 cd /home/slitaz
72 xterm -geometry 80x16 \
73 -title "clean-distro" \
74 -e "tazlito clean-distro && sleep 1"
75 }
77 show_flavors()
78 {
79 tazlito list-flavors | \
80 awk '{if (show && $1 != "") print $1} /^==/ {show=1}'
81 }
83 get_flavor_action()
84 {
85 cd /home/slitaz
86 xterm -geometry 80x16 \
87 -title "get-flavor $COMMUNITY_FLAVOR" \
88 -e "tazlito get-flavor $COMMUNITY_FLAVOR && echo -e \"----\nENTER to continue...\" && read close"
89 }
91 gen_distro_action()
92 {
93 cd /home/slitaz
94 xterm -geometry 80x16 \
95 -title "gen-distro" \
96 -e "tazlito gen-distro && echo -e \"----\nENTER to continue...\" && read close"
97 }
99 gen_flavor_action()
100 {
101 cd /home/slitaz
102 xterm -geometry 80x16 \
103 -title "gen-flavor $GEN_FLAVOR_NAME" \
104 -e "tazlito gen-flavor $GEN_FLAVOR_NAME && echo -e \"----\nENTER to continue...\" && read close"
105 }
107 edit_distro_script()
108 {
109 [ ! -f $DISTRO_SCRIPT ] && echo "#!/bin/sh" > $DISTRO_SCRIPT
110 chmod +x $DISTRO_SCRIPT
111 editor $DISTRO_SCRIPT
112 }
114 loram_action()
115 {
116 case "$LORAM_RAM$LORAM_CDROM$LORAM_HTTP" in
117 falsetruefalse) type=cdrom ;;
118 falsefalsetrue) type=http ;;
119 *) type=ram ;;
120 esac
121 xterm -geometry 80x16 \
122 -title "build loram iso image $LORAM_OUT" \
123 -e "tazlito build-loram $LORAM_IN $LORAM_OUT $type ; echo -e \"----\nENTER to continue...\" && read close"
124 }
126 merge_input()
127 {
128 set -- $(cat /tmp/tazlito.mergelist 2> /dev/null)
129 while [ -n "$2" ]; do
130 echo "$2 | $1"
131 shift 2
132 done
133 }
135 merge_add()
136 {
137 echo -n " $ISO_IN $ISO_RAM" >> /tmp/tazlito.mergelist
138 }
140 merge_del()
141 {
142 set -- $(cat /tmp/tazlito.mergelist)
143 ARGS=""
144 while [ -n "$2" ]; do
145 case "$1" in
146 $ISO_ITEM) ;;
147 *) [ -n "$ARGS" ] && ARGS="$ARGS "
148 ARGS="$ARGS$1 $2" ;;
149 esac
150 shift 2
151 done
152 echo -n "$ARGS" > /tmp/tazlito.mergelist
153 }
155 merge_args()
156 {
157 first=true
158 while [ -n "$2" ]; do
159 echo "$(stat -c "%s" $1) $1 $2"
160 shift 2
161 done | sort -nr | while read size file ram; do
162 if $first; then
163 cp $file $ISO_OUT
164 echo -n "$ram $ISO_OUT "
165 first=false
166 continue
167 fi
168 dir=$tmp/$(basename $file)
169 mkdir $dir
170 mount -o loop,ro $file $dir
171 echo -n "$ram $dir/boot/rootfs.gz "
172 done
173 }
175 merge_action()
176 {
177 set -- $(cat /tmp/tazlito.mergelist 2> /dev/null)
178 rm -f /tmp/tazlito.mergelist
179 tmp=/tmp/tazlitobox$$
180 mkdir $tmp
181 [ -n "$4" ] || return
182 xterm -geometry 80x16 -title "build meta iso image $ISO_OUT" \
183 -e "script -c 'tazlito merge $(merge_args $@)' && echo -e \"----\nENTER to continue...\" && read close"
184 mv $ISO_OUT.merged $ISO_OUT
185 for i in $tmp/*; do
186 umount -d $i
187 done
188 rm -rf $tmp
189 }
191 # Boxes
193 export HELP='
194 <window title="Tazlito Box - Help" icon-name="media-cdrom">
195 <vbox>
196 <text use-markup="true">
197 <label>"
198 <b>Tazlito Box - Help</b>"
199 </label>
200 </text>
202 <frame Overview>
203 <text wrap="true" width-chars="52" use-markup="true">
204 <label>
205 "
206 Tazlito Box is a tiny interface to the SliTaz Live Tool aka Tazlito.
207 You can simply generate a LiveCD in a few minutes, using your
208 own flavor or one from the SliTaz community. Tazlito can also
209 generate a LiveCD flavor using all of the currently installed
210 packages. Tazlito commands are executed in a XTerm, you can
211 press ENTER or the mouse to close the window.
212 "
213 </label>
214 </text>
215 </frame>
217 <frame Default paths>
218 <text wrap="true" width-chars="50" use-markup="true">
219 <label>
220 "
221 Distro : /home/slitaz/distro
222 Flavors : /home/slitaz/flavors
223 Packages : /home/slitaz/packages
224 "
225 </label>
226 </text>
227 </frame>
229 <hbox>
230 <button>
231 <input file icon="exit"></input>
232 <action type="closewindow">HELP</action>
233 </button>
234 </hbox>
236 </vbox>
237 </window>
238 '
240 # List all flavors on the mirror.
241 export LIST_FLAVORS_BOX='
242 <window title="Community flavors list" icon-name="tazlito">
243 <vbox>
244 <tree>
245 <width>500</width><height>200</height>
246 <variable>COMMUNITY_FLAVOR</variable>
247 <label>Name|ISO|Rootfs|Description</label>
248 <input exported_column="0">$BIN list_flavors</input>
249 </tree>
250 <hbox>
251 <button>
252 <label>Recharge list</label>
253 <input file icon="reload"></input>
254 <action>$BIN recharge_list</action>
255 <action>refresh:COMMUNITY_FLAVOR</action>
256 </button>
257 <button>
258 <label>Exit</label>
259 <input file icon="exit"></input>
260 <action type="closewindow">LIST_FLAVORS_BOX</action>
261 </button>
262 </hbox>
263 </vbox>
264 </window>'
266 # Execute tazlito commands in a XTerm. Notebook: tab-pos="GTK_POS_LEFT"
267 export TAZLITO_BOX='
268 <window title="Tazlito Box" icon-name="media-cdrom">
269 <vbox>
271 <hbox>
272 <text use-markup="true">
273 <label>"<b>SliTaz Live Tool</b>"</label>
274 </text>
275 <pixmap>
276 <input file>/usr/share/pixmaps/tazlito.png</input>
277 </pixmap>
278 </hbox>
280 <notebook labels="Writeiso|Live flavor|Flavors list|Gen flavor|Meta|Low RAM|Configuration">
282 <frame Filesystem to ISO>
284 <text wrap="true" width-chars="60" use-markup="true">
285 <label>
286 "
287 Writeiso will generate an ISO image of the current filesystem as
288 is, including the /home directory. It is an easy way to remaster a
289 SliTaz Live system, you just have to: boot, modify, writeiso.
290 "
291 </label>
292 </text>
294 <hbox>
295 <text use-markup="true">
296 <label>"<b>Compression:</b>"</label>
297 </text>
298 <combobox>
299 <variable>COMPRESSION</variable>
300 <item>gzip</item>
301 <item>lzma</item>
302 <item>none</item>
303 </combobox>
304 <button>
305 <label>Writeiso</label>
306 <input file icon="forward"></input>
307 <action>$BIN writeiso_action</action>
308 </button>
309 </hbox>
311 </frame>
313 <frame Current packages selection>
315 <text wrap="true" width-chars="60" use-markup="true">
316 <label>
317 "
318 Gen Live flavor will create a LiveCD based on all the currently
319 installed packages. To build the rootfs and ISO image it will use
320 original SliTaz packages. Any addfiles can be copied before
321 generating the distro.
322 "
323 </label>
324 </text>
326 <hbox>
327 <text use-markup="true">
328 <label>"<b>Flavor name :</b>"</label>
329 </text>
330 <entry>
331 <default>slitaz</default>
332 <variable>GEN_LIVEFLAVOR_NAME</variable>
333 </entry>
334 </hbox>
336 <hbox>
337 <button>
338 <label>Addfiles</label>
339 <input file icon="gtk-open"></input>
340 <action>$BIN addfiles_action</action>
341 </button>
342 <button>
343 <label>Gen distro</label>
344 <input file icon="forward"></input>
345 <action>$BIN gen_liveflavor_action</action>
346 </button>
347 <button>
348 <label>Clean distro</label>
349 <input file icon="edit-clear"></input>
350 <action>$BIN clean_distro_action</action>
351 </button>
352 </hbox>
354 </frame>
356 <frame Community and personal flavors>
358 <text wrap="true" width-chars="60" use-markup="true">
359 <label>
360 "
361 Get and build preconfigured flavors from the community. The list of
362 flavors can be recharged from the SliTaz mirror. Some addfiles can
363 be copied before generating the distro.
364 "
365 </label>
366 </text>
368 <hbox>
369 <text use-markup="true">
370 <label>"<b>Flavor :</b>"</label>
371 </text>
372 <entry>
373 <default>core</default>
374 <variable>COMMUNITY_FLAVOR</variable>
375 </entry>
376 <button>
377 <label>List flavors</label>
378 <input file icon="media-cdrom"></input>
379 <action type="launch">LIST_FLAVORS_BOX</action>
380 </button>
381 </hbox>
383 <hbox>
384 <button>
385 <label>Get flavor</label>
386 <input file icon="forward"></input>
387 <action>$BIN get_flavor_action</action>
388 </button>
389 <button>
390 <label>Addfiles</label>
391 <input file icon="gtk-open"></input>
392 <action>$BIN addfiles_action</action>
393 </button>
394 <button>
395 <label>Gen distro</label>
396 <input file icon="forward"></input>
397 <action>$BIN gen_distro_action</action>
398 </button>
399 <button>
400 <label>Clean distro</label>
401 <input file icon="edit-clear"></input>
402 <action>$BIN clean_distro_action</action>
403 </button>
404 </hbox>
406 </frame>
407 <frame Generate a flavor>
409 <text wrap="true" width-chars="60" use-markup="true">
410 <label>
411 "
412 Gen Flavor will generate a new flavor file based on a rootfs in
413 /home/slitaz/distro. All addfiles will be included in the flavor file.
414 "
415 </label>
416 </text>
418 <hbox>
419 <text use-markup="true">
420 <label>"<b>New flavor :</b>"</label>
421 </text>
422 <entry>
423 <default>slitaz</default>
424 <variable>GEN_FLAVOR_NAME</variable>
425 </entry>
426 </hbox>
428 <hbox>
429 <button>
430 <label>Addfiles</label>
431 <input file icon="gtk-open"></input>
432 <action>$BIN addfiles_action</action>
433 </button>
434 <button>
435 <label>Gen new flavor</label>
436 <input file icon="forward"></input>
437 <action>$BIN gen_flavor_action</action>
438 </button>
439 </hbox>
441 </frame>
443 <frame Meta ISO image>
445 <vbox>
446 <hbox>
447 <vbox>
448 <text wrap="true" width-chars="33" use-markup="true">
449 <label>
450 "
451 Combines several ISO flavors like
452 nested Russian dolls. The amount
453 of RAM available at startup will be
454 used to select the utmost one. "
455 </label>
456 </text>
457 <hbox>
458 <text use-markup="true">
459 <label>"<b>ISO input: </b> "</label>
460 </text>
461 <entry accept="filename">
462 <variable>ISO_IN</variable>
463 </entry>
464 <button>
465 <input file stock="gtk-open"></input>
466 <action type="fileselect">ISO_IN</action>
467 </button>
468 </hbox>
469 <hbox>
470 <text use-markup="true">
471 <label>"<b>RAM needed:</b> "</label>
472 </text>
473 <entry>
474 <default>128M</default>
475 <variable>ISO_RAM</variable>
476 </entry>
477 <button>
478 <input file icon="add"></input>
479 <action>$BIN merge_add</action>
480 <action>refresh:ISO_ITEM</action>
481 </button>
482 </hbox>
483 </vbox>
484 <tree>
485 <width>140</width><height>50</height>
486 <label>RAM|ISO</label>
487 <variable>ISO_ITEM</variable>
488 <input>$BIN merge_input</input>
489 <action>$BIN merge_del</action>
490 <action>refresh:ISO_ITEM</action>
491 </tree>
492 </hbox>
493 <hbox>
494 <text use-markup="true">
495 <label>"<b>ISO output:</b>"</label>
496 </text>
497 <entry accept="filename">
498 <default>meta.iso</default>
499 <variable>ISO_OUT</variable>
500 </entry>
501 <button>
502 <input file icon="go-next"></input>
503 <label>"Build ISO"</label>
504 <action>$BIN merge_action</action>
505 </button>
506 </hbox>
507 </vbox>
509 </frame>
511 <frame Low RAM ISO image>
513 <vbox>
514 <hbox>
515 <text wrap="true" width-chars="25" use-markup="true">
516 <label>
517 "
518 Build a Low RAM version
519 of a SliTaz ISO image.
520 The root filesystem is
521 compressed and slower.
522 "
523 </label>
524 </text>
526 <vbox>
527 <radiobutton>
528 <label>The filesystem is always in RAM.</label>
529 <variable>LORAM_RAM</variable>
530 </radiobutton>
531 <radiobutton>
532 <label>The filesystem may be on a CDROM.</label>
533 <variable>LORAM_CDROM</variable>
534 </radiobutton>
535 <radiobutton>
536 <label>The filesystem is on the WEB.</label>
537 <variable>LORAM_HTTP</variable>
538 </radiobutton>
539 </vbox>
540 </hbox>
541 <hbox>
542 <text use-markup="true">
543 <label>"<b>ISO input: </b>"</label>
544 </text>
545 <entry accept="filename">
546 <variable>LORAM_IN</variable>
547 </entry>
548 <button>
549 <input file stock="gtk-open"></input>
550 <action type="fileselect">LORAM_IN</action>
551 </button>
552 </hbox>
553 <hbox>
554 <text use-markup="true">
555 <label>"<b>ISO output:</b>"</label>
556 </text>
557 <entry accept="filename">
558 <default>loram.iso</default>
559 <variable>LORAM_OUT</variable>
560 </entry>
561 <button>
562 <input file icon="go-next"></input>
563 <label>"Build ISO"</label>
564 <action>$BIN loram_action</action>
565 </button>
566 </hbox>
567 </vbox>
569 </frame>
571 <frame Flavor config and packages list>
573 <text wrap="true" width-chars="60" use-markup="true">
574 <label>
575 "
576 Before editing files you must have a flavor description. A distro
577 script can be used to perform actions into the rootfs before
578 compression.
579 "
580 </label>
581 </text>
583 <hbox>
584 <text use-markup="true">
585 <label>"<b>Flavor config :</b>"</label>
586 </text>
587 <entry>
588 <default>/home/slitaz/tazlito.conf</default>
589 <variable>CONFIG_FILE</variable>
590 </entry>
591 <button>
592 <input file icon="accessories-text-editor"></input>
593 <action>editor $CONFIG_FILE</action>
594 </button>
595 </hbox>
597 <hbox>
598 <text use-markup="true">
599 <label>"<b>Packages list :</b>"</label>
600 </text>
601 <entry>
602 <default>/home/slitaz/distro-packages.list</default>
603 <variable>PKGS_LIST</variable>
604 </entry>
605 <button>
606 <input file icon="accessories-text-editor"></input>
607 <action>editor $PKGS_LIST</action>
608 </button>
609 </hbox>
611 <hbox>
612 <text use-markup="true">
613 <label>"<b>Distro script :</b> "</label>
614 </text>
615 <entry>
616 <default>/home/slitaz/distro.sh</default>
617 <variable>DISTRO_SCRIPT</variable>
618 </entry>
619 <button>
620 <input file icon="accessories-text-editor"></input>
621 <action>$BIN edit_distro_script</action>
622 </button>
623 </hbox>
625 </frame>
627 </notebook>
629 <hbox>
630 <button help>
631 <input file icon="help-browser"></input>
632 <action type="launch">HELP</action>
633 </button>
634 <button>
635 <label>Exit</label>
636 <input file icon="exit"></input>
637 <action type="exit">Exit</action>
638 </button>
639 </hbox>
641 </vbox>
642 </window>
643 '
645 case $1 in
646 *_*)
647 # Exec all function called by args (must have an underscore).
648 $1 ;;
649 *)
650 # Tazlitobox action.
651 check_root
652 gtkdialog --center --program=TAZLITO_BOX ;;
653 esac
655 exit 0