tazlito view tazlitobox @ rev 136

box: some code clean-up, add distro script editing and info
author Christophe Lincoln <pankso@slitaz.org>
date Sat Jan 23 17:10:02 2010 +0100 (2010-01-23)
parents e2ca73f557c3
children 6b97ef60644a
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 writeiso_action()
49 {
50 xterm -geometry 80x16 \
51 -title "writeiso" \
52 -e "tazlito writeiso $COMPRESSION"
53 }
55 export HELP='
56 <window title="Tazlito Box - Help" icon-name="media-cdrom">
57 <vbox>
58 <text use-markup="true">
59 <label>"
60 <b>Tazlito Box - Help</b>"
61 </label>
62 </text>
64 <frame Overview>
65 <text wrap="true" width-chars="52" use-markup="true">
66 <label>
67 "
68 Tazlito Box is a tiny interface to the SliTaz Live Tool aka Tazlito.
69 You can simply generate a LiveCD in a few minutes, using your
70 own flavor or one from the SliTaz community. Tazlito can also
71 generate a LiveCD flavor using all of the currently installed
72 packages. Tazlito commands are executed in a XTerm, you can
73 press ENTER or the mouse to close the window.
74 "
75 </label>
76 </text>
77 </frame>
79 <frame Default paths>
80 <text wrap="true" width-chars="50" use-markup="true">
81 <label>
82 "
83 Distro : /home/slitaz/distro
84 Flavors : /home/slitaz/flavors
85 Packages : /home/slitaz/packages
86 "
87 </label>
88 </text>
89 </frame>
91 <hbox>
92 <button>
93 <input file icon="exit"></input>
94 <action type="closewindow">HELP</action>
95 </button>
96 </hbox>
98 </vbox>
99 </window>
100 '
102 # List all flavors on the mirror.
103 export LIST_FLAVORS_BOX='
104 <window title="Community flavors list" icon-name="tazlito">
105 <vbox>
106 <tree>
107 <width>500</width><height>200</height>
108 <variable>COMMUNITY_FLAVOR</variable>
109 <label>Name|ISO|Rootfs|Description</label>
110 <input exported_column="0">$BIN list_flavors</input>
111 </tree>
112 <hbox>
113 <button>
114 <label>Recharge list</label>
115 <input file icon="reload"></input>
116 <action>$BIN recharge_list</action>
117 <action>refresh:COMMUNITY_FLAVOR</action>
118 </button>
119 <button>
120 <label>Exit</label>
121 <input file icon="exit"></input>
122 <action type="closewindow">LIST_FLAVORS_BOX</action>
123 </button>
124 </hbox>
125 </vbox>
126 </window>'
128 # Execute tazlito commands in a XTerm. Notebook: tab-pos="GTK_POS_LEFT"
129 export TAZLITO_BOX='
130 <window title="Tazlito Box" icon-name="media-cdrom">
131 <vbox>
133 <hbox>
134 <text use-markup="true">
135 <label>"<b>SliTaz Live Tool</b>"</label>
137 </text>
138 <pixmap>
139 <input file>/usr/share/pixmaps/tazlito.png</input>
140 </pixmap>
142 </hbox>
144 <notebook labels="Writeiso|Live flavor|Flavors list|Gen flavor|Configuration">
146 <frame Filesystem to ISO>
148 <text wrap="true" width-chars="60" use-markup="true">
149 <label>
150 "
151 Writeiso will generate an ISO image of the current filesystem as
152 is, including the /home directory. It is an easy way to remaster a
153 SliTaz Live system, you just have to: boot, modify, writeiso.
154 "
155 </label>
156 </text>
158 <hbox>
159 <text use-markup="true">
160 <label>"<b>Compression (gzip,lzma,none):</b>"</label>
161 </text>
162 <entry>
163 <default>gzip</default>
164 <variable>COMPRESSION</variable>
165 </entry>
166 </hbox>
168 <hbox>
169 <button>
170 <label>Writeiso</label>
171 <input file icon="forward"></input>
172 <action>$BIN writeiso_action</action>
173 </button>
174 </hbox>
175 </frame>
177 <frame Current packages selection>
178 <text wrap="true" width-chars="60" use-markup="true">
179 <label>
180 "
181 Gen Live flavor will create a LiveCD based on all the currently
182 installed packages. To build the rootfs and ISO image it will use
183 original SliTaz packages. Some addfiles can be copied before
184 gen distro.
185 "
186 </label>
187 </text>
189 <hbox>
190 <text use-markup="true">
191 <label>"<b>Flavor name :</b>"</label>
192 </text>
193 <entry>
194 <default>slitaz</default>
195 <variable>GEN_LIVEFLAVOR_NAME</variable>
196 </entry>
197 </hbox>
199 <hbox>
200 <button>
201 <label>Addfiles</label>
202 <input file icon="gtk-open"></input>
203 <action>$BIN addfiles_action</action>
204 </button>
205 <button>
206 <label>Gen distro</label>
207 <input file icon="forward"></input>
208 <action>cd /home/slitaz</action>
209 <action>sed -i "s/ISO_NAME=.*/ISO_NAME=\"slitaz-$GEN_LIVEFLAVOR_NAME\"/" /etc/tazlito/tazlito.conf</action>
210 <action>xterm -geometry 80x16 -title "gen-liveflavor" -e "tazlito gen-liveflavor $GEN_LIVEFLAVOR_NAME && echo -e \"----\nENTER to continue...\" && read close"</action>
211 </button>
212 <button>
213 <label>Clean distro</label>
214 <input file icon="edit-clear"></input>
215 <action>cd /home/slitaz</action>
216 <action>xterm -geometry 80x16 -title "clean-distro" -e "tazlito clean-distro && sleep 1"</action>
217 </button>
218 </hbox>
220 </frame>
222 <frame Community and personal flavors>
223 <text wrap="true" width-chars="60" use-markup="true">
224 <label>
225 "
226 Get and build preconfigured flavors from the community. Flavors
227 list can be recharged from SliTaz mirror. Somme addfiles can be
228 copied before generating the distro.
229 "
230 </label>
231 </text>
233 <hbox>
234 <text use-markup="true">
235 <label>"<b>Flavor :</b>"</label>
236 </text>
237 <entry>
238 <default>core</default>
239 <variable>COMMUNITY_FLAVOR</variable>
240 </entry>
241 <button>
242 <label>List flavors</label>
243 <input file icon="media-cdrom"></input>
244 <action type="launch">LIST_FLAVORS_BOX</action>
245 </button>
246 </hbox>
248 <hbox>
249 <button>
250 <label>Get flavor</label>
251 <input file icon="forward"></input>
252 <action>cd /home/slitaz</action>
253 <action>xterm -geometry 80x16 -title "get-flavor $COMMUNITY_FLAVOR" -e "tazlito get-flavor $COMMUNITY_FLAVOR && echo -e \"----\nENTER to continue...\" && read close"</action>
254 </button>
255 <button>
256 <label>Addfiles</label>
257 <input file icon="gtk-open"></input>
258 <action>$BIN addfiles_action</action>
259 </button>
260 <button>
261 <label>Gen distro</label>
262 <input file icon="forward"></input>
263 <action>cd /home/slitaz</action>
264 <action>xterm -geometry 80x16 -title "gen-distro" -e "tazlito gen-distro && echo -e \"----\nENTER to continue...\" && read close"</action>
265 </button>
266 <button>
267 <label>Clean distro</label>
268 <input file icon="edit-clear"></input>
269 <action>xterm -geometry 80x16 -title "clean-distro" -e "tazlito clean-distro && sleep 1"</action>
270 </button>
271 </hbox>
272 </frame>
274 <frame Generate a flavor>
276 <text wrap="true" width-chars="60" use-markup="true">
277 <label>
278 "
279 Gen Flavor will generate a new flavor file based on rootfs in
280 /home/slitaz/distro. All addfiles will be included in the flavor file.
281 "
282 </label>
283 </text>
285 <hbox>
286 <text use-markup="true">
287 <label>"<b>New flavor :</b>"</label>
288 </text>
289 <entry>
290 <default>slitaz</default>
291 <variable>GEN_FLAVOR_NAME</variable>
292 </entry>
293 </hbox>
294 <hbox>
295 <button>
296 <label>Addfiles</label>
297 <input file icon="gtk-open"></input>
298 <action>$BIN addfiles_action</action>
299 </button>
300 <button>
301 <label>Gen new flavor</label>
302 <input file icon="forward"></input>
303 <action>cd /home/slitaz</action>
304 <action>xterm -geometry 80x16 -title "gen-flavor $GEN_FLAVOR_NAME" -e "tazlito gen-flavor $GEN_FLAVOR_NAME && echo -e \"----\nENTER to continue...\" && read close"</action>
305 </button>
306 </hbox>
307 </frame>
309 <frame Flavor config and packages list>
310 <text wrap="true" width-chars="60" use-markup="true">
311 <label>
312 "
313 Before editing files you must have a flavor description. Distro
314 script can be used to perform action into the rootfs before
315 compression.
316 "
317 </label>
318 </text>
320 <hbox>
321 <text use-markup="true">
322 <label>"<b>Flavor config :</b>"</label>
323 </text>
324 <entry>
325 <default>/home/slitaz/tazlito.conf</default>
326 <variable>CONFIG_FILE</variable>
327 </entry>
328 <button>
329 <input file icon="accessories-text-editor"></input>
330 <action>editor $CONFIG_FILE</action>
331 </button>
332 </hbox>
334 <hbox>
335 <text use-markup="true">
336 <label>"<b>Packages list :</b>"</label>
337 </text>
338 <entry>
339 <default>/home/slitaz/distro-packages.list</default>
340 <variable>PKGS_LIST</variable>
341 </entry>
342 <button>
343 <input file icon="accessories-text-editor"></input>
344 <action>editor $PKGS_LIST</action>
345 </button>
346 </hbox>
348 <hbox>
349 <text use-markup="true">
350 <label>"<b>Distro script :</b> "</label>
351 </text>
352 <entry>
353 <default>/home/slitaz/distro.sh</default>
354 <variable>DISTRO_SCRIPT</variable>
355 </entry>
356 <button>
357 <input file icon="accessories-text-editor"></input>
358 <action>[ ! -f $DISTRO_SCRIPT ] && echo "#!/bin/sh" > $DISTRO_SCRIPT</action>
359 <action>chmod +x $DISTRO_SCRIPT</action>
360 <action>editor $DISTRO_SCRIPT</action>
361 </button>
362 </hbox>
364 </frame>
366 </notebook>
368 <hbox>
369 <button help>
370 <input file icon="help-browser"></input>
371 <action type="launch">HELP</action>
372 </button>
373 <button>
374 <label>Exit</label>
375 <input file icon="exit"></input>
376 <action type="exit">Exit</action>
377 </button>
378 </hbox>
380 </vbox>
381 </window>
382 '
384 case $1 in
385 *_*)
386 # Exec all function called by args (must have an underscore).
387 $1 ;;
388 *)
389 # Tazlitobox action.
390 check_root
391 gtkdialog --center --program=TAZLITO_BOX ;;
392 esac
394 exit 0