tazlito view tazlito-wiz @ rev 536

tazlito: typo
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Apr 07 10:03:40 2022 +0000 (2022-04-07)
parents 7c8e4ca19511
children
line source
1 #!/bin/sh
2 #
3 # Live system creation wizard in GTK using Yad.
4 #
5 # Copyright (C) 2012-2015 SliTaz GNU/Linux - GNU gpl v2
6 # Authors : Christophe Lincoln <pankso@slitaz.org>
7 #
9 default_icon="--image=slitaz-icon"
10 opts="--height=320 --width=600 --center --image-on-top --window-icon=slitaz-icon --title=LiveWizard"
11 rel=$(cat /etc/slitaz-release)
12 #[ "$rel" != "cooking" ] && rel=stable
13 live="/home/slitaz/$rel/live"
14 db='/var/lib/tazpkg'
15 list="$live/distro-packages.list"
16 distro="/home/slitaz/$rel/distro"
17 addfiles="$distro/addfiles"
20 # TazLito wizard is only for root.
22 if [ $(id -u) -ne 0 ]; then
23 exec tazbox su $0
24 exit 0
25 fi
28 # I18n
30 . /lib/libtaz.sh
31 export TEXTDOMAIN='tazlito'
34 # Sanity check.
36 mkdir -p $live && cd $live
37 #rm -rf *
40 #
41 # Functions
42 #
44 edit_list() {
45 cat $list | yad --list $opts --image='system-software-update' \
46 --text="<b>$(_ 'Edit the distro packages list')</b>" \
47 --no-headers --print-all --separator='' \
48 --editable --column=0:TEXT > "$live/list"
49 mv -f "$live/list" "$list"
50 }
53 # Start page GUI
55 start_main() {
56 yad --form $opts $default_icon \
57 --text="<b>$(_ 'SliTaz Live system creator wizard')</b>" \
58 --field="$(_ "Distro name:")" \
59 --field="$(_ "Based on:")":CB \
60 --field="":LBL --field=" ":LBL \
61 --field="$(_ "*.flavor file (optional):")":SFL \
62 --button='gtk-help:4' \
63 --button="$(_ 'Write ISO')!iso-image-burn:3" \
64 --button="$(_ 'TazPanel Live'):2" \
65 --button='gtk-cancel:1' \
66 --button='gtk-go-forward:0' \
67 'custom' 'core!core64!gtkonly!justx!base'
68 }
71 # Start page handler
73 start() {
74 # Store box results
75 main=$(start_main)
77 # Deal with --button values
78 case $? in
79 1) exit 0;;
80 2) tazpanel live; exit 0;;
81 3) terminal -T 'write-iso' -e 'tazlito writeiso lzma'; exit 0;;
82 4) tazweb 'file:///usr/share/doc/tazlito/tazlito.html'; exit 0;;
83 esac
85 # Deal with $main values
87 (
88 export output='raw'
89 # Numbers are moved the progressbar
90 echo '30'
91 # Lines started with '#' are displayed in the log
92 tazpkg recharge | sed 's|^.*|#&|'
93 name="$(echo $main | cut -d'|' -f1)"; name="${name:-custom}"
94 skel="$(echo $main | cut -d'|' -f2)"
95 flvf="$(echo $main | cut -d'|' -f5)"
96 if [ ${flvf/*./} = flavor ]; then
97 cp -a $flvf $live ; skel=$(basename $flvf)
98 fi
99 echo "$skel" > $live/skel
100 echo '60'
101 tazlito get-flavor $skel | sed 's|^.*|#&|'
102 echo '90'
103 sed -i "s|^ISO_NAME=.*|ISO_NAME=\"$name\"|" tazlito.conf
104 sed -i "s|^VOLUM_NAME=.*|VOLUM_NAME=\"SliTaz $name\"|" tazlito.conf
105 ) | \
106 yad --progress $opts --image='system-software-update' \
107 --text="<b>$(_ 'Getting flavor file and packages list...')</b>" \
108 --enable-log="$(_ 'Log')" --log-expanded --button='gtk-go-forward:0'
110 }
113 # Packages page GUI
115 pkgs_main() {
116 pkgs=$(cat $list | wc -l)
117 skel=$(cat $live/skel)
118 text=$(_p 'Packages - The "%s" has %d package' 'Packages - The "%s" has %d packages' "$pkgs" "$skel" "$pkgs")
119 yad --form $opts --image='application-x-tazpkg' \
120 --text="<b>$text</b>" --separator=' ' \
121 --field="$(_ 'Additional packages separated by space or by line:')\\n$(_ '(will be auto added to "Edit packages list")')":TXT \
122 --button="$(_ 'Edit packages list')!document-properties:2" \
123 --button='gtk-cancel:1' --button='gtk-go-forward:0'
124 }
127 # Packages page handler
129 pkgs() {
130 # Store box results
131 main=$(pkgs_main)
132 # Deal with --button values
133 case $? in
134 1) exit 0 ;;
135 2) add_to_list ; edit_list ;;
136 *) add_to_list ;;
137 esac
138 }
141 add_to_list() {
142 for pkg in $(echo $main | sed s'/\\n/ /'g); do
143 vers=$(grep -E "^$pkg \|" $db/packages.desc | awk '{print $3}')
144 [ -z $vers ] || \
145 (grep -v -q "^$pkg-$vers" $list && \
146 echo "$pkg-$vers" >> $list
147 )
148 unset vers
149 done
150 }
153 # Wallpaper page GUI
155 wallpaper_main() {
156 yad --form $opts --image='preferences-desktop-wallpaper' \
157 --text="<b>$(_ 'SliTaz desktop wallpaper')</b>" --separator='' \
158 --field="$(_ 'Wallpaper JPG image:')":FL \
159 --button='gtk-cancel:1' --button='gtk-go-forward:0'
160 }
163 # Wallpaper page handler
165 wallpaper() {
166 # Store box results
167 main=$(wallpaper_main)
168 # Deal with --button values
169 case $? in
170 1) exit 0 ;;
171 *) continue ;;
172 esac
173 if echo "$main" | fgrep -q .jpg; then
174 mkdir -p $addfiles/rootfs/usr/share/images
175 cp -f $main $addfiles/rootfs/usr/share/images
176 fi
177 }
180 # Last page GUI
182 gen_distro_main() {
183 (
184 _ "
185 Now it's time to generate the distro. Last chance to start over or stop. \
186 Creating a Live system uses quite a lot of resources and takes some time.
187 Note you can still add some files to the SliTaz root filesystem or on the CD-ROM."
188 echo
189 echo $addfiles
190 ) | yad --text-info $opts $default_icon \
191 --text="<b>$(_ 'Generate the distribution')</b>" --wrap --margins=20 \
192 --button='gtk-cancel:1' --button='gtk-go-forward:0'
193 }
196 # Last page handler
198 gen_distro() {
199 # Store box results
200 main=$(gen_distro_main)
202 # Deal with --button values
203 case $? in
204 1) exit 0 ;;
205 *)
206 export output='raw'
207 echo -e "\n" | tazlito gen-distro 2>&1 | yad \
208 --text-info $opts $default_icon --tail \
209 --text="<b>$(_ 'Building the Live system...')</b>" \
210 --button='gtk-go-forward:0'
211 ;;
212 esac
213 }
216 # Summary
218 summary() {
219 . ./tazlito.conf
220 iso_size=$(du -sh $distro/$ISO_NAME.iso | awk '{print $1}')
221 distro_size=$(du -sh $distro/rootfs | awk '{print $1}')
222 text="$(_ 'Live system summary')"
223 echo -e "\
224 $(_ 'Generated ISO') \n$distro/$ISO_NAME.iso
225 $(_ 'Image size') \n$iso_size
226 $(_ 'Uncompressed size') \n$distro_size" | \
227 yad --list $opts $default_icon --text="<b>$text</b>" \
228 --column="$(_ 'Information')":0 --column="$(_ 'Value')":1 \
229 --button="gtk-close":0
230 }
233 #
234 # Script commands
235 #
237 case "$1" in
238 usage)
239 echo "Usage: $(basename $0) [command]" ;;
240 *)
241 start
242 pkgs
243 wallpaper
244 gen_distro
245 summary ;;
246 esac
248 exit 0