tazlito view tazlito-wiz @ rev 389

get-flavor: run "upgrade-flavor" before extracting
author Xander Ziiryanoff <psychomaniak@xakep.ru>
date Tue Nov 10 22:46:40 2015 +0100 (2015-11-10)
parents 5d7c04a1ac79
children d7aa98b45a0f
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="$live/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 $list | yad --list $opts --text="$text" \
49 --no-headers --print-all --separator="" \
50 --editable --column=0:TEXT > $live/list
51 mv -f $live/list $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!core64!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" && \
81 [ -z $(which xterm) ] && xterm='terminal' || xterm='xterm'
82 $xterm -geometry 70x10-0-0 -e tazpkg recharge
83 name=$(echo $main | cut -d "|" -f 1)
84 skel=$(echo $main | cut -d "|" -f 2)
85 echo "$skel" > $live/skel
86 echo "60"
87 [ "$name" ] || name="custom"
88 $xterm -geometry 60x12-0-0 -e tazlito get-flavor $skel
89 echo "90" && sleep 1
90 sed -i s"/^ISO_NAME=.*/ISO_NAME=\"$name\"/" tazlito.conf
91 sed -i s"/^VOLUM_NAME=.*/VOLUM_NAME=\"SliTaz $name\"/" \
92 tazlito.conf) | progress
93 }
95 # Packages page GUI
96 pkgs_main() {
97 pkgs=$(cat $list | wc -l)
98 skel=$(cat $live/skel)
99 text=$(eval_gettext "Packages - The \$skel has \$pkgs packages")
100 yad --form $opts --text="<b>$text</b>" --separator=" " \
101 --field="$(gettext "Additional packages separated by space or by line:")\\n\(will be auto added to \'Edit packages list\'\)":TXT \
102 --button="$(gettext "Edit packages list")!document-properties:2" \
103 --button="gtk-cancel:1" --button="gtk-ok:0" --image=tazpkg
104 }
106 # Packages page handler
107 pkgs() {
108 # Store box results
109 main=$(pkgs_main)
110 # Deal with --button values
111 case $? in
112 1) exit 0 ;;
113 2) add_to_list ; edit_list ;;
114 *) add_to_list ;;
115 esac
116 }
118 add_to_list()
119 {
120 for pkg in $(echo $main | sed s'/\\n/ /'g)
121 do
122 vers=$(grep -E "^$pkg \|" $db/packages.desc | awk '{print $3}')
123 [ -z $vers ] || \
124 (grep -v -q "^$pkg-$vers" $list && \
125 echo "$pkg-$vers" >> $list
126 )
127 unset vers
128 done
129 }
131 # Wallpaper page GUI
132 wallpaper_main() {
133 text=$(gettext "SliTaz desktop wallpaper")
134 yad --form $opts --text="<b>$text</b>" --separator="" \
135 --field="$(gettext "Wallpaper JPG image:")":FL
136 }
138 # Wallpaper page handler
139 wallpaper() {
140 # Store box results
141 main=$(wallpaper_main)
142 # Deal with --button values
143 case $? in
144 1) exit 0 ;;
145 *) continue ;;
146 esac
147 if echo "$main" | fgrep -q .jpg; then
148 mkdir -p $addfiles/rootfs/usr/share/images
149 cp -f $main $addfiles/rootfs/usr/share/images
150 fi
151 }
153 # Last page GUI
154 gen_distro_main() {
155 info=$(gettext "
156 Now it's time to generate the distro. Last chance to start over or stop. \
157 Creating a Live system uses quite a lot of resources and takes some time.
158 Note you can still add some files to the SliTaz root filesystem or on the \
159 cdrom.";echo
160 echo $addfiles )
161 text=$(gettext "<b>Generate the distribution</b>")
162 echo "$info" | yad --text-info $opts --text="$text" \
163 --wrap --margins=20
164 }
166 # Last page handler
167 gen_distro() {
168 # Store box results
169 main=$(gen_distro_main)
170 # Deal with --button values
171 case $? in
172 1) exit 0 ;;
173 *)
174 export output=gtk
175 echo -e "\n" | tazlito gen-distro 2>&1 | yad \
176 --text-info $opts --tail \
177 --text="<b>$(gettext "Building the Live system...")</b>" ;;
178 esac
179 }
181 # Summary
182 summary() {
183 . tazlito.conf
184 iso_size=$(du -sh $distro/$ISO_NAME.iso | awk '{print $1}')
185 distro_size=$(du -sh $distro/rootfs | awk '{print $1}')
186 text="$(gettext "Live system summary")"
187 echo -e "\
188 $(gettext "Generated ISO ") \n$distro/$ISO_NAME.iso
189 $(gettext "Image size") \n$iso_size
190 $(gettext "Uncompressed size") \n$distro_size" | \
191 yad --list $opts --text="<b>$text</b>" \
192 --column="Information":0 --column="Value":1 \
193 --button="gtk-close":0
194 }
196 #
197 # Script commands
198 #
200 case "$1" in
201 usage)
202 echo "Usage: $(basename $0) [command]" ;;
203 *)
204 start
205 pkgs
206 wallpaper
207 gen_distro
208 summary ;;
209 esac
211 exit 0