tazlito view tazlitobox @ rev 192

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