rev |
line source |
domcox@599
|
1 #!/bin/sh
|
domcox@656
|
2 # tazinst - SliTaz GNU/Linux installer.
|
domcox@599
|
3 #
|
domcox@599
|
4 # So this is the SliTaz installer. The script starts with a
|
domcox@599
|
5 # few main variables, then all the functions and then the
|
domcox@599
|
6 # full sequence of functions.
|
domcox@599
|
7 #
|
domcox@599
|
8 # (C) 2007-2011 SliTaz - GNU General Public License v3.
|
domcox@599
|
9 #
|
domcox@599
|
10 # Authors : Christophe Lincoln <pankso@slitaz.org>
|
domcox@612
|
11 # Dominique Corbex <domcox@slitaz.org>
|
domcox@654
|
12 #
|
domcox@656
|
13 # Exit codes:
|
domcox@654
|
14 # 1: Parameters error
|
domcox@654
|
15 # 2: Configuration file error
|
domcox@654
|
16 # 3: Source error
|
domcox@654
|
17 # 4: Cancelled by user
|
domcox@654
|
18 # 5: Target partition error
|
domcox@656
|
19 # 6: SliTaz system to upgrade not found
|
domcox@654
|
20 # 8: Internal error
|
domcox@599
|
21
|
domcox@656
|
22 VERSION=3.10
|
domcox@655
|
23
|
domcox@655
|
24 # Internationalization
|
domcox@655
|
25 . /usr/bin/gettext.sh
|
domcox@655
|
26 TEXTDOMAIN='tazinst'
|
domcox@655
|
27 export TEXTDOMAIN
|
domcox@612
|
28
|
domcox@599
|
29 SOURCE_ROOT=/media/source
|
domcox@599
|
30 TARGET_ROOT=/mnt/target
|
domcox@599
|
31 LOG=/var/log/tazinst.log
|
domcox@599
|
32 BACKLIST="SliTaz GNU/Linux installer"
|
domcox@599
|
33
|
domcox@654
|
34 # DEBUG=1: Enable debug msgs
|
domcox@599
|
35 DEBUG=0
|
domcox@599
|
36
|
domcox@654
|
37 # Predefined urls
|
domcox@612
|
38 URL_STABLE="http://mirror.slitaz.org/iso/stable/slitaz-4.0.iso"
|
domcox@599
|
39 URL_COOKING="http://mirror.slitaz.org/iso/cooking/slitaz-cooking.iso"
|
domcox@599
|
40 URL_ROLLING="http://mirror.slitaz.org/iso/rolling/slitaz-core.iso"
|
domcox@599
|
41
|
domcox@656
|
42 # Config
|
domcox@656
|
43 [ -r /etc/slitaz/tazinst.conf ] && . /etc/slitaz/tazinst.conf
|
domcox@656
|
44
|
domcox@599
|
45 # Print a short help
|
domcox@599
|
46 usage()
|
domcox@599
|
47 {
|
domcox@599
|
48 echo -e "\n`gettext \"Tazinst - SliTaz installer - Version\"`: $VERSION\n"
|
domcox@599
|
49 echo -e "\033[1m`gettext \"Usage\"`:"
|
domcox@656
|
50 echo -e "\033[0m `gettext \"tazinst [command] [config-file|url|options]\"`\n"
|
domcox@599
|
51 echo -e "\033[1m`gettext \"Commands\"`: \033[0m"
|
domcox@655
|
52 echo -e "usage `gettext \"Print this short usage.\"`"
|
domcox@655
|
53 echo -e "install `gettext \"Install SliTaz on HDD using a configuration file.\"`"
|
domcox@655
|
54 echo -e "upgrade `gettext \"Upgrade SliTaz on HDD using a configuration file.\"`"
|
domcox@655
|
55 echo -e "config `gettext \"Generate a configuration file.\"`"
|
domcox@656
|
56 echo -e "check `gettext \"Check configuration file validity.\"`"
|
domcox@656
|
57 echo -e "showurl `gettext \"Show the full URL of a predefined URL (stable|cooking|rolling).\"`"
|
domcox@655
|
58 echo -e "cli `gettext \"Install or upgrade using command line options:\"`"
|
domcox@599
|
59 echo -e " -i `gettext \"Full Install (not upgrading, all present data will be lost).\"`"
|
domcox@599
|
60 echo -e " -u `gettext \"Upgrade (Needs an active internet connection).\"`"
|
domcox@599
|
61 echo -e " -t <type> `gettext \"Install type (cdrom|usb|iso|web|weboot).\"`"
|
paul@618
|
62 echo -e " -s <source> `gettext \"Source media (ex: file.iso|usb partition|web url).\"`"
|
domcox@599
|
63 echo -e " -p <partition> `gettext \"Partition where SliTaz will be installed (ex:/dev/hda3).\"`"
|
paul@608
|
64 echo -e " -f <fs> `gettext \"Partition to be formatted (fs=ext2|ext3|ext4|etc..).\"`"
|
domcox@599
|
65 echo -e " -g `gettext \"Install Grub.\"`"
|
domcox@599
|
66 echo -e " -w `gettext \"Dual-boot a Windows partition (auto|hd<disk>,<part> ex:hd0,0).\"`"
|
domcox@599
|
67 echo -e " -d `gettext \"Debug mode.\"`"
|
domcox@599
|
68 exit 0
|
domcox@599
|
69 }
|
domcox@599
|
70
|
domcox@599
|
71 # Print an error msg & exit
|
domcox@599
|
72 # $1: exit code
|
domcox@599
|
73 # $@: err msg
|
domcox@599
|
74 abort()
|
domcox@599
|
75 {
|
domcox@599
|
76 # unmouting source & target
|
domcox@599
|
77 if mount | grep -q $SOURCE_ROOT; then
|
domcox@599
|
78 umount $SOURCE_ROOT 2>>$LOG
|
domcox@599
|
79 fi
|
domcox@599
|
80 if mount | grep -q $TARGET_ROOT; then
|
domcox@599
|
81 umount $TARGET_ROOT 2>>$LOG
|
domcox@599
|
82 fi
|
domcox@654
|
83 echo -e "`gettext \"Error\"` $@"
|
domcox@656
|
84 # echo -e "`gettext \"Installation cancelled\"`"
|
paul@608
|
85 test $(id -u) = 0 && echo "Installation cancelled on error $@" >> $LOG
|
domcox@599
|
86 exit $1
|
domcox@599
|
87 }
|
domcox@599
|
88
|
domcox@599
|
89 # Print a warning msg
|
domcox@599
|
90 warning()
|
domcox@599
|
91 {
|
domcox@654
|
92 echo -e "`gettext \"Warning:\"` $@" | tee -a $LOG
|
domcox@599
|
93 }
|
domcox@599
|
94
|
domcox@599
|
95 # Print a debug msg
|
domcox@599
|
96 debug()
|
domcox@599
|
97 {
|
domcox@599
|
98 [ $DEBUG -gt 0 ] && echo -e "\033[1mDEBUG: \033[0m$1"
|
domcox@599
|
99 echo "DEBUG: $1" >>$LOG
|
domcox@599
|
100 }
|
domcox@599
|
101
|
domcox@599
|
102 # print a msg
|
domcox@599
|
103 msg()
|
domcox@599
|
104 {
|
domcox@599
|
105 STEP=$(($STEP+1))
|
domcox@599
|
106 echo "$STEP. $@" | tee -a $LOG
|
domcox@599
|
107 }
|
domcox@599
|
108
|
domcox@599
|
109 ########################
|
domcox@599
|
110 # Gen-config functions #
|
domcox@599
|
111 ########################
|
domcox@599
|
112
|
domcox@599
|
113 # Generate a config file
|
domcox@599
|
114 # $1: Configuration file
|
domcox@599
|
115 gen_config()
|
domcox@599
|
116 {
|
domcox@599
|
117 CONFILE=$1
|
domcox@654
|
118 touch $CONFILE || abort 2 `gettext "Unable to write to $CONFILE"`
|
domcox@599
|
119 if [ -r "$CONFILE" ]; then
|
domcox@599
|
120 cat > $CONFILE << _EOF_
|
domcox@599
|
121 # tazinst.conf: SliTaz Installer configuration file.
|
domcox@599
|
122 #
|
domcox@599
|
123
|
domcox@599
|
124 # Install type : [cdrom|usb|iso|web|weboot]
|
domcox@599
|
125 INST_TYPE="cdrom"
|
domcox@599
|
126
|
domcox@599
|
127 # Install source
|
domcox@599
|
128 # usb:/dev/xxx, ex: SRC_FILE=/dev/sdb1
|
domcox@599
|
129 # iso:file.iso, ex: SRC_FILE=~/slitaz.3.0.iso
|
domcox@599
|
130 # web: url, ex: SRC_FILE=http://mirror.slitaz.org/iso/cooking/slitaz-cooking.iso
|
paul@618
|
131 # web: predefined mirrors (stable|cooking|rolling), ex: SRC_FILE=cooking
|
domcox@599
|
132 SRC_FILE=""
|
domcox@599
|
133
|
domcox@599
|
134 # Install Target (Root Partition).
|
domcox@599
|
135 TGT_PARTITION="/dev/hda5"
|
domcox@599
|
136
|
domcox@599
|
137 # Target File system.
|
domcox@599
|
138 # SliTaz uses ext3 by default but another filesystem can be used if wanted,
|
domcox@599
|
139 # for this please adjust your /etc/fstab after installation. Valid options are:
|
domcox@599
|
140 # (btrfs|ext2|ext3|ext4|fat16|fat32|hfs|hfs+|jfs|ntfs|reiser4|reiserfs|ufs|xfs)
|
domcox@599
|
141 TGT_FS="ext3"
|
domcox@599
|
142
|
domcox@599
|
143 # Home partition.
|
domcox@599
|
144 # On most GNU/Linux systems users personal files are stored in the directory
|
paul@618
|
145 # /home. Home can be on another hard disk or on a separate partition.
|
domcox@599
|
146 TGT_HOME=""
|
domcox@599
|
147 # Home File system (if /home is on a separate partition)
|
domcox@599
|
148 TGT_HOME_FS=""
|
domcox@599
|
149
|
domcox@599
|
150 # Hostname
|
domcox@599
|
151 TGT_HOSTNAME="slitaz"
|
domcox@599
|
152
|
domcox@599
|
153 # root password
|
domcox@599
|
154 # The root administrator privilege lets you manage and configure the full
|
domcox@599
|
155 # system. A root user can damage your system so you should always setup a
|
domcox@599
|
156 # strong password with special characters and/or numbers.
|
domcox@599
|
157 TGT_ROOT_PWD="root"
|
domcox@599
|
158
|
domcox@599
|
159 # The default user for the system will have his personal files stored
|
domcox@599
|
160 # in /home/*user* (and will be automatically added to the audio group).
|
domcox@599
|
161 TGT_USER="tux"
|
domcox@599
|
162 TGT_USER_PWD=""
|
domcox@599
|
163
|
domcox@599
|
164 # Grub bootloader
|
domcox@599
|
165 # install grub [yes|no]
|
domcox@599
|
166 TGT_GRUB="no"
|
domcox@599
|
167
|
domcox@599
|
168 # Windows dual-boot
|
domcox@599
|
169 # Dual boot is disabled if WINBOOT is empty: TGT_WINBOOT=""
|
domcox@599
|
170 # You may let tazinst find your win partition, mode=auto: TGT_WINBOOT="auto"
|
paul@618
|
171 # or use manual setting: "hd[disk],[partition]" ex:TGT_WINBOOT=hd0,0
|
domcox@599
|
172 TGT_WINBOOT=""
|
domcox@599
|
173
|
domcox@599
|
174 _EOF_
|
domcox@599
|
175
|
domcox@599
|
176 else
|
domcox@654
|
177 abort 2 `gettext "Configuration file $CONFILE not found"`
|
domcox@599
|
178 fi
|
domcox@599
|
179 }
|
domcox@599
|
180
|
domcox@599
|
181 ######################
|
domcox@599
|
182 # Checking functions #
|
domcox@599
|
183 ######################
|
domcox@599
|
184
|
domcox@599
|
185 # def values and start log
|
domcox@599
|
186 # $@ :
|
domcox@599
|
187 init()
|
domcox@599
|
188 {
|
domcox@599
|
189 echo "=== Tazinst start at `date` ===" >$LOG
|
domcox@599
|
190 echo "Command: $0 $@" >>$LOG
|
domcox@599
|
191
|
domcox@599
|
192 # Default Type
|
domcox@599
|
193 INST_TYPE=cdrom
|
domcox@599
|
194 # Default Hostname.
|
domcox@599
|
195 TGT_HOSTNAME=slitaz
|
domcox@599
|
196 # Default root passwd
|
domcox@599
|
197 TGT_ROOT_PWD=root
|
domcox@599
|
198 # Default user
|
domcox@599
|
199 TGT_USER=tux
|
domcox@599
|
200 # Default Grub Install
|
domcox@599
|
201 TGT_GRUB=no
|
domcox@599
|
202 }
|
domcox@599
|
203
|
domcox@599
|
204 # Read Conf
|
domcox@599
|
205 # $1: conf file
|
domcox@599
|
206 read_configuration_file()
|
domcox@599
|
207 {
|
domcox@599
|
208 CONFILE=$1
|
domcox@599
|
209 if [ -n "$CONFILE" ]; then
|
domcox@599
|
210 if [ -r "$CONFILE" ]; then
|
domcox@599
|
211 debug "Using config-file=$CONFILE"
|
domcox@599
|
212 # source doesn't like file without a path
|
domcox@599
|
213 [ $(echo "$CONFILE" | grep -c "/") == "0" ] && CONFILE="./$CONFILE"
|
domcox@654
|
214 source $CONFILE || abort 2 `gettext "Unable to read $CONFILE"`
|
domcox@599
|
215 else
|
domcox@654
|
216 abort 2 `gettext "Configuration file not found"`
|
domcox@599
|
217 fi
|
domcox@599
|
218 else
|
domcox@654
|
219 abort 2 `gettext "No configuration file provided"`
|
domcox@599
|
220 fi
|
domcox@599
|
221 }
|
domcox@599
|
222
|
domcox@599
|
223 # Cli options
|
domcox@599
|
224 # $@: tazinst parms
|
domcox@599
|
225 check_cli_options()
|
domcox@599
|
226 {
|
domcox@599
|
227 shift
|
domcox@599
|
228 while getopts "c:df:ghip:s:t:uw:" opt ; do
|
domcox@599
|
229 case $opt in
|
domcox@599
|
230 d) DEBUG=1 ;;
|
domcox@599
|
231 f) TGT_FS=$OPTARG ;;
|
domcox@599
|
232 g) TGT_GRUB="yes" ;;
|
domcox@599
|
233 h) usage ;;
|
domcox@599
|
234 i) INSTALL="install" ;;
|
domcox@599
|
235 p) TGT_PARTITION=$OPTARG ;;
|
domcox@599
|
236 s) SRC_FILE=$OPTARG ;;
|
domcox@599
|
237 t) INST_TYPE=$OPTARG ;;
|
domcox@599
|
238 u) UPGRADE="upgrade" ;;
|
domcox@599
|
239 w) TGT_WINBOOT=$OPTARG ;;
|
domcox@599
|
240 [?]) abort 1 ;;
|
domcox@599
|
241 esac
|
domcox@599
|
242 done
|
domcox@599
|
243
|
domcox@599
|
244 # Duplicate install modes are forbidden
|
domcox@654
|
245 [ -n "$INSTALL" ] && [ -n "$UPGRADE" ] && abort 1 `gettext "Mismatched parameters"`
|
domcox@599
|
246 INST_ACTION="$INSTALL$UPGRADE"
|
domcox@599
|
247 # Don't allow formatting on upgrades
|
domcox@599
|
248 [ "$INST_ACTION" == "upgrade" ] && [ -n "$TGT_FS" ] && \
|
domcox@654
|
249 warning `gettext "Partition $TGT_PARTITION will not be formatted during upgrade"`
|
domcox@599
|
250 }
|
domcox@599
|
251
|
domcox@599
|
252 # check main vars
|
domcox@599
|
253 check_vars()
|
domcox@599
|
254 {
|
domcox@599
|
255 # error handling
|
domcox@599
|
256 local error=no
|
domcox@599
|
257 local found=no
|
domcox@599
|
258 local partition=""
|
domcox@599
|
259
|
domcox@599
|
260 debug "--- Tazinst main options ---"
|
domcox@599
|
261 debug "action=$INST_ACTION"
|
domcox@599
|
262 debug "type=$INST_TYPE"
|
domcox@599
|
263 debug "source=$SRC_FILE"
|
domcox@599
|
264 debug "/ partition=$TGT_PARTITION"
|
domcox@599
|
265 debug "/ filesystem=$TGT_FS"
|
domcox@599
|
266 debug "/home partition=$TGT_HOME"
|
domcox@599
|
267 debug "/home filesystem=$TGT_HOME_FS"
|
domcox@599
|
268 debug "hostname=$TGT_HOSTNAME"
|
domcox@599
|
269 debug "root-pwd=$TGT_ROOT_PWD"
|
domcox@599
|
270 debug "user=$TGT_USER"
|
domcox@599
|
271 debug "user-pwd=$TGT_USER_PWD"
|
domcox@599
|
272 debug "grub=$TGT_GRUB"
|
domcox@599
|
273 debug "winboot=$TGT_WINBOOT"
|
domcox@599
|
274 debug "--------------------------------------"
|
domcox@599
|
275
|
domcox@599
|
276 # Check Action
|
domcox@599
|
277 case $INST_ACTION in
|
domcox@656
|
278 install|upgrade|check) ;;
|
domcox@654
|
279 *) msg `gettext "INST_ACTION=$INST_ACTION: Invalid setting"`; error=yes ;;
|
domcox@599
|
280 esac
|
domcox@599
|
281
|
domcox@599
|
282 # Check Type
|
domcox@599
|
283 case $INST_TYPE in
|
domcox@599
|
284 cdrom|weboot) ;;
|
domcox@599
|
285 usb|iso|web)
|
domcox@599
|
286 # We need a valid source
|
domcox@599
|
287 if [ -z "$SRC_FILE" ]; then
|
domcox@654
|
288 msg `gettext "Type is $INST_TYPE, but INST_SOURCE is not set"`; error=yes
|
domcox@599
|
289 fi ;;
|
domcox@654
|
290 *) msg `gettext "INST_TYPE=$INST_TYPE: Invalid setting"`; error=yes ;;
|
domcox@599
|
291 esac
|
domcox@599
|
292
|
domcox@599
|
293 # Check Source file
|
domcox@599
|
294 # 1. assign predefs
|
domcox@599
|
295 if [ "$INST_TYPE" == "web" ]; then
|
domcox@599
|
296 [ "$SRC_FILE" == "stable" ] && SRC_FILE=$URL_STABLE
|
domcox@599
|
297 [ "$SRC_FILE" == "cooking" ] && SRC_FILE=$URL_COOKING
|
domcox@599
|
298 [ "$SRC_FILE" == "rolling" ] && SRC_FILE=$URL_ROLLING
|
domcox@599
|
299 fi
|
domcox@599
|
300 # 2. check avail.
|
domcox@599
|
301 case $INST_TYPE in
|
domcox@599
|
302 iso)
|
domcox@599
|
303 if [ ! -r "$SRC_FILE" ]; then
|
domcox@654
|
304 msg `gettext "SRC_FILE=$SRC_FILE: file not found"`; error=yes
|
domcox@599
|
305 fi ;;
|
domcox@599
|
306 web)
|
domcox@656
|
307 if ! wget -sq "$SRC_FILE" 2> /dev/null ; then
|
domcox@654
|
308 msg `gettext "SRC_FILE=$SRC_FILE: file not found on the web"`; error=yes
|
domcox@599
|
309 fi ;;
|
domcox@599
|
310 esac
|
domcox@599
|
311
|
domcox@599
|
312 # Check Target Partition
|
domcox@599
|
313 found=no
|
domcox@599
|
314 LIST_PARTITION=$(fdisk -l | awk '/^\/dev/{printf "%s ",$1}')
|
domcox@599
|
315 for partition in $LIST_PARTITION; do
|
domcox@599
|
316 [ "$partition" == "$TGT_PARTITION" ] && found="yes"
|
domcox@599
|
317 done
|
domcox@599
|
318 if [ "$found" != "yes" ]; then
|
domcox@654
|
319 msg `gettext "TGT_PARTITION=$TGT_PARTITION Partition not found"`; error=yes
|
domcox@599
|
320 fi
|
domcox@599
|
321
|
domcox@599
|
322 # Check Filesystem
|
domcox@599
|
323 case $TGT_FS in
|
domcox@599
|
324 "") ;;
|
domcox@599
|
325 btrfs|ext2|ext3|ext4|fat16|fat32|hfs|hfs+|jfs|ntfs|reiser4|reiserfs|ufs|xfs)
|
domcox@599
|
326 found=no
|
domcox@599
|
327 for xdir in /sbin /usr/sbin /usr/bin; do
|
domcox@599
|
328 [ -x "$xdir/mkfs.$TGT_FS" ] && found=yes
|
domcox@599
|
329 done
|
domcox@599
|
330 if [ "$found" == "no" ]; then
|
domcox@654
|
331 msg `gettext "$TGT_FS: mkfs.$TGT_FS is not installed."`; error=yes
|
domcox@599
|
332 fi ;;
|
domcox@654
|
333 *) msg `gettext "TGT_FS=$TGT_FS: Unknown filesystem"`; error=yes ;;
|
domcox@599
|
334 esac
|
domcox@599
|
335
|
domcox@599
|
336 # Check Home partition
|
domcox@599
|
337 if [ -n "$TGT_HOME" ]; then
|
domcox@599
|
338 found=no
|
domcox@599
|
339 for partition in $LIST_PARTITION; do
|
domcox@599
|
340 [ "$partition" == "$TGT_HOME" ] && found=yes
|
domcox@599
|
341 done
|
domcox@599
|
342 if [ "$found" != "yes" ]; then
|
domcox@654
|
343 msg `gettext "TGT_HOME=$TGT_HOME: Partition not found"`; error=yes
|
domcox@599
|
344 fi
|
domcox@599
|
345 fi
|
domcox@599
|
346
|
domcox@599
|
347 # Check Home Filesystem
|
domcox@599
|
348 case $TGT_HOME_FS in
|
domcox@599
|
349 "") ;;
|
domcox@599
|
350 btrfs|ext2|ext3|ext4|fat16|fat32|hfs|hfs+|jfs|ntfs|reiser4|reiserfs|ufs|xfs)
|
domcox@599
|
351 found=no
|
domcox@599
|
352 for xdir in /sbin /usr/sbin /usr/bin; do
|
domcox@599
|
353 [ -x "$xdir/mkfs.$TGT_FS" ] && found=yes
|
domcox@599
|
354 done
|
domcox@599
|
355 if [ "$found" == "no" ]; then
|
domcox@654
|
356 msg `gettext "$TGT_FS: mkfs.$TGT_FS is not installed."`; error=yes
|
domcox@599
|
357 fi ;;
|
domcox@654
|
358 *) msg `gettext "TGT_HOME_FS=$TGT_HOME_FS: unknown filesystem"`; error=yes ;;
|
domcox@599
|
359 esac
|
domcox@599
|
360
|
domcox@599
|
361 # Check Grub
|
domcox@599
|
362 case $TGT_GRUB in
|
domcox@599
|
363 yes|no) ;;
|
domcox@654
|
364 *) msg `gettext "TGT_GRUB=$TGT_GRUB: Invalid setting"`; error=yes ;;
|
domcox@599
|
365 esac
|
domcox@599
|
366
|
domcox@599
|
367 # Check Winboot
|
domcox@599
|
368 case $TGT_WINBOOT in
|
domcox@599
|
369 "") ;;
|
domcox@599
|
370 auto) ;;
|
domcox@599
|
371 hd[[:digit:]],[[:digit:]]) ;;
|
domcox@654
|
372 *) msg `gettext "TGT_WINBOOT=$TGT_WINBOOT: Invalid format"`; error=yes ;;
|
domcox@599
|
373 esac
|
domcox@599
|
374
|
domcox@599
|
375 # Stop on error
|
domcox@599
|
376 [ "$error" == "yes" ] && abort 1
|
domcox@599
|
377 }
|
domcox@599
|
378
|
domcox@599
|
379 # Exit install if user is not root.
|
domcox@599
|
380 check_root()
|
domcox@599
|
381 {
|
domcox@599
|
382 if test $(id -u) != 0 ; then
|
domcox@654
|
383 echo -e "`gettext \"You must be the root user (system administrator) to install SliTaz, \
|
domcox@654
|
384 please use 'su' to get a root SHell and restart installation.\"`"
|
domcox@599
|
385 exit 0
|
domcox@599
|
386 fi
|
domcox@599
|
387 }
|
domcox@599
|
388
|
domcox@599
|
389 # Mount cdrom
|
domcox@599
|
390 check_cdrom()
|
domcox@599
|
391 {
|
domcox@599
|
392 # Set device name
|
domcox@599
|
393 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3` [ -n "$DRIVE_NAME" ] || DRIVE_NAME=cdrom
|
domcox@599
|
394 CDROM=/dev/$DRIVE_NAME
|
domcox@599
|
395 # Try to mount a cdrom
|
domcox@599
|
396 if mount -t iso9660 $CDROM $SOURCE_ROOT 2>>$LOG; then
|
domcox@599
|
397 debug "Using files from cdrom ($CDROM)..."
|
domcox@599
|
398 sleep 2
|
domcox@599
|
399 else
|
domcox@654
|
400 warning `gettext "Failed to mount $CDROM"`
|
domcox@599
|
401 fi
|
domcox@599
|
402 }
|
domcox@599
|
403
|
domcox@599
|
404 # Link LiveUSB
|
domcox@599
|
405 check_usb()
|
domcox@599
|
406 {
|
domcox@599
|
407 # /home is on USB dev
|
domcox@599
|
408 if [ -d /home/boot ]; then
|
domcox@599
|
409 debug "Using files from USB device..."
|
domcox@599
|
410 ln -s /home/boot $SOURCE_ROOT/boot
|
domcox@599
|
411 SOURCE_STATUS="link"
|
domcox@599
|
412 sleep 2
|
domcox@599
|
413 else
|
domcox@599
|
414 # Try to mount LiveUSB
|
domcox@599
|
415 if mount $SRC_FILE $SOURCE_ROOT 2>>$LOG; then
|
domcox@599
|
416 debug "Using files from USB device ($SRC_FILE)..."
|
domcox@599
|
417 SOURCE_STATUS="mount"
|
domcox@599
|
418 else
|
domcox@654
|
419 warning `gettext "Failed to mount USB device $SRC_FILE"`
|
domcox@599
|
420 fi
|
domcox@599
|
421 fi
|
domcox@599
|
422 }
|
domcox@599
|
423
|
domcox@599
|
424 # Mount ISO file
|
domcox@599
|
425 check_iso()
|
domcox@599
|
426 {
|
domcox@599
|
427 local src_md5
|
domcox@599
|
428 # Integrity check
|
domcox@599
|
429 src_md5=$(echo $SRC_FILE | sed 's/.iso$/.md5/')
|
domcox@599
|
430 if [ -r "$src_md5" ]; then
|
domcox@599
|
431 [ $(md5sum $SRC_FILE | cut -d' ' -f1) == $(cat "$src_md5" | cut -d' ' -f1) ] || \
|
domcox@654
|
432 abort 3 `gettext "$SRC-FILE corrupted"`
|
domcox@599
|
433 else
|
domcox@654
|
434 warning `gettext "$src_md5 not found, unable to check integrity of $SRC_FILE"`
|
domcox@599
|
435 fi
|
domcox@599
|
436 # Try to mount ISO
|
domcox@599
|
437 if mount -o loop -t iso9660 $SRC_FILE $SOURCE_ROOT 2>>$LOG; then
|
domcox@599
|
438 debug "Using files from ISO ($SRC_FILE)..."
|
domcox@599
|
439 sleep 2
|
domcox@599
|
440 else
|
domcox@654
|
441 warning `gettext "Failed to mount ISO '$SRC_FILE'"`
|
domcox@599
|
442 fi
|
domcox@599
|
443 }
|
domcox@599
|
444
|
domcox@599
|
445 # Source is on the web
|
domcox@599
|
446 check_web()
|
domcox@599
|
447 {
|
domcox@599
|
448 local src_md5
|
domcox@599
|
449 debug "Downloading $SRC_FILE"
|
domcox@599
|
450 if wget $SRC_FILE -P /tmp; then
|
domcox@599
|
451 debug "Download completed."
|
domcox@599
|
452 else
|
domcox@654
|
453 warning `gettext "Failed to download '$SRC_FILE'"`
|
domcox@599
|
454 fi
|
domcox@599
|
455 src_md5=$(echo $SRC_FILE | sed 's/.iso$/.md5/')
|
domcox@599
|
456 debug "Downloading $src_md5"
|
domcox@654
|
457 wget $src_md5 -P /tmp || warning `gettext "Failed to download '$src_md5'"`
|
domcox@599
|
458 tmpfile=$(echo $SRC_FILE | awk 'BEGIN{RS="/"}{out=$1}END{printf"%s",out}')
|
domcox@599
|
459 SRC_FILE="/tmp/$tmpfile"
|
domcox@599
|
460 check_iso
|
domcox@599
|
461 }
|
domcox@599
|
462
|
domcox@599
|
463 # We may be in Tiny Web boot mode
|
domcox@599
|
464 check_weboot()
|
domcox@599
|
465 {
|
domcox@599
|
466 if [ -d $SRC_FILE/boot ]; then
|
domcox@599
|
467 debug "Using files from HTTP device..."
|
domcox@599
|
468 ln -s $SRC_FILE/boot $SOURCE_ROOT/boot
|
domcox@599
|
469 sleep 2
|
domcox@599
|
470 else
|
domcox@654
|
471 abort 3 `gettext "Web boot files not found"`
|
domcox@599
|
472 fi
|
domcox@599
|
473 }
|
domcox@599
|
474
|
domcox@599
|
475 # set up source and check Slitaz' content
|
domcox@599
|
476 check_source()
|
domcox@599
|
477 {
|
domcox@599
|
478 debug "Creating mount point ($SOURCE_ROOT)..."
|
domcox@599
|
479 mkdir -p $SOURCE_ROOT
|
domcox@599
|
480 sleep 1
|
domcox@599
|
481 case $INST_TYPE in
|
domcox@599
|
482 cdrom)
|
domcox@599
|
483 check_cdrom ;;
|
domcox@599
|
484 usb)
|
domcox@599
|
485 check_usb ;;
|
domcox@599
|
486 iso)
|
domcox@599
|
487 check_iso ;;
|
domcox@599
|
488 web)
|
domcox@599
|
489 check_web ;;
|
domcox@599
|
490 weboot)
|
domcox@599
|
491 check_cdrom
|
domcox@599
|
492 check_web ;;
|
domcox@599
|
493 *)
|
domcox@654
|
494 abort 8 `gettext "Internal"` ;;
|
domcox@599
|
495 esac
|
domcox@599
|
496
|
domcox@599
|
497 # Exit with error msg if no rootfs.gz found.
|
domcox@599
|
498 debug "Checking installation media..."
|
domcox@599
|
499 if [ ! -f $SOURCE_ROOT/boot/rootfs.gz -a \
|
domcox@599
|
500 ! -f $SOURCE_ROOT/boot/rootfs1.gz ]; then
|
domcox@654
|
501 abort 3 `gettext "Invalid source"`
|
domcox@599
|
502 else
|
domcox@599
|
503 debug "Installation media checked ok"
|
domcox@599
|
504 fi
|
domcox@599
|
505 }
|
domcox@599
|
506
|
domcox@599
|
507 # Tiny summary
|
domcox@599
|
508 summary()
|
domcox@599
|
509 {
|
domcox@654
|
510 echo -e "`gettext \"Installation settings summary:\"`"
|
domcox@599
|
511 STEP=0
|
domcox@599
|
512
|
domcox@599
|
513 if [ "$INST_ACTION" == "install" ]; then
|
domcox@599
|
514 if [ -n "$TGT_FS" ]; then
|
domcox@654
|
515 msg `gettext "Format root partition '$TGT_PARTITION' ($TGT_FS)"`
|
domcox@599
|
516 fi
|
domcox@599
|
517 if [ -n "$TGT_HOME_FS" ]; then
|
domcox@654
|
518 msg `gettext "Format /home partition '$TGT_HOME' ($TGT_HOME_FS)"`
|
domcox@599
|
519 fi
|
domcox@654
|
520 msg `gettext "Install SliTaz on '$TGT_PARTITION' from $INST_TYPE"`
|
domcox@654
|
521 [ -n "$TGT_HOME" ] && msg `gettext "Set Home partition to '$TGT_HOME'"`
|
domcox@654
|
522 msg `gettext "Set Hostname as '$TGT_HOSTNAME'"`
|
domcox@654
|
523 msg `gettext "Set Default user as '$TGT_USER'"`
|
domcox@599
|
524 else
|
domcox@654
|
525 msg `gettext "Check '$TGT_PARTITION'"`
|
domcox@654
|
526 msg `gettext "Backup /etc, /home and the packages list"`
|
domcox@654
|
527 msg `gettext "Upgrade SliTaz on '$TGT_PARTITION' from $INST_TYPE"`
|
domcox@654
|
528 msg `gettext "Restore /etc, /home"`
|
domcox@654
|
529 msg `gettext "Upgrade additional packages."`
|
domcox@599
|
530 fi
|
domcox@599
|
531 if [ -n "$TGT_WINBOOT" ]; then
|
domcox@654
|
532 msg `gettext "Enable Windows dual-boot ($TGT_WINBOOT)"`
|
domcox@599
|
533 fi
|
domcox@599
|
534 if [ "$TGT_GRUB" == "yes" ]; then
|
domcox@654
|
535 msg `gettext "Install Grub"`
|
domcox@599
|
536 fi
|
domcox@599
|
537
|
domcox@654
|
538 echo -ne "`gettext \"Continue:(y/n)\"`"
|
domcox@599
|
539 read answer
|
domcox@599
|
540 case $answer in
|
domcox@655
|
541 [oOyY]) echo -e "`gettext \"Running $BACKLIST..\"`" ;;
|
domcox@654
|
542 *) abort 4 `gettext "Cancelled by user"` ;;
|
domcox@599
|
543 esac
|
domcox@599
|
544 STEP=0
|
domcox@599
|
545 }
|
domcox@599
|
546
|
domcox@599
|
547 #######################
|
domcox@599
|
548 # Installer functions #
|
domcox@599
|
549 #######################
|
domcox@599
|
550
|
domcox@599
|
551 # Mount and mkfs with progress.
|
domcox@599
|
552 prepare_install()
|
domcox@599
|
553 {
|
domcox@599
|
554 debug "Preparing target partition..."
|
domcox@612
|
555 # Target may be used
|
domcox@612
|
556 mount | grep -q $TGT_PARTITION && \
|
domcox@654
|
557 abort 5 `gettext $TGT_PARTITION": Partition in use"`
|
domcox@599
|
558 # Mount point can be already used.
|
domcox@599
|
559 if mount | grep -q $TARGET_ROOT; then
|
domcox@599
|
560 umount $TARGET_ROOT 2>>$LOG
|
domcox@599
|
561 fi
|
domcox@599
|
562 sleep 2
|
domcox@599
|
563
|
domcox@599
|
564 # Formatting root partition
|
domcox@599
|
565 case $TGT_FS in
|
domcox@599
|
566 "")
|
domcox@599
|
567 debug "The partition ($TGT_PARTITION) will be cleaned..."
|
domcox@599
|
568 # ROOT_FS=$(parted /dev/hda5 print -m | grep "^1:" | cut -d':' -f5) ;;
|
domcox@599
|
569 ROOT_FS=auto ;;
|
domcox@599
|
570 *)
|
domcox@654
|
571 msg `gettext "Formatting $TGT_PARTITION ($TGT_FS)"`
|
domcox@599
|
572 mkfs.$TGT_FS $TGT_PARTITION >>$LOG 2>>$LOG
|
domcox@599
|
573 ROOT_FS=$TGT_FS ;;
|
domcox@599
|
574 esac
|
domcox@599
|
575 sleep 2
|
domcox@599
|
576
|
domcox@599
|
577 # Formatting /home
|
domcox@599
|
578 if [ -n "$TGT_HOME" ]; then
|
domcox@599
|
579 case $TGT_HOME_FS in
|
domcox@599
|
580 "")
|
domcox@599
|
581 debug "The partition ($TGT_HOME) will be kept..." ;;
|
domcox@599
|
582 *)
|
domcox@654
|
583 msg `gettext "Formatting /home on $TGT_HOME ($TGT_HOME_FS)"`
|
domcox@599
|
584 mkfs.$TGT_HOME_FS -L "Home" $TGT_HOME >>$LOG 2>>$LOG ;;
|
domcox@599
|
585 esac
|
domcox@599
|
586 sleep 2
|
domcox@599
|
587 fi
|
domcox@599
|
588
|
domcox@599
|
589 # Mount target.
|
domcox@599
|
590 debug "Creating mount point: $TARGET_ROOT"
|
domcox@599
|
591 mkdir -p $TARGET_ROOT >>$LOG
|
domcox@599
|
592 sleep 2
|
domcox@599
|
593
|
domcox@599
|
594 mount -t $ROOT_FS $TGT_PARTITION $TARGET_ROOT >>$LOG 2>>$LOG
|
domcox@599
|
595 if [ $(mount | grep -c "mnt/target") == "0" ]; then
|
domcox@654
|
596 abort 5 `gettext "Can't mount $TGT_PARTITION"`
|
domcox@599
|
597 fi
|
domcox@599
|
598 }
|
domcox@599
|
599
|
domcox@599
|
600 # Get a clean target device (15%).
|
domcox@599
|
601 clean_target()
|
domcox@599
|
602 {
|
domcox@599
|
603 if [ -z "$TGT_FS" ]; then
|
domcox@599
|
604 # partition was not formatted
|
domcox@599
|
605 debug "Cleaning the root partition ($TGT_PARTITION)..."
|
domcox@599
|
606 # Keep /home in case of reinstall.
|
domcox@654
|
607 cd $TARGET_ROOT || abort 8 `gettext "Internal"`
|
domcox@599
|
608 for dir in *
|
domcox@599
|
609 do
|
domcox@599
|
610 case "$dir" in
|
domcox@599
|
611 home)
|
domcox@599
|
612 debug "keeping /home found on: $TGT_PARTITION"
|
domcox@599
|
613 mv home home.bak ;;
|
domcox@599
|
614 lost+found)
|
domcox@599
|
615 continue ;;
|
domcox@599
|
616 *)
|
domcox@599
|
617 debug "removing target: $dir"
|
domcox@599
|
618 rm -rf $dir 2>>$LOG ;;
|
domcox@599
|
619 esac
|
domcox@599
|
620 done
|
domcox@599
|
621 if [ -d mklost+found ]; then
|
domcox@599
|
622 mklost+found 2>>$LOG
|
domcox@599
|
623 fi
|
domcox@599
|
624 fi
|
domcox@599
|
625 sleep 2
|
domcox@599
|
626 }
|
domcox@599
|
627
|
domcox@599
|
628 # Kernel is renamed to standard vmlinuz-$VERSION.
|
domcox@599
|
629 install_kernel()
|
domcox@599
|
630 {
|
domcox@599
|
631 if [ -d /$TARGET_ROOT/lib/modules ]; then
|
domcox@599
|
632 KERNEL=$(ls /$TARGET_ROOT/lib/modules | tail -1)
|
domcox@599
|
633 KERNEL="vmlinuz-$KERNEL"
|
domcox@599
|
634 else
|
domcox@654
|
635 warning `gettext "Falling back to running kernel name.."`
|
domcox@599
|
636 KERNEL=vmlinuz-`uname -r`
|
domcox@599
|
637 fi
|
domcox@599
|
638 mkdir -p $TARGET_ROOT/boot
|
domcox@599
|
639 cp $SOURCE_ROOT/boot/bzImage $TARGET_ROOT/boot/$KERNEL
|
domcox@599
|
640 debug "install_kernel: $KERNEL"
|
domcox@599
|
641 sleep 2
|
domcox@599
|
642 }
|
domcox@599
|
643
|
domcox@599
|
644 # Copy isolinux r/w files (not syslinux, some files are read only).
|
domcox@599
|
645 copy_bootloaders()
|
domcox@599
|
646 {
|
domcox@599
|
647 if [ -d "$SOURCE/ROOT/boot/isolinux" ]; then
|
domcox@599
|
648 debug "Copy isolinux r/w files"
|
domcox@599
|
649 mkdir -p $TARGET_ROOT/boot/isolinux
|
domcox@599
|
650 cp -a $SOURCE_ROOT/boot/isolinux/*.cfg $TARGET_ROOT/boot/isolinux
|
domcox@599
|
651 cp -a $SOURCE_ROOT/boot/isolinux/*.kbd $TARGET_ROOT/boot/isolinux
|
domcox@599
|
652 cp -a $SOURCE_ROOT/boot/isolinux/*.txt $TARGET_ROOT/boot/isolinux
|
domcox@599
|
653 cp -a $SOURCE_ROOT/boot/isolinux/*.bin $TARGET_ROOT/boot/isolinux
|
domcox@599
|
654 cp -a $SOURCE_ROOT/boot/isolinux/*.msg $TARGET_ROOT/boot/isolinux
|
domcox@599
|
655 cp -a $SOURCE_ROOT/boot/isolinux/*.lss $TARGET_ROOT/boot/isolinux
|
domcox@599
|
656 cp -a $SOURCE_ROOT/boot/isolinux/*.c32 $TARGET_ROOT/boot/isolinux
|
domcox@599
|
657 fi
|
domcox@599
|
658 }
|
domcox@599
|
659
|
domcox@599
|
660 need_package()
|
domcox@599
|
661 {
|
domcox@599
|
662 [ -d /var/lib/tazpkg/installed/$1 ] || tazpkg get-install $1
|
domcox@599
|
663 }
|
domcox@599
|
664
|
domcox@599
|
665 # extract packed rootfs: squashfs or cromfs
|
domcox@599
|
666 extract_loramfs()
|
domcox@599
|
667 {
|
domcox@599
|
668 local i
|
domcox@599
|
669 for i in $(cpio -idvum 2> /dev/null); do
|
domcox@599
|
670 case "$i" in
|
domcox@599
|
671 rootfs*)
|
domcox@599
|
672 need_package squashfs
|
domcox@599
|
673 if ! unsquashfs $i ; then
|
domcox@599
|
674 need_package cromfs
|
domcox@599
|
675 unmkcromfs $i squashfs-root
|
domcox@599
|
676 fi
|
domcox@599
|
677 mv -f squashfs-root/* .
|
domcox@599
|
678 rmdir squashfs-root
|
domcox@599
|
679 rm -f $i
|
domcox@599
|
680 esac
|
domcox@599
|
681 done
|
domcox@599
|
682 }
|
domcox@599
|
683
|
domcox@599
|
684 # This is a loram rootfs.gz, skip loram bootstrap and extract
|
domcox@599
|
685 extract_first_loramfs()
|
domcox@599
|
686 {
|
domcox@599
|
687 (zcat $1 || unlzma -c $1) | cpio -i extractfs.cpio 2> /dev/null &&
|
domcox@599
|
688 ( cd / ; cpio -id ) < extractfs.cpio && rm -f extractfs.cpio
|
domcox@599
|
689 ofs=$(awk '/07070100/ { o+=index($0,"07070100"); printf "%d\n",o/4 ; exit } { o+=1+length() }' < $1)
|
domcox@599
|
690 dd if=$1 skip=$(($ofs / 1024)) bs=4k count=1 2> /dev/null | \
|
domcox@599
|
691 ( dd skip=$(($ofs % 1024)) bs=4 2> /dev/null ; \
|
domcox@599
|
692 dd if=$1 skip=$((1 + ($ofs / 1024) )) bs=4k ) | extract_loramfs
|
domcox@599
|
693 }
|
domcox@599
|
694
|
domcox@599
|
695 # Extract lzma'ed or gziped rootfs.
|
domcox@599
|
696 extract_rootfs()
|
domcox@599
|
697 {
|
domcox@599
|
698 local isloramfs
|
domcox@599
|
699 isloramfs=
|
domcox@654
|
700 cd $TARGET_ROOT || abort 8 `gettext "Internal"`
|
domcox@599
|
701 if [ -d $1/../fs/etc ]; then
|
domcox@599
|
702 # This is a tazlitobox loram (cdrom)
|
domcox@599
|
703 cp -a $1/../fs/. .
|
domcox@599
|
704 else
|
domcox@599
|
705 for i in $(ls $1/rootfs* | sort -r); do
|
domcox@599
|
706 if [ ! -d etc ]; then
|
domcox@599
|
707 if [ $( (zcat $i 2>/dev/null || lzma d $i -so) | wc -c) \
|
domcox@599
|
708 -lt $(stat -c %s $i) ]; then
|
domcox@599
|
709 # This is a tazlitobox loram (ram)
|
domcox@599
|
710 isloramfs=$i
|
domcox@599
|
711 extract_first_loramfs $i
|
domcox@599
|
712 continue
|
domcox@599
|
713 fi
|
domcox@599
|
714 fi
|
domcox@599
|
715 if [ -n "$isloramfs" ]; then
|
domcox@599
|
716 extract_loramfs < $i
|
domcox@599
|
717 continue
|
domcox@599
|
718 fi
|
domcox@599
|
719 ( zcat $i 2>/dev/null || lzma d $i -so || \
|
domcox@599
|
720 cat $i ) 2>>$LOG | cpio -idu
|
domcox@599
|
721 done 2>>$LOG > /dev/null
|
domcox@599
|
722 fi
|
domcox@599
|
723 cp /etc/keymap.conf etc
|
domcox@599
|
724 # unpack /usr (double check...)
|
domcox@599
|
725 if ls etc/tazlito | grep -q ".extract"; then
|
domcox@599
|
726 for i in etc/tazlito/*.extract; do
|
domcox@599
|
727 [ -f "$i" ] && . $i /media/cdrom
|
domcox@599
|
728 done
|
domcox@599
|
729 fi
|
domcox@599
|
730 }
|
domcox@599
|
731
|
domcox@599
|
732 # Pre configure freshly installed system (60 - 80%).
|
domcox@599
|
733 pre_config_system()
|
domcox@599
|
734 {
|
domcox@654
|
735 cd $TARGET_ROOT || abort 8 `gettext "Internal"`
|
domcox@599
|
736 # Restore backup of existing /home if exists.
|
domcox@599
|
737 # (created by prepare_target_dev)
|
domcox@599
|
738 if [ -d home.bak ]; then
|
domcox@599
|
739 debug "Restoring directory: /home..."
|
domcox@599
|
740 rm -rf home
|
domcox@599
|
741 mv home.bak home
|
domcox@599
|
742 sleep 1
|
domcox@599
|
743 fi
|
domcox@599
|
744 # Add root device to CHECK_FS in rcS.conf to check filesystem
|
domcox@599
|
745 # on each boot.
|
domcox@599
|
746 debug "Adding $TGT_PARTITION and CHECK_FS to file /etc/rcS.conf..."
|
domcox@599
|
747 sed -i s#'CHECK_FS=\"\"'#"CHECK_FS=\"$TGT_PARTITION\""# etc/rcS.conf
|
domcox@599
|
748 sleep 2
|
domcox@599
|
749 # Set hostname.
|
domcox@654
|
750 msg `gettext "Configuring host name: $TGT_HOSTNAME"`
|
domcox@599
|
751 echo $TGT_HOSTNAME > etc/hostname
|
domcox@599
|
752 }
|
domcox@599
|
753
|
domcox@599
|
754 # Set root passwd and create user after rootfs extraction.
|
domcox@599
|
755 users_settings()
|
domcox@599
|
756 {
|
domcox@599
|
757 cat > $TARGET_ROOT/users.sh << _EOF_
|
domcox@599
|
758 #!/bin/sh
|
domcox@654
|
759 echo "root:$TGT_ROOT_PWD" | chpasswd > /etc/null
|
domcox@599
|
760 adduser -D -H $TGT_USER
|
domcox@599
|
761
|
domcox@599
|
762 for grp in audio cdrom floppy dialout disk kmem tape tty video; do
|
domcox@599
|
763 if ! grep \$grp /etc/group | grep -q $TGT_USER ; then
|
domcox@599
|
764 grep -q \$grp /etc/group && addgroup $TGT_USER \$grp
|
domcox@599
|
765 fi
|
domcox@599
|
766 done
|
domcox@599
|
767
|
domcox@654
|
768 echo "$TGT_USER:$TGT_USER_PWD" | chpasswd > /etc/null
|
domcox@599
|
769 if [ ! -d /home/$TGT_USER ]; then
|
domcox@599
|
770 cp -a /etc/skel /home/$TGT_USER
|
domcox@612
|
771 [ -e /root/.xinitrc ] && cp /root/.xinitrc /home/$TGT_USER
|
domcox@599
|
772 mkdir -p /home/$TGT_USER/.config/slitaz
|
domcox@599
|
773 cp -a /etc/slitaz/applications.conf /home/$TGT_USER/.config/slitaz
|
domcox@656
|
774 # Set ownership
|
domcox@654
|
775 if grep -q ^users: /etc/group; then
|
domcox@654
|
776 chown -R $TGT_USER:users /home/$TGT_USER
|
domcox@654
|
777 else
|
domcox@654
|
778 chown -R $TGT_USER:$TGT_USER /home/$TGT_USER
|
domcox@654
|
779 fi
|
domcox@599
|
780 # Path for user desktop files.
|
domcox@599
|
781 for i in /home/$TGT_USER/.local/share/applications/*.desktop
|
domcox@599
|
782 do
|
domcox@599
|
783 [ -e "$i" ] && sed -i s/"user_name"/"$TGT_USER"/g \$i
|
domcox@599
|
784 done
|
domcox@599
|
785 fi
|
domcox@599
|
786 # Slim default user.
|
domcox@599
|
787 if [ -f /etc/slim.conf ]; then
|
domcox@599
|
788 sed -i s/"default_user .*"/"default_user $TGT_USER"/ \
|
domcox@599
|
789 /etc/slim.conf
|
domcox@599
|
790 fi
|
domcox@599
|
791 _EOF_
|
domcox@599
|
792 chmod +x $TARGET_ROOT/users.sh
|
domcox@599
|
793 chroot $TARGET_ROOT ./users.sh
|
domcox@599
|
794 rm $TARGET_ROOT/users.sh
|
domcox@599
|
795 sleep 2
|
domcox@599
|
796 }
|
domcox@599
|
797
|
paul@608
|
798 # /home can be on a separate partition. If default user exists in /home
|
paul@608
|
799 # we remove default file created by users_settings().
|
domcox@599
|
800 home_config()
|
domcox@599
|
801 {
|
domcox@599
|
802 debug "home_config: $TGT_HOME"
|
domcox@654
|
803 cd $TARGET_ROOT || abort 8 `gettext "Internal"`
|
domcox@599
|
804 mv home/$TGT_USER tmp
|
domcox@599
|
805 mount $TGT_HOME home
|
domcox@599
|
806 if [ -d $TARGET_ROOT/home/$TGTUSER ]; then
|
domcox@599
|
807 rm -rf tmp/$TGT_USER
|
domcox@599
|
808 else
|
domcox@599
|
809 mv tmp/$TGT_USER home
|
domcox@599
|
810 fi
|
domcox@599
|
811 echo "$TGT_HOME /home ext3 defaults 0 2" \
|
domcox@599
|
812 >> etc/fstab
|
domcox@599
|
813 umount home
|
domcox@599
|
814 }
|
domcox@599
|
815
|
domcox@599
|
816 # Search for a Windows partition
|
domcox@599
|
817 win_partition()
|
domcox@599
|
818 {
|
domcox@654
|
819 # msg `gettext "Searching for Windows"`
|
domcox@599
|
820 if [ "$TGT_WINBOOT" == "auto" ];then
|
domcox@599
|
821 WINBOOT=$(fdisk -l | awk '
|
domcox@599
|
822 BEGIN{disk=-1, found=-1, winboot=""}
|
domcox@599
|
823 {
|
domcox@599
|
824 # Counting disk
|
domcox@599
|
825 if ($1=="Disk"){disk++, part=-1}
|
domcox@599
|
826 # Counting partition
|
domcox@599
|
827 if (substr($1,1,4)=="/dev"){part++}
|
domcox@599
|
828 # Read partition Id
|
domcox@599
|
829 if ($2=="*"){Id=$6} else {Id=$5}
|
domcox@599
|
830 # Detect Windows type
|
domcox@599
|
831 if (Id=="7" || Id=="b"){
|
domcox@599
|
832 if (found){
|
domcox@599
|
833 # record 1st Windows partition found
|
domcox@599
|
834 winboot=sprintf("hd%d,%d",disk,part),found++}
|
domcox@599
|
835 }
|
domcox@599
|
836 }
|
domcox@599
|
837 END{printf "%s", winboot}')
|
domcox@599
|
838 if [ -z "$WINBOOT" ]; then
|
domcox@654
|
839 warning `gettext "No windows partition found. Dual-boot disabled"`
|
domcox@599
|
840 TGT_WINBOOT=""
|
domcox@599
|
841 fi
|
domcox@599
|
842 fi
|
domcox@599
|
843 }
|
domcox@599
|
844
|
domcox@599
|
845 # Determine GRUB partition number and GRUB disk number.
|
domcox@599
|
846 grub_partition()
|
domcox@599
|
847 {
|
domcox@599
|
848 DISK_LETTER=${TGT_PARTITION#/dev/[h-s]d}
|
domcox@599
|
849 DISK_LETTER=${DISK_LETTER%[0-9]}
|
domcox@599
|
850 GRUB_PARTITION=$((${TGT_PARTITION#/dev/[h-s]d[a-z]}-1))
|
domcox@599
|
851 for disk in a b c d e f g h
|
domcox@599
|
852 do
|
domcox@599
|
853 nb=$(($nb+1))
|
domcox@599
|
854 if [ "$disk" = "$DISK_LETTER" ]; then
|
domcox@599
|
855 GRUB_DISK=$(($nb-1))
|
domcox@599
|
856 break
|
domcox@599
|
857 fi
|
domcox@599
|
858 done
|
domcox@599
|
859 GRUB_ROOT="(hd${GRUB_DISK},${GRUB_PARTITION})"
|
domcox@599
|
860 }
|
domcox@599
|
861
|
domcox@599
|
862 # Create grub conf
|
domcox@599
|
863 grub_config()
|
domcox@599
|
864 {
|
domcox@599
|
865 grub_partition
|
domcox@612
|
866 if [ "$TGT_GRUB" == "yes" ]; then
|
domcox@612
|
867 win_partition
|
domcox@612
|
868 fi
|
domcox@599
|
869 # Create the target GRUB configuration.
|
domcox@599
|
870 mkdir -p $TARGET_ROOT/boot/grub
|
domcox@599
|
871 . /etc/locale.conf
|
domcox@599
|
872 cat > $TARGET_ROOT/boot/grub/menu.lst << _EOF_
|
domcox@599
|
873 # /boot/grub/menu.lst: GRUB boot loader configuration.
|
domcox@599
|
874 #
|
domcox@599
|
875
|
domcox@599
|
876 # By default, boot the first entry.
|
domcox@599
|
877 default 0
|
domcox@599
|
878
|
domcox@599
|
879 # Boot automatically after 8 secs.
|
domcox@599
|
880 timeout 8
|
domcox@599
|
881
|
domcox@599
|
882 # Graphical splash image.
|
domcox@599
|
883 splashimage=/boot/grub/splash.xpm.gz
|
domcox@599
|
884
|
domcox@599
|
885 # Change the colors.
|
domcox@599
|
886 #color yellow/brown light-green/black
|
domcox@599
|
887
|
domcox@599
|
888 # For booting SliTaz from : $TGT_PARTITION
|
domcox@599
|
889 #
|
domcox@599
|
890 title SliTaz GNU/Linux (cooking) (Kernel $KERNEL)
|
domcox@599
|
891 root $GRUB_ROOT
|
domcox@599
|
892 kernel /boot/$KERNEL root=$TGT_PARTITION lang=$LANG
|
domcox@599
|
893
|
domcox@599
|
894 _EOF_
|
domcox@599
|
895 if [ -n "$TGT_WINBOOT" ]; then
|
domcox@654
|
896 msg `gettext "Enabling Windows dual-boot"`
|
domcox@612
|
897 cat >> $TARGET_ROOT/boot/grub/menu.lst << _EOF_
|
domcox@599
|
898 # For booting Windows :
|
domcox@599
|
899 #
|
domcox@599
|
900 title Microsoft Windows
|
domcox@599
|
901 rootnoverify ($WINBOOT)
|
domcox@599
|
902 chainloader +1
|
domcox@599
|
903
|
domcox@599
|
904 _EOF_
|
domcox@599
|
905 fi
|
domcox@599
|
906 # log
|
domcox@599
|
907 debug "grub_config: $TARGET_ROOT/boot/grub/menu.lst"
|
domcox@599
|
908 echo "--- menu.lst -------------" >>$LOG
|
domcox@599
|
909 cat $TARGET_ROOT/boot/grub/menu.lst >>$LOG
|
domcox@599
|
910 echo "--- menu.lst -------------" >>$LOG
|
domcox@599
|
911 sleep 2
|
domcox@599
|
912 }
|
domcox@599
|
913
|
domcox@599
|
914 # Files install, calling for functions or with cmds.
|
domcox@599
|
915 install_files()
|
domcox@599
|
916 {
|
domcox@654
|
917 msg `gettext "Installing SliTaz on $TGT_PARTITION"`
|
domcox@599
|
918 # saving pwd
|
domcox@599
|
919 local save_pwd=$(pwd)
|
domcox@599
|
920
|
domcox@599
|
921 debug "Cleaning the root partition if necessary..."
|
domcox@599
|
922 clean_target
|
domcox@599
|
923
|
domcox@599
|
924 debug "Extracting the root system..."
|
domcox@599
|
925 extract_rootfs $SOURCE_ROOT/boot
|
domcox@599
|
926
|
domcox@599
|
927 debug "Installing the kernel..."
|
domcox@599
|
928 install_kernel
|
domcox@599
|
929
|
domcox@599
|
930 debug "Copying the bootloader syslinux/isolinux..."
|
domcox@599
|
931 copy_bootloaders
|
domcox@599
|
932
|
domcox@599
|
933 debug "Preconfiguring the system..."
|
domcox@599
|
934 pre_config_system
|
domcox@599
|
935
|
domcox@654
|
936 msg `gettext "Configuring root and default $TGT_USER account..."`
|
domcox@599
|
937 users_settings
|
domcox@599
|
938
|
domcox@599
|
939 if [ "$TGT_HOME" != "" ]; then
|
domcox@654
|
940 msg `gettext "Configuring $TGT_HOME to be used as /home..."`
|
domcox@599
|
941 home_config
|
domcox@599
|
942 sleep 2
|
domcox@599
|
943 fi
|
domcox@599
|
944
|
domcox@599
|
945 debug "Creating configuration file for GRUB (menu.lst)..."
|
domcox@599
|
946 grub_config
|
domcox@599
|
947
|
domcox@599
|
948 debug "Files installation completed"
|
domcox@599
|
949 sleep 2
|
domcox@599
|
950 # restoring pwd
|
domcox@599
|
951 cd $save_pwd
|
domcox@599
|
952 }
|
domcox@599
|
953
|
domcox@599
|
954 # GRUB info with disk name used for grub-install.
|
domcox@599
|
955 grub_install()
|
domcox@599
|
956 {
|
domcox@599
|
957 if [ "$TGT_GRUB" == "yes" ]; then
|
domcox@599
|
958 TARGET_DISK=`echo $TGT_PARTITION | sed s/"[0-9]"/''/`
|
domcox@654
|
959 msg `gettext "Running grub-install on : $TARGET_DISK"`
|
domcox@599
|
960 grub-install --no-floppy \
|
domcox@599
|
961 --root-directory=$TARGET_ROOT $TARGET_DISK 2>>$LOG
|
domcox@599
|
962 debug "Grub installation done..."
|
domcox@599
|
963 else
|
domcox@599
|
964 debug "Grub not installed"
|
domcox@599
|
965 fi
|
domcox@599
|
966 }
|
domcox@599
|
967
|
domcox@599
|
968 # Copy log file, umount target and eject cdrom.
|
domcox@599
|
969 umount_devices()
|
domcox@599
|
970 {
|
domcox@599
|
971 # Umount target
|
domcox@599
|
972 if mount | grep -q $TARGET_ROOT; then
|
domcox@654
|
973 echo -e "`gettext \"Unmounting target ($TGT_PARTITION)...\"`"
|
domcox@599
|
974 umount $TARGET_ROOT 2>>$LOG
|
domcox@599
|
975 fi
|
domcox@599
|
976
|
domcox@599
|
977 # Umount source
|
domcox@599
|
978 if mount | grep -q $SOURCE_ROOT; then
|
domcox@654
|
979 echo -e "`gettext \"Unmounting $SOURCE_ROOT\"`"
|
domcox@599
|
980 umount $SOURCE_ROOT
|
domcox@599
|
981 fi
|
domcox@599
|
982
|
domcox@599
|
983 # Eject cd
|
domcox@599
|
984 if [ "$INST_TYPE" == "cdrom" ]; then
|
domcox@654
|
985 echo -e "`gettext \"Ejecting cdrom...\"`"
|
domcox@599
|
986 eject
|
domcox@599
|
987 fi
|
domcox@599
|
988 sleep 2
|
domcox@599
|
989 }
|
domcox@599
|
990
|
domcox@599
|
991 # End of installation.
|
domcox@599
|
992 end_of_install()
|
domcox@599
|
993 {
|
domcox@654
|
994 echo -e "`gettext \"Installation complete. You can now restart (reboot) \"`"
|
domcox@654
|
995 echo -e "`gettext \"from your SliTaz GNU/Linux system.\"`"
|
domcox@599
|
996 echo "=== Tazinst end at `date` ===" >>$LOG
|
domcox@612
|
997 # Log files
|
domcox@654
|
998 echo -e "`gettext \"Copying log files ($LOG)...\"`"
|
domcox@612
|
999 cp -a $LOG $TARGET_ROOT/var/log
|
domcox@612
|
1000 sleep 2
|
domcox@612
|
1001 # umount
|
domcox@599
|
1002 umount_devices
|
domcox@599
|
1003 }
|
domcox@599
|
1004
|
domcox@599
|
1005 #####################
|
domcox@599
|
1006 # Upgrade functions #
|
domcox@599
|
1007 #####################
|
domcox@599
|
1008
|
domcox@599
|
1009 # Mount.
|
domcox@599
|
1010 prepare_upgrade()
|
domcox@599
|
1011 {
|
domcox@599
|
1012 debug "Preparing the target partition..."
|
domcox@612
|
1013 # Target may be used
|
domcox@612
|
1014 mount | grep -q $TGT_PARTITION && \
|
domcox@654
|
1015 abort 5 `gettext "$TGT_PARTITION": Partition in use"`
|
domcox@599
|
1016 # Mount point can be already used.
|
domcox@599
|
1017 if mount | grep -q $TARGET_ROOT; then
|
domcox@599
|
1018 umount $TARGET_ROOT 2>>$LOG
|
domcox@599
|
1019 fi
|
domcox@599
|
1020 mkdir -p $TARGET_ROOT && sleep 2
|
domcox@599
|
1021 # Mount target.
|
domcox@599
|
1022 mount $TGT_PARTITION $TARGET_ROOT >>$LOG 2>>$LOG
|
domcox@599
|
1023 if [ $(mount | grep -c "mnt/target") == "0" ]; then
|
domcox@654
|
1024 abort 5 `gettext "Can't mount $TGT_PARTITION"`
|
domcox@599
|
1025 fi
|
domcox@599
|
1026 }
|
domcox@599
|
1027
|
domcox@599
|
1028 # Check for a valid SliTaz
|
domcox@599
|
1029 check_release()
|
domcox@599
|
1030 {
|
domcox@599
|
1031 if [ -f $TARGET_ROOT/etc/slitaz-release ]; then
|
domcox@599
|
1032 release=`cat $TARGET_ROOT/etc/slitaz-release`
|
domcox@654
|
1033 msg `gettext "Preparing upgrade of SliTaz release: $release"`
|
domcox@599
|
1034 else
|
domcox@654
|
1035 abort 6 `gettext "The partition '$TGT_PARTITION' doesn't appear to contain \
|
domcox@654
|
1036 a SliTaz system, the file: /etc/slitaz-release doesn't exist."`
|
domcox@599
|
1037 fi && sleep 2
|
domcox@599
|
1038 }
|
domcox@599
|
1039
|
domcox@599
|
1040 # Backup target packages list.
|
domcox@599
|
1041 backup_files()
|
domcox@599
|
1042 {
|
domcox@654
|
1043 cd $TARGET_ROOT || abort 8 `gettext "Internal"`
|
domcox@599
|
1044 ls -1 var/lib/tazpkg/installed > home/packages-selection.list
|
domcox@599
|
1045 for dir in *
|
domcox@599
|
1046 do
|
domcox@599
|
1047 case "$dir" in
|
domcox@599
|
1048 boot)
|
domcox@599
|
1049 rm -rf boot/vmlinuz-* ;;
|
domcox@599
|
1050 home)
|
domcox@599
|
1051 mv home home.bak
|
domcox@599
|
1052 debug "keeping /home found on: $TGT_PARTITION" ;;
|
domcox@599
|
1053 etc)
|
domcox@599
|
1054 tar czf etc.tar.gz etc
|
domcox@599
|
1055 mv etc etc.bak
|
domcox@599
|
1056 debug "keeping /etc found on: $TGT_PARTITION" ;;
|
domcox@599
|
1057 var)
|
domcox@599
|
1058 if [ -d var/www ]; then
|
domcox@599
|
1059 mv var/www www.bak
|
domcox@599
|
1060 debug "keeping /var/www found on: $TGT_PARTITION"
|
domcox@599
|
1061 fi
|
domcox@599
|
1062 rm -rf var 2>>$LOG ;;
|
domcox@599
|
1063 lost+found)
|
domcox@599
|
1064 continue ;;
|
domcox@599
|
1065 *)
|
domcox@599
|
1066 debug "removing target: $dir"
|
domcox@599
|
1067 rm -rf $dir 2>>$LOG ;;
|
domcox@599
|
1068 esac
|
domcox@599
|
1069 done
|
domcox@599
|
1070 if [ -d mklost+found ]; then
|
domcox@599
|
1071 mklost+found 2>>$LOG
|
domcox@599
|
1072 fi
|
domcox@599
|
1073 sleep 2
|
domcox@599
|
1074 }
|
domcox@599
|
1075
|
domcox@599
|
1076 # Restore backups.
|
domcox@599
|
1077 restore_files()
|
domcox@599
|
1078 {
|
domcox@599
|
1079 rm -rf $TARGET_ROOT/home
|
domcox@599
|
1080 mv $TARGET_ROOT/home.bak $TARGET_ROOT/home
|
domcox@599
|
1081 rm -rf $TARGET_ROOT/etc
|
domcox@599
|
1082 mv $TARGET_ROOT/etc.bak $TARGET_ROOT/etc
|
domcox@599
|
1083 if [ -d $TARGET_ROOT/www.bak ]; then
|
domcox@599
|
1084 rm -rf $TARGET_ROOT/var/www
|
domcox@599
|
1085 mv $TARGET_ROOT/www.bak $TARGET_ROOT/var/www
|
domcox@599
|
1086 fi
|
domcox@599
|
1087 debug "backups restored: `date`"
|
domcox@599
|
1088
|
domcox@599
|
1089 # /var/lib/slitaz-installer
|
domcox@599
|
1090 mkdir -p $TARGET_ROOT/var/lib/tazinst
|
domcox@599
|
1091 mv $TARGET_ROOT/etc.tar.gz $TARGET_ROOT/var/lib/tazinst
|
domcox@599
|
1092 mv $TARGET_ROOT/home/packages-selection.list $TARGET_ROOT/var/lib/tazinst
|
domcox@599
|
1093 }
|
domcox@599
|
1094
|
domcox@599
|
1095 # Added pkgs
|
domcox@599
|
1096 install_pkgs()
|
domcox@599
|
1097 {
|
domcox@599
|
1098 # Check if the pkg is on the mirror.
|
domcox@599
|
1099 debug "Checking the availability of packages..."
|
domcox@599
|
1100 touch packages-to-install.list
|
domcox@599
|
1101 packages=0
|
domcox@599
|
1102 diff=`cat packages-selection.diff | sort`
|
domcox@599
|
1103 for pkg in $diff
|
domcox@599
|
1104 do
|
domcox@599
|
1105 if grep -q ^$pkg-[0-9] /var/lib/tazpkg/packages.list; then
|
domcox@599
|
1106 packages=$(($packages+1))
|
domcox@599
|
1107 echo "$pkg" >> packages-to-install.list
|
domcox@599
|
1108 fi
|
domcox@599
|
1109 done
|
domcox@599
|
1110
|
domcox@599
|
1111 # Calculate the percent for one package and install.
|
domcox@599
|
1112 debug "Installing any packages..."
|
domcox@599
|
1113 sleep 2
|
domcox@599
|
1114 if [ "$packages" == "0" ]; then
|
domcox@599
|
1115 debug "packages to install: 0"
|
domcox@599
|
1116 else
|
domcox@599
|
1117 onepkg=$((48/$packages))
|
domcox@599
|
1118 pct=50
|
domcox@599
|
1119 # Get-install all missing pkgs.
|
domcox@599
|
1120 for pkg in `cat packages-to-install.list`
|
domcox@599
|
1121 do
|
domcox@599
|
1122 pct=$(($pct+$onepkg))
|
domcox@599
|
1123 echo $pct
|
domcox@599
|
1124 debug "Installing: $pkg..."
|
domcox@599
|
1125 # Get install package and answer yes in case of dependencies.
|
domcox@599
|
1126 pkgname=`grep ^$pkg /var/lib/tazpkg/packages.list`
|
domcox@599
|
1127 tazpkg get $pkg >/dev/null 2>/dev/null
|
domcox@599
|
1128 yes "" | tazpkg install $pkgname.tazpkg --root=$TARGET_ROOT >/dev/null 2>/dev/null
|
domcox@599
|
1129 rm -f $pkgname.tazpkg
|
domcox@599
|
1130 done
|
domcox@599
|
1131 fi
|
domcox@599
|
1132 echo 100
|
domcox@599
|
1133 debug "Installation of packages complete..."
|
domcox@599
|
1134 sleep 2
|
domcox@599
|
1135 }
|
domcox@599
|
1136
|
domcox@599
|
1137 # Search for added pkgs
|
domcox@599
|
1138 update_pkgs()
|
domcox@599
|
1139 {
|
domcox@654
|
1140 cd $TARGET_ROOT/var/lib/tazinst || abort 8 `gettext "Internal"`
|
domcox@599
|
1141 # LiveCD packages list.
|
domcox@599
|
1142 debug "Creating package lists..."
|
domcox@599
|
1143 ls -1 $TARGET_ROOT/var/lib/tazpkg/installed > packages-source.list || exit 1
|
domcox@599
|
1144 debug "packages-source.list: done"
|
domcox@599
|
1145 # Diff
|
domcox@599
|
1146 diff packages-source.list packages-selection.list | \
|
domcox@599
|
1147 grep ^+[a-z] | sed s/^+// > packages-selection.diff
|
domcox@599
|
1148 debug "packages-selection.diff: done"
|
domcox@599
|
1149 # Get mirror list.
|
domcox@599
|
1150 tazpkg recharge >>$LOG 2>>$LOG
|
domcox@599
|
1151 if [ -f /var/lib/tazpkg/packages.list ]; then
|
domcox@599
|
1152 install_pkgs
|
domcox@599
|
1153 else
|
domcox@599
|
1154 touch packages-to-install.list
|
domcox@654
|
1155 warning `gettext "The list of available packages on the mirror could not be \
|
domcox@599
|
1156 downloaded. No missing packages will be reinstalled now, but \
|
domcox@599
|
1157 you can do so later by looking at the following list: \
|
domcox@654
|
1158 /var/lib/tazinst/packages-selection.diff"`
|
domcox@599
|
1159 fi
|
domcox@599
|
1160 sleep 2
|
domcox@599
|
1161 }
|
domcox@599
|
1162
|
domcox@599
|
1163 # Update grub conf
|
domcox@599
|
1164 grub_update()
|
domcox@599
|
1165 {
|
domcox@599
|
1166 # Backup and create a new grub menu.lst.
|
domcox@599
|
1167 if [ "$TGT_GRUB" == "yes" ]; then
|
domcox@654
|
1168 msg `gettext "Grub update"`
|
domcox@599
|
1169 mv $TARGET_ROOT/boot/grub/menu.lst \
|
domcox@599
|
1170 $TARGET_ROOT/boot/grub/menu.lst.bak 2>/dev/null
|
domcox@599
|
1171 grub_config
|
domcox@599
|
1172 fi
|
domcox@599
|
1173 }
|
domcox@599
|
1174
|
domcox@599
|
1175 # Prepare the partition to upgrade, backup, install, restore configs
|
domcox@599
|
1176 # and reinstall pkgs.
|
domcox@599
|
1177 upgrade_files()
|
domcox@599
|
1178 {
|
domcox@599
|
1179 # saving pwd
|
domcox@599
|
1180 local save_pwd=$(pwd)
|
domcox@654
|
1181 cd $TARGET_ROOT || abort 8 `gettext "Internal"`
|
domcox@599
|
1182
|
domcox@599
|
1183 debug "Searching for /etc/slitaz-release"
|
domcox@599
|
1184 check_release
|
domcox@599
|
1185
|
domcox@654
|
1186 msg `gettext "Backup /etc, /home and the packages list..."`
|
domcox@599
|
1187 backup_files
|
domcox@599
|
1188
|
domcox@654
|
1189 msg `gettext "Upgrading SliTaz on $TGT_PARTITION"`
|
domcox@599
|
1190
|
domcox@599
|
1191 debug "Copying the bootloader syslinux/isolinux..."
|
domcox@599
|
1192 copy_bootloaders
|
domcox@599
|
1193
|
domcox@599
|
1194 debug "Extracting the root system..."
|
domcox@599
|
1195 extract_rootfs $SOURCE_ROOT/boot
|
domcox@599
|
1196
|
domcox@654
|
1197 msg `gettext "Restoring configuration files..."`
|
domcox@599
|
1198 restore_files
|
domcox@599
|
1199
|
domcox@599
|
1200 debug "Installing the kernel..."
|
domcox@599
|
1201 install_kernel
|
domcox@599
|
1202
|
domcox@654
|
1203 msg `gettext "Upgrading added packages..."`
|
domcox@599
|
1204 update_pkgs
|
domcox@599
|
1205
|
domcox@599
|
1206 # restoring pwd
|
domcox@599
|
1207 cd $save_pwd
|
domcox@599
|
1208 }
|
domcox@599
|
1209
|
domcox@599
|
1210 # End of system upgrade.
|
domcox@599
|
1211 end_of_upgrade()
|
domcox@599
|
1212 {
|
domcox@599
|
1213 pkgscd=`cat $TARGET_ROOT/var/lib/tazinst/packages-source.list | wc -l`
|
domcox@599
|
1214 pkginst=`cat $TARGET_ROOT/var/lib/tazinst/packages-to-install.list | wc -l`
|
domcox@654
|
1215 echo -e "`gettext \"Upgrade finished. You can now restart (reboot) from your SliTaz GNU/Linux system.\"`"
|
domcox@654
|
1216 echo -e "`gettext \"Packages on the cdrom :\"`" $pkgscd
|
domcox@654
|
1217 echo -e "`gettext \"Packages installed from the mirror :\"`" $pkginst
|
domcox@599
|
1218 echo "=== Tazinst end at `date` ===" >>$LOG
|
domcox@599
|
1219 umount_devices
|
domcox@599
|
1220 }
|
domcox@599
|
1221
|
domcox@599
|
1222 ######################
|
domcox@599
|
1223 # Installer sequence #
|
domcox@599
|
1224 ######################
|
domcox@599
|
1225
|
domcox@599
|
1226 case $1 in
|
domcox@599
|
1227 install)
|
domcox@599
|
1228 INST_ACTION=install
|
domcox@599
|
1229 check_root
|
domcox@599
|
1230 init $@
|
domcox@599
|
1231 read_configuration_file $2
|
domcox@599
|
1232 check_vars
|
domcox@599
|
1233 check_source
|
domcox@599
|
1234 prepare_install
|
domcox@599
|
1235 install_files
|
domcox@599
|
1236 grub_install
|
domcox@599
|
1237 end_of_install ;;
|
domcox@599
|
1238 upgrade)
|
domcox@599
|
1239 INST_ACTION=upgrade
|
domcox@599
|
1240 check_root
|
domcox@599
|
1241 init $@
|
domcox@599
|
1242 read_configuration_file $2
|
domcox@599
|
1243 check_vars
|
domcox@599
|
1244 check_source
|
domcox@599
|
1245 prepare_upgrade
|
domcox@599
|
1246 upgrade_files
|
domcox@599
|
1247 grub_update
|
domcox@599
|
1248 end_of_upgrade ;;
|
domcox@599
|
1249 config)
|
domcox@599
|
1250 gen_config $2 ;;
|
domcox@599
|
1251 cli)
|
domcox@599
|
1252 check_root
|
domcox@599
|
1253 init $@
|
domcox@599
|
1254 check_cli_options $@
|
domcox@599
|
1255 check_vars
|
domcox@599
|
1256 check_source
|
domcox@599
|
1257 summary
|
domcox@599
|
1258 case $INST_ACTION in
|
domcox@599
|
1259 upgrade)
|
domcox@599
|
1260 prepare_upgrade
|
domcox@599
|
1261 upgrade_files
|
domcox@599
|
1262 grub_update
|
domcox@599
|
1263 end_of_upgrade ;;
|
domcox@599
|
1264 install)
|
domcox@599
|
1265 prepare_install
|
domcox@599
|
1266 install_files
|
domcox@599
|
1267 grub_install
|
domcox@599
|
1268 end_of_install ;;
|
domcox@599
|
1269 esac ;;
|
domcox@656
|
1270 showurl)
|
domcox@656
|
1271 case $2 in
|
domcox@656
|
1272 stable)
|
domcox@656
|
1273 echo $URL_STABLE ;;
|
domcox@656
|
1274 cooking)
|
domcox@656
|
1275 echo $URL_COOKING ;;
|
domcox@656
|
1276 rolling)
|
domcox@656
|
1277 echo $URL_ROLLING ;;
|
domcox@656
|
1278 esac ;;
|
domcox@656
|
1279 check)
|
domcox@656
|
1280 LOG="/dev/null"
|
domcox@656
|
1281 INST_ACTION=check
|
domcox@656
|
1282 check_root
|
domcox@656
|
1283 init $@
|
domcox@656
|
1284 read_configuration_file $2
|
domcox@656
|
1285 check_vars ;;
|
domcox@599
|
1286 usage|*)
|
domcox@599
|
1287 usage ;;
|
domcox@599
|
1288 esac
|
domcox@599
|
1289
|
domcox@599
|
1290 exit 0
|