tazlito view tazlito-wiz @ rev 345

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