tazlito view oldstuff/tazlitobox @ rev 463

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