flavors-stable diff xfce/rootfs/usr/bin/tazlito @ rev 130
Rename: core-xfce --> xfce
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Wed Feb 22 23:26:35 2012 +0100 (2012-02-22) |
parents | core-xfce/rootfs/usr/bin/tazlito@d851f7b01f92 |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xfce/rootfs/usr/bin/tazlito Wed Feb 22 23:26:35 2012 +0100 1.3 @@ -0,0 +1,1825 @@ 1.4 +#!/bin/sh 1.5 +# TazLito - SliTaz Live Tool. 1.6 +# 1.7 +# Tazlito is a tool to help generate and configure SliTaz LiveCD 1.8 +# ISO images. You can create a custom distro in one command from a list of 1.9 +# packages, extract an existing ISO image to hack it, create a new initramfs 1.10 +# and/or a new ISO. Most commands must be run by root, except the stats 1.11 +# and the configuration file manipulation. 1.12 +# 1.13 +# (C) 2007-2010 SliTaz - GNU General Public License. 1.14 +# 1.15 +# Authors : Christophe Lincoln <pankso@slitaz.org> 1.16 +# Pascal Bellard <pascal.bellard@slitaz.org> 1.17 +# 1.18 +VERSION=2.0 1.19 + 1.20 +# Tazlito configuration variables to be shorter 1.21 +# and to use words rather than numbers. 1.22 +COMMAND=$1 1.23 +LIST_NAME=$2 1.24 +TMP_DIR=/tmp/tazlito-$$-$RANDOM 1.25 +TMP_MNT=/media/tazlito-$$-$RANDOM 1.26 +TOP_DIR=`pwd` 1.27 +INITRAMFS=rootfs.gz 1.28 +LOCALSTATE=/var/lib/tazpkg 1.29 +INSTALLED=$LOCALSTATE/installed 1.30 +CACHE_DIR=/var/cache/tazpkg 1.31 +MIRROR=$LOCALSTATE/mirror 1.32 +DEFAULT_MIRROR="http://mirror.slitaz.org/packages/`cat /etc/slitaz-release`/" 1.33 + 1.34 +# Try to include config file, continue if command is gen-config or exit. 1.35 +# The main config used by default is in /etc/tazlito. 1.36 +if [ -f "/etc/tazlito/tazlito.conf" ] ; then 1.37 + CONFIG_FILE="/etc/tazlito/tazlito.conf" 1.38 +fi 1.39 +# Specific distro config file can be put in a distro tree. 1.40 +if [ -f "$TOP_DIR/tazlito.conf" ] ; then 1.41 + CONFIG_FILE="$TOP_DIR/tazlito.conf" 1.42 +fi 1.43 +if [ ! "$CONFIG_FILE" = "" ] ; then 1.44 + . $CONFIG_FILE 1.45 +else 1.46 + if [ "$COMMAND" = "gen-config" ] ; then 1.47 + continue 1.48 + else 1.49 + echo "Unable to find any configuration file. Please read the docs" 1.50 + echo "or run '`basename $0` gen-config' to get an empty config file." 1.51 + exit 0 1.52 + fi 1.53 +fi 1.54 + 1.55 +# While Tazpkg is not used the default mirror url file does not exist 1.56 +# and user can't recharge the list of flavors. 1.57 +if test $(id -u) = 0 ; then 1.58 + if [ ! -f "$MIRROR" ]; then 1.59 + echo "$DEFAULT_MIRROR" > $MIRROR 1.60 + fi 1.61 +fi 1.62 + 1.63 +# Set the rootfs and rootcd path with $DISTRO 1.64 +# configuration variable. 1.65 +ROOTFS=$DISTRO/rootfs 1.66 +ROOTCD=$DISTRO/rootcd 1.67 +FLAVORS_REPOSITORY=/home/slitaz/flavors 1.68 + 1.69 +##################### 1.70 +# Tazlito functions # 1.71 +##################### 1.72 + 1.73 +# Print the usage. 1.74 +usage () 1.75 +{ 1.76 + echo -e "\nSliTaz Live Tool - Version: $VERSION\n 1.77 +\033[1mUsage: \033[0m `basename $0` [command] [list|iso|flavor|compression] [dir|iso] 1.78 +\033[1mCommands: \033[0m\n 1.79 + usage Print this short usage. 1.80 + stats View Tazlito and distro configuration statistics. 1.81 + gen-config Generate a new configuration file for a distro. 1.82 + configure Configure the main config file or a specific tazlito.conf. 1.83 + gen-iso Generate a new ISO from a distro tree. 1.84 + gen-initiso Generate a new initramfs and ISO from the distro tree. 1.85 + list-flavors List all available package lists on the mirror. 1.86 + gen-flavor Generate a new live-CD description. 1.87 + gen-liveflavor Generate a live-CD description from current system. 1.88 + show-flavor Show live-CD description. 1.89 + get-flavor Get a flavor's list of packages. 1.90 + upgrade-flavor Update package list to the latest available versions. 1.91 + extract-flavor Extract a (*.flavor) flavor into $FLAVORS_REPOSITORY. 1.92 + pack-flavor Pack (and update) a flavor from $FLAVORS_REPOSITORY. 1.93 + check-list Check a distro-packages.list for updates. 1.94 + extract-distro Extract an ISO to a directory and rebuild LiveCD tree. 1.95 + gen-distro Generate a Live distro and ISO from a list of packages. 1.96 + clean-distro Remove all files generated by gen-distro. 1.97 + check-distro Help to check if distro is ready to release. 1.98 + writeiso Use running system to generate a bootable ISO (with /home). 1.99 + merge Merge multiple rootfs into one iso. 1.100 + repack Recompress rootfs into iso with maximum ratio. 1.101 + frugal-install Frugal install in /boot/frugal from a distro or ISO 1.102 + emu-iso Emulate an ISO image with Qemu. 1.103 + burn-iso Burn ISO image to a cdrom using Wodim.\n" 1.104 +} 1.105 + 1.106 +# Status function. 1.107 +status() 1.108 +{ 1.109 + local CHECK=$? 1.110 + echo -en "\\033[70G[ " 1.111 + if [ $CHECK = 0 ]; then 1.112 + echo -en "\\033[1;33mOK" 1.113 + else 1.114 + echo -en "\\033[1;31mFailed" 1.115 + fi 1.116 + echo -e "\\033[0;39m ]" 1.117 + return $CHECK 1.118 +} 1.119 + 1.120 +yesorno() 1.121 +{ 1.122 + echo -n "$1" 1.123 + case "$DEFAULT_ANSWER" in 1.124 + Y|y) answer="y";; 1.125 + N|n) answer="n";; 1.126 + *) read answer;; 1.127 + esac 1.128 +} 1.129 + 1.130 +field() 1.131 +{ 1.132 + grep "^$1" "$2" | sed 's/.*: \([0-9KMG\.]*\).*/\1/' 1.133 +} 1.134 + 1.135 +todomsg() 1.136 +{ 1.137 + echo -e "\\033[70G[ \\033[1;31mTODO\\033[0;39m ]" 1.138 +} 1.139 + 1.140 +# Download a file from this mirror 1.141 +download_from() 1.142 +{ 1.143 + local i 1.144 + local mirrors 1.145 + mirrors="$1" 1.146 + shift 1.147 + for i in $mirrors; do 1.148 + case "$i" in 1.149 + http://*|ftp://*) wget -c $i$@ && break;; 1.150 + *) cp $i/$1 . && break;; 1.151 + esac 1.152 + done 1.153 +} 1.154 + 1.155 +# Download a file trying all mirrors 1.156 +download() 1.157 +{ 1.158 + local i 1.159 + for i in $(cat $MIRROR $LOCALSTATE/undigest/*/mirror 2> /dev/null); do 1.160 + download_from "$i" "$@" && break 1.161 + done 1.162 +} 1.163 + 1.164 +# Execute hooks provided by some packages 1.165 +genisohooks() 1.166 +{ 1.167 + local here=`pwd` 1.168 + for i in $(ls $ROOTFS/etc/tazlito/*.$1 2> /dev/null); do 1.169 + cd $ROOTFS 1.170 + . $i $ROOTCD 1.171 + done 1.172 + cd $here 1.173 +} 1.174 + 1.175 +cleanup() 1.176 +{ 1.177 + if [ -d $TMP_MNT ]; then 1.178 + umount $TMP_MNT 1.179 + rmdir $TMP_MNT 1.180 + rm -f /boot 1.181 + fi 1.182 +} 1.183 + 1.184 +# Echo the package name if the tazpkg is already installed 1.185 +installed_package_name() 1.186 +{ 1.187 + local tazpkg 1.188 + local package 1.189 + local VERSION 1.190 + local EXTRAVERSION 1.191 + tazpkg=$1 1.192 + # Try to find package name and version to be able 1.193 + # to repack it from installation 1.194 + # A dash (-) can exist in name *and* in version 1.195 + package=${tazpkg%-*} 1.196 + i=$package 1.197 + while true; do 1.198 + VERSION="" 1.199 + eval $(grep -s ^VERSION= $INSTALLED/$i/receipt) 1.200 + EXTRAVERSION="" 1.201 + eval $(grep -s ^EXTRAVERSION= $INSTALLED/$i/receipt) 1.202 + if [ "$i-$VERSION$EXTRAVERSION" = "$tazpkg" ]; then 1.203 + echo $i 1.204 + break 1.205 + fi 1.206 + case "$i" in 1.207 + *-*);; 1.208 + *) break;; 1.209 + esac 1.210 + i=${i%-*} 1.211 + done 1.212 +} 1.213 + 1.214 +# Check if user is root. 1.215 +check_root() 1.216 +{ 1.217 + if test $(id -u) != 0 ; then 1.218 + echo -e "\nYou must be root to run `basename $0` with this option." 1.219 + echo -e "Please type 'su' and root password to become super-user.\n" 1.220 + exit 0 1.221 + fi 1.222 +} 1.223 + 1.224 +# Check for the rootfs tree. 1.225 +check_rootfs() 1.226 +{ 1.227 + if [ ! -d "$ROOTFS/etc" ] ; then 1.228 + echo -e "\nUnable to find a distro rootfs...\n" 1.229 + exit 0 1.230 + fi 1.231 +} 1.232 + 1.233 +# Check for the boot dir into the root CD tree. 1.234 +verify_rootcd() 1.235 +{ 1.236 + if [ ! -d "$ROOTCD/boot" ] ; then 1.237 + echo -e "\nUnable to find the rootcd boot directory...\n" 1.238 + exit 0 1.239 + fi 1.240 +} 1.241 + 1.242 +create_iso() 1.243 +{ 1.244 + genisoimage -R -o $1 -b boot/isolinux/isolinux.bin \ 1.245 + -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \ 1.246 + -V "$VOLUM_NAME" -p "$PREPARED" -input-charset iso8859-1 \ 1.247 + -boot-info-table $2 1.248 + if [ -x /usr/bin/isohybrid ]; then 1.249 + echo -n "Creating hybrid ISO..." 1.250 + /usr/bin/isohybrid $1 2> /dev/null 1.251 + status 1.252 + fi 1.253 +} 1.254 + 1.255 +# Generate a new ISO image using isolinux. 1.256 +gen_livecd_isolinux() 1.257 +{ 1.258 + # Some packages may want to alter iso 1.259 + genisohooks iso 1.260 + if [ ! -f "$ROOTCD/boot/isolinux/isolinux.bin" ]; then 1.261 + echo -e "\nUnable to find isolinux binary.\n" 1.262 + cleanup 1.263 + exit 0 1.264 + fi 1.265 + # Set date for boot msg. 1.266 + if grep -q 'XXXXXXXX' $ROOTCD/boot/isolinux/isolinux.msg; then 1.267 + DATE=`date +%Y%m%d` 1.268 + echo -n "Setting build date to: $DATE..." 1.269 + sed -i s/'XXXXXXXX'/"$DATE"/ $ROOTCD/boot/isolinux/isolinux.msg 1.270 + status 1.271 + fi 1.272 + cd $ROOTCD 1.273 + echo -n "Computing md5..." 1.274 + find * -type f ! -name md5sum -exec md5sum {} \; > md5sum 1.275 + status 1.276 + cd $DISTRO 1.277 + echo "" 1.278 + echo -e "\033[1mGenerating ISO image\033[0m" 1.279 + echo "================================================================================" 1.280 + create_iso $ISO_NAME.iso $ROOTCD 1.281 + echo -n "Creating the ISO md5sum..." 1.282 + md5sum $ISO_NAME.iso > $ISO_NAME.md5 1.283 + status 1.284 + echo "================================================================================" 1.285 + # Some packages may want to alter final iso 1.286 + genisohooks final 1.287 +} 1.288 + 1.289 +lzma_history_bits() 1.290 +{ 1.291 + # 1.292 + # This genertae ISO who boot with Qemu but give 1.293 + # rootfs errors in frugal or liveUSB mode. 1.294 + # 1.295 + #local n 1.296 + #local sz 1.297 + #n=20 # 1Mb 1.298 + #sz=$(du -sk $1 | cut -f1) 1.299 + #while [ $sz -gt 1024 -a $n -lt 28 ]; do 1.300 + #n=$(( $n + 1 )) 1.301 + #sz=$(( $sz / 2 )) 1.302 + #done 1.303 + #echo $n 1.304 + echo 24 1.305 +} 1.306 + 1.307 +lzma_switches() 1.308 +{ 1.309 + echo "-d$(lzma_history_bits $1) -mt$(grep ^processor < /proc/cpuinfo | wc -l)" 1.310 +} 1.311 + 1.312 +# Pack rootfs 1.313 +pack_rootfs() 1.314 +{ 1.315 + ( cd $1 ; find . -print | cpio -o -H newc ) | \ 1.316 + if [ "$COMPRESSION" = "none" ]; then 1.317 + echo "Generating uncompressed initramfs... " 1.318 + cat > $2 1.319 + elif [ -x /usr/bin/lzma -a "$COMPRESSION" != "gzip" ]; then 1.320 + echo -n "Generating lzma'ed initramfs... " 1.321 + lzma e -si -so $(lzma_switches $1) > $2 1.322 + else 1.323 + echo "Generating gziped initramfs... " 1.324 + gzip -9 > $2 1.325 + fi 1.326 + echo 1 > /tmp/rootfs 1.327 +} 1.328 + 1.329 +# Compression functions for writeiso. 1.330 +write_initramfs() 1.331 +{ 1.332 + if [ "$COMPRESSION" = "lzma" ]; then 1.333 + echo -n "Creating rootfs.gz with lzma compression... " 1.334 + cat /tmp/list | cpio -o -H newc | lzma e -si -so > /rootfs.gz 1.335 + elif [ "$COMPRESSION" = "gzip" ]; then 1.336 + echo "Creating rootfs.gz with gzip compression... " 1.337 + cat /tmp/list | cpio -o -H newc | gzip -9 > /rootfs.gz 1.338 + else 1.339 + echo "Creating rootfs.gz without compression... " 1.340 + cat /tmp/list | cpio -o -H newc > /rootfs.gz 1.341 + fi 1.342 + echo 1 > /tmp/rootfs 1.343 +} 1.344 + 1.345 +# Generate a new initramfs from the root filesystem. 1.346 +gen_initramfs() 1.347 +{ 1.348 + # Just in case CTRL+c 1.349 + rm -f $DISTRO/gen 1.350 + # Some packages may want to alter rootfs 1.351 + genisohooks rootfs 1.352 + cd $1 1.353 + echo "" 1.354 + 1.355 + # Link duplicate files 1.356 + find . -type f -size +0c -exec stat -c '%s-%a-%u-%g %i %h %n' {} \; | \ 1.357 + sort | ( save=0; old_attr=""; old_inode=""; old_link=""; old_file="" 1.358 + while read attr inode link file; do 1.359 + if [ "$attr" = "$old_attr" -a "$inode" != "$old_inode" ]; then 1.360 + if cmp "$file" "$old_file" >/dev/null; then 1.361 + rm -f "$file" 1.362 + ln "$old_file" "$file" 1.363 + inode="$old_inode" 1.364 + [ "$link" = "1" ] && save="$(expr $save + ${attr%%-*})" 1.365 + fi 1.366 + fi 1.367 + old_attr="$attr" ; old_inode="$inode" ; old_file="$file" 1.368 + done 1.369 + echo "$save bytes saved in duplicate files." 1.370 + ) 1.371 + 1.372 + # Use lzma if installed. Display rootfs size in realtime. 1.373 + rm -f /tmp/rootfs 1.374 + pack_rootfs . $DISTRO/$(basename $1).gz & 1.375 + sleep 2 1.376 + echo -en "\nFilesystem size:" 1.377 + while [ ! -f /tmp/rootfs ] 1.378 + do 1.379 + sleep 1 1.380 + echo -en "\\033[18G`du -sh $DISTRO/rootfs.gz | awk '{print $1}'` " 1.381 + done 1.382 + echo -e "\n" 1.383 + cd $DISTRO 1.384 + mv $(basename $1).gz $ROOTCD/boot 1.385 +} 1.386 + 1.387 +distro_sizes() 1.388 +{ 1.389 + echo "Build date : `date +%Y%m%d\ \at\ \%H:%M:%S`" 1.390 + echo "Packages : `ls -1 $ROOTFS*$INSTALLED/*/receipt | wc -l`" 1.391 + echo "Rootfs size : `du -csh $ROOTFS*/ | awk '{ s=$1 } END { print s }'`" 1.392 + echo "Initramfs size : `du -csh $ROOTCD/boot/rootfs*.gz | awk '{ s=$1 } END { print s }'`" 1.393 + echo "ISO image size : `du -sh $ISO_NAME.iso | awk '{ print $1 }'`" 1.394 + echo "================================================================================" 1.395 + echo "Image is ready: $ISO_NAME.iso" 1.396 + echo "" 1.397 +} 1.398 + 1.399 +# Print ISO and rootfs size. 1.400 +distro_stats() 1.401 +{ 1.402 + echo "" 1.403 + echo -e "\033[1mDistro statistics\033[0m ($DISTRO)" 1.404 + echo "================================================================================" 1.405 + distro_sizes 1.406 +} 1.407 + 1.408 +# Create an empty configuration file. 1.409 +empty_config_file() 1.410 +{ 1.411 + cat >> tazlito.conf << "EOF" 1.412 +# tazlito.conf: Tazlito (SliTaz Live Tool) 1.413 +# configuration file. 1.414 +# 1.415 + 1.416 +# Name of the ISO image to generate. 1.417 +ISO_NAME="" 1.418 + 1.419 +# ISO image volume name. 1.420 +VOLUM_NAME="SliTaz" 1.421 + 1.422 +# Name of the preparer. 1.423 +PREPARED="$USER" 1.424 + 1.425 +# Path to the packages repository and the packages.list. 1.426 +PACKAGES_REPOSITORY="" 1.427 + 1.428 +# Path to the distro tree to gen-distro from a 1.429 +# list of packages. 1.430 +DISTRO="" 1.431 + 1.432 +# Path to the directory containing additional files 1.433 +# to copy into the rootfs and rootcd of the LiveCD. 1.434 +ADDFILES="$DISTRO/addfiles" 1.435 + 1.436 +# Default answer for binary question (Y or N) 1.437 +DEFAULT_ANSWER="ASK" 1.438 + 1.439 +# Compression utility (lzma, gzip or none) 1.440 +COMPRESSION="lzma" 1.441 +EOF 1.442 +} 1.443 + 1.444 +# extract rootfs.gz somewhere 1.445 +extract_rootfs() 1.446 +{ 1.447 + (zcat $1 || unlzma -c $1 || cat $1) 2>/dev/null | \ 1.448 + (cd $2; cpio -idm > /dev/null) 1.449 +} 1.450 + 1.451 +# Remove duplicate files 1.452 +mergefs() 1.453 +{ 1.454 + echo -n "Merge $(basename $1) ($(du -hs $1 | awk '{ print $1}')) into " 1.455 + echo -n "$(basename $2) ($(du -hs $2 | awk '{ print $1}'))" 1.456 + # merge symlinks files and devices 1.457 + ( cd $1; find ) | while read file; do 1.458 + if [ -L $1/$file ]; then 1.459 + [ -L $2/$file ] && 1.460 + [ "$(readlink $1/$file)" == "$(readlink $2/$file)" ] && 1.461 + rm -f $2/$file 1.462 + elif [ -f $1/$file ]; then 1.463 + [ -f $2/$file ] && 1.464 + cmp $1/$file $2/$file > /dev/null 2>&1 && rm -f $2/$file 1.465 + [ -f $2/$file ] && 1.466 + [ "$(basename $file)" == "volatile.cpio.gz" ] && 1.467 + [ "$(dirname $(dirname $file))" == \ 1.468 + "./var/lib/tazpkg/installed" ] && rm -f $2/$file 1.469 + elif [ -b $1/$file ]; then 1.470 + [ -b $2/$file ] && rm -f $2/$file 1.471 + elif [ -c $1/$file ]; then 1.472 + [ -c $2/$file ] && rm -f $2/$file 1.473 + fi 1.474 + done 1.475 + 1.476 + # cleanup directories 1.477 + ( cd $1; find ) | while read file; do 1.478 + if [ -d $1/$file ]; then 1.479 + [ -d $2/$file ] && rmdir $2/$file 2> /dev/null 1.480 + fi 1.481 + done 1.482 + true 1.483 + status 1.484 +} 1.485 + 1.486 +cleanup_merge() 1.487 +{ 1.488 + rm -rf $TMP_DIR 1.489 + exit 1 1.490 +} 1.491 + 1.492 +human2cent() 1.493 +{ 1.494 +case "$1" in 1.495 +*k) echo $1 | sed 's/\(.*\).\(.\)k/\1\2/';; 1.496 +*M) echo $(( $(echo $1 | sed 's/\(.*\).\(.\)M/\1\2/') * 1024));; 1.497 +*G) echo $(( $(echo $1 | sed 's/\(.*\).\(.\)G/\1\2/') * 1024 * 1024));; 1.498 +esac 1.499 +} 1.500 + 1.501 +cent2human() 1.502 +{ 1.503 +if [ $1 -lt 10000 ]; then 1.504 + echo "$(($1 / 10)).$(($1 % 10))k" 1.505 +elif [ $1 -lt 10000000 ]; then 1.506 + echo "$(($1 / 10240)).$(( ($1/1024) % 10))M" 1.507 +else 1.508 + echo "$(($1 / 10485760)).$(( ($1/1048576) % 10))G" 1.509 +fi 1.510 +} 1.511 + 1.512 +get_size() 1.513 +{ 1.514 +cat /var/lib/tazpkg/packages.list $TMP_DIR/packages.list 2>/dev/null | awk "{ \ 1.515 +if (/^$(echo $1 | sed 's/[$+.\]/\\&/g')$/) get=1; \ 1.516 +if (/installed/ && get == 1) { print ; get++ } \ 1.517 +} 1.518 +END { if (get < 2) print \" 0.0k (0.0k installed)\" }" | \ 1.519 +sed 's/ *\(.*\) .\(.*\) installed./\1 \2/' | while read packed unpacked; do 1.520 + echo "$(human2cent $packed) $(human2cent $unpacked)" 1.521 +done 1.522 +} 1.523 + 1.524 +# Display package list with version, set packed_size and unpacked_size 1.525 +get_pkglist() 1.526 +{ 1.527 +packed_size=0; unpacked_size=0 1.528 +grep -v ^# $FLAVORS_REPOSITORY/$1/packages.list > $TMP_DIR/flavor.pkg 1.529 +while read pkg; do 1.530 + set -- $(get_size $pkg) 1.531 + packed_size=$(( $packed_size + $1 )) 1.532 + unpacked_size=$(( $unpacked_size + $2 )) 1.533 + for i in $(grep -hs ^$pkg /var/lib/tazpkg/packages.list \ 1.534 + $TMP_DIR/packages.list); do 1.535 + echo $i 1.536 + break 1.537 + done 1.538 +done < $TMP_DIR/flavor.pkg 1.539 +rm -f $TMP_DIR/flavor.pkg 1.540 +} 1.541 + 1.542 +# Update isolinux config files for multiple rootfs 1.543 +update_bootconfig() 1.544 +{ 1.545 + echo -n "Updating boot config files..." 1.546 + grep -l 'include common' $1/*.cfg | \ 1.547 + while read file ; do 1.548 + awk -v n=$(echo $2 | awk '{ print NF/2 }') '{ 1.549 +if (/label/) label=$0; 1.550 +else if (/kernel/) kernel=$0; 1.551 +else if (/append/) { 1.552 + i=index($0,"rootfs.gz"); 1.553 + append=substr($0,i+9); 1.554 +} 1.555 +else if (/include/) { 1.556 + for (i = 1; i <= n; i++) { 1.557 + print label i 1.558 + print kernel; 1.559 + initrd="initrd=/boot/rootfs" n ".gz" 1.560 + for (j = n - 1; j >= i; j--) { 1.561 + initrd=initrd ",/boot/rootfs" j ".gz"; 1.562 + } 1.563 + printf "\tappend %s%s\n",initrd,append; 1.564 + print ""; 1.565 + } 1.566 + print; 1.567 +} 1.568 +else print; 1.569 +}' < $file > $file.$$ 1.570 + mv -f $file.$$ $file 1.571 + done 1.572 + cat >> $1/common.cfg <<EOT 1.573 + 1.574 +label slitaz 1.575 + kernel /boot/isolinux/ifmem.c32 1.576 + append$(echo $2 | awk '{ 1.577 + for (i=1; i<=NF; i++) 1.578 + if (i % 2 == 0) printf " slitaz%d",i/2 1.579 + else printf " %s",$i 1.580 +}') noram 1.581 + 1.582 +label noram 1.583 + config noram.cfg 1.584 + 1.585 +EOT 1.586 + cat > $1/noram.cfg <<EOT 1.587 +display isolinux.msg 1.588 +say Not enough RAM to boot slitaz. 1.589 +default reboot 1.590 +label reboot 1.591 + com32 reboot.c32 1.592 + 1.593 +implicit 0 1.594 +prompt 1 1.595 +timeout 80 1.596 +F1 help.txt 1.597 +F2 options.txt 1.598 +F3 isolinux.msg 1.599 +F4 display.txt 1.600 +F5 enhelp.txt 1.601 +F6 enopts.txt 1.602 +EOT 1.603 + status 1.604 +} 1.605 + 1.606 +#################### 1.607 +# Tazlito commands # 1.608 +#################### 1.609 + 1.610 +case "$COMMAND" in 1.611 + stats) 1.612 + # Tazlito general statistics from the config file. 1.613 + # 1.614 + echo "" 1.615 + echo -e "\033[1mTazlito statistics\033[0m 1.616 +=============================================================================== 1.617 +Config file : $CONFIG_FILE 1.618 +ISO name : $ISO_NAME.iso 1.619 +Volume name : $VOLUM_NAME 1.620 +Prepared : $PREPARED 1.621 +Packages repository : $PACKAGES_REPOSITORY 1.622 +Distro directory : $DISTRO" 1.623 + if [ ! "$ADDFILES" = "" ] ; then 1.624 + echo -e "Additional files : $ADDFILES" 1.625 + fi 1.626 + echo "================================================================================" 1.627 + echo "" 1.628 + ;; 1.629 + list-addfiles) 1.630 + # Simple list of additonal files in the rootfs 1.631 + echo "" 1.632 + cd $ADDFILES 1.633 + find rootfs -type f 1.634 + echo "" ;; 1.635 + gen-config) 1.636 + # Generate a new config file in the current dir or the specified 1.637 + # directory by $2. 1.638 + # 1.639 + if [ -n "$2" ] ; then 1.640 + mkdir -p $2 && cd $2 1.641 + fi 1.642 + echo -n "Generating empty tazlito.conf..." 1.643 + empty_config_file 1.644 + status 1.645 + echo "" 1.646 + if [ -f "tazlito.conf" ] ; then 1.647 + echo "Configuration file is ready to edit." 1.648 + echo "File location : `pwd`/tazlito.conf" 1.649 + echo "" 1.650 + fi 1.651 + ;; 1.652 + configure) 1.653 + # Configure a tazlito.conf config file. Start by getting 1.654 + # a empty config file and sed it. 1.655 + # 1.656 + if [ -f "tazlito.conf" ] ; then 1.657 + rm tazlito.conf 1.658 + else 1.659 + if test $(id -u) = 0 ; then 1.660 + cd /etc 1.661 + else 1.662 + echo "You must be root to configure the main config file or in" 1.663 + echo "the same directory of the file you want to configure." 1.664 + exit 0 1.665 + fi 1.666 + fi 1.667 + empty_config_file 1.668 + echo"" 1.669 + echo -e "\033[1mConfiguring :\033[0m `pwd`/tazlito.conf" 1.670 + echo "================================================================================" 1.671 + # ISO name. 1.672 + echo -n "ISO name : " ; read answer 1.673 + sed -i s#'ISO_NAME=\"\"'#"ISO_NAME=\"$answer\""# tazlito.conf 1.674 + # Volume name. 1.675 + echo -n "Volume name : " ; read answer 1.676 + sed -i s/'VOLUM_NAME=\"SliTaz\"'/"VOLUM_NAME=\"$answer\""/ tazlito.conf 1.677 + # Packages repository. 1.678 + echo -n "Packages repository : " ; read answer 1.679 + sed -i s#'PACKAGES_REPOSITORY=\"\"'#"PACKAGES_REPOSITORY=\"$answer\""# tazlito.conf 1.680 + # Distro path. 1.681 + echo -n "Distro path : " ; read answer 1.682 + sed -i s#'DISTRO=\"\"'#"DISTRO=\"$answer\""# tazlito.conf 1.683 + echo "================================================================================" 1.684 + echo "Config file is ready to use." 1.685 + echo "You can now extract an ISO or generate a distro." 1.686 + echo "" 1.687 + ;; 1.688 + gen-iso) 1.689 + # Simply generate a new iso. 1.690 + # 1.691 + check_root 1.692 + verify_rootcd 1.693 + gen_livecd_isolinux 1.694 + distro_stats 1.695 + ;; 1.696 + gen-initiso) 1.697 + # Simply generate a new initramfs with a new iso. 1.698 + # 1.699 + check_root 1.700 + verify_rootcd 1.701 + gen_initramfs $ROOTFS 1.702 + gen_livecd_isolinux 1.703 + distro_stats 1.704 + ;; 1.705 + extract-distro) 1.706 + # Extract an ISO image to a directory and rebuild the LiveCD tree. 1.707 + # 1.708 + check_root 1.709 + ISO_IMAGE=$2 1.710 + if [ -z "$ISO_IMAGE" ] ; then 1.711 + echo -e "\nPlease specify the path to the ISO image." 1.712 + echo -e "Example : `basename $0` image.iso /path/target\n" 1.713 + exit 0 1.714 + fi 1.715 + # Set the distro path by checking for $3 on cmdline. 1.716 + if [ -n "$3" ] ; then 1.717 + TARGET=$3 1.718 + else 1.719 + TARGET=$DISTRO 1.720 + fi 1.721 + # Exit if existing distro is found. 1.722 + if [ -d "$TARGET/rootfs" ] ; then 1.723 + echo -e "\nA rootfs exists in : $TARGET" 1.724 + echo -e "Please clean the distro tree or change directory path.\n" 1.725 + exit 0 1.726 + fi 1.727 + echo "" 1.728 + echo -e "\033[1mTazlito extracting :\033[0m `basename $ISO_IMAGE`" 1.729 + echo "================================================================================" 1.730 + # Start to mount the ISO. 1.731 + echo "" 1.732 + echo "Mounting ISO image..." 1.733 + mkdir -p $TMP_DIR 1.734 + # Get ISO file size. 1.735 + isosize=`du -sh $ISO_IMAGE | cut -f1` 1.736 + mount -o loop $ISO_IMAGE $TMP_DIR 1.737 + sleep 2 1.738 + # Prepare target dir, copy the kernel and the rootfs. 1.739 + mkdir -p $TARGET/rootfs 1.740 + mkdir -p $TARGET/rootcd/boot 1.741 + echo -n "Copying the Linux kernel..." 1.742 + if cp $TMP_DIR/boot/vmlinuz* $TARGET/rootcd/boot 2> /dev/null; then 1.743 + ln $TARGET/rootcd/boot/vmlinuz* $TARGET/rootcd/boot/bzImage 1.744 + else 1.745 + cp $TMP_DIR/boot/bzImage $TARGET/rootcd/boot 1.746 + fi 1.747 + status 1.748 + echo -n "Copying isolinux files..." 1.749 + cp -a $TMP_DIR/boot/isolinux $TARGET/rootcd/boot 1.750 + for i in $(ls $TMP_DIR); do 1.751 + [ "$i" = "boot" ] && continue 1.752 + cp -a $TMP_DIR/$i $TARGET/rootcd 1.753 + done 1.754 + status 1.755 + if [ -d $TMP_DIR/boot/syslinux ]; then 1.756 + echo -n "Copying syslinux files..." 1.757 + cp -a $TMP_DIR/boot/syslinux $TARGET/rootcd/boot 1.758 + status 1.759 + fi 1.760 + if [ -d $TMP_DIR/boot/extlinux ]; then 1.761 + echo -n "Copying extlinux files..." 1.762 + cp -a $TMP_DIR/boot/extlinux $TARGET/rootcd/boot 1.763 + status 1.764 + fi 1.765 + if [ -d $TMP_DIR/boot/grub ]; then 1.766 + echo -n "Copying GRUB files..." 1.767 + cp -a $TMP_DIR/boot/grub $TARGET/rootcd/boot 1.768 + status 1.769 + fi 1.770 + 1.771 + echo -n "Copying the rootfs..." 1.772 + cp $TMP_DIR/boot/rootfs.?z $TARGET/rootcd/boot 1.773 + status 1.774 + # Extract initramfs. 1.775 + cd $TARGET/rootfs 1.776 + echo -n "Extracting the rootfs... " 1.777 + extract_rootfs ../rootcd/boot/rootfs.gz $TARGET/rootfs 1.778 + # unpack /usr 1.779 + for i in etc/tazlito/*.extract; do 1.780 + [ -f "$i" ] && . $i ../rootcd 1.781 + done 1.782 + # Umount and remove temp directory and cd to $TARGET to get stats. 1.783 + umount $TMP_DIR && rm -rf $TMP_DIR 1.784 + cd .. 1.785 + echo "" 1.786 + echo "================================================================================" 1.787 + echo "Extracted : `basename $ISO_IMAGE` ($isosize)" 1.788 + echo "Distro tree : `pwd`" 1.789 + echo "Rootfs size : `du -sh rootfs`" 1.790 + echo "Rootcd size : `du -sh rootcd`" 1.791 + echo "================================================================================" 1.792 + echo "" 1.793 + ;; 1.794 + list-flavors) 1.795 + # Show available flavors. 1.796 + if [ ! -s /etc/tazlito/flavors.list -o "$2" == "--recharge" ]; then 1.797 + download flavors.list -O - > /etc/tazlito/flavors.list 1.798 + fi 1.799 + echo "" 1.800 + echo -e "\033[1mList of flavors\033[0m" 1.801 + echo "================================================================================" 1.802 + cat /etc/tazlito/flavors.list 1.803 + echo "" 1.804 + ;; 1.805 + show-flavor) 1.806 + # Show flavor description. 1.807 + FLAVOR=${2%.flavor} 1.808 + if [ ! -f "$FLAVOR.flavor" ]; then 1.809 + echo "File $FLAVOR.flavor not found." 1.810 + exit 1 1.811 + fi 1.812 + mkdir $TMP_DIR 1.813 + zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i 2> /dev/null) 1.814 + if [ "$3" = "--brief" ]; then 1.815 + if [ "$4" != "--noheader" ]; then 1.816 + echo "Name ISO Rootfs Description" 1.817 + echo "================================================================================" 1.818 + fi 1.819 + printf "%-16.16s %6.6s %6.6s %s\n" "$FLAVOR" \ 1.820 + "$(field ISO $TMP_DIR/$FLAVOR.desc)" \ 1.821 + "$(field 'Rootfs size' $TMP_DIR/$FLAVOR.desc)" \ 1.822 + "$(grep ^Description $TMP_DIR/$FLAVOR.desc | cut -d: -f2)" 1.823 + else 1.824 + echo "================================================================================" 1.825 + cat $TMP_DIR/$FLAVOR.desc 1.826 + fi 1.827 + rm -Rf $TMP_DIR 1.828 + ;; 1.829 + gen-liveflavor) 1.830 + # Generate a new flavor form the live system. 1.831 + FLAVOR=${2%.flavor} 1.832 + DESC="" 1.833 + case "$FLAVOR" in 1.834 + '') echo -n "Flavor name : " 1.835 + read FLAVOR 1.836 + [ -z "$FLAVOR" ] && exit 1;; 1.837 + -?|-h*|--help) echo -e " 1.838 + 1.839 +SliTaz Live Tool - Version: $VERSION 1.840 +\033[1mUsage: \033[0m `basename $0` gen-liveflavor flavor-name [flavor-patch-file] 1.841 +\033[1mflavor-patch-file format: \033[0m 1.842 +code data 1.843 ++ package to add 1.844 +- package to remove 1.845 +! non-free package to add 1.846 +? display message 1.847 +@ flavor description 1.848 + 1.849 +\033[1mExample: \033[0m 1.850 +@ Developer tools for slitaz maintainers 1.851 ++ slitaz-toolchain 1.852 ++ mercurial 1.853 +" 1.854 + exit 1;; 1.855 + esac 1.856 + mv /etc/tazlito/distro-packages.list \ 1.857 + /etc/tazlito/distro-packages.list.$$ 2> /dev/null 1.858 + rm -f distro-packages.list non-free.list 2> /dev/null 1.859 + tazpkg recharge 1.860 + [ -n "$3" ] && while read action pkg; do 1.861 + case "$action" in 1.862 + +) yes | tazpkg get-install $pkg;; 1.863 + -) yes | tazpkg remove $pkg;; 1.864 + !) echo $pkg >> non-free.list;; 1.865 + @) DESC="$pkg";; 1.866 + \?) echo -en "$pkg"; read action;; 1.867 + esac 1.868 + done < $3 1.869 + yes '' | tazlito gen-distro 1.870 + echo "$DESC" | tazlito gen-flavor "$FLAVOR" 1.871 + mv /etc/tazlito/distro-packages.list.$$ \ 1.872 + /etc/tazlito/distro-packages.list 2> /dev/null 1.873 + ;; 1.874 + gen-flavor) 1.875 + # Generate a new flavor from the last iso image generated. 1.876 + FLAVOR=${2%.flavor} 1.877 + echo "" 1.878 + echo -e "\033[1mFlavor generation\033[0m" 1.879 + echo "================================================================================" 1.880 + if [ -z "$FLAVOR" ]; then 1.881 + echo -n "Flavor name : " 1.882 + read FLAVOR 1.883 + [ -z "$FLAVOR" ] && exit 1 1.884 + fi 1.885 + check_rootfs 1.886 + FILES="$FLAVOR.pkglist" 1.887 + echo -n "Creating file $FLAVOR.flavor..." 1.888 + for i in rootcd rootfs; do 1.889 + if [ -d "$ADDFILES/$i" ] ; then 1.890 + FILES="$FILES\n$FLAVOR.$i" 1.891 + ( cd "$ADDFILES/$i"; find . | \ 1.892 + cpio -o -H newc 2> /dev/null | gzip -9 ) > $FLAVOR.$i 1.893 + fi 1.894 + done 1.895 + status 1.896 + answer=`grep -s ^Description $FLAVOR.desc` 1.897 + answer=${answer#Description : } 1.898 + if [ -z "$answer" ]; then 1.899 + echo -n "Description : " 1.900 + read answer 1.901 + fi 1.902 + echo -n "Compressing flavor $FLAVOR..." 1.903 + echo "Flavor : $FLAVOR" > $FLAVOR.desc 1.904 + echo "Description : $answer" >> $FLAVOR.desc 1.905 + ( cd $DISTRO; distro_sizes) >> $FLAVOR.desc 1.906 + \rm -f $FLAVOR.pkglist $FLAVOR.nonfree 2> /dev/null 1.907 + for i in $(ls $ROOTFS$INSTALLED); do 1.908 + eval $(grep ^VERSION= $ROOTFS$INSTALLED/$i/receipt) 1.909 + EXTRAVERSION="" 1.910 + eval $(grep ^EXTRAVERSION= $ROOTFS$INSTALLED/$i/receipt) 1.911 + eval $(grep ^CATEGORY= $ROOTFS$INSTALLED/$i/receipt) 1.912 + if [ "$CATEGORY" = "non-free" -a "${i%%-*}" != "get" ] 1.913 + then 1.914 + echo "$i" >> $FLAVOR.nonfree 1.915 + else 1.916 + echo "$i-$VERSION$EXTRAVERSION" >> $FLAVOR.pkglist 1.917 + fi 1.918 + done 1.919 + [ -s $FLAVOR.nonfree ] && $FILES="$FILES\n$FLAVOR.nonfree" 1.920 + for i in $LOCALSTATE/undigest/*/mirror ; do 1.921 + [ -s $i ] && cat $i >> $FLAVOR.mirrors 1.922 + done 1.923 + [ -s $FLAVOR.mirrors ] && $FILES="$FILES\n$FLAVOR.mirrors" 1.924 + echo -e "$FLAVOR.desc\n$FILES" | cpio -o -H newc 2>/dev/null | \ 1.925 + gzip -9 > $FLAVOR.flavor 1.926 + rm `echo -e $FILES` 1.927 + status 1.928 + echo "================================================================================" 1.929 + echo "Flavor size : `du -sh $FLAVOR.flavor`" 1.930 + echo "" 1.931 + ;; 1.932 + upgrade-flavor) 1.933 + # Update package list to the lastest versions available. 1.934 + FLAVOR=${2%.flavor} 1.935 + if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then 1.936 + mkdir $TMP_DIR 1.937 + zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i >/dev/null ) 1.938 + echo -n "Updating $FLAVOR package list..." 1.939 + [ -s /var/lib/tazpkg/packages.list ] || tazpkg recharge 1.940 + packed_size=0; unpacked_size=0 1.941 + while read org; do 1.942 + i=0 1.943 + pkg=$org 1.944 + while ! grep -q ^$pkg$ /var/lib/tazpkg/packages.txt; do 1.945 + pkg=${pkg%-*} 1.946 + i=$(($i + 1)) 1.947 + [ $i -gt 5 ] && break; 1.948 + done 1.949 + set -- $(get_size $pkg) 1.950 + packed_size=$(( $packed_size + $1 )) 1.951 + unpacked_size=$(( $unpacked_size + $2 )) 1.952 + for i in $(grep ^$pkg /var/lib/tazpkg/packages.list); do 1.953 + echo $i 1.954 + break 1.955 + done 1.956 + done < $TMP_DIR/$FLAVOR.pkglist \ 1.957 + > $TMP_DIR/$FLAVOR.pkglist.$$ 1.958 + mv -f $TMP_DIR/$FLAVOR.pkglist.$$ $TMP_DIR/$FLAVOR.pkglist 1.959 + if [ -s $TMP_DIR/$FLAVOR.rootfs ]; then 1.960 + packed_size=$(($packed_size \ 1.961 + + $(cat $TMP_DIR/$FLAVOR.rootfs | wc -c ) / 100 )) 1.962 + unpacked_size=$(($unpacked_size \ 1.963 + + $(zcat $TMP_DIR/$FLAVOR.rootfs | wc -c ) / 100 )) 1.964 + fi 1.965 + # Estimate lzma 1.966 + packed_size=$(($packed_size * 2 / 3)) 1.967 + iso_size=$(( $packed_size + 26000 )) 1.968 + if [ -s $TMP_DIR/$FLAVOR.rootcd ]; then 1.969 + iso_size=$(($iso_size \ 1.970 + + $(zcat $TMP_DIR/$FLAVOR.rootcd | wc -c ) / 100 )) 1.971 + fi 1.972 + sed -i -e '/Image is ready/d' \ 1.973 + -e "s/Rootfs size\( *:\) \(.*\)/Rootfs size\1 $(cent2human $unpacked_size) (estimated)/" \ 1.974 + -e "s/Initramfs size\( *:\) \(.*\)/Initramfs size\1 $(cent2human $packed_size) (estimated)/" \ 1.975 + -e "s/ISO image size\( *:\) \(.*\)/ISO image size\1 $(cent2human $iso_size) (estimated)/" \ 1.976 + -e "s/date\( *:\) \(.*\)/date\1 $(date +%Y%m%d\ \at\ \%H:%M:%S)/" \ 1.977 + $TMP_DIR/$FLAVOR.desc 1.978 + ( cd $TMP_DIR ; ls | cpio -o -H newc ) | gzip -9 > \ 1.979 + $FLAVOR.flavor 1.980 + status 1.981 + rm -Rf $TMP_DIR 1.982 + fi 1.983 + ;; 1.984 + extract-flavor) 1.985 + # Extract a flavor into $FLAVORS_REPOSITORY. 1.986 + FLAVOR=${2%.flavor} 1.987 + if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then 1.988 + mkdir $TMP_DIR 1.989 + zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i >/dev/null ) 1.990 + echo -n "Extracting $FLAVOR..." 1.991 + rm -rf $FLAVORS_REPOSITORY/$FLAVOR 2> /dev/null 1.992 + mkdir -p $FLAVORS_REPOSITORY/$FLAVOR 1.993 + echo "FLAVOR=\"$FLAVOR\"" > $FLAVORS_REPOSITORY/$FLAVOR/receipt 1.994 + grep ^Description $TMP_DIR/$FLAVOR.desc | \ 1.995 + sed 's/.*: \(.*\)$/SHORT_DESC="\1"/' >> \ 1.996 + $FLAVORS_REPOSITORY/$FLAVOR/receipt 1.997 + grep -q '^Rootfs list' $TMP_DIR/$FLAVOR.desc && \ 1.998 + grep '^Rootfs list' $TMP_DIR/$FLAVOR.desc | \ 1.999 + sed 's/.*: \(.*\)$/ROOTFS_SELECTION="\1"/' >> \ 1.1000 + $FLAVORS_REPOSITORY/$FLAVOR/receipt 1.1001 + grep '^Rootfs size' $TMP_DIR/$FLAVOR.desc | \ 1.1002 + sed 's/.*: \(.*\)$/ROOTFS_SIZE="\1"/' >> \ 1.1003 + $FLAVORS_REPOSITORY/$FLAVOR/receipt 1.1004 + grep ^Initramfs $TMP_DIR/$FLAVOR.desc | \ 1.1005 + sed 's/.*: \(.*\)$/INITRAMFS_SIZE="\1"/' >> \ 1.1006 + $FLAVORS_REPOSITORY/$FLAVOR/receipt 1.1007 + grep ^ISO $TMP_DIR/$FLAVOR.desc | \ 1.1008 + sed 's/.*: \(.*\)$/ISO_SIZE="\1"/' >> \ 1.1009 + $FLAVORS_REPOSITORY/$FLAVOR/receipt 1.1010 + for i in rootcd rootfs; do 1.1011 + [ -f $TMP_DIR/$FLAVOR.$i ] || continue 1.1012 + mkdir $FLAVORS_REPOSITORY/$FLAVOR/$i 1.1013 + zcat $TMP_DIR/$FLAVOR.$i | \ 1.1014 + (cd $FLAVORS_REPOSITORY/$FLAVOR/$i; \ 1.1015 + cpio -idm > /dev/null) 1.1016 + done 1.1017 + [ -s $TMP_DIR/$FLAVOR.mirrors ] && 1.1018 + cp $TMP_DIR/$FLAVOR.mirrors \ 1.1019 + $FLAVORS_REPOSITORY/$FLAVOR/mirrors 1.1020 + [ -s /var/lib/tazpkg/packages.list ] || tazpkg recharge 1.1021 + while read org; do 1.1022 + i=0 1.1023 + pkg=$org 1.1024 + while ! grep -q ^$pkg$ /var/lib/tazpkg/packages.txt; do 1.1025 + pkg=${pkg%-*} 1.1026 + i=$(($i + 1)) 1.1027 + [ $i -gt 5 ] && break; 1.1028 + done 1.1029 + echo $pkg 1.1030 + done < $TMP_DIR/$FLAVOR.pkglist \ 1.1031 + > $FLAVORS_REPOSITORY/$FLAVOR/packages.list 1.1032 + status 1.1033 + rm -Rf $TMP_DIR 1.1034 + fi 1.1035 + ;; 1.1036 + pack-flavor) 1.1037 + # Create a flavor from $FLAVORS_REPOSITORY. 1.1038 + FLAVOR=${2%.flavor} 1.1039 + if [ -s $FLAVORS_REPOSITORY/$FLAVOR/receipt ]; then 1.1040 + mkdir $TMP_DIR 1.1041 + echo -n "Creating flavor $FLAVOR..." 1.1042 + [ -s /var/lib/tazpkg/packages.list ] || tazpkg recharge 1.1043 + if [ -s $FLAVORS_REPOSITORY/$FLAVOR/mirrors ]; then 1.1044 + cp $FLAVORS_REPOSITORY/$FLAVOR/mirrors \ 1.1045 + $TMP_DIR/$FLAVOR.mirrors 1.1046 + for i in $(cat $TMP_DIR/$FLAVOR.mirrors); do 1.1047 + wget -O - $i/packages.list >> $TMP_DIR/packages.list 1.1048 + done 1.1049 + fi 1.1050 + [ -s $FLAVORS_REPOSITORY/$FLAVOR/packages.list ] && 1.1051 + get_pkglist $FLAVOR > $TMP_DIR/$FLAVOR.pkglist 1.1052 + if grep -q ^ROOTFS_SELECTION \ 1.1053 + $FLAVORS_REPOSITORY/$FLAVOR/receipt; then 1.1054 + . $FLAVORS_REPOSITORY/$FLAVOR/receipt 1.1055 + set -- $ROOTFS_SELECTION 1.1056 + [ -n "$FRUGAL_RAM" ] || FRUGAL_RAM=$1 1.1057 + [ -f $FLAVORS_REPOSITORY/$2/packages.list ] || 1.1058 + tazlito extract-flavor $2 1.1059 + get_pkglist $2 > $TMP_DIR/$FLAVOR.pkglist 1.1060 + fi 1.1061 + for i in rootcd rootfs; do 1.1062 + [ -d $FLAVORS_REPOSITORY/$FLAVOR/$i ] || \ 1.1063 + continue 1.1064 + ( cd $FLAVORS_REPOSITORY/$FLAVOR/$i ; find . | \ 1.1065 + cpio -o -H newc 2> /dev/null ) | \ 1.1066 + gzip -9 >$TMP_DIR/$FLAVOR.$i 1.1067 + done 1.1068 + if [ -s $TMP_DIR/$FLAVOR.rootfs ]; then 1.1069 + packed_size=$(($packed_size \ 1.1070 + + $(cat $TMP_DIR/$FLAVOR.rootfs | wc -c ) / 100 )) 1.1071 + unpacked_size=$(($unpacked_size \ 1.1072 + + $(zcat $TMP_DIR/$FLAVOR.rootfs | wc -c ) / 100 )) 1.1073 + fi 1.1074 + # Estimate lzma 1.1075 + packed_size=$(($packed_size * 2 / 3)) 1.1076 + iso_size=$(( $packed_size + 26000 )) 1.1077 + if [ -s $TMP_DIR/$FLAVOR.rootcd ]; then 1.1078 + iso_size=$(($iso_size \ 1.1079 + + $(zcat $TMP_DIR/$FLAVOR.rootcd | wc -c ) / 100 )) 1.1080 + fi 1.1081 + VERSION="" 1.1082 + MAINTAINER="" 1.1083 + ROOTFS_SELECTION="" 1.1084 + ROOTFS_SIZE="$(cent2human $unpacked_size) (estimated)" 1.1085 + INITRAMFS_SIZE="$(cent2human $packed_size) (estimated)" 1.1086 + ISO_SIZE="$(cent2human $iso_size) (estimated)" 1.1087 + . $FLAVORS_REPOSITORY/$FLAVOR/receipt 1.1088 + cat > $TMP_DIR/$FLAVOR.desc <<EOT 1.1089 +Flavor : $FLAVOR 1.1090 +Description : $SHORT_DESC 1.1091 +EOT 1.1092 + [ -n "$VERSION" ] && cat >> $TMP_DIR/$FLAVOR.desc <<EOT 1.1093 +Version : $VERSION 1.1094 +EOT 1.1095 + [ -n "$MAINTAINER" ] && cat >> $TMP_DIR/$FLAVOR.desc <<EOT 1.1096 +Maintainer : $MAINTAINER 1.1097 +EOT 1.1098 + [ -n "$FRUGAL_RAM" ] && cat >> $TMP_DIR/$FLAVOR.desc <<EOT 1.1099 +LiveCD RAM size : $FRUGAL_RAM 1.1100 +EOT 1.1101 + [ -n "$ROOTFS_SELECTION" ] && cat >> $TMP_DIR/$FLAVOR.desc <<EOT 1.1102 +Rootfs list : $ROOTFS_SELECTION 1.1103 +EOT 1.1104 + cat >> $TMP_DIR/$FLAVOR.desc <<EOT 1.1105 +Build date : $(date +%Y%m%d\ \at\ \%H:%M:%S) 1.1106 +Packages : $(grep -v ^# $TMP_DIR/$FLAVOR.pkglist | wc -l) 1.1107 +Rootfs size : $ROOTFS_SIZE 1.1108 +Initramfs size : $INITRAMFS_SIZE 1.1109 +ISO image size : $ISO_SIZE 1.1110 +================================================================================ 1.1111 + 1.1112 +EOT 1.1113 + rm -f $TMP_DIR/packages.list 1.1114 + ( cd $TMP_DIR ; ls | cpio -o -H newc 2> /dev/null) | \ 1.1115 + gzip -9 > $FLAVOR.flavor 1.1116 + status 1.1117 + rm -Rf $TMP_DIR 1.1118 + else 1.1119 + echo "No $FLAVOR flavor in $FLAVORS_REPOSITORY." 1.1120 + fi 1.1121 + ;; 1.1122 + get-flavor) 1.1123 + # Get a flavor's files and prepare for gen-distro. 1.1124 + FLAVOR=${2%.flavor} 1.1125 + echo "" 1.1126 + if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then 1.1127 + echo -n "Cleaning $DISTRO..." 1.1128 + rm -R $DISTRO 2> /dev/null 1.1129 + mkdir -p $DISTRO 1.1130 + status 1.1131 + mkdir $TMP_DIR 1.1132 + echo -n "Extracting flavor $FLAVOR.flavor... " 1.1133 + zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i 2>/dev/null ) 1.1134 + echo -n "Creating distro-packages.list..." 1.1135 + mv $TMP_DIR/$FLAVOR.nonfree non-free.list 2> /dev/null 1.1136 + mv $TMP_DIR/$FLAVOR.pkglist distro-packages.list 1.1137 + status 1.1138 + for i in rootcd rootfs; do 1.1139 + if [ -f $TMP_DIR/$FLAVOR.$i ]; then 1.1140 + echo -n "Adding $i... " 1.1141 + mkdir -p "$ADDFILES/$i" 1.1142 + zcat $TMP_DIR/$FLAVOR.$i | \ 1.1143 + ( cd "$ADDFILES/$i"; cpio -id 2> /dev/null) 1.1144 + fi 1.1145 + done 1.1146 + if [ -s $TMP_DIR/$FLAVOR.mirrors ]; then 1.1147 + n="" 1.1148 + while read line; do 1.1149 + mkdir -p $LOCALSTATE/undigest/$FLAVOR$n 1.1150 + echo "$line" > $LOCALSTATE/undigest/$FLAVOR$n/mirror 1.1151 + n=$(( $n + 1 )) 1.1152 + done < $TMP_DIR/$FLAVOR.mirrors 1.1153 + tazpkg recharge 1.1154 + fi 1.1155 + rm -f /etc/tazlito/rootfs.list 1.1156 + grep -q '^Rootfs list' $TMP_DIR/$FLAVOR.desc && 1.1157 + grep '^Rootfs list' $TMP_DIR/$FLAVOR.desc | \ 1.1158 + sed 's/.*: \(.*\)$/\1/' > /etc/tazlito/rootfs.list 1.1159 + echo -n "Updating tazlito.conf..." 1.1160 + [ -f tazlito.conf ] || cp /etc/tazlito/tazlito.conf . 1.1161 + cat tazlito.conf | grep -v "^#VOLUM_NAME" | \ 1.1162 + sed "s/^VOLUM_NA/VOLUM_NAME=\"SliTaz $FLAVOR\"\\n#VOLUM_NA/" \ 1.1163 + > tazlito.conf.$$ && mv tazlito.conf.$$ tazlito.conf 1.1164 + sed -i "s/ISO_NAME=.*/ISO_NAME=\"slitaz-$FLAVOR\"/" tazlito.conf 1.1165 + status 1.1166 + rm -Rf $TMP_DIR 1.1167 + fi 1.1168 + echo "" 1.1169 + ;; 1.1170 + check-list) 1.1171 + # Use current packages list in $PWD by default. 1.1172 + DISTRO_PKGS_LIST=distro-packages.list 1.1173 + [ -d "$2" ] && DISTRO_PKGS_LIST=$2/distro-packages.list 1.1174 + [ -f "$2" ] && DISTRO_PKGS_LIST=$2 1.1175 + [ ! -f $DISTRO_PKGS_LIST ] && echo "No packages list found." && exit 0 1.1176 + echo "" 1.1177 + echo -e "\033[1mLiveCD packages list check\033[0m" 1.1178 + echo "================================================================================" 1.1179 + for pkg in `cat $DISTRO_PKGS_LIST` 1.1180 + do 1.1181 + if ! grep -q "$pkg" /var/lib/tazpkg/packages.list; then 1.1182 + echo "Update: $pkg" 1.1183 + up=$(($up + 1)) 1.1184 + fi 1.1185 + done 1.1186 + [ -z $up ] && echo -e "List is up-to-date\n" && exit 0 1.1187 + echo "================================================================================" 1.1188 + echo -e "Updates: $up\n" ;; 1.1189 + gen-distro) 1.1190 + # Generate a live distro tree with a set of packages. 1.1191 + # 1.1192 + check_root 1.1193 + 1.1194 + # Check if a package list was specified on cmdline. 1.1195 + LIST_NAME="distro-packages.list" 1.1196 + CDROM="" 1.1197 + while [ -n "$2" ]; do 1.1198 + case "$2" in 1.1199 + --iso=*) 1.1200 + CDROM="-o loop ${2#--iso=}" 1.1201 + ;; 1.1202 + --cdrom) 1.1203 + CDROM="/dev/cdrom" 1.1204 + ;; 1.1205 + --force) 1.1206 + DELETE_ROOTFS="true" 1.1207 + ;; 1.1208 + *) if [ ! -f "$2" ] ; then 1.1209 + echo -e "\nUnable to find the specified packages list." 1.1210 + echo -e "List name : $2\n" 1.1211 + exit 1 1.1212 + fi 1.1213 + LIST_NAME=$2 1.1214 + ;; 1.1215 + esac 1.1216 + shift 1.1217 + done 1.1218 + 1.1219 + if [ -d $ROOTFS ] ; then 1.1220 + # Delete $ROOTFS if --force is set on command line 1.1221 + if [ ! -z $DELETE_ROOTFS ]; then 1.1222 + rm -rf $ROOTFS 1.1223 + unset $DELETE_ROOTFS 1.1224 + else 1.1225 + echo -e "\nA rootfs exists in : $DISTRO" 1.1226 + echo -e "Please clean the distro tree or change directory path.\n" 1.1227 + exit 0 1.1228 + fi 1.1229 + fi 1.1230 + if [ ! -f "$LIST_NAME" -a -d $INSTALLED ] ; then 1.1231 + # Build list with installed packages 1.1232 + for i in $(ls $INSTALLED); do 1.1233 + eval $(grep ^VERSION= $INSTALLED/$i/receipt) 1.1234 + EXTRAVERSION="" 1.1235 + eval $(grep ^EXTRAVERSION= $INSTALLED/$i/receipt) 1.1236 + echo "$i-$VERSION$EXTRAVERSION" >> $LIST_NAME 1.1237 + done 1.1238 + fi 1.1239 + # Exit if no list name. 1.1240 + if [ ! -f "$LIST_NAME" ]; then 1.1241 + echo -e "\nNo packages list found or specified. Please read the docs.\n" 1.1242 + exit 0 1.1243 + fi 1.1244 + # Start generation. 1.1245 + echo "" 1.1246 + echo -e "\033[1mTazlito generating a distro\033[0m" 1.1247 + echo "================================================================================" 1.1248 + # Misc checks 1.1249 + [ -n "$PACKAGES_REPOSITORY" ] || PACKAGES_REPOSITORY="." 1.1250 + [ -d $PACKAGES_REPOSITORY ] || mkdir -p $PACKAGES_REPOSITORY 1.1251 + # Get the list of packages using cat for a file list. 1.1252 + LIST=`cat $LIST_NAME` 1.1253 + # Verify if all packages in list are present in $PACKAGES_REPOSITORY. 1.1254 + REPACK="" 1.1255 + DOWNLOAD="" 1.1256 + for pkg in $LIST 1.1257 + do 1.1258 + [ "$pkg" = "" ] && continue 1.1259 + pkg=${pkg%.tazpkg} 1.1260 + [ -f $PACKAGES_REPOSITORY/$pkg.tazpkg ] && continue 1.1261 + PACKAGE=$(installed_package_name $pkg) 1.1262 + [ -n "$PACKAGE" -a "$REPACK" = "y" ] && continue 1.1263 + [ -z "$PACKAGE" -a -n "$DOWNLOAD" ] && continue 1.1264 + echo -e "\nUnable to find $pkg in the repository." 1.1265 + echo -e "Path : $PACKAGES_REPOSITORY\n" 1.1266 + if [ -n "$PACKAGE" -a -z "$REPACK" ]; then 1.1267 + yesorno "Repack packages from rootfs (y/N) ? " 1.1268 + REPACK="$answer" 1.1269 + [ "$answer" = "y" ] || REPACK="n" 1.1270 + [ "$DOWNLOAD" = "y" ] && break 1.1271 + fi 1.1272 + if [ -f $MIRROR -a -z "$DOWNLOAD" ]; then 1.1273 + yesorno "Download packages from mirror (Y/n) ? " 1.1274 + DOWNLOAD="$answer" 1.1275 + if [ "$answer" = "n" ]; then 1.1276 + [ -z "$PACKAGE" ] && exit 1 1.1277 + else 1.1278 + DOWNLOAD="y" 1.1279 + [ -n "$REPACK" ] && break 1.1280 + fi 1.1281 + fi 1.1282 + [ "$REPACK" = "n" -a "$DOWNLOAD" = "n" ] && exit 1 1.1283 + done 1.1284 + 1.1285 + # Mount cdrom to be able to repack boot-loader packages 1.1286 + if [ ! -e /boot -a -n "$CDROM" ]; then 1.1287 + mkdir $TMP_MNT 1.1288 + if mount -r $CDROM $TMP_MNT 2> /dev/null; then 1.1289 + ln -s $TMP_MNT/boot / 1.1290 + if [ ! -d "$ADDFILES/rootcd" ] ; then 1.1291 + mkdir -p $ADDFILES/rootcd 1.1292 + for i in $(ls $TMP_MNT); do 1.1293 + [ "$i" = "boot" ] && continue 1.1294 + cp -a $TMP_MNT/$i $ADDFILES/rootcd 1.1295 + done 1.1296 + fi 1.1297 + else 1.1298 + rmdir $TMP_MNT 1.1299 + fi 1.1300 + fi 1.1301 + 1.1302 + # Root fs stuff. 1.1303 + echo "Preparing the rootfs directory..." 1.1304 + mkdir -p $ROOTFS 1.1305 + sleep 2 1.1306 + for pkg in $LIST 1.1307 + do 1.1308 + [ "$pkg" = "" ] && continue 1.1309 + # First copy and extract the package in tmp dir. 1.1310 + pkg=${pkg%.tazpkg} 1.1311 + PACKAGE=$(installed_package_name $pkg) 1.1312 + mkdir -p $TMP_DIR 1.1313 + if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then 1.1314 + # Look for package in cache 1.1315 + if [ -f $CACHE_DIR/$pkg.tazpkg ]; then 1.1316 + ln -s $CACHE_DIR/$pkg.tazpkg $PACKAGES_REPOSITORY 1.1317 + # Look for package in running distribution 1.1318 + elif [ -n "$PACKAGE" -a "$REPACK" = "y" ]; then 1.1319 + tazpkg repack $PACKAGE && \ 1.1320 + mv $pkg.tazpkg $PACKAGES_REPOSITORY 1.1321 + fi 1.1322 + fi 1.1323 + if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then 1.1324 + # Get package from mirror 1.1325 + [ "$DOWNLOAD" = "y" ] && \ 1.1326 + download $pkg.tazpkg && \ 1.1327 + mv $pkg.tazpkg $PACKAGES_REPOSITORY 1.1328 + fi 1.1329 + if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then 1.1330 + echo "Missing package $pkg." 1.1331 + cleanup 1.1332 + exit 1 1.1333 + fi 1.1334 + done 1.1335 + if [ -f non-free.list ]; then 1.1336 + echo "Preparing non-free packages..." 1.1337 + cp non-free.list $ROOTFS/etc/tazlito/non-free.list 1.1338 + for pkg in $(cat non-free.list); do 1.1339 + if [ ! -d $INSTALLED/$pkg ]; then 1.1340 + if [ ! -d $INSTALLED/get-$pkg ]; then 1.1341 + tazpkg get-install get-$pkg 1.1342 + fi 1.1343 + get-$pkg 1.1344 + fi 1.1345 + tazpkg repack $pkg 1.1346 + pkg=$(ls $pkg*.tazpkg) 1.1347 + grep -q "^$pkg$" $LIST_NAME || \ 1.1348 + echo $pkg >>$LIST_NAME 1.1349 + mv $pkg $PACKAGES_REPOSITORY 1.1350 + done 1.1351 + fi 1.1352 + echo "" 1.1353 + cp $LIST_NAME $DISTRO/distro-packages.list 1.1354 + sed 's/\(.*\)/\1.tazpkg/' < $DISTRO/distro-packages.list > $DISTRO/list-packages 1.1355 + cd $PACKAGES_REPOSITORY 1.1356 + yes y | tazpkg install-list \ 1.1357 + $DISTRO/list-packages --root=$ROOTFS 1.1358 + cd $DISTRO 1.1359 + cp distro-packages.list $ROOTFS/etc/tazlito 1.1360 + # Copy all files from $ADDFILES/rootfs to the rootfs. 1.1361 + if [ -d "$ADDFILES/rootfs" ] ; then 1.1362 + echo -n "Copying addfiles content to the rootfs... " 1.1363 + cp -a $ADDFILES/rootfs/* $ROOTFS 1.1364 + status 1.1365 + fi 1.1366 + echo "Root file system is generated..." 1.1367 + # Root CD part. 1.1368 + echo -n "Preparing the rootcd directory..." 1.1369 + mkdir -p $ROOTCD 1.1370 + status 1.1371 + # Move the boot dir with the Linux kernel from rootfs. 1.1372 + # The boot dir goes directly on the CD. 1.1373 + if [ -d "$ROOTFS/boot" ] ; then 1.1374 + echo -n "Moving the boot directory..." 1.1375 + mv $ROOTFS/boot $ROOTCD 1.1376 + cd $ROOTCD/boot 1.1377 + ln vmlinuz-* bzImage 1.1378 + status 1.1379 + fi 1.1380 + cd $DISTRO 1.1381 + # Copy all files from $ADDFILES/rootcd to the rootcd. 1.1382 + if [ -d "$ADDFILES/rootcd" ] ; then 1.1383 + echo -n "Copying addfiles content to the rootcd... " 1.1384 + cp -a $ADDFILES/rootcd/* $ROOTCD 1.1385 + status 1.1386 + fi 1.1387 + # Execute the distro script (used to perform tasks in the rootfs 1.1388 + # before compression. Give rootfs path in arg 1.1389 + [ -z $DISTRO_SCRIPT ] && DISTRO_SCRIPT=$TOP_DIR/distro.sh 1.1390 + if [ -x $DISTRO_SCRIPT ]; then 1.1391 + echo "Executing distro script..." 1.1392 + sh $DISTRO_SCRIPT $DISTRO 1.1393 + fi 1.1394 + if [ -s /etc/tazlito/rootfs.list ]; then 1.1395 + [ -f $ROOTCD/boot/isolinux/ifmem.c32 ] || 1.1396 + cp /boot/isolinux/ifmem.c32 $ROOTCD/boot/isolinux 1.1397 + n=0 1.1398 + last=$ROOTFS 1.1399 + while read flavor; do 1.1400 + n=$(($n+1)) 1.1401 + echo "Building $flavor rootfs..." 1.1402 + download $flavor.flavor 1.1403 + zcat $flavor.flavor | cpio -i $flavor.pkglist 1.1404 + sed 's/.*/&.tazpkg/' < $flavor.pkglist \ 1.1405 + > $DISTRO/list-packages0$n 1.1406 + mkdir ${ROOTFS}0$n 1.1407 + cd $PACKAGES_REPOSITORY 1.1408 + yes y | tazpkg install-list \ 1.1409 + $DISTRO/list-packages0$n --root=${ROOTFS}0$n 1.1410 + rm -rf ${ROOTFS}0$n/boot 1.1411 + status 1.1412 + cd $DISTRO 1.1413 + mv $flavor.pkglist ${ROOTFS}0$n/etc/tazlito/distro-packages.list 1.1414 + rm -f $flavor.flavor install-list 1.1415 + mergefs ${ROOTFS}0$n $last 1.1416 + last=${ROOTFS}0$n 1.1417 + done <<EOT 1.1418 +$(awk '{ for (i = 4; i <= NF; i+=2) print $i; }' < /etc/tazlito/rootfs.list) 1.1419 +EOT 1.1420 + i=$(($n+1)) 1.1421 + while [ $n -gt 0 ]; do 1.1422 + mv ${ROOTFS}0$n ${ROOTFS}$i 1.1423 + echo "Compression ${ROOTFS}0$n ($(du -hs ${ROOTFS}$i | awk '{ print $1 }')) ..." 1.1424 + gen_initramfs ${ROOTFS}$i 1.1425 + n=$(($n-1)) 1.1426 + i=$(($i-1)) 1.1427 + done 1.1428 + mv $ROOTFS ${ROOTFS}$i 1.1429 + gen_initramfs ${ROOTFS}$i 1.1430 + update_bootconfig $ROOTCD/boot/isolinux \ 1.1431 + "$(cat /etc/tazlito/rootfs.list)" 1.1432 + else 1.1433 + # Initramfs and ISO image stuff. 1.1434 + gen_initramfs $ROOTFS 1.1435 + fi 1.1436 + gen_livecd_isolinux 1.1437 + distro_stats 1.1438 + cleanup 1.1439 + ;; 1.1440 + clean-distro) 1.1441 + # Remove old distro tree. 1.1442 + # 1.1443 + check_root 1.1444 + echo "" 1.1445 + echo -e "\033[1mCleaning :\033[0m $DISTRO" 1.1446 + echo "================================================================================" 1.1447 + if [ -d "$DISTRO" ] ; then 1.1448 + if [ -d "$ROOTFS" ] ; then 1.1449 + echo -n "Removing the rootfs..." 1.1450 + rm -f $DISTRO/$INITRAMFS 1.1451 + rm -rf $ROOTFS 1.1452 + status 1.1453 + fi 1.1454 + if [ -d "$ROOTCD" ] ; then 1.1455 + echo -n "Removing the rootcd..." 1.1456 + rm -rf $ROOTCD 1.1457 + status 1.1458 + fi 1.1459 + echo -n "Removing eventual ISO image..." 1.1460 + rm -f $DISTRO/$ISO_NAME.iso 1.1461 + rm -f $DISTRO/$ISO_NAME.md5 1.1462 + status 1.1463 + fi 1.1464 + echo "================================================================================" 1.1465 + echo "" 1.1466 + ;; 1.1467 + check-distro) 1.1468 + # Check for a few LiveCD needed files not installed by packages. 1.1469 + # 1.1470 + check_rootfs 1.1471 + echo "" 1.1472 + echo -e "\033[1mChecking distro :\033[0m $ROOTFS" 1.1473 + echo "================================================================================" 1.1474 + # SliTaz release info. 1.1475 + if [ ! -f "$ROOTFS/etc/slitaz-release" ]; then 1.1476 + echo "Missing release info : /etc/slitaz-release" 1.1477 + else 1.1478 + release=`cat $ROOTFS/etc/slitaz-release` 1.1479 + echo -n "Release : $release" 1.1480 + status 1.1481 + fi 1.1482 + # Tazpkg mirror. 1.1483 + if [ ! -f "$ROOTFS/var/lib/tazpkg/mirror" ]; then 1.1484 + echo -n "Mirror URL : Missing /var/lib/tazpkg/mirror" 1.1485 + todomsg 1.1486 + else 1.1487 + echo -n "Mirror configuration exists..." 1.1488 + status 1.1489 + fi 1.1490 + # Isolinux msg 1.1491 + if grep -q "cooking-XXXXXXXX" /$ROOTCD/boot/isolinux/isolinux.msg; then 1.1492 + echo -n "Isolinux msg : Missing cooking date XXXXXXXX (ex `date +%Y%m%d`)" 1.1493 + todomsg 1.1494 + else 1.1495 + echo -n "Isolinux message seems good..." 1.1496 + status 1.1497 + fi 1.1498 + echo "================================================================================" 1.1499 + echo "" 1.1500 + ;; 1.1501 + writeiso) 1.1502 + # Writefs to ISO image including /home unlike gen-distro we dont use 1.1503 + # packages to generate a rootfs, we build a compressed rootfs with all 1.1504 + # the current filesystem similar to 'tazusb writefs'. 1.1505 + # 1.1506 + DISTRO="/home/slitaz/distro" 1.1507 + ROOTCD="$DISTRO/rootcd" 1.1508 + if [ -z $2 ]; then 1.1509 + COMPRESSION=none 1.1510 + else 1.1511 + COMPRESSION=$2 1.1512 + fi 1.1513 + if [ -z $3 ]; then 1.1514 + ISO_NAME="slitaz" 1.1515 + else 1.1516 + ISO_NAME="$3" 1.1517 + fi 1.1518 + check_root 1.1519 + # Start info 1.1520 + echo "" 1.1521 + echo -e "\033[1mWrite filesystem to ISO\033[0m 1.1522 +=============================================================================== 1.1523 +The command writeiso will write the current filesystem into a suitable cpio 1.1524 +archive (rootfs.gz) and generate a bootable ISO image (slitaz.iso). 1.1525 + 1.1526 +Archive compression: $COMPRESSION" 1.1527 + echo "" 1.1528 + 1.1529 + # Save some space 1.1530 + rm /var/cache/tazpkg/* -r -f 1.1531 + rm -rf /home/slitaz/distro 1.1532 + 1.1533 + # Optionally remove sound card selection and screen resolution. 1.1534 + echo "Do you wish to remove the sound card and screen config ? " 1.1535 + echo -n "Press ENTER to keep or anser (No|yes|exit): " 1.1536 + read anser 1.1537 + case $anser in 1.1538 + e|E|"exit"|Exit) 1.1539 + exit 0 ;; 1.1540 + y|Y|yes|Yes) 1.1541 + echo -n "Removing current sound card and screen configuration..." 1.1542 + rm -f /var/lib/sound-card-driver 1.1543 + rm -f /etc/asound.state 1.1544 + rm -f /etc/X11/screen.conf 1.1545 + rm -f /etc/X11/xorg.conf ;; 1.1546 + *) 1.1547 + echo -n "Keeping current sound card and screen configuration..." ;; 1.1548 + esac 1.1549 + status 1.1550 + 1.1551 + # Create list of files including default user files since it is defined in /etc/passwd 1.1552 + # and some new users might have been added. 1.1553 + find /bin /etc /init /sbin /var /dev /lib /root /usr /home >/tmp/list 1.1554 + 1.1555 + for dir in /proc /sys /tmp /mnt /media /media/cdrom /media/flash /media/usbdisk 1.1556 + do 1.1557 + echo $dir >>/tmp/list 1.1558 + done 1.1559 + 1.1560 + # Generate initramfs with specified compression and display rootf 1.1561 + # size in realtime. 1.1562 + rm -f /tmp/rootfs 1.1563 + write_initramfs & 1.1564 + sleep 2 1.1565 + echo -en "\nFilesystem size:" 1.1566 + while [ ! -f /tmp/rootfs ] 1.1567 + do 1.1568 + sleep 1 1.1569 + echo -en "\\033[18G`du -sh /rootfs.gz | awk '{print $1}'` " 1.1570 + done 1.1571 + echo -e "\n" 1.1572 + 1.1573 + # Move freshly generated rootfs to the cdrom. 1.1574 + mkdir -p $ROOTCD/boot 1.1575 + mv -f /rootfs.gz $ROOTCD/boot 1.1576 + 1.1577 + # Now we need the kernel and isolinux files. 1.1578 + if mount /dev/cdrom /media/cdrom 2>/dev/null; then 1.1579 + cp /media/cdrom/boot/bzImage $ROOTCD/boot 1.1580 + cp -a /media/cdrom/boot/isolinux $ROOTCD/boot 1.1581 + umount /media/cdrom 1.1582 + else 1.1583 + echo -e " 1.1584 +Unable to mount the cdrom to copy the Kernel and needed files. When SliTaz 1.1585 +is running in RAM the kernel and bootloader files are keeped on the cdrom. 1.1586 +Please insert a LiveCD or unmount curent cdrom to let Tazlito handle the media.\n" 1.1587 + echo -en "----\nENTER to continue..."; read i 1.1588 + exit 1 1.1589 + fi 1.1590 + 1.1591 + # Generate the iso image. 1.1592 + cd $DISTRO 1.1593 + echo "Generating ISO image..." 1.1594 + genisoimage -R -o $ISO_NAME.iso -b boot/isolinux/isolinux.bin \ 1.1595 + -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \ 1.1596 + -V "SliTaz" -input-charset iso8859-1 -boot-info-table $ROOTCD 1.1597 + if [ -x /usr/bin/isohybrid ]; then 1.1598 + echo -n "Creating hybrid ISO..." 1.1599 + /usr/bin/isohybrid $ISO_NAME.iso 2> /dev/null 1.1600 + status 1.1601 + fi 1.1602 + echo -n "Creating the ISO md5sum..." 1.1603 + md5sum $ISO_NAME.iso > $ISO_NAME.md5 1.1604 + status 1.1605 + 1.1606 + echo "===============================================================================" 1.1607 + echo "ISO image: `du -sh /home/slitaz/distro/$ISO_NAME.iso`" 1.1608 + echo "" 1.1609 + echo -n "Exit or burn ISO to cdrom (Exit|burn)? "; read anser 1.1610 + case $anser in 1.1611 + burn) 1.1612 + eject 1.1613 + echo -n "Please insert a blank cdrom and press ENTER..." 1.1614 + read i && sleep 2 1.1615 + tazlito burn-iso /home/slitaz/distro/$ISO_NAME.iso 1.1616 + echo -en "----\nENTER to continue..."; read i ;; 1.1617 + *) 1.1618 + exit 0 ;; 1.1619 + esac ;; 1.1620 + burn-iso) 1.1621 + # Guess cdrom device, ask user and burn the ISO. 1.1622 + # 1.1623 + check_root 1.1624 + DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3` 1.1625 + DRIVE_SPEED=`cat /proc/sys/dev/cdrom/info | grep "drive speed" | cut -f 3` 1.1626 + # We can specify an alternative ISO from the cmdline. 1.1627 + if [ -n "$2" ] ; then 1.1628 + iso=$2 1.1629 + else 1.1630 + iso=$DISTRO/$ISO_NAME.iso 1.1631 + fi 1.1632 + if [ ! -f "$iso" ]; then 1.1633 + echo -e "\nUnable to find ISO : $iso\n" 1.1634 + exit 0 1.1635 + fi 1.1636 + echo "" 1.1637 + echo -e "\033[1mTazlito burn ISO\033[0m " 1.1638 + echo "================================================================================" 1.1639 + echo "Cdrom device : /dev/$DRIVE_NAME" 1.1640 + echo "Drive speed : $DRIVE_SPEED" 1.1641 + echo "ISO image : $iso" 1.1642 + echo "================================================================================" 1.1643 + echo "" 1.1644 + yesorno "Burn ISO image (y/N) ? " 1.1645 + if [ "$answer" == "y" ]; then 1.1646 + echo "" 1.1647 + echo "Starting Wodim to burn the iso..." && sleep 2 1.1648 + echo "================================================================================" 1.1649 + wodim speed=$DRIVE_SPEED dev=/dev/$DRIVE_NAME $iso 1.1650 + echo "================================================================================" 1.1651 + echo "ISO image is burned to cdrom." 1.1652 + else 1.1653 + echo -e "\nExiting. No ISO burned." 1.1654 + fi 1.1655 + echo "" 1.1656 + ;; 1.1657 + merge) 1.1658 + # Merge multiple rootfs into one iso. 1.1659 + # 1.1660 + if [ -z "$2" ]; then 1.1661 + cat << EOT 1.1662 +Usage: tazlito merge size1 iso size2 rootfs2 [sizeN rootfsN]... 1.1663 + 1.1664 +Merge multiple rootfs into one iso. Rootfs are like russian dolls 1.1665 +i.e: rootfsN is a subset of rootfsN-1 1.1666 +rootfs1 is found in iso, sizeN is the RAM size need to launch rootfsN. 1.1667 +The boot loader will select the rootfs according to the RAM size detected. 1.1668 + 1.1669 +Example: 1.1670 +$ tazlito merge 160M slitaz-core.iso 96M rootfs-justx.gz 32M rootfs-base.gz 1.1671 + 1.1672 +Will start slitaz-core with 160M+ RAM, slitaz-justX with 96M-160M RAM, 1.1673 +slitaz-base with 32M-96M RAM and display an error message if RAM < 32M. 1.1674 +EOT 1.1675 + exit 2 1.1676 + fi 1.1677 + 1.1678 + shift # skip merge 1.1679 + append="$1 slitaz1" 1.1680 + shift # skip size1 1.1681 + mkdir -p $TMP_DIR/mnt $TMP_DIR/rootfs1 1.1682 + 1.1683 + ISO=$1.merged 1.1684 + # Extract filesystems 1.1685 + echo -n "Mounting $1" 1.1686 + mount -o loop,ro $1 $TMP_DIR/mnt 2> /dev/null 1.1687 + status || cleanup_merge 1.1688 + cp -a $TMP_DIR/mnt $TMP_DIR/iso 1.1689 + rm -f $TMP_DIR/iso/boot/bzImage 1.1690 + ln $TMP_DIR/iso/boot/vmlinuz* $TMP_DIR/iso/boot/bzImage 1.1691 + umount -d $TMP_DIR/mnt 1.1692 + if [ -f $TMP_DIR/iso/boot/rootfs1.gz ]; then 1.1693 + echo "$1 is already a merged iso. Aborting." 1.1694 + cleanup_merge 1.1695 + fi 1.1696 + if [ ! -f $TMP_DIR/iso/boot/isolinux/ifmem.c32 ]; then 1.1697 + if [ ! -f /boot/isolinux/ifmem.c32 ]; then 1.1698 + cat <<EOT 1.1699 +No file /boot/isolinux/ifmem.c32 1.1700 +Please install syslinux package ! 1.1701 +EOT 1.1702 + rm -rf $TMP_DIR 1.1703 + exit 1 1.1704 + fi 1.1705 + cp /boot/isolinux/ifmem.c32 $TMP_DIR/iso/boot/isolinux 1.1706 + fi 1.1707 + 1.1708 + echo -n "Extracting iso/rootfs.gz" 1.1709 + extract_rootfs $TMP_DIR/iso/boot/rootfs.gz $TMP_DIR/rootfs1 && 1.1710 + [ -d $TMP_DIR/rootfs1/etc ] 1.1711 + status || cleanup_merge 1.1712 + n=1 1.1713 + while [ -n "$2" ]; do 1.1714 + shift # skip rootfs N-1 1.1715 + p=$n 1.1716 + n=$(($n + 1)) 1.1717 + append="$append $1 slitaz$n" 1.1718 + shift # skip size N 1.1719 + mkdir -p $TMP_DIR/rootfs$n 1.1720 + echo -n "Extracting $1" 1.1721 + extract_rootfs $1 $TMP_DIR/rootfs$n && 1.1722 + [ -d $TMP_DIR/rootfs$n/etc ] 1.1723 + status || cleanup_merge 1.1724 + mergefs $TMP_DIR/rootfs$n $TMP_DIR/rootfs$p 1.1725 + echo "Creating rootfs$p.gz" 1.1726 + pack_rootfs $TMP_DIR/rootfs$p $TMP_DIR/iso/boot/rootfs$p.gz 1.1727 + status 1.1728 + done 1.1729 + echo "Creating rootfs$n.gz" 1.1730 + pack_rootfs $TMP_DIR/rootfs$n $TMP_DIR/iso/boot/rootfs$n.gz 1.1731 + status 1.1732 + rm -f $TMP_DIR/iso/boot/rootfs.gz 1.1733 + update_bootconfig $TMP_DIR/iso/boot/isolinux "$append" 1.1734 + echo "Generating $ISO" 1.1735 + create_iso $ISO $TMP_DIR/iso 1.1736 + rm -rf $TMP_DIR 1.1737 + ;; 1.1738 + 1.1739 + repack) 1.1740 + # Repack an iso with maximum lzma compression ratio. 1.1741 + # 1.1742 + 1.1743 + ISO=$2 1.1744 + 1.1745 + mkdir -p $TMP_DIR/mnt 1.1746 + # Extract filesystems 1.1747 + echo -n "Mounting $ISO" 1.1748 + mount -o loop,ro $ISO $TMP_DIR/mnt 2> /dev/null 1.1749 + status || cleanup_merge 1.1750 + cp -a $TMP_DIR/mnt $TMP_DIR/iso 1.1751 + umount -d $TMP_DIR/mnt 1.1752 + 1.1753 + for i in $TMP_DIR/iso/boot/rootfs* ; do 1.1754 + echo -n "Repacking $(basename $i)" 1.1755 + (zcat $i || unlzma -c $i || cat $i) \ 1.1756 + 2>/dev/null > $TMP_DIR/rootfs 1.1757 + lzma e $TMP_DIR/rootfs $i \ 1.1758 + $(lzma_switches $TMP_DIR/rootfs) 1.1759 + status 1.1760 + done 1.1761 + 1.1762 + echo "Generating $ISO" 1.1763 + create_iso $ISO $TMP_DIR/iso 1.1764 + rm -rf $TMP_DIR ;; 1.1765 + 1.1766 + frugal-install|-fi) 1.1767 + ISO_IMAGE="$2" 1.1768 + echo "" 1.1769 + mkdir -p /boot/frugal 1.1770 + if [ -f "$ISO_IMAGE" ]; then 1.1771 + echo -n "Using ISO image: $ISO_IMAGE" 1.1772 + mkdir -p /tmp/iso && mount -o loop $ISO_IMAGE /tmp/iso 1.1773 + status 1.1774 + echo -n "Installing the Kernel and rootfs..." 1.1775 + cp -a /tmp/iso/boot/bzImage /boot/frugal 1.1776 + cp -a /tmp/iso/boot/rootfs.gz /boot/frugal 1.1777 + umount /tmp/iso 1.1778 + status 1.1779 + else 1.1780 + echo -n "Using distro: $DISTRO" 1.1781 + cd $DISTRO && status 1.1782 + echo -n "Installing the Kernel and rootfs..." 1.1783 + cp -a $DISTRO/rootcd/boot/bzImage /boot/frugal 1.1784 + cp -a $DISTRO/rootcd/boot/rootfs.gz /boot/frugal 1.1785 + status 1.1786 + fi 1.1787 + # Grub entry 1.1788 + if ! grep -q "^kernel /boot/frugal/bzImage" /boot/grub/menu.lst; then 1.1789 + echo -n "Configuring GRUB menu list..." 1.1790 + cat >> /boot/grub/menu.lst << EOT 1.1791 +title SliTaz GNU/Linux (frugal) 1.1792 +root (hd0,0) 1.1793 +kernel /boot/frugal/bzImage root=/dev/null 1.1794 +initrd /boot/frugal/rootfs.gz 1.1795 +EOT 1.1796 + else 1.1797 + echo -n "GRUB menu list is up-to-date..." 1.1798 + fi 1.1799 + status 1.1800 + echo "" ;; 1.1801 + 1.1802 + emu-iso) 1.1803 + # Emulate an ISO image with Qemu. 1.1804 + if [ -n "$2" ] ; then 1.1805 + iso=$2 1.1806 + else 1.1807 + iso=$DISTRO/$ISO_NAME.iso 1.1808 + fi 1.1809 + if [ ! -f "$iso" ]; then 1.1810 + echo -e "\nUnable to find ISO : $iso\n" 1.1811 + exit 0 1.1812 + fi 1.1813 + if [ ! -x "/usr/bin/qemu" ]; then 1.1814 + echo -e "\nUnable to find Qemu binary. Please install: qemu\n" 1.1815 + exit 0 1.1816 + fi 1.1817 + echo -e "\nStarting Qemu emulator:\n" 1.1818 + echo -e "qemu $QEMU_OPTS $iso\n" 1.1819 + qemu $QEMU_OPTS $iso ;; 1.1820 + 1.1821 + usage|*) 1.1822 + # Clear and print usage also for all unknown commands. 1.1823 + # 1.1824 + clear 1.1825 + usage ;; 1.1826 +esac 1.1827 + 1.1828 +exit 0