tazlito view tazlito-wiz @ rev 270
Update docs
author | Paul Issott <paul@slitaz.org> |
---|---|
date | Sun Apr 01 16:43:17 2012 +0100 (2012-04-01) |
parents | eccb6026959e |
children | 95ee294e4147 |
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 # 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
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" \
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="TazPanel Live:2" \
61 --button="gtk-cancel:1" \
62 --button="gtk-ok:0" \
63 " " "core!gtkonly!justx!base"
64 }
66 # Start page handler
67 start() {
68 # Store box results
69 main=$(start_main)
70 # Deal with --button values
71 case $? in
72 1) exit 0 ;;
73 2) tazweb http://tazpanel:82/live.cgi && exit 0 ;;
74 *) continue ;;
75 esac
76 # Deal with $main values
77 text=$(gettext "Getting flavor file and packages list...")
78 (echo "30" && sleep 1
79 name=$(echo $main | cut -d "|" -f 1)
80 skel=$(echo $main | cut -d "|" -f 2)
81 echo "$skel" > $live/skel
82 echo "60"
83 [ "$name" ] || name="custom"
84 tazlito get-flavor $skel
85 echo "90" && sleep 1
86 sed -i s"/^ISO_NAME=.*/ISO_NAME=\"$name\"/" tazlito.conf
87 sed -i s"/^VOLUM_NAME=.*/VOLUM_NAME=\"SliTaz $name\"/" \
88 tazlito.conf) | progress
89 }
91 # Packages page GUI
92 pkgs_main() {
93 pkgs=$(cat $list | wc -l)
94 skel=$(cat $live/skel)
95 text=$(eval_gettext "Packages - The \$skel has \$pkgs packages")
96 yad --form $opts --text="<b>$text</b>" --separator=" " \
97 --field="$(gettext "Additional packages separated by space or by line:")":TXT \
98 --button="$(gettext "Edit packages list"):2" \
99 --button="gtk-cancel:1" --button="gtk-ok:0"
100 }
102 # Packages page handler
103 pkgs() {
104 # Store box results
105 main=$(pkgs_main)
106 # Deal with --button values
107 case $? in
108 1) exit 0 ;;
109 2) edit_list ;;
110 *) continue ;;
111 esac
112 # Deal with $main values
113 for pkg in $(echo $main | sed s'/\\n//'g)
114 do
115 vers=$(fgrep "$pkg |" $db/packages.desc | awk '{print $3}')
116 if ! grep "^${pkg}$" $list; then
117 echo "$pkg-$vers" >> $list
118 fi
119 done
120 }
122 # Wallpaper page GUI
123 wallpaper_main() {
124 text=$(gettext "SliTaz desktop wallpaper")
125 yad --form $opts --text="<b>$text</b>" --separator="" \
126 --field="$(gettext "Wallpaper JPG image:")":FL
127 }
129 # Wallpaper page handler
130 wallpaper() {
131 # Store box results
132 main=$(wallpaper_main)
133 # Deal with --button values
134 case $? in
135 1) exit 0 ;;
136 *) continue ;;
137 esac
138 if echo "$main" | fgrep -q .jpg; then
139 mkdir -p $addfiles/rootfs/usr/share/images
140 cp -f $main $addfiles/rootfs/usr/share/images
141 fi
142 }
144 # Last page GUI
145 gen_distro_main() {
146 info=$(gettext "
147 Now it's time to generate the distro. Last chance to start over or stop. \
148 Creating a Live system uses quite a lot of resources and takes some time.
149 Note you can still add some files to the SliTaz root filesystem or on the \
150 cdrom.")
151 text=$(gettext "<b>Generate the distribution</b>")
152 echo "$info" | yad --text-info $opts --text="$text" \
153 --wrap --margins=20
154 }
156 # Last page handler
157 gen_distro() {
158 # Store box results
159 main=$(gen_distro_main)
160 # Deal with --button values
161 case $? in
162 1) exit 0 ;;
163 *) echo -e "\n" | tazlito gen-distro 2>&1 | yad \
164 --text-info $opts --tail \
165 --text="<b>$(gettext "Building the Live system...")</b>" ;;
166 esac
167 }
169 # Summary
170 summary() {
171 . tazlito.conf
172 iso_size=$(du -sh $distro/$ISO_NAME.iso | awk '{print $1}')
173 distro_size=$(du -sh $distro/rootfs | awk '{print $1}')
174 text="$(gettext "Live system summary")"
175 echo -e "\
176 $(gettext "Generated ISO ") \n$distro/$ISO_NAME.iso
177 $(gettext "Image size") \n$iso_size
178 $(gettext "Uncompressed size") \n$distro_size" | \
179 yad --list $opts --text="<b>$text</b>" \
180 --column="Information":0 --column="Value":1 \
181 --button="gtk-close":0
182 }
184 #
185 # Script commands
186 #
188 case "$1" in
189 usage)
190 echo "Usage: $(basename $0) [command]" ;;
191 *)
192 start
193 pkgs
194 wallpaper
195 gen_distro
196 summary ;;
197 esac
199 exit 0