flavors rev 105
core: add tazinst doc in /usr/share/doc/slitaz
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Tue May 31 00:30:56 2011 +0200 (2011-05-31) |
parents | 4fb95495f106 |
children | cb63aca1b107 |
files | core/rootfs/usr/bin/tazinst core/rootfs/usr/share/doc/slitaz/tazinst.fr.html |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/core/rootfs/usr/bin/tazinst Tue May 31 00:30:56 2011 +0200 1.3 @@ -0,0 +1,1248 @@ 1.4 +#!/bin/sh 1.5 +# slitaz-installer - SliTaz GNU/Linux installer. 1.6 +# 1.7 +# So this is the SliTaz installer. The script starts with a 1.8 +# few main variables, then all the functions and then the 1.9 +# full sequence of functions. 1.10 +# 1.11 +# (C) 2007-2011 SliTaz - GNU General Public License v3. 1.12 +# 1.13 +# Authors : Christophe Lincoln <pankso@slitaz.org> 1.14 +# 1.15 + 1.16 +VERSION=2.99 1.17 + 1.18 +# 1.19 +SOURCE_ROOT=/media/source 1.20 +TARGET_ROOT=/mnt/target 1.21 +LOG=/var/log/tazinst.log 1.22 +BACKLIST="SliTaz GNU/Linux installer" 1.23 + 1.24 +# Default debug 1.25 +DEBUG=0 1.26 + 1.27 +# Mirror urls 1.28 +URL_STABLE="http://mirror.slitaz.org/iso/stable/slitaz-3.0.iso" 1.29 +URL_COOKING="http://mirror.slitaz.org/iso/cooking/slitaz-cooking.iso" 1.30 +URL_ROLLING="http://mirror.slitaz.org/iso/rolling/slitaz-core.iso" 1.31 + 1.32 +# Print a short help 1.33 +usage() 1.34 +{ 1.35 + echo -e "\n`gettext \"Tazinst - SliTaz installer - Version\"`: $VERSION\n" 1.36 + echo -e "\033[1m`gettext \"Usage\"`:" 1.37 + echo -e "\033[0m `gettext \"tazinst [command] [config-file|options]\n\"`" 1.38 + echo -e "\033[1m`gettext \"Commands\"`: \033[0m" 1.39 + echo -e "usage Print this short usage." 1.40 + echo -e "install Install SliTaz on HDD using a configuration file." 1.41 + echo -e "upgrade Upgrade SLiTaz on HDD using a configuration file." 1.42 + echo -e "config Generate a configuration file." 1.43 + echo -e "cli Install or upgrade using command line options:" 1.44 + echo -e " -i `gettext \"Full Install (not upgrading, all present data will be lost).\"`" 1.45 + echo -e " -u `gettext \"Upgrade (Needs an active internet connection).\"`" 1.46 + echo -e " -t <type> `gettext \"Install type (cdrom|usb|iso|web|weboot).\"`" 1.47 + echo -e " -m <source> `gettext \"Source media (ex: file.iso|usb partition|web url)\"`" 1.48 + echo -e " -p <partition> `gettext \"Partition where SliTaz will be installed (ex:/dev/hda3).\"`" 1.49 + echo -e " -f <fs> `gettext \"Partition will be formatted (fs=ext2|ext3|ext4|etc..).\"`" 1.50 + echo -e " -g `gettext \"Install Grub.\"`" 1.51 + echo -e " -w `gettext \"Dual-boot a Windows partition (auto|hd<disk>,<part> ex:hd0,0).\"`" 1.52 + echo -e " -d `gettext \"Debug mode.\"`" 1.53 + exit 0 1.54 +} 1.55 + 1.56 +# Print an error msg & exit 1.57 +# $1: exit code 1.58 +# $@: err msg 1.59 +abort() 1.60 +{ 1.61 + # unmouting source & target 1.62 + if mount | grep -q $SOURCE_ROOT; then 1.63 + umount $SOURCE_ROOT 2>>$LOG 1.64 + fi 1.65 + if mount | grep -q $TARGET_ROOT; then 1.66 + umount $TARGET_ROOT 2>>$LOG 1.67 + fi 1.68 + echo "Error $@" 1.69 + echo "Installation canceled" 1.70 + test $(id -u) = 0 && echo "Installation canceled on error $@" >> $LOG 1.71 + exit $1 1.72 +} 1.73 + 1.74 +# Print a warning msg 1.75 +warning() 1.76 +{ 1.77 + echo "Warning: $@" | tee -a $LOG 1.78 +} 1.79 + 1.80 +# Print a debug msg 1.81 +debug() 1.82 +{ 1.83 + [ $DEBUG -gt 0 ] && echo -e "\033[1mDEBUG: \033[0m$1" 1.84 + echo "DEBUG: $1" >>$LOG 1.85 +} 1.86 + 1.87 +# print a msg 1.88 +msg() 1.89 +{ 1.90 + STEP=$(($STEP+1)) 1.91 + echo "$STEP. $@" | tee -a $LOG 1.92 +} 1.93 + 1.94 +######################## 1.95 +# Gen-config functions # 1.96 +######################## 1.97 + 1.98 +# Generate a config file 1.99 +# $1: Configuration file 1.100 +gen_config() 1.101 +{ 1.102 + CONFILE=$1 1.103 + touch $CONFILE || error 1 "Unable to write $CONFILE" 1.104 + if [ -r "$CONFILE" ]; then 1.105 + cat > $CONFILE << _EOF_ 1.106 +# tazinst.conf: SliTaz Installer configuration file. 1.107 +# 1.108 + 1.109 +# Install type : [cdrom|usb|iso|web|weboot] 1.110 +INST_TYPE="cdrom" 1.111 + 1.112 +# Install source 1.113 +# usb:/dev/xxx, ex: SRC_FILE=/dev/sdb1 1.114 +# iso:file.iso, ex: SRC_FILE=~/slitaz.3.0.iso 1.115 +# web: url, ex: SRC_FILE=http://mirror.slitaz.org/iso/cooking/slitaz-cooking.iso 1.116 +# web: predefinites (stable|cooking|rolling), ex: SRC_FILE=cooking 1.117 +SRC_FILE="" 1.118 + 1.119 +# Install Target (Root Partition). 1.120 +TGT_PARTITION="/dev/hda5" 1.121 + 1.122 +# Target File system. 1.123 +# SliTaz uses ext3 by default but another filesystem can be used if wanted, 1.124 +# for this please adjust your /etc/fstab after installation. Valid options are: 1.125 +# (btrfs|ext2|ext3|ext4|fat16|fat32|hfs|hfs+|jfs|ntfs|reiser4|reiserfs|ufs|xfs) 1.126 +TGT_FS="ext3" 1.127 + 1.128 +# Home partition. 1.129 +# On most GNU/Linux systems users personal files are stored in the directory 1.130 +# /home. Home can be on a separate partition or another hard disk. 1.131 +TGT_HOME="" 1.132 +# Home File system (if /home is on a separate partition) 1.133 +TGT_HOME_FS="" 1.134 + 1.135 +# Hostname 1.136 +TGT_HOSTNAME="slitaz" 1.137 + 1.138 +# roor password 1.139 +# The root administrator privilege lets you manage and configure the full 1.140 +# system. A root user can damage your system so you should always setup a 1.141 +# strong password with special characters and/or numbers. 1.142 +TGT_ROOT_PWD="root" 1.143 + 1.144 +# The default user for the system will have his personal files stored 1.145 +# in /home/*user* (and will be automatically added to the audio group). 1.146 +TGT_USER="tux" 1.147 +TGT_USER_PWD="" 1.148 + 1.149 +# Grub bootloader 1.150 +# install grub [yes|no] 1.151 +TGT_GRUB="no" 1.152 +# Where to find menu.lst (dedicated grub part. or multi-os install) 1.153 +# If you don't know what to do, it's safe to leave it blank 1.154 +TGT_MENU_PARTITION="" 1.155 + 1.156 +# Windows dual-boot 1.157 +# Dual boot is disabled if WINBOOT is empty: TGT_WINBOOT="" 1.158 +# You may let tazinst find your win partition, mode=auto: TGT_WINBOOT="auto" 1.159 +# or set manual setting: "hd[disk],[partition]" ex:TGT_WINBOOT=hd0,0 1.160 +TGT_WINBOOT="" 1.161 + 1.162 +_EOF_ 1.163 + 1.164 + else 1.165 + abort 2 "Configuration file $CONFILE not found" 1.166 + fi 1.167 + 1.168 +} 1.169 + 1.170 +###################### 1.171 +# Checking functions # 1.172 +###################### 1.173 + 1.174 + 1.175 +# def values and start log 1.176 +# $@ : 1.177 +init() 1.178 +{ 1.179 + echo "=== Tazinst start at `date` ===" >$LOG 1.180 + echo "Command: $0 $@" >>$LOG 1.181 + 1.182 + # Default Type 1.183 + INST_TYPE=cdrom 1.184 + # Default Hostname. 1.185 + TGT_HOSTNAME=slitaz 1.186 + # Default root passwd 1.187 + TGT_ROOT_PWD=root 1.188 + # Default user 1.189 + TGT_USER=tux 1.190 + # Default Grub Install 1.191 + TGT_GRUB=no 1.192 +} 1.193 + 1.194 +# Read Conf 1.195 +# $1: conf file 1.196 +read_configuration_file() 1.197 +{ 1.198 + CONFILE=$1 1.199 + if [ -n "$CONFILE" ]; then 1.200 + if [ -r "$CONFILE" ]; then 1.201 + debug "Using config-file=$CONFILE" 1.202 + # source doesn't like file without a path 1.203 + [ $(echo "$CONFILE" | grep -c "/") == "0" ] && CONFILE="./$CONFILE" 1.204 + source $CONFILE || abort 2 "Unable to read $CONFILE" 1.205 + else 1.206 + abort 2 "Configuration file not found" 1.207 + fi 1.208 + else 1.209 + abort 2 "No configuration file provided" 1.210 + fi 1.211 +} 1.212 + 1.213 +# Cli options 1.214 +# $@: tazinst parms 1.215 +check_cli_options() 1.216 +{ 1.217 + shift 1.218 + while getopts "c:df:ghip:s:t:uw:" opt ; do 1.219 + case $opt in 1.220 + d) DEBUG=1 ;; 1.221 + f) TGT_FS=$OPTARG ;; 1.222 + g) TGT_GRUB="yes" ;; 1.223 + h) usage ;; 1.224 + i) INSTALL="install" ;; 1.225 + p) TGT_PARTITION=$OPTARG ;; 1.226 + s) SRC_FILE=$OPTARG ;; 1.227 + t) INST_TYPE=$OPTARG ;; 1.228 + u) UPGRADE="upgrade" ;; 1.229 + w) TGT_WINBOOT=$OPTARG ;; 1.230 + [?]) abort 1 ;; 1.231 + esac 1.232 + done 1.233 + 1.234 + # Duplicate install modes are forbidden 1.235 + [ -n "$INSTALL" ] && [ -n "$UPGRADE" ] && abort 1 "Mismatched parameters" 1.236 + INST_ACTION="$INSTALL$UPGRADE" 1.237 + # Don't allow formatting on upgrades 1.238 + [ "$INST_ACTION" == "upgrade" ] && [ -n "$TGT_FS" ] && \ 1.239 + warning "Partition $TGT_PARTITION will not be formatted during upgrade" 1.240 +} 1.241 + 1.242 +# check main vars 1.243 +check_vars() 1.244 +{ 1.245 + # error handling 1.246 + local error=no 1.247 + local found=no 1.248 + local partition="" 1.249 + 1.250 + debug "--- Tazinst main options ---" 1.251 + debug "action=$INST_ACTION" 1.252 + debug "type=$INST_TYPE" 1.253 + debug "source=$SRC_FILE" 1.254 + debug "/ partition=$TGT_PARTITION" 1.255 + debug "/ filesystem=$TGT_FS" 1.256 + debug "/home partition=$TGT_HOME" 1.257 + debug "/home filesystem=$TGT_HOME_FS" 1.258 + debug "hostname=$TGT_HOSTNAME" 1.259 + debug "root-pwd=$TGT_ROOT_PWD" 1.260 + debug "user=$TGT_USER" 1.261 + debug "user-pwd=$TGT_USER_PWD" 1.262 + debug "grub=$TGT_GRUB" 1.263 + debug "winboot=$TGT_WINBOOT" 1.264 + debug "--------------------------------------" 1.265 + 1.266 + # Check Action 1.267 + case $INST_ACTION in 1.268 + install|upgrade) ;; 1.269 + *) msg "INST_ACTION=$INST_ACTION: Invalid setting"; error=yes ;; 1.270 + esac 1.271 + 1.272 + # Check Type 1.273 + case $INST_TYPE in 1.274 + cdrom|weboot) ;; 1.275 + usb|iso|web) 1.276 + # We need a valid source 1.277 + if [ -z "$SRC_FILE" ]; then 1.278 + echo "Type is $INST_TYPE, but INST_SOURCE is not set"; error=yes 1.279 + fi ;; 1.280 + *) msg "INST_TYPE=$INST_TYPE: Invalid setting"; error=yes ;; 1.281 + esac 1.282 + 1.283 + # Check Source file 1.284 + # 1. assign predefs 1.285 + if [ "$INST_TYPE" == "web" ]; then 1.286 + [ "$SRC_FILE" == "stable" ] && SRC_FILE=$URL_STABLE 1.287 + [ "$SRC_FILE" == "cooking" ] && SRC_FILE=$URL_COOKING 1.288 + [ "$SRC_FILE" == "rolling" ] && SRC_FILE=$URL_ROLLING 1.289 + fi 1.290 + # 2. check avail. 1.291 + case $INST_TYPE in 1.292 + iso) 1.293 + if [ ! -r "$SRC_FILE" ]; then 1.294 + msg "SRC_FILE=$SRC_FILE: file not found" ; error=yes 1.295 + fi ;; 1.296 + web) 1.297 + if [ $(wget -sq "$SRC_FILE") ]; then 1.298 + msg "SRC_FILE=$SRC_FILE: file not found" ; error=yes 1.299 + fi ;; 1.300 + esac 1.301 + 1.302 + # Check Target Partition 1.303 + found=no 1.304 + LIST_PARTITION=$(fdisk -l | awk '/^\/dev/{printf "%s ",$1}') 1.305 + for partition in $LIST_PARTITION; do 1.306 + [ "$partition" == "$TGT_PARTITION" ] && found="yes" 1.307 + done 1.308 + if [ "$found" != "yes" ]; then 1.309 + msg "TGT_PARTITION=$TGT_PARTITION Partition not found"; error=yes 1.310 + fi 1.311 + 1.312 + # Check Filesystem 1.313 + case $TGT_FS in 1.314 + "") ;; 1.315 + btrfs|ext2|ext3|ext4|fat16|fat32|hfs|hfs+|jfs|ntfs|reiser4|reiserfs|ufs|xfs) 1.316 + found=no 1.317 + for xdir in /sbin /usr/sbin /usr/bin; do 1.318 + [ -x "$xdir/mkfs.$TGT_FS" ] && found=yes 1.319 + done 1.320 + if [ "$found" == "no" ]; then 1.321 + msg "$TGT_FS: mkfs.$TGT_FS is not installed."; error=yes 1.322 + fi ;; 1.323 + *) msg "TGT_FS=$TGT_FS: Invalid setting"; error=yes ;; 1.324 + esac 1.325 + 1.326 + # Check Home partition 1.327 + if [ -n "$TGT_HOME" ]; then 1.328 + found=no 1.329 + for partition in $LIST_PARTITION; do 1.330 + [ "$partition" == "$TGT_HOME" ] && found=yes 1.331 + done 1.332 + if [ "$found" != "yes" ]; then 1.333 + msg "TGT_HOME=$TGT_HOME: Not found"; error=yes 1.334 + fi 1.335 + fi 1.336 + 1.337 + # Check Home Filesystem 1.338 + case $TGT_HOME_FS in 1.339 + "") ;; 1.340 + btrfs|ext2|ext3|ext4|fat16|fat32|hfs|hfs+|jfs|ntfs|reiser4|reiserfs|ufs|xfs) 1.341 + found=no 1.342 + for xdir in /sbin /usr/sbin /usr/bin; do 1.343 + [ -x "$xdir/mkfs.$TGT_FS" ] && found=yes 1.344 + done 1.345 + if [ "$found" == "no" ]; then 1.346 + msg "$TGT_FS: mkfs.$TGT_FS is not installed."; error=yes 1.347 + fi ;; 1.348 + *) msg "TGT_HOME_FS=$TGT_HOME_FS: Invalid setting"; error=yes ;; 1.349 + esac 1.350 + 1.351 + # Check Grub 1.352 + case $TGT_GRUB in 1.353 + yes|no) ;; 1.354 + *) msg "TGT_GRUB=$TGT_GRUB: Invalid setting"; error=yes ;; 1.355 + esac 1.356 + 1.357 + # Check Winboot 1.358 + case $TGT_WINBOOT in 1.359 + "") ;; 1.360 + auto) ;; 1.361 + hd[[:digit:]],[[:digit:]]) ;; 1.362 + *) msg "TGT_WINBOOT=$TGT_WINBOOT: Invalid format"; error=yes ;; 1.363 + esac 1.364 + 1.365 + # Stop on error 1.366 + [ "$error" == "yes" ] && abort 1 1.367 +} 1.368 + 1.369 +# Exit install if user is not root. 1.370 +check_root() 1.371 +{ 1.372 + if test $(id -u) != 0 ; then 1.373 + echo "You must be the root user (system administrator) to install SliTaz, \ 1.374 +please use 'su' to get a root SHell and restart installation." 1.375 + exit 0 1.376 + fi 1.377 +} 1.378 + 1.379 +# Mount cdrom 1.380 +check_cdrom() 1.381 +{ 1.382 + # Set device name 1.383 + DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3` [ -n "$DRIVE_NAME" ] || DRIVE_NAME=cdrom 1.384 + CDROM=/dev/$DRIVE_NAME 1.385 + # Try to mount a cdrom 1.386 + if mount -t iso9660 $CDROM $SOURCE_ROOT 2>>$LOG; then 1.387 + debug "Using files from cdrom ($CDROM)..." 1.388 + sleep 2 1.389 + else 1.390 + warning "Failed to mount $CDROM" 1.391 + fi 1.392 +} 1.393 + 1.394 +# Link LiveUSB 1.395 +check_usb() 1.396 +{ 1.397 + # /home is on USB dev 1.398 + if [ -d /home/boot ]; then 1.399 + debug "Using files from USB device..." 1.400 + ln -s /home/boot $SOURCE_ROOT/boot 1.401 + SOURCE_STATUS="link" 1.402 + sleep 2 1.403 + else 1.404 + # Try to mount LiveUSB 1.405 + if mount $SRC_FILE $SOURCE_ROOT 2>>$LOG; then 1.406 + debug "Using files from USB device ($SRC_FILE)..." 1.407 + SOURCE_STATUS="mount" 1.408 + else 1.409 + warning "Failed to mount USB device $SRC_FILE" 1.410 + fi 1.411 + fi 1.412 +} 1.413 + 1.414 +# Mount ISO file 1.415 +check_iso() 1.416 +{ 1.417 + local src_md5 1.418 + # Integrity check 1.419 + src_md5=$(echo $SRC_FILE | sed 's/.iso$/.md5/') 1.420 + if [ -r "$src_md5" ]; then 1.421 + [ $(md5sum $SRC_FILE | cut -d' ' -f1) == $(cat "$src_md5" | cut -d' ' -f1) ] || \ 1.422 + abort 3 "$SRC-FILE corrupted" 1.423 + else 1.424 + warning "$src_md5 not found, unable to check integrity of $SRC_FILE" 1.425 + fi 1.426 + # Try to mount ISO 1.427 + if mount -o loop -t iso9660 $SRC_FILE $SOURCE_ROOT 2>>$LOG; then 1.428 + debug "Using files from ISO ($SRC_FILE)..." 1.429 + sleep 2 1.430 + else 1.431 + warning "Failed to mount ISO '$SRC_FILE'" 1.432 + fi 1.433 +} 1.434 + 1.435 +# Source is on the web 1.436 +check_web() 1.437 +{ 1.438 + local src_md5 1.439 + debug "Downloading $SRC_FILE" 1.440 + if wget $SRC_FILE -P /tmp; then 1.441 + debug "Download completed." 1.442 + else 1.443 + warning "Failed to download '$SRC_FILE'" 1.444 + fi 1.445 + src_md5=$(echo $SRC_FILE | sed 's/.iso$/.md5/') 1.446 + debug "Downloading $src_md5" 1.447 + wget $src_md5 -P /tmp || warning "Failed to download '$src_md5'" 1.448 + tmpfile=$(echo $SRC_FILE | awk 'BEGIN{RS="/"}{out=$1}END{printf"%s",out}') 1.449 + SRC_FILE="/tmp/$tmpfile" 1.450 + check_iso 1.451 +} 1.452 + 1.453 +# We may be in Tiny Web boot mode 1.454 +check_weboot() 1.455 +{ 1.456 + if [ -d $SRC_FILE/boot ]; then 1.457 + debug "Using files from HTTP device..." 1.458 + ln -s $SRC_FILE/boot $SOURCE_ROOT/boot 1.459 + sleep 2 1.460 + else 1.461 + abort 3 "Error: Web boot files not found" 1.462 + fi 1.463 +} 1.464 + 1.465 +# set up source and check Slitaz' content 1.466 +check_source() 1.467 +{ 1.468 + debug "Creating mount point ($SOURCE_ROOT)..." 1.469 + mkdir -p $SOURCE_ROOT 1.470 + sleep 1 1.471 + case $INST_TYPE in 1.472 + cdrom) 1.473 + check_cdrom ;; 1.474 + usb) 1.475 + check_usb ;; 1.476 + iso) 1.477 + check_iso ;; 1.478 + web) 1.479 + check_web ;; 1.480 + weboot) 1.481 + check_cdrom 1.482 + check_web ;; 1.483 + *) 1.484 + abort 8 "Internal" ;; 1.485 + esac 1.486 + 1.487 + # Exit with error msg if no rootfs.gz found. 1.488 + debug "Checking installation media..." 1.489 + if [ ! -f $SOURCE_ROOT/boot/rootfs.gz -a \ 1.490 + ! -f $SOURCE_ROOT/boot/rootfs1.gz ]; then 1.491 + abort 3 "Invalid source" 1.492 + else 1.493 + debug "Installation media checked ok" 1.494 + fi 1.495 +} 1.496 + 1.497 +# Tiny summary 1.498 +summary() 1.499 +{ 1.500 + echo "Installation settings summary:" 1.501 + STEP=0 1.502 + 1.503 + if [ "$INST_ACTION" == "install" ]; then 1.504 + if [ -n "$TGT_FS" ]; then 1.505 + msg "Format root partition '$TGT_PARTITION' ($TGT_FS)" 1.506 + fi 1.507 + if [ -n "$TGT_HOME_FS" ]; then 1.508 + msg "Format /home partition '$TGT_HOME' ($TGT_HOME_FS)" 1.509 + fi 1.510 + msg "Install SliTaz on '$TGT_PARTITION' from $INST_TYPE" 1.511 + [ -n "$TGT_HOME" ] && msg "Set Home partition to '$TGT_HOME'" 1.512 + msg "Set Hostname as '$TGT_HOSTNAME'" 1.513 + msg "Set Default user as '$TGT_USER'" 1.514 + else 1.515 + msg "Check '$TGT_PARTITION'" 1.516 + msg "Backup /etc, /home and the packages list" 1.517 + msg "Upgrade SliTaz on '$TGT_PARTITION' from $INST_TYPE" 1.518 + msg "Restore /etc, /home" 1.519 + msg "Upgrade additional packages." 1.520 + fi 1.521 + if [ -n "$TGT_WINBOOT" ]; then 1.522 + msg "Enable Windows dual-boot ($TGT_WINBOOT)" 1.523 + fi 1.524 + if [ "$TGT_GRUB" == "yes" ]; then 1.525 + msg "Install Grub" 1.526 + fi 1.527 + 1.528 + echo -n "Continue:(y/n)" 1.529 + read answer 1.530 + case $answer in 1.531 + [yY]) echo "Running $BACKLIST.." ;; 1.532 + *) abort 4 "Cancelled by user" ;; 1.533 + esac 1.534 + STEP=0 1.535 +} 1.536 + 1.537 +####################### 1.538 +# Installer functions # 1.539 +####################### 1.540 + 1.541 +# Mount and mkfs with progress. 1.542 +prepare_install() 1.543 +{ 1.544 + debug "Preparing target partition..." 1.545 + # Mount point can be already used. 1.546 + if mount | grep -q $TARGET_ROOT; then 1.547 + umount $TARGET_ROOT 2>>$LOG 1.548 + fi 1.549 + sleep 2 1.550 + 1.551 + # Formatting root partition 1.552 + case $TGT_FS in 1.553 + "") 1.554 + debug "The partition ($TGT_PARTITION) will be cleaned..." 1.555 +# ROOT_FS=$(parted /dev/hda5 print -m | grep "^1:" | cut -d':' -f5) ;; 1.556 + ROOT_FS=auto ;; 1.557 + *) 1.558 + msg "Formatting $TGT_PARTITION ($TGT_FS)" 1.559 + mkfs.$TGT_FS $TGT_PARTITION >>$LOG 2>>$LOG 1.560 + ROOT_FS=$TGT_FS ;; 1.561 + esac 1.562 + sleep 2 1.563 + 1.564 + # Formatting /home 1.565 + if [ -n "$TGT_HOME" ]; then 1.566 + case $TGT_HOME_FS in 1.567 + "") 1.568 + debug "The partition ($TGT_HOME) will be kept..." ;; 1.569 + *) 1.570 + msg "Formatting /home on $TGT_HOME ($TGT_HOME_FS)" 1.571 + mkfs.$TGT_HOME_FS -L "Home" $TGT_HOME >>$LOG 2>>$LOG ;; 1.572 + esac 1.573 + sleep 2 1.574 + fi 1.575 + 1.576 + # Mount target. 1.577 + debug "Creating mount point: $TARGET_ROOT" 1.578 + mkdir -p $TARGET_ROOT >>$LOG 1.579 + sleep 2 1.580 + 1.581 + mount -t $ROOT_FS $TGT_PARTITION $TARGET_ROOT >>$LOG 2>>$LOG 1.582 + if [ $(mount | grep -c "mnt/target") == "0" ]; then 1.583 + abort 5 "Can't mount $TGT_PARTITION" 1.584 + fi 1.585 +} 1.586 + 1.587 +# Get a clean target device (15%). 1.588 +clean_target() 1.589 +{ 1.590 + if [ -z "$TGT_FS" ]; then 1.591 + # partition was not formatted 1.592 + debug "Cleaning the root partition ($TGT_PARTITION)..." 1.593 + # Keep /home in case of reinstall. 1.594 + cd $TARGET_ROOT || abort 8 "Internal" 1.595 + for dir in * 1.596 + do 1.597 + case "$dir" in 1.598 + home) 1.599 + debug "keeping /home found on: $TGT_PARTITION" 1.600 + mv home home.bak ;; 1.601 + lost+found) 1.602 + continue ;; 1.603 + *) 1.604 + debug "removing target: $dir" 1.605 + rm -rf $dir 2>>$LOG ;; 1.606 + esac 1.607 + done 1.608 + if [ -d mklost+found ]; then 1.609 + mklost+found 2>>$LOG 1.610 + fi 1.611 + fi 1.612 + sleep 2 1.613 +} 1.614 + 1.615 +# Kernel is renamed to standard vmlinuz-$VERSION. 1.616 +install_kernel() 1.617 +{ 1.618 + if [ -d /$TARGET_ROOT/lib/modules ]; then 1.619 + KERNEL=$(ls /$TARGET_ROOT/lib/modules | tail -1) 1.620 + KERNEL="vmlinuz-$KERNEL" 1.621 + else 1.622 + warning "Falling back to running kernel name.." 1.623 + KERNEL=vmlinuz-`uname -r` 1.624 + fi 1.625 + mkdir -p $TARGET_ROOT/boot 1.626 + cp $SOURCE_ROOT/boot/bzImage $TARGET_ROOT/boot/$KERNEL 1.627 + debug "install_kernel: $KERNEL" 1.628 + sleep 2 1.629 +} 1.630 + 1.631 +# Copy isolinux r/w files (not syslinux, some files are read only). 1.632 +copy_bootloaders() 1.633 +{ 1.634 + if [ -d "$SOURCE/ROOT/boot/isolinux" ]; then 1.635 + debug "Copy isolinux r/w files" 1.636 + mkdir -p $TARGET_ROOT/boot/isolinux 1.637 + cp -a $SOURCE_ROOT/boot/isolinux/*.cfg $TARGET_ROOT/boot/isolinux 1.638 + cp -a $SOURCE_ROOT/boot/isolinux/*.kbd $TARGET_ROOT/boot/isolinux 1.639 + cp -a $SOURCE_ROOT/boot/isolinux/*.txt $TARGET_ROOT/boot/isolinux 1.640 + cp -a $SOURCE_ROOT/boot/isolinux/*.bin $TARGET_ROOT/boot/isolinux 1.641 + cp -a $SOURCE_ROOT/boot/isolinux/*.msg $TARGET_ROOT/boot/isolinux 1.642 + cp -a $SOURCE_ROOT/boot/isolinux/*.lss $TARGET_ROOT/boot/isolinux 1.643 + cp -a $SOURCE_ROOT/boot/isolinux/*.c32 $TARGET_ROOT/boot/isolinux 1.644 + fi 1.645 +} 1.646 + 1.647 +need_package() 1.648 +{ 1.649 + [ -d /var/lib/tazpkg/installed/$1 ] || tazpkg get-install $1 1.650 +} 1.651 + 1.652 +# extract packed rootfs: squashfs or cromfs 1.653 +extract_loramfs() 1.654 +{ 1.655 + local i 1.656 + for i in $(cpio -idvum 2> /dev/null); do 1.657 + case "$i" in 1.658 + rootfs*) 1.659 + need_package squashfs 1.660 + if ! unsquashfs $i ; then 1.661 + need_package cromfs 1.662 + unmkcromfs $i squashfs-root 1.663 + fi 1.664 + mv -f squashfs-root/* . 1.665 + rmdir squashfs-root 1.666 + rm -f $i 1.667 + esac 1.668 + done 1.669 +} 1.670 + 1.671 +# This is a loram rootfs.gz, skip loram bootstrap and extract 1.672 +extract_first_loramfs() 1.673 +{ 1.674 + (zcat $1 || unlzma -c $1) | cpio -i extractfs.cpio 2> /dev/null && 1.675 + ( cd / ; cpio -id ) < extractfs.cpio && rm -f extractfs.cpio 1.676 + ofs=$(awk '/07070100/ { o+=index($0,"07070100"); printf "%d\n",o/4 ; exit } { o+=1+length() }' < $1) 1.677 + dd if=$1 skip=$(($ofs / 1024)) bs=4k count=1 2> /dev/null | \ 1.678 + ( dd skip=$(($ofs % 1024)) bs=4 2> /dev/null ; \ 1.679 + dd if=$1 skip=$((1 + ($ofs / 1024) )) bs=4k ) | extract_loramfs 1.680 +} 1.681 + 1.682 +# Extract lzma'ed or gziped rootfs. 1.683 +extract_rootfs() 1.684 +{ 1.685 + local isloramfs 1.686 + isloramfs= 1.687 + cd $TARGET_ROOT || abort 8 "Internal" 1.688 + if [ -d $1/../fs/etc ]; then 1.689 + # This is a tazlitobox loram (cdrom) 1.690 + cp -a $1/../fs/. . 1.691 + else 1.692 + for i in $(ls $1/rootfs* | sort -r); do 1.693 + if [ ! -d etc ]; then 1.694 + if [ $( (zcat $i 2>/dev/null || lzma d $i -so) | wc -c) \ 1.695 + -lt $(stat -c %s $i) ]; then 1.696 + # This is a tazlitobox loram (ram) 1.697 + isloramfs=$i 1.698 + extract_first_loramfs $i 1.699 + continue 1.700 + fi 1.701 + fi 1.702 + if [ -n "$isloramfs" ]; then 1.703 + extract_loramfs < $i 1.704 + continue 1.705 + fi 1.706 + ( zcat $i 2>/dev/null || lzma d $i -so || \ 1.707 + cat $i ) 2>>$LOG | cpio -idu 1.708 + done 2>>$LOG > /dev/null 1.709 + fi 1.710 + cp /etc/keymap.conf etc 1.711 + # unpack /usr (double check...) 1.712 + if ls etc/tazlito | grep -q ".extract"; then 1.713 + for i in etc/tazlito/*.extract; do 1.714 + [ -f "$i" ] && . $i /media/cdrom 1.715 + done 1.716 + fi 1.717 +} 1.718 + 1.719 +# Pre configure freshly installed system (60 - 80%). 1.720 +pre_config_system() 1.721 +{ 1.722 + cd $TARGET_ROOT || abort 8 "Internal" 1.723 + # Restore backup of existing /home if exists. 1.724 + # (created by prepare_target_dev) 1.725 + if [ -d home.bak ]; then 1.726 + debug "Restoring directory: /home..." 1.727 + rm -rf home 1.728 + mv home.bak home 1.729 + sleep 1 1.730 + fi 1.731 + # Add root device to CHECK_FS in rcS.conf to check filesystem 1.732 + # on each boot. 1.733 + debug "Adding $TGT_PARTITION and CHECK_FS to file /etc/rcS.conf..." 1.734 + sed -i s#'CHECK_FS=\"\"'#"CHECK_FS=\"$TGT_PARTITION\""# etc/rcS.conf 1.735 + sleep 2 1.736 + # Set hostname. 1.737 + msg "Configuring host name: $TGT_HOSTNAME" 1.738 + echo $TGT_HOSTNAME > etc/hostname 1.739 +} 1.740 + 1.741 +# Set root passwd and create user after rootfs extraction. 1.742 +users_settings() 1.743 +{ 1.744 + cat > $TARGET_ROOT/users.sh << _EOF_ 1.745 +#!/bin/sh 1.746 +echo "root:$TGT_ROOT_PWD" | chpasswd 1.747 +adduser -D -H $TGT_USER 1.748 + 1.749 +for grp in audio cdrom floppy dialout disk kmem tape tty video; do 1.750 + if ! grep \$grp /etc/group | grep -q $TGT_USER ; then 1.751 + grep -q \$grp /etc/group && addgroup $TGT_USER \$grp 1.752 + fi 1.753 +done 1.754 + 1.755 +echo "$TGT_USER:$TGT_USER_PWD" | chpasswd 1.756 +if [ ! -d /home/$TGT_USER ]; then 1.757 + cp -a /etc/skel /home/$TGT_USER 1.758 + cp /root/.xinitrc /home/$TGT_USER 1.759 + mkdir -p /home/$TGT_USER/.config/slitaz 1.760 + cp -a /etc/slitaz/applications.conf /home/$TGT_USER/.config/slitaz 1.761 + chown -R $TGT_USER.users /home/$TGT_USER 1.762 + # Path for user desktop files. 1.763 + for i in /home/$TGT_USER/.local/share/applications/*.desktop 1.764 + do 1.765 + [ -e "$i" ] && sed -i s/"user_name"/"$TGT_USER"/g \$i 1.766 + done 1.767 +fi 1.768 +# Slim default user. 1.769 +if [ -f /etc/slim.conf ]; then 1.770 + sed -i s/"default_user .*"/"default_user $TGT_USER"/ \ 1.771 + /etc/slim.conf 1.772 +fi 1.773 +_EOF_ 1.774 + chmod +x $TARGET_ROOT/users.sh 1.775 + chroot $TARGET_ROOT ./users.sh 1.776 + rm $TARGET_ROOT/users.sh 1.777 + sleep 2 1.778 +} 1.779 + 1.780 +# /home can be on a separate partition. If default user exist in /home 1.781 +# we remove default file crated by users_settings(). 1.782 +home_config() 1.783 +{ 1.784 + debug "home_config: $TGT_HOME" 1.785 + cd $TARGET_ROOT || abort 8 "Internal" 1.786 + mv home/$TGT_USER tmp 1.787 + mount $TGT_HOME home 1.788 + if [ -d $TARGET_ROOT/home/$TGTUSER ]; then 1.789 + rm -rf tmp/$TGT_USER 1.790 + else 1.791 + mv tmp/$TGT_USER home 1.792 + fi 1.793 + echo "$TGT_HOME /home ext3 defaults 0 2" \ 1.794 + >> etc/fstab 1.795 + umount home 1.796 +} 1.797 + 1.798 +# Search for a Windows partition 1.799 +win_partition() 1.800 +{ 1.801 + msg "Enabling Windows dual-boot" 1.802 + if [ "$TGT_WINBOOT" == "auto" ];then 1.803 + WINBOOT=$(fdisk -l | awk ' 1.804 +BEGIN{disk=-1, found=-1, winboot=""} 1.805 +{ 1.806 + # Counting disk 1.807 + if ($1=="Disk"){disk++, part=-1} 1.808 + # Counting partition 1.809 + if (substr($1,1,4)=="/dev"){part++} 1.810 + # Read partition Id 1.811 + if ($2=="*"){Id=$6} else {Id=$5} 1.812 + # Detect Windows type 1.813 + if (Id=="7" || Id=="b"){ 1.814 + if (found){ 1.815 + # record 1st Windows partition found 1.816 + winboot=sprintf("hd%d,%d",disk,part),found++} 1.817 + } 1.818 +} 1.819 +END{printf "%s", winboot}') 1.820 + if [ -z "$WINBOOT" ]; then 1.821 + warning "No windows partition found. Dual-boot disabled" 1.822 + TGT_WINBOOT="" 1.823 + fi 1.824 + fi 1.825 +} 1.826 + 1.827 +# Determine GRUB partition number and GRUB disk number. 1.828 +grub_partition() 1.829 +{ 1.830 + DISK_LETTER=${TGT_PARTITION#/dev/[h-s]d} 1.831 + DISK_LETTER=${DISK_LETTER%[0-9]} 1.832 + GRUB_PARTITION=$((${TGT_PARTITION#/dev/[h-s]d[a-z]}-1)) 1.833 + for disk in a b c d e f g h 1.834 + do 1.835 + nb=$(($nb+1)) 1.836 + if [ "$disk" = "$DISK_LETTER" ]; then 1.837 + GRUB_DISK=$(($nb-1)) 1.838 + break 1.839 + fi 1.840 + done 1.841 + GRUB_ROOT="(hd${GRUB_DISK},${GRUB_PARTITION})" 1.842 +} 1.843 + 1.844 +# Create grub conf 1.845 +grub_config() 1.846 +{ 1.847 + grub_partition 1.848 + win_partition 1.849 + # Create the target GRUB configuration. 1.850 + mkdir -p $TARGET_ROOT/boot/grub 1.851 + . /etc/locale.conf 1.852 + cat > $TARGET_ROOT/boot/grub/menu.lst << _EOF_ 1.853 +# /boot/grub/menu.lst: GRUB boot loader configuration. 1.854 +# 1.855 + 1.856 +# By default, boot the first entry. 1.857 +default 0 1.858 + 1.859 +# Boot automatically after 8 secs. 1.860 +timeout 8 1.861 + 1.862 +# Graphical splash image. 1.863 +splashimage=/boot/grub/splash.xpm.gz 1.864 + 1.865 +# Change the colors. 1.866 +#color yellow/brown light-green/black 1.867 + 1.868 +# For booting SliTaz from : $TGT_PARTITION 1.869 +# 1.870 +title SliTaz GNU/Linux (cooking) (Kernel $KERNEL) 1.871 +root $GRUB_ROOT 1.872 +kernel /boot/$KERNEL root=$TGT_PARTITION lang=$LANG 1.873 + 1.874 +_EOF_ 1.875 + if [ -n "$TGT_WINBOOT" ]; then 1.876 + cat >> $TARGET_ROOT/boot/grub/menu.lst << _EOF_ 1.877 +# For booting Windows : 1.878 +# 1.879 +title Microsoft Windows 1.880 + rootnoverify ($WINBOOT) 1.881 + chainloader +1 1.882 + 1.883 +_EOF_ 1.884 + fi 1.885 + # log 1.886 + debug "grub_config: $TARGET_ROOT/boot/grub/menu.lst" 1.887 + echo "--- menu.lst -------------" >>$LOG 1.888 + cat $TARGET_ROOT/boot/grub/menu.lst >>$LOG 1.889 + echo "--- menu.lst -------------" >>$LOG 1.890 + sleep 2 1.891 +} 1.892 + 1.893 +# Files install, calling for functions or with cmds. 1.894 +install_files() 1.895 +{ 1.896 + msg "Installing SliTaz on $TGT_PARTITION" 1.897 + # saving pwd 1.898 + local save_pwd=$(pwd) 1.899 + 1.900 + debug "Cleaning the root partition if necessary..." 1.901 + clean_target 1.902 + 1.903 + debug "Extracting the root system..." 1.904 + extract_rootfs $SOURCE_ROOT/boot 1.905 + 1.906 + debug "Installing the kernel..." 1.907 + install_kernel 1.908 + 1.909 + debug "Copying the bootloader syslinux/isolinux..." 1.910 + copy_bootloaders 1.911 + 1.912 + debug "Preconfiguring the system..." 1.913 + pre_config_system 1.914 + 1.915 + msg "Configuring root and default $USER account..." 1.916 + users_settings 1.917 + 1.918 + if [ "$TGT_HOME" != "" ]; then 1.919 + msg "Configuring $TGT_HOME to be used as /home..." 1.920 + home_config 1.921 + sleep 2 1.922 + fi 1.923 + 1.924 + debug "Creating configuration file for GRUB (menu.lst)..." 1.925 + grub_config 1.926 + 1.927 + debug "Files installation completed" 1.928 + sleep 2 1.929 + # restoring pwd 1.930 + cd $save_pwd 1.931 +} 1.932 + 1.933 +# GRUB info with disk name used for grub-install. 1.934 +grub_install() 1.935 +{ 1.936 + if [ "$TGT_GRUB" == "yes" ]; then 1.937 + TARGET_DISK=`echo $TGT_PARTITION | sed s/"[0-9]"/''/` 1.938 + msg "Running grub-install on : $TARGET_DISK" 1.939 + grub-install --no-floppy \ 1.940 + --root-directory=$TARGET_ROOT $TARGET_DISK 2>>$LOG 1.941 + debug "Grub installation done..." 1.942 + else 1.943 + debug "Grub not installed" 1.944 + fi 1.945 +} 1.946 + 1.947 +# Copy log file, umount target and eject cdrom. 1.948 +umount_devices() 1.949 +{ 1.950 + # Log files 1.951 + debug "Copying log files ($LOG)..." 1.952 + cp -a $LOG $TARGET_ROOT/var/log 1.953 + sleep 2 1.954 + 1.955 + # Umount target 1.956 + if mount | grep -q $TARGET_ROOT; then 1.957 + echo "Unmounting target ($TGT_PARTITION)..." 1.958 + umount $TARGET_ROOT 2>>$LOG 1.959 + fi 1.960 + 1.961 + # Umount source 1.962 + if mount | grep -q $SOURCE_ROOT; then 1.963 + echo "Unmounting $SOURCE_ROOT" 1.964 + umount $SOURCE_ROOT 1.965 + fi 1.966 + 1.967 + # Eject cd 1.968 + if [ "$INST_TYPE" == "cdrom" ]; then 1.969 + echo "Ejecting cdrom..." 1.970 + eject 1.971 + fi 1.972 + sleep 2 1.973 +} 1.974 + 1.975 +# End of installation. 1.976 +end_of_install() 1.977 +{ 1.978 + echo "Installation complete. You can now restart (reboot) \ 1.979 +from your SliTaz GNU/Linux system." 1.980 + echo "=== Tazinst end at `date` ===" >>$LOG 1.981 + umount_devices 1.982 +} 1.983 + 1.984 +##################### 1.985 +# Upgrade functions # 1.986 +##################### 1.987 + 1.988 +# Mount. 1.989 +prepare_upgrade() 1.990 +{ 1.991 + debug "Preparing the target partition..." 1.992 + # Mount point can be already used. 1.993 + if mount | grep -q $TARGET_ROOT; then 1.994 + umount $TARGET_ROOT 2>>$LOG 1.995 + fi 1.996 + mkdir -p $TARGET_ROOT && sleep 2 1.997 + # Mount target. 1.998 + mount $TGT_PARTITION $TARGET_ROOT >>$LOG 2>>$LOG 1.999 + if [ $(mount | grep -c "mnt/target") == "0" ]; then 1.1000 + abort 5 "Can't mount $TGT_PARTITION" 1.1001 + fi 1.1002 +} 1.1003 + 1.1004 +# Check for a valid SliTaz 1.1005 +check_release() 1.1006 +{ 1.1007 + if [ -f $TARGET_ROOT/etc/slitaz-release ]; then 1.1008 + release=`cat $TARGET_ROOT/etc/slitaz-release` 1.1009 + msg "Preparing upgrade of SliTaz release: $release" 1.1010 + else 1.1011 + abort 6 "The partition '$TGT_PARTITION' doesn't appear to contain \ 1.1012 +a SliTaz system, the file: /etc/slitaz-release doesn't exist." 1.1013 + fi && sleep 2 1.1014 +} 1.1015 + 1.1016 +# Backup target packages list. 1.1017 +backup_files() 1.1018 +{ 1.1019 + cd $TARGET_ROOT || abort 8 "Internal" 1.1020 + ls -1 var/lib/tazpkg/installed > home/packages-selection.list 1.1021 + for dir in * 1.1022 + do 1.1023 + case "$dir" in 1.1024 + boot) 1.1025 + rm -rf boot/vmlinuz-* ;; 1.1026 + home) 1.1027 + mv home home.bak 1.1028 + debug "keeping /home found on: $TGT_PARTITION" ;; 1.1029 + etc) 1.1030 + tar czf etc.tar.gz etc 1.1031 + mv etc etc.bak 1.1032 + debug "keeping /etc found on: $TGT_PARTITION" ;; 1.1033 + var) 1.1034 + if [ -d var/www ]; then 1.1035 + mv var/www www.bak 1.1036 + debug "keeping /var/www found on: $TGT_PARTITION" 1.1037 + fi 1.1038 + rm -rf var 2>>$LOG ;; 1.1039 + lost+found) 1.1040 + continue ;; 1.1041 + *) 1.1042 + debug "removing target: $dir" 1.1043 + rm -rf $dir 2>>$LOG ;; 1.1044 + esac 1.1045 + done 1.1046 + if [ -d mklost+found ]; then 1.1047 + mklost+found 2>>$LOG 1.1048 + fi 1.1049 + sleep 2 1.1050 +} 1.1051 + 1.1052 +# Restore backups. 1.1053 +restore_files() 1.1054 +{ 1.1055 + rm -rf $TARGET_ROOT/home 1.1056 + mv $TARGET_ROOT/home.bak $TARGET_ROOT/home 1.1057 + rm -rf $TARGET_ROOT/etc 1.1058 + mv $TARGET_ROOT/etc.bak $TARGET_ROOT/etc 1.1059 + if [ -d $TARGET_ROOT/www.bak ]; then 1.1060 + rm -rf $TARGET_ROOT/var/www 1.1061 + mv $TARGET_ROOT/www.bak $TARGET_ROOT/var/www 1.1062 + fi 1.1063 + debug "backups restored: `date`" 1.1064 + 1.1065 + # /var/lib/slitaz-installer 1.1066 + mkdir -p $TARGET_ROOT/var/lib/tazinst 1.1067 + mv $TARGET_ROOT/etc.tar.gz $TARGET_ROOT/var/lib/tazinst 1.1068 + mv $TARGET_ROOT/home/packages-selection.list $TARGET_ROOT/var/lib/tazinst 1.1069 +} 1.1070 + 1.1071 +# Added pkgs 1.1072 +install_pkgs() 1.1073 +{ 1.1074 + # Check if the pkg is on the mirror. 1.1075 + debug "Checking the availability of packages..." 1.1076 + touch packages-to-install.list 1.1077 + packages=0 1.1078 + diff=`cat packages-selection.diff | sort` 1.1079 + for pkg in $diff 1.1080 + do 1.1081 + if grep -q ^$pkg-[0-9] /var/lib/tazpkg/packages.list; then 1.1082 + packages=$(($packages+1)) 1.1083 + echo "$pkg" >> packages-to-install.list 1.1084 + fi 1.1085 + done 1.1086 + 1.1087 + # Calculate the percent for one package and install. 1.1088 + debug "Installing any packages..." 1.1089 + sleep 2 1.1090 + if [ "$packages" == "0" ]; then 1.1091 + debug "packages to install: 0" 1.1092 + else 1.1093 + onepkg=$((48/$packages)) 1.1094 + pct=50 1.1095 + # Get-install all missing pkgs. 1.1096 + for pkg in `cat packages-to-install.list` 1.1097 + do 1.1098 + pct=$(($pct+$onepkg)) 1.1099 + echo $pct 1.1100 + debug "Installing: $pkg..." 1.1101 + # Get install package and answer yes in case of dependencies. 1.1102 + pkgname=`grep ^$pkg /var/lib/tazpkg/packages.list` 1.1103 + tazpkg get $pkg >/dev/null 2>/dev/null 1.1104 + yes "" | tazpkg install $pkgname.tazpkg --root=$TARGET_ROOT >/dev/null 2>/dev/null 1.1105 + rm -f $pkgname.tazpkg 1.1106 + done 1.1107 + fi 1.1108 + echo 100 1.1109 + debug "Installation of packages complete..." 1.1110 + sleep 2 1.1111 +} 1.1112 + 1.1113 +# Search for added pkgs 1.1114 +update_pkgs() 1.1115 +{ 1.1116 + cd $TARGET_ROOT/var/lib/tazinst || abort 8 "Internal" 1.1117 + # LiveCD packages list. 1.1118 + debug "Creating package lists..." 1.1119 + ls -1 $TARGET_ROOT/var/lib/tazpkg/installed > packages-source.list || exit 1 1.1120 + debug "packages-source.list: done" 1.1121 + # Diff 1.1122 + diff packages-source.list packages-selection.list | \ 1.1123 + grep ^+[a-z] | sed s/^+// > packages-selection.diff 1.1124 + debug "packages-selection.diff: done" 1.1125 + # Get mirror list. 1.1126 + tazpkg recharge >>$LOG 2>>$LOG 1.1127 + if [ -f /var/lib/tazpkg/packages.list ]; then 1.1128 + install_pkgs 1.1129 + else 1.1130 + touch packages-to-install.list 1.1131 + warning "The list of available packages on the mirror could not be \ 1.1132 +downloaded. No missing packages will be reinstalled now, but \ 1.1133 +you can do so later by looking at the following list: \ 1.1134 +/var/lib/tazinst/packages-selection.diff" 1.1135 + fi 1.1136 + sleep 2 1.1137 +} 1.1138 + 1.1139 +# Update grub conf 1.1140 +grub_update() 1.1141 +{ 1.1142 + # Backup and create a new grub menu.lst. 1.1143 + if [ "$TGT_GRUB" == "yes" ]; then 1.1144 + msg "Grub update" 1.1145 + mv $TARGET_ROOT/boot/grub/menu.lst \ 1.1146 + $TARGET_ROOT/boot/grub/menu.lst.bak 2>/dev/null 1.1147 + grub_config 1.1148 + fi 1.1149 +} 1.1150 + 1.1151 +# Prepare the partition to upgrade, backup, install, restore configs 1.1152 +# and reinstall pkgs. 1.1153 +upgrade_files() 1.1154 +{ 1.1155 + # saving pwd 1.1156 + local save_pwd=$(pwd) 1.1157 + cd $TARGET_ROOT || abort 8 "Internal" 1.1158 + 1.1159 + debug "Searching for /etc/slitaz-release" 1.1160 + check_release 1.1161 + 1.1162 + msg "Backup /etc, /home and the packages list..." 1.1163 + backup_files 1.1164 + 1.1165 + msg "Upgrading SliTaz on $TGT_PARTITION" 1.1166 + 1.1167 + debug "Copying the bootloader syslinux/isolinux..." 1.1168 + copy_bootloaders 1.1169 + 1.1170 + debug "Extracting the root system..." 1.1171 + extract_rootfs $SOURCE_ROOT/boot 1.1172 + 1.1173 + msg "Restoring configuration files..." 1.1174 + restore_files 1.1175 + 1.1176 + debug "Installing the kernel..." 1.1177 + install_kernel 1.1178 + 1.1179 + msg "Upgrading added packages..." 1.1180 + update_pkgs 1.1181 + 1.1182 + # restoring pwd 1.1183 + cd $save_pwd 1.1184 +} 1.1185 + 1.1186 +# End of system upgrade. 1.1187 +end_of_upgrade() 1.1188 +{ 1.1189 + pkgscd=`cat $TARGET_ROOT/var/lib/tazinst/packages-source.list | wc -l` 1.1190 + pkginst=`cat $TARGET_ROOT/var/lib/tazinst/packages-to-install.list | wc -l` 1.1191 + echo -e "Upgrade finished. You can now restart (reboot) \ 1.1192 +from your SliTaz GNU/Linux system. 1.1193 +Packages on the cdrom : $pkgscd 1.1194 +Packages installed from the mirror : $pkginst" 1.1195 + echo "=== Tazinst end at `date` ===" >>$LOG 1.1196 + umount_devices 1.1197 +} 1.1198 + 1.1199 +###################### 1.1200 +# Installer sequence # 1.1201 +###################### 1.1202 + 1.1203 +case $1 in 1.1204 + install) 1.1205 + INST_ACTION=install 1.1206 + check_root 1.1207 + init $@ 1.1208 + read_configuration_file $2 1.1209 + check_vars 1.1210 + check_source 1.1211 + prepare_install 1.1212 + install_files 1.1213 + grub_install 1.1214 + end_of_install ;; 1.1215 + upgrade) 1.1216 + INST_ACTION=upgrade 1.1217 + check_root 1.1218 + init $@ 1.1219 + read_configuration_file $2 1.1220 + check_vars 1.1221 + check_source 1.1222 + prepare_upgrade 1.1223 + upgrade_files 1.1224 + grub_update 1.1225 + end_of_upgrade ;; 1.1226 + config) 1.1227 + gen_config $2 ;; 1.1228 + cli) 1.1229 + check_root 1.1230 + init $@ 1.1231 + check_cli_options $@ 1.1232 + check_vars 1.1233 + check_source 1.1234 + summary 1.1235 + case $INST_ACTION in 1.1236 + upgrade) 1.1237 + prepare_upgrade 1.1238 + upgrade_files 1.1239 + grub_update 1.1240 + end_of_upgrade ;; 1.1241 + install) 1.1242 + prepare_install 1.1243 + install_files 1.1244 + grub_install 1.1245 + end_of_install ;; 1.1246 + esac ;; 1.1247 + usage|*) 1.1248 + usage ;; 1.1249 +esac 1.1250 + 1.1251 +exit 0
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/core/rootfs/usr/share/doc/slitaz/tazinst.fr.html Tue May 31 00:30:56 2011 +0200 2.3 @@ -0,0 +1,223 @@ 2.4 +<!DOCTYPE html> 2.5 +<html xmlns="http://www.w3.org/1999/xhtml"> 2.6 +<head> 2.7 + <title>Tazinst Manual - Manuel de l'installeur 'tazinst'</title> 2.8 + <meta charset="utf-8" /> 2.9 + <link rel="shortcut icon" href="favicon.ico" /> 2.10 + <link rel="stylesheet" type="text/css" href="style.css" /> 2.11 +</head> 2.12 +<body> 2.13 + 2.14 +<!-- Header --> 2.15 +<div id="header"> 2.16 + <h1>Tazinst Manual</h1> 2.17 +</div> 2.18 + 2.19 +<!-- Start content --> 2.20 +<div id="content"> 2.21 + 2.22 +<h2>NOM</h2> 2.23 +<p> 2.24 + Tazinst - Tiny autonomous zone installer manager 2.25 +</p> 2.26 + 2.27 +<h2>SYNTAXE</h2> 2.28 +<pre> 2.29 +tazinst [commande] [fichier de configuration] 2.30 +</pre> 2.31 + 2.32 +<h2>DESCRIPTION</h2> 2.33 +<p> 2.34 + Tazinst est l'installateur ultra léger (~29 Ko) de SliTaz sur disque dur. 2.35 + Il permet d'installer SliTaz au choix à partir du Live-CD, d'une clé 2.36 + LiveUSB, d'une image ISO de SliTaz, ou depuis le web en téléchargeant la 2.37 + version stable, la version cooking ou en donnant le lien http d'une autre 2.38 + iso (ex: iso de developpement). 2.39 +</p> 2.40 +<p> 2.41 + Tazinst permet de formatter la partition cible aux formats de base ext2, 2.42 + ext3, ext4 ou d'autres formats si les paquets correspondants ont été 2.43 + installés. La partition /home peut être installée sur une autre partition, 2.44 + et si besoin être formattée avant l'installation dans un des formats 2.45 + disponibles. Tazinst peut, à la demande, installer le chargeur de démarrage 2.46 + Grub dans le mbr du disque cible. Un dual-boot avec une partition Windows© 2.47 + existante est possible, la recherche de la partition Windows© étant soit 2.48 + automatique, soit précisée manuellement. 2.49 +</p> 2.50 +<p> 2.51 + Tazinst permet également la mise à jour de SliTaz déjà installé sur une 2.52 + partition du disque dur, ce qui est pratique en cas de changement de 2.53 + version. Dans ce cas, Slitaz est mis à jour, les données présentes dans 2.54 + /home sont préservées, et les paquets supplémentaires sont réinstallés 2.55 + dans la nouvelle version. 2.56 +</p> 2.57 +<p> 2.58 + Tazinst a été créé pour les besoins de SliTaz GNU/Linux, mini distribution 2.59 + autonome. 2.60 +</p> 2.61 +<p> 2.62 + Tazinst, écrit en script shell à partir de zéro est compatible Bash, et 2.63 + fonctionne avec Ash du projet Busybox. Tazinst est distribué sous license 2.64 + libre GNU gpl v3. 2.65 +</p> 2.66 + 2.67 +<h2>COMMANDES</h2> 2.68 +<a name="config"></a> 2.69 +<h3>config</h3> 2.70 +<p> 2.71 + Génère un fichier de configuration autodocumenté, qui une fois édité suivant 2.72 + les besoins de l'utilisateur, permettra d'installer ou mettre à jour SliTaz 2.73 + sur disque dur, en utilisant <code>tazinst install [nom du fichier]</code>. 2.74 +</p> 2.75 +<pre> 2.76 +tazinst config /var/lib/tazinst.conf 2.77 +</pre> 2.78 + 2.79 +<p> 2.80 + Le fichier de configuration contient les variables suivantes : 2.81 +</p> 2.82 +<ul> 2.83 + <li>Les variables décrivant la source d'installation :</li> 2.84 +</ul> 2.85 + 2.86 +<ol> 2.87 +<li class="level1"><div class="li"> * INST_TYPE : le type du support contenant les 2.88 +fichiers sources de SliTaz, au choix : cdrom (LiveCD de SliTaz), usb (LiveUSB de SliTaz), 2.89 +iso (Image ISO de SliTaz), web (Image ISO sur le Web), weboot, ex : <code>INST_TYPE=web 2.90 +</code></div> 2.91 +</li> 2.92 +<li class="level1"><div class="li"> * SRC_FILE : le nom de la source contenant SliTaz. 2.93 +Il dépend du type de support : 2.94 + <ul> 2.95 + <li class="level2"><div class="li">cdrom (LiveCD de SliTaz) : <i>inutilisé</i> 2.96 + </div></li> 2.97 + <li class="level2"><div class="li">usb (LiveUSB de SliTaz) : Nom de la partition 2.98 + hôte de périphérique USB, ex : <code>SRC_FILE=/dev/sdb1</code> 2.99 + </div></li> 2.100 + <li class="level2"><div class="li">iso (Image ISO de SliTaz) : Nom du fichier ISO, 2.101 + ex : <code>SRC_FILE=~/slitaz.3.0.iso</code> 2.102 + </div></li> 2.103 + <li class="level2"><div class="li">web (Image ISO sur le Web) : Nom de l'URL, 2.104 + ex : <code>SRC_FILE=http://mirror.slitaz.org/iso/cooking/slitaz-cooking.iso 2.105 + </code>. À noter que 3 URL sont prédéfinies : 'stable', 'cooking, 'rolling', 2.106 + ex : <code>SRC_FILE=cooking</code> téléchargera la dernière cooking disponible 2.107 + sur le web 2.108 + </div></li> 2.109 + <li class="level2"><div class="li">weboot : <i>inutilisé</i></div></li> 2.110 + </ul></div> 2.111 +</li> 2.112 +</ol> 2.113 + 2.114 +<ul> 2.115 +<li class="level1"><div class="li"> Les variables décrivant la partition cible : </div> 2.116 +</li> 2.117 +</ul> 2.118 + 2.119 +<ol> 2.120 +<li class="level1"><div class="li"> * TGT_PARTITION : Le nom de la partition cible sur 2.121 +laquelle SliTaz sera insallé ou mis à jour, ex : <code>TGT_PARTITION=/dev/hda3</code></div> 2.122 +</li> 2.123 +<li class="level1"><div class="li">TGT_FS : Si cette variable est renseignée, la partition 2.124 +cible sera formatée dans le système de fichiers indiqué, sinon, la partition sera nettoyée 2.125 +et le répertoire /home sera conservé, ex : <code>TGT_FS=ext3</code></div> 2.126 +</li> 2.127 +<li class="level1"><div class="li">TGT_HOME : Cette variable indique, si besoin est, le nom 2.128 +de la partition recevant le répertoire /home, ex : <code>TGT_HOME=/dev/hda5</code></div> 2.129 +</li> 2.130 +<li class="level1"><div class="li">TGT_HOME_FS : Si cette variable est renseignée, la 2.131 +partition/home sera formatée dans le système de fichiers indiqué, ex : 2.132 +<code>TGT_HOME_FS=ext2</code></div> 2.133 +</li> 2.134 +</ol> 2.135 + 2.136 +<ul> 2.137 +<li class="level1"><div class="li"> Les variables de configuration de Slitaz : </div> 2.138 +</li> 2.139 +</ul> 2.140 + 2.141 +<ol> 2.142 +<li class="level1"><div class="li">TGT_HOSTNAME : Nom du système, ex : <code>TGT_HOSTNAME=hd-slitaz 2.143 +</code>, par défaut <code>TGT_HOSTNAME=slitaz</code></div> 2.144 +</li> 2.145 +<li class="level1"><div class="li">TGT_ROOT_PWD : Mot de passe du super-utilisateur, ex : 2.146 +<code>TGT_ROOT_PWD=toor</code>, par défaut <code>TGT_ROOT_PWD=root</code></div> 2.147 +</li> 2.148 +<li class="level1"><div class="li">TGT_USER : Nom de l'utitisateur par défaut, ex : 2.149 +<code>TGT_USER=toto</code>, par défaut <code>TGT_USER=tux</code></div> 2.150 +</li> 2.151 +<li class="level1"><div class="li">TGT_USER_PWD : Mot de passe de l'utitisateur par 2.152 +défaut, ex : <code>TGT_USER_PWD=titi</code>, par défaut <code>TGT_USER_PWD=tux</code></div> 2.153 +</li> 2.154 +</ol> 2.155 + 2.156 +<ul> 2.157 +<li class="level1"><div class="li"> Les variables de configuration du chargeur de démarrage 2.158 +(bootloader) : </div> 2.159 +</li> 2.160 +</ul> 2.161 + 2.162 +<ol> 2.163 + <li>TGT_GRUB : Installation de GRUB (yes ou no), ex : 2.164 + <code>TGT_GRUB=yes</code>, par défaut <code>TGT_GRUB=no</code> 2.165 + </li> 2.166 + <li class="level1"><div class="li">TGT_MENU_PARTITION: Nom de la partition où le fichier de 2.167 + configuration de GRUB est installé. Normalement, cette variable n'est pas renseignée, elle peut 2.168 + servir dans le cas où GRUB est installé dans une partition dédiée, ou dans une configuration 2.169 + multi-os, ex : <code>TGT_MENU_PARTITION=/dev/hda4</code></div> 2.170 + </li> 2.171 + <li class="level1"><div class="li">TGT_WINBOOT : Si cette variable est renseignée, elle 2.172 + indique la partition contenant Windows© pour mettre en place un Dual-boot. Elle peut être 2.173 + aussi positionnée à 'auto', dans ce cas le dual-boot se fera sur la première partition 2.174 + Windows© détectée, ex : <code>TGT_WINBOOT=auto</code></div> 2.175 + </li> 2.176 +</ol> 2.177 + 2.178 +<p> 2.179 + À noter que seules les variables précédées d'une atérisque sont obligatoires, 2.180 + les autres sont optionnelles. Ainsi un fichier de configuration minimaliste 2.181 + peut être le suivant: 2.182 +</p> 2.183 +<pre> 2.184 +INST_TYPE=cdrom 2.185 +TGT_PARTITION=/dev/hda3 2.186 +</pre> 2.187 +<p> 2.188 + Ce fichier permettra une installation de SliTaz sur /dev/hda3, sans 2.189 + formatter la partition, à partir d'un LiveCD. 2.190 +</p> 2.191 + 2.192 +<a name="install"></a> 2.193 +<h3>install</h3> 2.194 +<p> 2.195 + Lance l'installation de SliTaz en fonction des données présentes dans le 2.196 + fichier de configuration. 2.197 +</p> 2.198 +<pre> 2.199 +tazinst install /var/lib/tazinst.conf 2.200 +</pre> 2.201 + 2.202 +<a name="upgrade"></a> 2.203 +<h3>upgrade</h3> 2.204 +<p> 2.205 + Lance la mise à jour de SliTaz en fonction des données présentes dans le 2.206 + fichier de configuration. 2.207 +</p> 2.208 +<pre> 2.209 +tazinst upgrade /var/lib/tazinst.conf 2.210 +</pre> 2.211 + 2.212 +<h2>MAINTENEUR</h2> 2.213 +<p> 2.214 + Christophe Lincoln <pankso at slitaz.org> 2.215 + Dominique Corbex <domcox at slitaz.org> 2.216 +</p> 2.217 + 2.218 +<!-- End of content --> 2.219 +</div> 2.220 + 2.221 +<div id="footer"> 2.222 + Copyright © 2011 <a href="http://www.slitaz.org/">SliTaz GNU/Linux</a> 2.223 +</div> 2.224 + 2.225 +</body> 2.226 +</html>