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