tazlito view tazlitobox @ rev 185

tazlitobox: remove loram http
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Nov 05 17:06:48 2010 +0100 (2010-11-05)
parents 492ac55668ff
children cc8b4e7e46b3
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" in
117 falsetrue) type=cdrom ;;
118 *) type=ram ;;
119 esac
120 xterm -geometry 80x16 \
121 -title "build loram iso image $LORAM_OUT" \
122 -e "tazlito build-loram $LORAM_IN $LORAM_OUT $type ; echo -e \"----\nENTER to continue...\" && read close"
123 }
125 merge_input()
126 {
127 set -- $(cat /tmp/tazlito.mergelist 2> /dev/null)
128 while [ -n "$2" ]; do
129 echo "$2 | $1"
130 shift 2
131 done
132 }
134 merge_add()
135 {
136 echo -n " $ISO_IN $ISO_RAM" >> /tmp/tazlito.mergelist
137 }
139 merge_del()
140 {
141 set -- $(cat /tmp/tazlito.mergelist)
142 ARGS=""
143 while [ -n "$2" ]; do
144 case "$1" in
145 $ISO_ITEM) ;;
146 *) [ -n "$ARGS" ] && ARGS="$ARGS "
147 ARGS="$ARGS$1 $2" ;;
148 esac
149 shift 2
150 done
151 echo -n "$ARGS" > /tmp/tazlito.mergelist
152 }
154 merge_args()
155 {
156 first=true
157 while [ -n "$2" ]; do
158 echo "$(stat -c "%s" $1) $1 $2"
159 shift 2
160 done | sort -nr | while read size file ram; do
161 if $first; then
162 cp $file $ISO_OUT
163 echo -n "$ram $ISO_OUT "
164 first=false
165 continue
166 fi
167 dir=$tmp/$(basename $file)
168 mkdir $dir
169 mount -o loop,ro $file $dir
170 echo -n "$ram $dir/boot/rootfs.gz "
171 done
172 }
174 merge_action()
175 {
176 set -- $(cat /tmp/tazlito.mergelist 2> /dev/null)
177 rm -f /tmp/tazlito.mergelist
178 tmp=/tmp/tazlitobox$$
179 mkdir $tmp
180 [ -n "$4" ] || return
181 xterm -geometry 80x16 -title "build meta iso image $ISO_OUT" \
182 -e "script -c 'tazlito merge $(merge_args $@)' && echo -e \"----\nENTER to continue...\" && read close"
183 mv $ISO_OUT.merged $ISO_OUT
184 for i in $tmp/*; do
185 umount -d $i
186 done
187 rm -rf $tmp
188 }
190 # Boxes
192 export HELP='
193 <window title="Tazlito Box - Help" icon-name="media-cdrom">
194 <vbox>
195 <text use-markup="true">
196 <label>"
197 <b>Tazlito Box - Help</b>"
198 </label>
199 </text>
201 <frame Overview>
202 <text wrap="true" width-chars="52" use-markup="true">
203 <label>
204 "
205 Tazlito Box is a tiny interface to the SliTaz Live Tool aka Tazlito.
206 You can simply generate a LiveCD in a few minutes, using your
207 own flavor or one from the SliTaz community. Tazlito can also
208 generate a LiveCD flavor using all of the currently installed
209 packages. Tazlito commands are executed in a XTerm, you can
210 press ENTER or the mouse to close the window.
211 "
212 </label>
213 </text>
214 </frame>
216 <frame Default paths>
217 <text wrap="true" width-chars="50" use-markup="true">
218 <label>
219 "
220 Distro : /home/slitaz/distro
221 Flavors : /home/slitaz/flavors
222 Packages : /home/slitaz/packages
223 "
224 </label>
225 </text>
226 </frame>
228 <hbox>
229 <button>
230 <input file icon="exit"></input>
231 <action type="closewindow">HELP</action>
232 </button>
233 </hbox>
235 </vbox>
236 </window>
237 '
239 # List all flavors on the mirror.
240 export LIST_FLAVORS_BOX='
241 <window title="Community flavors list" icon-name="tazlito">
242 <vbox>
243 <tree>
244 <width>500</width><height>200</height>
245 <variable>COMMUNITY_FLAVOR</variable>
246 <label>Name|ISO|Rootfs|Description</label>
247 <input exported_column="0">$BIN list_flavors</input>
248 </tree>
249 <hbox>
250 <button>
251 <label>Recharge list</label>
252 <input file icon="reload"></input>
253 <action>$BIN recharge_list</action>
254 <action>refresh:COMMUNITY_FLAVOR</action>
255 </button>
256 <button>
257 <label>Exit</label>
258 <input file icon="exit"></input>
259 <action type="closewindow">LIST_FLAVORS_BOX</action>
260 </button>
261 </hbox>
262 </vbox>
263 </window>'
265 # Execute tazlito commands in a XTerm. Notebook: tab-pos="GTK_POS_LEFT"
266 export TAZLITO_BOX='
267 <window title="Tazlito Box" icon-name="media-cdrom">
268 <vbox>
270 <hbox>
271 <text use-markup="true">
272 <label>"<b>SliTaz Live Tool</b>"</label>
273 </text>
274 <pixmap>
275 <input file>/usr/share/pixmaps/tazlito.png</input>
276 </pixmap>
277 </hbox>
279 <notebook labels="Writeiso|Live flavor|Flavors list|Gen flavor|Meta|Low RAM|Configuration">
281 <frame Filesystem to ISO>
283 <text wrap="true" width-chars="60" use-markup="true">
284 <label>
285 "
286 Writeiso will generate an ISO image of the current filesystem as
287 is, including the /home directory. It is an easy way to remaster a
288 SliTaz Live system, you just have to: boot, modify, writeiso.
289 "
290 </label>
291 </text>
293 <hbox>
294 <text use-markup="true">
295 <label>"<b>Compression:</b>"</label>
296 </text>
297 <combobox>
298 <variable>COMPRESSION</variable>
299 <item>gzip</item>
300 <item>lzma</item>
301 <item>none</item>
302 </combobox>
303 <button>
304 <label>Writeiso</label>
305 <input file icon="forward"></input>
306 <action>$BIN writeiso_action</action>
307 </button>
308 </hbox>
310 </frame>
312 <frame Current packages selection>
314 <text wrap="true" width-chars="60" use-markup="true">
315 <label>
316 "
317 Gen Live flavor will create a LiveCD based on all the currently
318 installed packages. To build the rootfs and ISO image it will use
319 original SliTaz packages. Any addfiles can be copied before
320 generating the distro.
321 "
322 </label>
323 </text>
325 <hbox>
326 <text use-markup="true">
327 <label>"<b>Flavor name :</b>"</label>
328 </text>
329 <entry>
330 <default>slitaz</default>
331 <variable>GEN_LIVEFLAVOR_NAME</variable>
332 </entry>
333 </hbox>
335 <hbox>
336 <button>
337 <label>Addfiles</label>
338 <input file icon="gtk-open"></input>
339 <action>$BIN addfiles_action</action>
340 </button>
341 <button>
342 <label>Gen distro</label>
343 <input file icon="forward"></input>
344 <action>$BIN gen_liveflavor_action</action>
345 </button>
346 <button>
347 <label>Clean distro</label>
348 <input file icon="edit-clear"></input>
349 <action>$BIN clean_distro_action</action>
350 </button>
351 </hbox>
353 </frame>
355 <frame Community and personal flavors>
357 <text wrap="true" width-chars="60" use-markup="true">
358 <label>
359 "
360 Get and build preconfigured flavors from the community. The list of
361 flavors can be recharged from the SliTaz mirror. Some addfiles can
362 be copied before generating the distro.
363 "
364 </label>
365 </text>
367 <hbox>
368 <text use-markup="true">
369 <label>"<b>Flavor :</b>"</label>
370 </text>
371 <entry>
372 <default>core</default>
373 <variable>COMMUNITY_FLAVOR</variable>
374 </entry>
375 <button>
376 <label>List flavors</label>
377 <input file icon="media-cdrom"></input>
378 <action type="launch">LIST_FLAVORS_BOX</action>
379 </button>
380 </hbox>
382 <hbox>
383 <button>
384 <label>Get flavor</label>
385 <input file icon="forward"></input>
386 <action>$BIN get_flavor_action</action>
387 </button>
388 <button>
389 <label>Addfiles</label>
390 <input file icon="gtk-open"></input>
391 <action>$BIN addfiles_action</action>
392 </button>
393 <button>
394 <label>Gen distro</label>
395 <input file icon="forward"></input>
396 <action>$BIN gen_distro_action</action>
397 </button>
398 <button>
399 <label>Clean distro</label>
400 <input file icon="edit-clear"></input>
401 <action>$BIN clean_distro_action</action>
402 </button>
403 </hbox>
405 </frame>
406 <frame Generate a flavor>
408 <text wrap="true" width-chars="60" use-markup="true">
409 <label>
410 "
411 Gen Flavor will generate a new flavor file based on a rootfs in
412 /home/slitaz/distro. All addfiles will be included in the flavor file.
413 "
414 </label>
415 </text>
417 <hbox>
418 <text use-markup="true">
419 <label>"<b>New flavor :</b>"</label>
420 </text>
421 <entry>
422 <default>slitaz</default>
423 <variable>GEN_FLAVOR_NAME</variable>
424 </entry>
425 </hbox>
427 <hbox>
428 <button>
429 <label>Addfiles</label>
430 <input file icon="gtk-open"></input>
431 <action>$BIN addfiles_action</action>
432 </button>
433 <button>
434 <label>Gen new flavor</label>
435 <input file icon="forward"></input>
436 <action>$BIN gen_flavor_action</action>
437 </button>
438 </hbox>
440 </frame>
442 <frame Meta ISO image>
444 <vbox>
445 <hbox>
446 <vbox>
447 <text wrap="true" width-chars="33" use-markup="true">
448 <label>
449 "
450 Combines several ISO flavors like
451 nested Russian dolls. The amount
452 of RAM available at startup will be
453 used to select the utmost one. "
454 </label>
455 </text>
456 <hbox>
457 <text use-markup="true">
458 <label>"<b>ISO input: </b> "</label>
459 </text>
460 <entry accept="filename">
461 <variable>ISO_IN</variable>
462 </entry>
463 <button>
464 <input file stock="gtk-open"></input>
465 <action type="fileselect">ISO_IN</action>
466 </button>
467 </hbox>
468 <hbox>
469 <text use-markup="true">
470 <label>"<b>RAM needed:</b> "</label>
471 </text>
472 <entry>
473 <default>128M</default>
474 <variable>ISO_RAM</variable>
475 </entry>
476 <button>
477 <input file icon="add"></input>
478 <action>$BIN merge_add</action>
479 <action>refresh:ISO_ITEM</action>
480 </button>
481 </hbox>
482 </vbox>
483 <tree>
484 <width>140</width><height>50</height>
485 <label>RAM|ISO</label>
486 <variable>ISO_ITEM</variable>
487 <input>$BIN merge_input</input>
488 <action>$BIN merge_del</action>
489 <action>refresh:ISO_ITEM</action>
490 </tree>
491 </hbox>
492 <hbox>
493 <text use-markup="true">
494 <label>"<b>ISO output:</b>"</label>
495 </text>
496 <entry accept="filename">
497 <default>meta.iso</default>
498 <variable>ISO_OUT</variable>
499 </entry>
500 <button>
501 <input file icon="go-next"></input>
502 <label>"Build ISO"</label>
503 <action>$BIN merge_action</action>
504 </button>
505 </hbox>
506 </vbox>
508 </frame>
510 <frame Low RAM ISO image>
512 <vbox>
513 <hbox>
514 <text wrap="true" width-chars="25" use-markup="true">
515 <label>
516 "
517 Build a Low RAM version
518 of a SliTaz ISO image.
519 The root filesystem is
520 compressed and slower.
521 "
522 </label>
523 </text>
525 <vbox>
526 <radiobutton>
527 <label>The filesystem is always in RAM.</label>
528 <variable>LORAM_RAM</variable>
529 </radiobutton>
530 <radiobutton>
531 <label>The filesystem may be on a CDROM.</label>
532 <variable>LORAM_CDROM</variable>
533 </radiobutton>
534 </vbox>
535 </hbox>
536 <hbox>
537 <text use-markup="true">
538 <label>"<b>ISO input: </b>"</label>
539 </text>
540 <entry accept="filename">
541 <variable>LORAM_IN</variable>
542 </entry>
543 <button>
544 <input file stock="gtk-open"></input>
545 <action type="fileselect">LORAM_IN</action>
546 </button>
547 </hbox>
548 <hbox>
549 <text use-markup="true">
550 <label>"<b>ISO output:</b>"</label>
551 </text>
552 <entry accept="filename">
553 <default>loram.iso</default>
554 <variable>LORAM_OUT</variable>
555 </entry>
556 <button>
557 <input file icon="go-next"></input>
558 <label>"Build ISO"</label>
559 <action>$BIN loram_action</action>
560 </button>
561 </hbox>
562 </vbox>
564 </frame>
566 <frame Flavor config and packages list>
568 <text wrap="true" width-chars="60" use-markup="true">
569 <label>
570 "
571 Before editing files you must have a flavor description. A distro
572 script can be used to perform actions into the rootfs before
573 compression.
574 "
575 </label>
576 </text>
578 <hbox>
579 <text use-markup="true">
580 <label>"<b>Flavor config :</b>"</label>
581 </text>
582 <entry>
583 <default>/home/slitaz/tazlito.conf</default>
584 <variable>CONFIG_FILE</variable>
585 </entry>
586 <button>
587 <input file icon="accessories-text-editor"></input>
588 <action>editor $CONFIG_FILE</action>
589 </button>
590 </hbox>
592 <hbox>
593 <text use-markup="true">
594 <label>"<b>Packages list :</b>"</label>
595 </text>
596 <entry>
597 <default>/home/slitaz/distro-packages.list</default>
598 <variable>PKGS_LIST</variable>
599 </entry>
600 <button>
601 <input file icon="accessories-text-editor"></input>
602 <action>editor $PKGS_LIST</action>
603 </button>
604 </hbox>
606 <hbox>
607 <text use-markup="true">
608 <label>"<b>Distro script :</b> "</label>
609 </text>
610 <entry>
611 <default>/home/slitaz/distro.sh</default>
612 <variable>DISTRO_SCRIPT</variable>
613 </entry>
614 <button>
615 <input file icon="accessories-text-editor"></input>
616 <action>$BIN edit_distro_script</action>
617 </button>
618 </hbox>
620 </frame>
622 </notebook>
624 <hbox>
625 <button help>
626 <input file icon="help-browser"></input>
627 <action type="launch">HELP</action>
628 </button>
629 <button>
630 <label>Exit</label>
631 <input file icon="exit"></input>
632 <action type="exit">Exit</action>
633 </button>
634 </hbox>
636 </vbox>
637 </window>
638 '
640 case $1 in
641 *_*)
642 # Exec all function called by args (must have an underscore).
643 $1 ;;
644 *)
645 # Tazlitobox action.
646 check_root
647 gtkdialog --center --program=TAZLITO_BOX ;;
648 esac
650 exit 0