tazlito view tazlitobox @ rev 164

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