tazlito view tazlitobox @ rev 139

box: move all GUI action to functions
author Christophe Lincoln <pankso@slitaz.org>
date Sat Jan 23 23:52:59 2010 +0100 (2010-01-23)
parents a31e7804380b
children 1e0f8206aa53
line source
1 #! /bin/sh
2 #
3 # Gtkdialog box for Tazlito - SliTaz Live Tool.
4 #
5 VERSION=2.2
7 export BIN=$0
9 # Check if user is root.
10 check_root()
11 {
12 if test $(id -u) != 0 ; then
13 echo -e "
14 You must be root to run `basename $0`. Please type 'su' and
15 root password to become super-user.\n"
16 exit 0
17 fi
18 }
20 # We need to parse flavors.list for GTK tree.
21 list_flavors()
22 {
23 tazlito list-flavors | grep ^[a-z] | while read line
24 do
25 info=`echo -n $line | awk '{print $1 " " $2 " " $3}'`
26 printinfo=`echo -n $line | awk '{print $1 "|" $2 "|" $3}'`
27 echo "$printinfo|`echo $line | sed s/\"$info\"//`"
28 done
29 }
31 recharge_list()
32 {
33 xterm -geometry 90x14 \
34 -title "list-flavors --recharge" \
35 -e "tazlito list-flavors --recharge | grep ^[a-z] && sleep 2"
36 }
38 # When using gen-liveflavor, gen-flavor or gen-distro, user can put some
39 # addfiles copied into the rootfs.
40 addfiles_action()
41 {
42 cd /home/slitaz
43 mkdir -p distro/addfiles/rootfs/usr/share/images
44 mkdir -p distro/addfiles/rootcd
45 file-manager distro/addfiles &
46 }
48 # All actions
50 writeiso_action()
51 {
52 xterm -geometry 80x16 \
53 -title "writeiso" \
54 -e "tazlito writeiso $COMPRESSION"
55 }
57 gen_liveflavor_action()
58 {
59 cd /home/slitaz
60 sed -i "s/ISO_NAME=.*/ISO_NAME=\"slitaz-$GEN_LIVEFLAVOR_NAME\"/" \
61 /etc/tazlito/tazlito.conf
62 xterm -geometry 80x16 \
63 -title "gen-liveflavor" \
64 -e "tazlito gen-liveflavor $GEN_LIVEFLAVOR_NAME && echo -e \"----\nENTER to continue...\" && read close"
65 }
67 clean_distro_action()
68 {
69 cd /home/slitaz
70 xterm -geometry 80x16 \
71 -title "clean-distro" \
72 -e "tazlito clean-distro && sleep 1"
73 }
75 get_flavor_action()
76 {
77 cd /home/slitaz
78 xterm -geometry 80x16 \
79 -title "get-flavor $COMMUNITY_FLAVOR" \
80 -e "tazlito get-flavor $COMMUNITY_FLAVOR && echo -e \"----\nENTER to continue...\" && read close"
81 }
83 gen_distro_action()
84 {
85 cd /home/slitaz
86 xterm -geometry 80x16 \
87 -title "gen-distro" \
88 -e "tazlito gen-distro && echo -e \"----\nENTER to continue...\" && read close"
89 }
91 gen_flavor_action()
92 {
93 cd /home/slitaz
94 xterm -geometry 80x16 \
95 -title "gen-flavor $GEN_FLAVOR_NAME" \
96 -e "tazlito gen-flavor $GEN_FLAVOR_NAME && echo -e \"----\nENTER to continue...\" && read close"
97 }
99 edit_distro_script()
100 {
101 [ ! -f $DISTRO_SCRIPT ] && echo "#!/bin/sh" > $DISTRO_SCRIPT
102 chmod +x $DISTRO_SCRIPT
103 editor $DISTRO_SCRIPT
104 }
106 # Boxes
108 export HELP='
109 <window title="Tazlito Box - Help" icon-name="media-cdrom">
110 <vbox>
111 <text use-markup="true">
112 <label>"
113 <b>Tazlito Box - Help</b>"
114 </label>
115 </text>
117 <frame Overview>
118 <text wrap="true" width-chars="52" use-markup="true">
119 <label>
120 "
121 Tazlito Box is a tiny interface to the SliTaz Live Tool aka Tazlito.
122 You can simply generate a LiveCD in a few minutes, using your
123 own flavor or one from the SliTaz community. Tazlito can also
124 generate a LiveCD flavor using all of the currently installed
125 packages. Tazlito commands are executed in a XTerm, you can
126 press ENTER or the mouse to close the window.
127 "
128 </label>
129 </text>
130 </frame>
132 <frame Default paths>
133 <text wrap="true" width-chars="50" use-markup="true">
134 <label>
135 "
136 Distro : /home/slitaz/distro
137 Flavors : /home/slitaz/flavors
138 Packages : /home/slitaz/packages
139 "
140 </label>
141 </text>
142 </frame>
144 <hbox>
145 <button>
146 <input file icon="exit"></input>
147 <action type="closewindow">HELP</action>
148 </button>
149 </hbox>
151 </vbox>
152 </window>
153 '
155 # List all flavors on the mirror.
156 export LIST_FLAVORS_BOX='
157 <window title="Community flavors list" icon-name="tazlito">
158 <vbox>
159 <tree>
160 <width>500</width><height>200</height>
161 <variable>COMMUNITY_FLAVOR</variable>
162 <label>Name|ISO|Rootfs|Description</label>
163 <input exported_column="0">$BIN list_flavors</input>
164 </tree>
165 <hbox>
166 <button>
167 <label>Recharge list</label>
168 <input file icon="reload"></input>
169 <action>$BIN recharge_list</action>
170 <action>refresh:COMMUNITY_FLAVOR</action>
171 </button>
172 <button>
173 <label>Exit</label>
174 <input file icon="exit"></input>
175 <action type="closewindow">LIST_FLAVORS_BOX</action>
176 </button>
177 </hbox>
178 </vbox>
179 </window>'
181 # Execute tazlito commands in a XTerm. Notebook: tab-pos="GTK_POS_LEFT"
182 export TAZLITO_BOX='
183 <window title="Tazlito Box" icon-name="media-cdrom">
184 <vbox>
186 <hbox>
187 <text use-markup="true">
188 <label>"<b>SliTaz Live Tool</b>"</label>
189 </text>
190 <pixmap>
191 <input file>/usr/share/pixmaps/tazlito.png</input>
192 </pixmap>
194 </hbox>
196 <notebook labels="Writeiso|Live flavor|Flavors list|Gen flavor|Configuration">
198 <frame Filesystem to ISO>
200 <text wrap="true" width-chars="60" use-markup="true">
201 <label>
202 "
203 Writeiso will generate an ISO image of the current filesystem as
204 is, including the /home directory. It is an easy way to remaster a
205 SliTaz Live system, you just have to: boot, modify, writeiso.
206 "
207 </label>
208 </text>
210 <hbox>
211 <text use-markup="true">
212 <label>"<b>Compression (gzip,lzma,none):</b>"</label>
213 </text>
214 <entry>
215 <default>gzip</default>
216 <variable>COMPRESSION</variable>
217 </entry>
218 </hbox>
220 <hbox>
221 <button>
222 <label>Writeiso</label>
223 <input file icon="forward"></input>
224 <action>$BIN writeiso_action</action>
225 </button>
226 </hbox>
227 </frame>
229 <frame Current packages selection>
230 <text wrap="true" width-chars="60" use-markup="true">
231 <label>
232 "
233 Gen Live flavor will create a LiveCD based on all the currently
234 installed packages. To build the rootfs and ISO image it will use
235 original SliTaz packages. Some addfiles can be copied before
236 gen distro.
237 "
238 </label>
239 </text>
241 <hbox>
242 <text use-markup="true">
243 <label>"<b>Flavor name :</b>"</label>
244 </text>
245 <entry>
246 <default>slitaz</default>
247 <variable>GEN_LIVEFLAVOR_NAME</variable>
248 </entry>
249 </hbox>
251 <hbox>
252 <button>
253 <label>Addfiles</label>
254 <input file icon="gtk-open"></input>
255 <action>$BIN addfiles_action</action>
256 </button>
257 <button>
258 <label>Gen distro</label>
259 <input file icon="forward"></input>
260 <action>$BIN gen_liveflavor_action</action>
261 </button>
262 <button>
263 <label>Clean distro</label>
264 <input file icon="edit-clear"></input>
265 <action>$BIN clean_distro_action</action>
266 </button>
267 </hbox>
268 </frame>
270 <frame Community and personal flavors>
271 <text wrap="true" width-chars="60" use-markup="true">
272 <label>
273 "
274 Get and build preconfigured flavors from the community. Flavors
275 llist can be recharged from SliTaz mirror. Some addfiles can be
276 copied before generating the distro.
277 "
278 </label>
279 </text>
281 <hbox>
282 <text use-markup="true">
283 <label>"<b>Flavor :</b>"</label>
284 </text>
285 <entry>
286 <default>core</default>
287 <variable>COMMUNITY_FLAVOR</variable>
288 </entry>
289 <button>
290 <label>List flavors</label>
291 <input file icon="media-cdrom"></input>
292 <action type="launch">LIST_FLAVORS_BOX</action>
293 </button>
294 </hbox>
296 <hbox>
297 <button>
298 <label>Get flavor</label>
299 <input file icon="forward"></input>
300 <action>$BIN get_flavor_action</action>
301 </button>
302 <button>
303 <label>Addfiles</label>
304 <input file icon="gtk-open"></input>
305 <action>$BIN addfiles_action</action>
306 </button>
307 <button>
308 <label>Gen distro</label>
309 <input file icon="forward"></input>
310 <action>$BIN gen_distro_action</action>
311 </button>
312 <button>
313 <label>Clean distro</label>
314 <input file icon="edit-clear"></input>
315 <action>$BIN clean_distro_action</action>
316 </button>
317 </hbox>
318 </frame>
320 <frame Generate a flavor>
322 <text wrap="true" width-chars="60" use-markup="true">
323 <label>
324 "
325 Gen Flavor will generate a new flavor file based on rootfs in
326 /home/slitaz/distro. All addfiles will be included in the flavor file.
327 "
328 </label>
329 </text>
331 <hbox>
332 <text use-markup="true">
333 <label>"<b>New flavor :</b>"</label>
334 </text>
335 <entry>
336 <default>slitaz</default>
337 <variable>GEN_FLAVOR_NAME</variable>
338 </entry>
339 </hbox>
340 <hbox>
341 <button>
342 <label>Addfiles</label>
343 <input file icon="gtk-open"></input>
344 <action>$BIN addfiles_action</action>
345 </button>
346 <button>
347 <label>Gen new flavor</label>
348 <input file icon="forward"></input>
349 <action>$BIN gen_flavor_action</action>
350 </button>
351 </hbox>
352 </frame>
354 <frame Flavor config and packages list>
355 <text wrap="true" width-chars="60" use-markup="true">
356 <label>
357 "
358 Before editing files you must have a flavor description. Distro
359 script can be used to perform actions into the rootfs before
360 compression.
361 "
362 </label>
363 </text>
365 <hbox>
366 <text use-markup="true">
367 <label>"<b>Flavor config :</b>"</label>
368 </text>
369 <entry>
370 <default>/home/slitaz/tazlito.conf</default>
371 <variable>CONFIG_FILE</variable>
372 </entry>
373 <button>
374 <input file icon="accessories-text-editor"></input>
375 <action>editor $CONFIG_FILE</action>
376 </button>
377 </hbox>
379 <hbox>
380 <text use-markup="true">
381 <label>"<b>Packages list :</b>"</label>
382 </text>
383 <entry>
384 <default>/home/slitaz/distro-packages.list</default>
385 <variable>PKGS_LIST</variable>
386 </entry>
387 <button>
388 <input file icon="accessories-text-editor"></input>
389 <action>editor $PKGS_LIST</action>
390 </button>
391 </hbox>
393 <hbox>
394 <text use-markup="true">
395 <label>"<b>Distro script :</b> "</label>
396 </text>
397 <entry>
398 <default>/home/slitaz/distro.sh</default>
399 <variable>DISTRO_SCRIPT</variable>
400 </entry>
401 <button>
402 <input file icon="accessories-text-editor"></input>
403 <action>$BIN edit_distro_script</action>
404 </button>
405 </hbox>
407 </frame>
409 </notebook>
411 <hbox>
412 <button help>
413 <input file icon="help-browser"></input>
414 <action type="launch">HELP</action>
415 </button>
416 <button>
417 <label>Exit</label>
418 <input file icon="exit"></input>
419 <action type="exit">Exit</action>
420 </button>
421 </hbox>
423 </vbox>
424 </window>
425 '
427 case $1 in
428 *_*)
429 # Exec all function called by args (must have an underscore).
430 $1 ;;
431 *)
432 # Tazlitobox action.
433 check_root
434 gtkdialog --center --program=TAZLITO_BOX ;;
435 esac
437 exit 0