tazlito view tazlito-wiz @ rev 261

Edit tazlito-wiz
author Paul Issott <paul@slitaz.org>
date Wed Mar 14 19:13:27 2012 +0000 (2012-03-14)
parents 44d0148872fb
children e8f4014b75f9
line source
1 #!/bin/sh
2 #
3 # Live system creation wizard in GTK using Yad.
4 #
5 # Copyright (C) 2012 SliTaz GNU/Linux - GNU gpl v2
6 #
7 # Authors : Christophe Lincoln <pankso@slitaz.org>
8 #
10 width="560"
11 icon="/usr/share/pixmaps/slitaz-icon.png"
12 opts="--height=300 --width=$width --image=$icon
13 --image-on-top --window-icon=$icon --title=LiveWizard"
14 rel=$(cat /etc/slitaz-release)
15 [ "$rel" != "cooking" ] && rel=stable
16 live=/home/slitaz/$rel/live
17 db="/var/lib/tazpkg"
18 list="distro-packages.list"
19 distro="/home/slitaz/$rel/distro"
20 addfiles="$distro/addfiles"
22 # TazLito wizard is only for root.
23 if test $(id -u) != 0 ; then
24 exec tazbox su $0
25 exit 0
26 fi
28 # I18n
29 . /usr/bin/gettext.sh
30 TEXTDOMAIN='tazlito-wiz'
31 export TEXTDOMAIN
33 # Sanity check.
34 mkdir -p $live && cd $live
35 #rm -rf *
37 #
38 # Functions
39 #
41 progress() {
42 yad --progress --height="140" --width="$width" \
43 --image=$icon --image-on-top --window-icon=$icon \
44 --text="<b>$text</b>" --title="SliTaz Live progress" --auto-close
45 }
47 edit_list() {
48 text=$(gettext "Edit the distro packages list")
49 cat $live/$list | yad --list $opts --text="$text" \
50 --no-headers --print-all --separator="" \
51 --editable --column=0:TEXT > $live/list
52 mv -f $live/list $live/$list
53 }
55 # Start page GUI
56 start_main() {
57 text=$(gettext "SliTaz Live system creator wizard")
58 yad --form $opts --text="<b>$text</b>" \
59 --field="$(gettext "Distro name:")" \
60 --field="$(gettext "Based on:")":CB \
61 --button="TazPanel Live:2" \
62 --button="gtk-cancel:1" \
63 --button="gtk-ok:0" \
64 " " "core!gtkonly!justx!base"
65 }
67 # Start page handler
68 start() {
69 # Store box results
70 main=$(start_main)
71 # Deal with --button values
72 case $? in
73 1) exit 0 ;;
74 2) tazweb http://tazpanel:82/live.cgi && exit 0 ;;
75 *) continue ;;
76 esac
77 # Deal with $main values
78 text=$(gettext "Getting flavor file and packages list...")
79 (echo "30" && sleep 1
80 name=$(echo $main | cut -d "|" -f 1)
81 skel=$(echo $main | cut -d "|" -f 2)
82 echo "$skel" > $live/skel
83 echo "60"
84 [ "$name" ] || name="custom"
85 tazlito get-flavor $skel
86 echo "90" && sleep 1
87 sed -i s"/^ISO_NAME=.*/ISO_NAME=\"$name\"/" tazlito.conf
88 sed -i s"/^VOLUM_NAME=.*/VOLUM_NAME=\"SliTaz $name\"/" \
89 tazlito.conf) | progress
90 }
92 # Packages page GUI
93 pkgs_main() {
94 pkgs=$(cat $list | wc -l)
95 skel=$(cat $live/skel)
96 text=$(eval_gettext "Packages - The \$skel has \$pkgs packages")
97 yad --form $opts --text="<b>$text</b>" --separator=" " \
98 --field="$(gettext "Additional packages separated by space or by line:")":TXT \
99 --button="$(gettext "Edit packages list"):2" \
100 --button="gtk-cancel:1" --button="gtk-ok:0"
101 }
103 # Packages page handler
104 pkgs() {
105 # Store box results
106 main=$(pkgs_main)
107 # Deal with --button values
108 case $? in
109 1) exit 0 ;;
110 2) edit_list ;;
111 *) continue ;;
112 esac
113 # Deal with $main values
114 for pkg in $(echo $main | sed s'/\\n//'g)
115 do
116 vers=$(fgrep "$pkg |" $db/packages.desc | awk '{print $3}')
117 if ! grep "^${pkg}$" $list; then
118 echo "$pkg-$vers" >> $list
119 fi
120 done
121 }
123 # Wallpaper page GUI
124 wallpaper_main() {
125 text=$(gettext "SliTaz desktop wallpaper")
126 yad --form $opts --text="<b>$text</b>" --separator="" \
127 --field="$(gettext "Wallpaper JPG image:")":FL
128 }
130 # Wallpaper page handler
131 wallpaper() {
132 # Store box results
133 main=$(wallpaper_main)
134 # Deal with --button values
135 case $? in
136 1) exit 0 ;;
137 *) continue ;;
138 esac
139 if echo "$main" | fgrep -q .jpg; then
140 mkdir -p $addfiles/rootfs/usr/share/images
141 cp -f $main $addfiles/rootfs/usr/share/images
142 fi
143 }
145 # Last page GUI
146 gen_distro_main() {
147 info=$(gettext "
148 Now it's time to generate the distro. Last chance to start over or stop. \
149 Creating a Live system uses quite a lot of resources and takes some time.
150 Note you can still add some files to the SliTaz root filesystem or on the \
151 cdrom.")
152 text=$(gettext "<b>Generate the distribution</b>")
153 echo "$info" | yad --text-info $opts --text="$text" \
154 --wrap --margins=20
155 }
157 # Last page handler
158 gen_distro() {
159 # Store box results
160 main=$(gen_distro_main)
161 # Deal with --button values
162 case $? in
163 1) exit 0 ;;
164 *) echo -e "\n" | tazlito gen-distro 2>1 | yad \
165 --text-info $opts --tail \
166 --text="<b>$(gettext "Building the Live system...")</b>" ;;
167 esac
168 }
170 # Summary
171 summary() {
172 . tazlito.conf
173 iso_size=$(du -sh $distro/$ISO_NAME.iso | awk '{print $1}')
174 distro_size=$(du -sh $distro/rootfs | awk '{print $1}')
175 text="$(gettext "Live system summary")"
176 echo -e "\
177 $(gettext "Generated ISO ") \n$distro/$ISO_NAME.iso
178 $(gettext "Image size") \n$iso_size
179 $(gettext "Uncompressed size") \n$distro_size" | \
180 yad --list $opts --text="<b>$text</b>" \
181 --column="Information":0 --column="Value":1 \
182 --button="gtk-close":0
183 }
185 #
186 # Script commands
187 #
189 case "$1" in
190 usage)
191 echo "Usage: $(basename $0) [command]" ;;
192 *)
193 start
194 pkgs
195 wallpaper
196 gen_distro
197 summary ;;
198 esac
200 exit 0