tazlito view tazlito-wiz @ rev 287
tazlito: do not deduplicate soft links
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Aug 07 18:49:08 2012 +0200 (2012-08-07) |
parents | e8f4014b75f9 |
children | b3041f9d49ab |
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="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 *) echo -e "\n" | tazlito gen-distro 2>&1 | yad \
166 --text-info $opts --tail \
167 --text="<b>$(gettext "Building the Live system...")</b>" ;;
168 esac
169 }
171 # Summary
172 summary() {
173 . tazlito.conf
174 iso_size=$(du -sh $distro/$ISO_NAME.iso | awk '{print $1}')
175 distro_size=$(du -sh $distro/rootfs | awk '{print $1}')
176 text="$(gettext "Live system summary")"
177 echo -e "\
178 $(gettext "Generated ISO ") \n$distro/$ISO_NAME.iso
179 $(gettext "Image size") \n$iso_size
180 $(gettext "Uncompressed size") \n$distro_size" | \
181 yad --list $opts --text="<b>$text</b>" \
182 --column="Information":0 --column="Value":1 \
183 --button="gtk-close":0
184 }
186 #
187 # Script commands
188 #
190 case "$1" in
191 usage)
192 echo "Usage: $(basename $0) [command]" ;;
193 *)
194 start
195 pkgs
196 wallpaper
197 gen_distro
198 summary ;;
199 esac
201 exit 0