flavors rev 18

core: up splash screen
author Christophe Lincoln <pankso@slitaz.org>
date Thu Feb 11 14:40:09 2010 +0100 (2010-02-11)
parents efec05420bca
children b5e7e17474d8
files core/rootcd/boot/isolinux/splash.lss core/rootfs/usr/bin/tazlito core/rootfs/usr/bin/tazlitobox core/rootfs/usr/share/applications/tazlito-doc.desktop core/rootfs/usr/share/applications/tazlitobox.desktop core/rootfs/usr/share/applications/tazpkg-doc.desktop
line diff
     1.1 Binary file core/rootcd/boot/isolinux/splash.lss has changed
     2.1 --- a/core/rootfs/usr/bin/tazlito	Thu Feb 11 14:39:04 2010 +0100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,1825 +0,0 @@
     2.4 -#!/bin/sh
     2.5 -# TazLito - SliTaz Live Tool.
     2.6 -#
     2.7 -# Tazlito is a tool to help generate and configure SliTaz LiveCD
     2.8 -# ISO images. You can create a custom distro in one command from a list of
     2.9 -# packages, extract an existing ISO image to hack it, create a new initramfs
    2.10 -# and/or a new ISO. Most commands must be run by root, except the stats
    2.11 -# and the configuration file manipulation.
    2.12 -#
    2.13 -# (C) 2007-2010 SliTaz - GNU General Public License.
    2.14 -#
    2.15 -# Authors : Christophe Lincoln <pankso@slitaz.org>
    2.16 -#           Pascal Bellard <pascal.bellard@slitaz.org>
    2.17 -#
    2.18 -VERSION=2.0
    2.19 -
    2.20 -# Tazlito configuration variables to be shorter
    2.21 -# and to use words rather than numbers.
    2.22 -COMMAND=$1
    2.23 -LIST_NAME=$2
    2.24 -TMP_DIR=/tmp/tazlito-$$-$RANDOM
    2.25 -TMP_MNT=/media/tazlito-$$-$RANDOM
    2.26 -TOP_DIR=`pwd`
    2.27 -INITRAMFS=rootfs.gz
    2.28 -LOCALSTATE=/var/lib/tazpkg
    2.29 -INSTALLED=$LOCALSTATE/installed
    2.30 -CACHE_DIR=/var/cache/tazpkg
    2.31 -MIRROR=$LOCALSTATE/mirror
    2.32 -DEFAULT_MIRROR="http://mirror.slitaz.org/packages/`cat /etc/slitaz-release`/"
    2.33 -
    2.34 -# Try to include config file, continue if command is gen-config or exit.
    2.35 -# The main config used by default is in /etc/tazlito.
    2.36 -if [ -f "/etc/tazlito/tazlito.conf" ] ; then
    2.37 -	CONFIG_FILE="/etc/tazlito/tazlito.conf"
    2.38 -fi
    2.39 -# Specific distro config file can be put in a distro tree.
    2.40 -if [ -f "$TOP_DIR/tazlito.conf" ] ; then
    2.41 -	CONFIG_FILE="$TOP_DIR/tazlito.conf"
    2.42 -fi
    2.43 -if [ ! "$CONFIG_FILE" = "" ] ; then
    2.44 -	. $CONFIG_FILE
    2.45 -else
    2.46 -	if [ "$COMMAND" = "gen-config" ] ; then
    2.47 -		continue
    2.48 -	else
    2.49 -		echo "Unable to find any configuration file. Please read the docs"
    2.50 -		echo "or run '`basename $0` gen-config' to get an empty config file."
    2.51 -		exit 0
    2.52 -	fi
    2.53 -fi
    2.54 -
    2.55 -# While Tazpkg is not used the default mirror url file does not exist
    2.56 -# and user can't recharge the list of flavors.
    2.57 -if test $(id -u) = 0 ; then
    2.58 -	if [ ! -f "$MIRROR" ]; then
    2.59 -		echo "$DEFAULT_MIRROR" > $MIRROR
    2.60 -	fi
    2.61 -fi
    2.62 -
    2.63 -# Set the rootfs and rootcd path with $DISTRO
    2.64 -# configuration variable.
    2.65 -ROOTFS=$DISTRO/rootfs
    2.66 -ROOTCD=$DISTRO/rootcd
    2.67 -FLAVORS_REPOSITORY=/home/slitaz/flavors
    2.68 -
    2.69 -#####################
    2.70 -# Tazlito functions #
    2.71 -#####################
    2.72 -
    2.73 -# Print the usage.
    2.74 -usage ()
    2.75 -{
    2.76 -	echo -e "\nSliTaz Live Tool - Version: $VERSION\n
    2.77 -\033[1mUsage: \033[0m `basename $0` [command] [list|iso|flavor|compression] [dir|iso]
    2.78 -\033[1mCommands: \033[0m\n
    2.79 -  usage           Print this short usage.
    2.80 -  stats           View Tazlito and distro configuration statistics.
    2.81 -  gen-config      Generate a new configuration file for a distro.
    2.82 -  configure       Configure the main config file or a specific tazlito.conf.
    2.83 -  gen-iso         Generate a new ISO from a distro tree.
    2.84 -  gen-initiso     Generate a new initramfs and ISO from the distro tree.
    2.85 -  list-flavors    List all available package lists on the mirror.
    2.86 -  gen-flavor      Generate a new live-CD description.
    2.87 -  gen-liveflavor  Generate a live-CD description from current system.
    2.88 -  show-flavor     Show live-CD description.
    2.89 -  get-flavor      Get a flavor's list of packages.
    2.90 -  upgrade-flavor  Update package list to the latest available versions.
    2.91 -  extract-flavor  Extract a (*.flavor) flavor into $FLAVORS_REPOSITORY.
    2.92 -  pack-flavor     Pack (and update) a flavor from $FLAVORS_REPOSITORY.
    2.93 -  check-list      Check a distro-packages.list for updates.
    2.94 -  extract-distro  Extract an ISO to a directory and rebuild LiveCD tree.
    2.95 -  gen-distro      Generate a Live distro and ISO from a list of packages.
    2.96 -  clean-distro    Remove all files generated by gen-distro.
    2.97 -  check-distro    Help to check if distro is ready to release.
    2.98 -  writeiso        Use running system to generate a bootable ISO (with /home).
    2.99 -  merge           Merge multiple rootfs into one iso.
   2.100 -  repack          Recompress rootfs into iso with maximum ratio.
   2.101 -  frugal-install  Frugal install in /boot/frugal from a distro or ISO
   2.102 -  emu-iso         Emulate an ISO image with Qemu.
   2.103 -  burn-iso        Burn ISO image to a cdrom using Wodim.\n"
   2.104 -}
   2.105 -
   2.106 -# Status function.
   2.107 -status()
   2.108 -{
   2.109 -	local CHECK=$?
   2.110 -	echo -en "\\033[70G[ "
   2.111 -	if [ $CHECK = 0 ]; then
   2.112 -		echo -en "\\033[1;33mOK"
   2.113 -	else
   2.114 -		echo -en "\\033[1;31mFailed"
   2.115 -	fi
   2.116 -	echo -e "\\033[0;39m ]"
   2.117 -	return $CHECK
   2.118 -}
   2.119 -
   2.120 -yesorno()
   2.121 -{
   2.122 -	echo -n "$1"
   2.123 -	case "$DEFAULT_ANSWER" in
   2.124 -	Y|y) answer="y";;
   2.125 -	N|n) answer="n";;
   2.126 -	*) read answer;;
   2.127 -	esac
   2.128 -}
   2.129 -
   2.130 -field()
   2.131 -{
   2.132 -	grep "^$1" "$2" | sed 's/.*: \([0-9KMG\.]*\).*/\1/'
   2.133 -}
   2.134 -
   2.135 -todomsg()
   2.136 -{
   2.137 -	echo -e "\\033[70G[ \\033[1;31mTODO\\033[0;39m ]"
   2.138 -}
   2.139 -
   2.140 -# Download a file from this mirror
   2.141 -download_from()
   2.142 -{
   2.143 -	local i
   2.144 -	local mirrors
   2.145 -	mirrors="$1"
   2.146 -	shift
   2.147 -	for i in $mirrors; do
   2.148 -		case "$i" in
   2.149 -		http://*|ftp://*) wget -c $i$@ && break;;
   2.150 -		*) cp $i/$1 . && break;;
   2.151 -		esac
   2.152 -	done
   2.153 -}
   2.154 -
   2.155 -# Download a file trying all mirrors
   2.156 -download()
   2.157 -{
   2.158 -	local i
   2.159 -	for i in $(cat $MIRROR $LOCALSTATE/undigest/*/mirror 2> /dev/null); do
   2.160 -		download_from "$i" "$@" && break
   2.161 -	done
   2.162 -}
   2.163 -
   2.164 -# Execute hooks provided by some packages
   2.165 -genisohooks()
   2.166 -{
   2.167 -	local here=`pwd`
   2.168 -	for i in $(ls $ROOTFS/etc/tazlito/*.$1 2> /dev/null); do
   2.169 -		cd $ROOTFS
   2.170 -		. $i $ROOTCD
   2.171 -	done
   2.172 -	cd $here
   2.173 -}
   2.174 -
   2.175 -cleanup()
   2.176 -{
   2.177 -	if [ -d $TMP_MNT ]; then
   2.178 -		umount $TMP_MNT
   2.179 -		rmdir $TMP_MNT
   2.180 -		rm -f /boot
   2.181 -	fi
   2.182 -}
   2.183 -
   2.184 -# Echo the package name if the tazpkg is already installed
   2.185 -installed_package_name()
   2.186 -{
   2.187 -	local tazpkg
   2.188 -	local package
   2.189 -	local VERSION
   2.190 -	local EXTRAVERSION
   2.191 -	tazpkg=$1
   2.192 -	# Try to find package name and version to be able
   2.193 -	# to repack it from installation
   2.194 -	# A dash (-) can exist in name *and* in version
   2.195 -	package=${tazpkg%-*}
   2.196 -	i=$package
   2.197 -	while true; do
   2.198 -		VERSION=""
   2.199 -		eval $(grep -s ^VERSION= $INSTALLED/$i/receipt)
   2.200 -		EXTRAVERSION=""
   2.201 -		eval $(grep -s ^EXTRAVERSION= $INSTALLED/$i/receipt)
   2.202 -		if [ "$i-$VERSION$EXTRAVERSION" = "$tazpkg" ]; then
   2.203 -			echo $i
   2.204 -			break
   2.205 -		fi
   2.206 -		case "$i" in
   2.207 -		*-*);;
   2.208 -		*) break;;
   2.209 -		esac
   2.210 -		i=${i%-*}
   2.211 -	done
   2.212 -}
   2.213 -
   2.214 -# Check if user is root.
   2.215 -check_root()
   2.216 -{
   2.217 -	if test $(id -u) != 0 ; then
   2.218 -	   echo -e "\nYou must be root to run `basename $0` with this option."
   2.219 -	   echo -e "Please type 'su' and root password to become super-user.\n"
   2.220 -	   exit 0
   2.221 -	fi
   2.222 -}
   2.223 -
   2.224 -# Check for the rootfs tree.
   2.225 -check_rootfs()
   2.226 -{
   2.227 -	if [ ! -d "$ROOTFS/etc" ] ; then
   2.228 -		echo -e "\nUnable to find a distro rootfs...\n"
   2.229 -		exit 0
   2.230 -	fi
   2.231 -}
   2.232 -
   2.233 -# Check for the boot dir into the root CD tree.
   2.234 -verify_rootcd()
   2.235 -{
   2.236 -	if [ ! -d "$ROOTCD/boot" ] ; then
   2.237 -		echo -e "\nUnable to find the rootcd boot directory...\n"
   2.238 -		exit 0
   2.239 -	fi
   2.240 -}
   2.241 -
   2.242 -create_iso()
   2.243 -{
   2.244 -	genisoimage -R -o $1 -b boot/isolinux/isolinux.bin \
   2.245 - 		-c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
   2.246 -		-V "$VOLUM_NAME" -p "$PREPARED" -input-charset iso8859-1 \
   2.247 -		-boot-info-table $2
   2.248 -	if [ -x /usr/bin/isohybrid ]; then
   2.249 -		echo -n "Creating hybrid ISO..."
   2.250 -		/usr/bin/isohybrid $1 2> /dev/null
   2.251 -		status
   2.252 -	fi
   2.253 -}
   2.254 -
   2.255 -# Generate a new ISO image using isolinux.
   2.256 -gen_livecd_isolinux()
   2.257 -{
   2.258 -	# Some packages may want to alter iso
   2.259 -	genisohooks iso
   2.260 -	if [ ! -f "$ROOTCD/boot/isolinux/isolinux.bin" ]; then
   2.261 -		echo -e "\nUnable to find isolinux binary.\n"
   2.262 -		cleanup
   2.263 -		exit 0
   2.264 -	fi
   2.265 -	# Set date for boot msg.
   2.266 -	if grep -q 'XXXXXXXX' $ROOTCD/boot/isolinux/isolinux.msg; then
   2.267 -		DATE=`date +%Y%m%d`
   2.268 -		echo -n "Setting build date to: $DATE..."
   2.269 -		sed -i s/'XXXXXXXX'/"$DATE"/ $ROOTCD/boot/isolinux/isolinux.msg
   2.270 -		status
   2.271 -	fi
   2.272 -	cd $ROOTCD
   2.273 -	echo -n "Computing md5..."
   2.274 -	find * -type f ! -name md5sum -exec md5sum {} \; > md5sum
   2.275 -	status
   2.276 -	cd $DISTRO
   2.277 -	echo ""
   2.278 -	echo -e "\033[1mGenerating ISO image\033[0m"
   2.279 -	echo "================================================================================"
   2.280 -	create_iso $ISO_NAME.iso $ROOTCD
   2.281 -	echo -n "Creating the ISO md5sum..."
   2.282 -	md5sum $ISO_NAME.iso > $ISO_NAME.md5
   2.283 -	status
   2.284 -	echo "================================================================================"
   2.285 -	# Some packages may want to alter final iso
   2.286 -	genisohooks final
   2.287 -}
   2.288 -
   2.289 -lzma_history_bits()
   2.290 -{
   2.291 -	#
   2.292 -	# This genertae ISO who boot with Qemu but give
   2.293 -	# rootfs errors in frugal or liveUSB mode.
   2.294 -	#
   2.295 -	#local n
   2.296 -	#local sz
   2.297 -	#n=20	# 1Mb
   2.298 -	#sz=$(du -sk $1 | cut -f1)
   2.299 -	#while [ $sz -gt 1024 -a $n -lt 28 ]; do
   2.300 -		#n=$(( $n + 1 ))
   2.301 -		#sz=$(( $sz / 2 ))
   2.302 -	#done
   2.303 -	#echo $n
   2.304 -	echo 24
   2.305 -}
   2.306 -
   2.307 -lzma_switches()
   2.308 -{
   2.309 -	echo "-d$(lzma_history_bits $1) -mt$(grep ^processor < /proc/cpuinfo | wc -l)"
   2.310 -}
   2.311 -
   2.312 -# Pack rootfs
   2.313 -pack_rootfs()
   2.314 -{
   2.315 -	( cd $1 ; find . -print | cpio -o -H newc ) | \
   2.316 -	if [ "$COMPRESSION" = "none" ]; then
   2.317 -		echo "Generating uncompressed initramfs... "
   2.318 -		cat > $2
   2.319 -	elif [ -x /usr/bin/lzma -a "$COMPRESSION" != "gzip" ]; then
   2.320 -		echo -n "Generating lzma'ed initramfs... "
   2.321 -		lzma e -si -so $(lzma_switches $1) > $2
   2.322 -	else
   2.323 -		echo "Generating gziped initramfs... "
   2.324 -		gzip -9 > $2
   2.325 -	fi
   2.326 -	echo 1 > /tmp/rootfs
   2.327 -}
   2.328 -
   2.329 -# Compression functions for writeiso.
   2.330 -write_initramfs()
   2.331 -{
   2.332 -	if [ "$COMPRESSION" = "lzma" ]; then
   2.333 -		echo -n "Creating rootfs.gz with lzma compression... "
   2.334 -		cat /tmp/list | cpio -o -H newc | lzma e -si -so > /rootfs.gz
   2.335 -	elif [ "$COMPRESSION" = "gzip" ]; then
   2.336 -		echo "Creating rootfs.gz with gzip compression... "
   2.337 -		cat /tmp/list | cpio -o -H newc | gzip -9 > /rootfs.gz
   2.338 -	else
   2.339 -		echo "Creating rootfs.gz without compression... "
   2.340 -		cat /tmp/list | cpio -o -H newc > /rootfs.gz
   2.341 -	fi
   2.342 -	echo 1 > /tmp/rootfs
   2.343 -}
   2.344 -
   2.345 -# Generate a new initramfs from the root filesystem.
   2.346 -gen_initramfs()
   2.347 -{
   2.348 -	# Just in case CTRL+c
   2.349 -	rm -f $DISTRO/gen
   2.350 -	# Some packages may want to alter rootfs
   2.351 -	genisohooks rootfs
   2.352 -	cd $1
   2.353 -	echo ""
   2.354 -
   2.355 -        # Link duplicate files
   2.356 -        find . -type f -size +0c -exec stat -c '%s-%a-%u-%g %i %h %n' {} \; | \
   2.357 -           sort | ( save=0; old_attr=""; old_inode=""; old_link=""; old_file=""
   2.358 -           while read attr inode link file; do
   2.359 -               if [ "$attr" = "$old_attr" -a "$inode" != "$old_inode" ]; then
   2.360 -                   if cmp "$file" "$old_file" >/dev/null; then
   2.361 -                       rm -f "$file"
   2.362 -                       ln "$old_file" "$file"
   2.363 -                       inode="$old_inode"
   2.364 -                       [ "$link" = "1" ] && save="$(expr $save + ${attr%%-*})"
   2.365 -                   fi
   2.366 -               fi
   2.367 -               old_attr="$attr" ; old_inode="$inode" ; old_file="$file"
   2.368 -           done
   2.369 -           echo "$save bytes saved in duplicate files."
   2.370 -        )
   2.371 -
   2.372 -	# Use lzma if installed. Display rootfs size in realtime.
   2.373 -	rm -f /tmp/rootfs
   2.374 -	pack_rootfs . $DISTRO/$(basename $1).gz &
   2.375 -	sleep 2
   2.376 -	echo -en "\nFilesystem size:"
   2.377 -	while [ ! -f /tmp/rootfs ]
   2.378 -	do
   2.379 -		sleep 1
   2.380 -		echo -en "\\033[18G`du -sh $DISTRO/rootfs.gz | awk '{print $1}'`    "
   2.381 -	done
   2.382 -	echo -e "\n"
   2.383 -	cd $DISTRO
   2.384 -	mv $(basename $1).gz $ROOTCD/boot
   2.385 -}
   2.386 -
   2.387 -distro_sizes()
   2.388 -{
   2.389 -	echo "Build date      : `date +%Y%m%d\ \at\ \%H:%M:%S`"
   2.390 -	echo "Packages        : `ls -1 $ROOTFS*$INSTALLED/*/receipt | wc -l`"
   2.391 -	echo "Rootfs size     : `du -csh $ROOTFS*/ | awk '{ s=$1 } END { print s }'`"
   2.392 -	echo "Initramfs size  : `du -csh $ROOTCD/boot/rootfs*.gz | awk '{ s=$1 } END { print s }'`"
   2.393 -	echo "ISO image size  : `du -sh $ISO_NAME.iso | awk '{ print $1 }'`"
   2.394 -	echo "================================================================================"
   2.395 -	echo "Image is ready: $ISO_NAME.iso"
   2.396 -	echo ""
   2.397 -}
   2.398 -
   2.399 -# Print ISO and rootfs size.
   2.400 -distro_stats()
   2.401 -{
   2.402 -	echo ""
   2.403 -	echo -e "\033[1mDistro statistics\033[0m ($DISTRO)"
   2.404 -	echo "================================================================================"
   2.405 -	distro_sizes
   2.406 -}
   2.407 -
   2.408 -# Create an empty configuration file.
   2.409 -empty_config_file()
   2.410 -{
   2.411 -	cat >> tazlito.conf << "EOF"
   2.412 -# tazlito.conf: Tazlito (SliTaz Live Tool)
   2.413 -# configuration file.
   2.414 -#
   2.415 -
   2.416 -# Name of the ISO image to generate.
   2.417 -ISO_NAME=""
   2.418 -
   2.419 -# ISO image volume name.
   2.420 -VOLUM_NAME="SliTaz"
   2.421 -
   2.422 -# Name of the preparer.
   2.423 -PREPARED="$USER"
   2.424 -
   2.425 -# Path to the packages repository and the packages.list.
   2.426 -PACKAGES_REPOSITORY=""
   2.427 -
   2.428 -# Path to the distro tree to gen-distro from a
   2.429 -# list of packages.
   2.430 -DISTRO=""
   2.431 -
   2.432 -# Path to the directory containing additional files
   2.433 -# to copy into the rootfs and rootcd of the LiveCD.
   2.434 -ADDFILES="$DISTRO/addfiles"
   2.435 -
   2.436 -# Default answer for binary question (Y or N)
   2.437 -DEFAULT_ANSWER="ASK"
   2.438 -
   2.439 -# Compression utility (lzma, gzip or none)
   2.440 -COMPRESSION="lzma"
   2.441 -EOF
   2.442 -}
   2.443 -
   2.444 -# extract rootfs.gz somewhere
   2.445 -extract_rootfs()
   2.446 -{
   2.447 -	(zcat $1 || unlzma -c $1 || cat $1) 2>/dev/null | \
   2.448 -		(cd $2; cpio -idm > /dev/null)
   2.449 -}
   2.450 -
   2.451 -# Remove duplicate files
   2.452 -mergefs()
   2.453 -{
   2.454 -	echo -n "Merge $(basename $1) ($(du -hs $1 | awk '{ print $1}')) into "
   2.455 -	echo -n       "$(basename $2) ($(du -hs $2 | awk '{ print $1}'))"
   2.456 -	# merge symlinks files and devices
   2.457 -	( cd $1; find ) | while read file; do
   2.458 -		if [ -L $1/$file ]; then
   2.459 -			[ -L $2/$file ] &&
   2.460 -			[ "$(readlink $1/$file)" == "$(readlink $2/$file)" ] &&
   2.461 -			rm -f $2/$file
   2.462 -		elif [ -f $1/$file ]; then
   2.463 -			[ -f $2/$file ] &&
   2.464 -			cmp $1/$file $2/$file > /dev/null 2>&1 && rm -f $2/$file
   2.465 -			[ -f $2/$file ] && 
   2.466 -			[ "$(basename $file)" == "volatile.cpio.gz" ] &&
   2.467 -			[ "$(dirname $(dirname $file))" == \
   2.468 -			  "./var/lib/tazpkg/installed" ] && rm -f $2/$file
   2.469 -		elif [ -b $1/$file ]; then
   2.470 -			[ -b $2/$file ] && rm -f $2/$file
   2.471 -		elif [ -c $1/$file ]; then
   2.472 -			[ -c $2/$file ] && rm -f $2/$file
   2.473 -		fi
   2.474 -	done
   2.475 -	
   2.476 -	# cleanup directories
   2.477 -	( cd $1; find ) | while read file; do
   2.478 -		if [ -d $1/$file ]; then
   2.479 -			[ -d $2/$file ] && rmdir $2/$file 2> /dev/null
   2.480 -		fi
   2.481 -	done
   2.482 -	true
   2.483 -	status
   2.484 -}
   2.485 -
   2.486 -cleanup_merge()
   2.487 -{
   2.488 -	rm -rf $TMP_DIR
   2.489 -	exit 1
   2.490 -}
   2.491 -
   2.492 -human2cent()
   2.493 -{
   2.494 -case "$1" in
   2.495 -*k) echo $1 | sed 's/\(.*\).\(.\)k/\1\2/';;
   2.496 -*M) echo $(( $(echo $1 | sed 's/\(.*\).\(.\)M/\1\2/') * 1024));;
   2.497 -*G) echo $(( $(echo $1 | sed 's/\(.*\).\(.\)G/\1\2/') * 1024 * 1024));;
   2.498 -esac
   2.499 -}
   2.500 -
   2.501 -cent2human()
   2.502 -{
   2.503 -if [ $1 -lt 10000 ]; then
   2.504 -  echo "$(($1 / 10)).$(($1 % 10))k"
   2.505 -elif [ $1 -lt 10000000 ]; then
   2.506 -  echo "$(($1 / 10240)).$(( ($1/1024) % 10))M"
   2.507 -else
   2.508 -  echo "$(($1 / 10485760)).$(( ($1/1048576) % 10))G"
   2.509 -fi
   2.510 -}
   2.511 -
   2.512 -get_size()
   2.513 -{
   2.514 -cat /var/lib/tazpkg/packages.list $TMP_DIR/packages.list 2>/dev/null | awk "{ \
   2.515 -if (/^$(echo $1 | sed 's/[$+.\]/\\&/g')$/) get=1; \
   2.516 -if (/installed/ && get == 1) { print ; get++ } \
   2.517 -}
   2.518 -END { if (get < 2) print \" 0.0k  (0.0k installed)\" }" | \
   2.519 -sed 's/ *\(.*\) .\(.*\) installed./\1 \2/' | while read packed unpacked; do
   2.520 -  echo "$(human2cent $packed) $(human2cent $unpacked)"
   2.521 -done
   2.522 -}
   2.523 -
   2.524 -# Display package list with version, set packed_size and unpacked_size
   2.525 -get_pkglist()
   2.526 -{
   2.527 -packed_size=0; unpacked_size=0
   2.528 -grep -v ^#  $FLAVORS_REPOSITORY/$1/packages.list > $TMP_DIR/flavor.pkg
   2.529 -while read pkg; do
   2.530 -	set -- $(get_size $pkg)
   2.531 -	packed_size=$(( $packed_size + $1 ))
   2.532 -	unpacked_size=$(( $unpacked_size + $2 ))
   2.533 -	for i in $(grep -hs ^$pkg /var/lib/tazpkg/packages.list \
   2.534 -				  $TMP_DIR/packages.list); do
   2.535 -		echo $i
   2.536 -		break
   2.537 -	done
   2.538 -done < $TMP_DIR/flavor.pkg
   2.539 -rm -f $TMP_DIR/flavor.pkg
   2.540 -}
   2.541 -
   2.542 -# Update isolinux config files for multiple rootfs
   2.543 -update_bootconfig()	
   2.544 -{
   2.545 -	echo -n "Updating boot config files..."
   2.546 -	grep -l 'include common' $1/*.cfg | \
   2.547 -	while read file ; do
   2.548 -			awk -v n=$(echo $2 | awk '{ print NF/2 }') '{
   2.549 -if (/label/) label=$0;
   2.550 -else if (/kernel/) kernel=$0;
   2.551 -else if (/append/) {
   2.552 -	i=index($0,"rootfs.gz");
   2.553 -	append=substr($0,i+9);
   2.554 -}
   2.555 -else if (/include/) {
   2.556 -	for (i = 1; i <= n; i++) {
   2.557 -		print label i
   2.558 -		print kernel;
   2.559 -		initrd="initrd=/boot/rootfs" n ".gz"
   2.560 -		for (j = n - 1; j >= i; j--) {
   2.561 -			initrd=initrd ",/boot/rootfs" j ".gz";
   2.562 -		}
   2.563 -		printf "\tappend %s%s\n",initrd,append;
   2.564 -		print "";
   2.565 -	}
   2.566 -	print;
   2.567 -}
   2.568 -else print;
   2.569 -}' < $file > $file.$$
   2.570 -			mv -f $file.$$ $file
   2.571 -	done
   2.572 -	cat >> $1/common.cfg <<EOT
   2.573 -
   2.574 -label slitaz
   2.575 -	kernel /boot/isolinux/ifmem.c32
   2.576 -	append$(echo $2 | awk '{
   2.577 -  for (i=1; i<=NF; i++)
   2.578 -     if (i % 2 == 0) printf " slitaz%d",i/2
   2.579 -     else printf " %s",$i
   2.580 -}') noram
   2.581 -
   2.582 -label noram
   2.583 -	config noram.cfg
   2.584 -
   2.585 -EOT
   2.586 -	cat > $1/noram.cfg <<EOT
   2.587 -display isolinux.msg
   2.588 -say Not enough RAM to boot slitaz.
   2.589 -default reboot
   2.590 -label reboot
   2.591 -	com32 reboot.c32
   2.592 -
   2.593 -implicit 0
   2.594 -prompt 1
   2.595 -timeout 80
   2.596 -F1 help.txt
   2.597 -F2 options.txt
   2.598 -F3 isolinux.msg
   2.599 -F4 display.txt
   2.600 -F5 enhelp.txt
   2.601 -F6 enopts.txt
   2.602 -EOT
   2.603 -	status
   2.604 -}
   2.605 -
   2.606 -####################
   2.607 -# Tazlito commands #
   2.608 -####################
   2.609 -
   2.610 -case "$COMMAND" in
   2.611 -	stats)
   2.612 -		# Tazlito general statistics from the config file.
   2.613 -		#
   2.614 -		echo ""
   2.615 -		echo -e "\033[1mTazlito statistics\033[0m
   2.616 -===============================================================================
   2.617 -Config file         : $CONFIG_FILE
   2.618 -ISO name            : $ISO_NAME.iso
   2.619 -Volume name         : $VOLUM_NAME
   2.620 -Prepared            : $PREPARED
   2.621 -Packages repository : $PACKAGES_REPOSITORY
   2.622 -Distro directory    : $DISTRO"
   2.623 -		if [ ! "$ADDFILES" = "" ] ; then
   2.624 -			echo -e "Additional files    : $ADDFILES"
   2.625 -		fi
   2.626 -		echo "================================================================================"
   2.627 -		echo ""
   2.628 -	    ;;
   2.629 -	list-addfiles)
   2.630 -		# Simple list of additonal files in the rootfs
   2.631 -		echo ""
   2.632 -		cd $ADDFILES
   2.633 -		find rootfs -type f
   2.634 -		echo "" ;;
   2.635 -	gen-config)
   2.636 -		# Generate a new config file in the current dir or the specified
   2.637 -		# directory by $2.
   2.638 -		#
   2.639 -		if [ -n "$2" ] ; then
   2.640 -			mkdir -p $2 && cd $2
   2.641 -		fi
   2.642 -		echo -n "Generating empty tazlito.conf..."
   2.643 -		empty_config_file
   2.644 -		status
   2.645 -		echo ""
   2.646 -		if [ -f "tazlito.conf" ] ; then
   2.647 -			echo "Configuration file is ready to edit."
   2.648 -			echo "File location : `pwd`/tazlito.conf"
   2.649 -			echo ""
   2.650 -		fi
   2.651 -		;;
   2.652 -	configure)
   2.653 -		# Configure a tazlito.conf config file. Start by getting
   2.654 -		# a empty config file and sed it.
   2.655 -		#
   2.656 -		if [ -f "tazlito.conf" ] ; then
   2.657 -			rm tazlito.conf
   2.658 -		else
   2.659 -			if test $(id -u) = 0 ; then
   2.660 -				cd /etc
   2.661 -			else
   2.662 -				echo "You must be root to configure the main config file or in"
   2.663 -				echo "the same directory of the file you want to configure."
   2.664 -				exit 0
   2.665 -			fi
   2.666 -		fi
   2.667 -		empty_config_file
   2.668 -		echo""
   2.669 -		echo -e "\033[1mConfiguring :\033[0m `pwd`/tazlito.conf"
   2.670 -		echo "================================================================================"
   2.671 -		# ISO name.
   2.672 -		echo -n "ISO name            : " ; read answer
   2.673 -		sed -i s#'ISO_NAME=\"\"'#"ISO_NAME=\"$answer\""# tazlito.conf
   2.674 -		# Volume name.
   2.675 -		echo -n "Volume name         : " ; read answer
   2.676 -		sed -i s/'VOLUM_NAME=\"SliTaz\"'/"VOLUM_NAME=\"$answer\""/ tazlito.conf
   2.677 -		# Packages repository.
   2.678 -		echo -n "Packages repository : " ; read answer
   2.679 -		sed -i s#'PACKAGES_REPOSITORY=\"\"'#"PACKAGES_REPOSITORY=\"$answer\""# tazlito.conf
   2.680 -		# Distro path.
   2.681 -		echo -n "Distro path         : " ; read answer
   2.682 -		sed -i s#'DISTRO=\"\"'#"DISTRO=\"$answer\""# tazlito.conf
   2.683 -		echo "================================================================================"
   2.684 -		echo "Config file is ready to use."
   2.685 -		echo "You can now extract an ISO or generate a distro."
   2.686 -		echo ""
   2.687 -		;;
   2.688 -	gen-iso)
   2.689 -		# Simply generate a new iso.
   2.690 -		#
   2.691 -		check_root
   2.692 -		verify_rootcd
   2.693 -		gen_livecd_isolinux
   2.694 -		distro_stats
   2.695 -		;;
   2.696 -	gen-initiso)
   2.697 -		# Simply generate a new initramfs with a new iso.
   2.698 -		#
   2.699 -		check_root
   2.700 -		verify_rootcd
   2.701 -		gen_initramfs $ROOTFS
   2.702 -		gen_livecd_isolinux
   2.703 -		distro_stats
   2.704 -		;;
   2.705 -	extract-distro)
   2.706 -		# Extract an ISO image to a directory and rebuild the LiveCD tree.
   2.707 -		#
   2.708 -		check_root
   2.709 -		ISO_IMAGE=$2
   2.710 -		if [ -z "$ISO_IMAGE" ] ; then
   2.711 -			echo -e "\nPlease specify the path to the ISO image."
   2.712 -			echo -e "Example : `basename $0` image.iso /path/target\n"
   2.713 -			exit 0
   2.714 -		fi
   2.715 -		# Set the distro path by checking for $3 on cmdline.
   2.716 -		if [ -n "$3" ] ; then
   2.717 -			TARGET=$3
   2.718 -		else
   2.719 -			TARGET=$DISTRO
   2.720 -		fi
   2.721 -		# Exit if existing distro is found.
   2.722 -		if [ -d "$TARGET/rootfs" ] ; then
   2.723 -			echo -e "\nA rootfs exists in : $TARGET"
   2.724 -			echo -e "Please clean the distro tree or change directory path.\n"
   2.725 -			exit 0
   2.726 -		fi
   2.727 -		echo ""
   2.728 -		echo -e "\033[1mTazlito extracting :\033[0m `basename $ISO_IMAGE`"
   2.729 -		echo "================================================================================"
   2.730 -		# Start to mount the ISO.
   2.731 -		echo ""
   2.732 -		echo "Mounting ISO image..."
   2.733 -		mkdir -p $TMP_DIR
   2.734 -		# Get ISO file size.
   2.735 -		isosize=`du -sh $ISO_IMAGE | cut -f1`
   2.736 -		mount -o loop $ISO_IMAGE $TMP_DIR
   2.737 -		sleep 2
   2.738 -		# Prepare target dir, copy the kernel and the rootfs.
   2.739 -		mkdir -p $TARGET/rootfs
   2.740 -		mkdir -p $TARGET/rootcd/boot
   2.741 -		echo -n "Copying the Linux kernel..."
   2.742 -		if cp $TMP_DIR/boot/vmlinuz* $TARGET/rootcd/boot 2> /dev/null; then
   2.743 -			ln $TARGET/rootcd/boot/vmlinuz* $TARGET/rootcd/boot/bzImage
   2.744 -		else
   2.745 -			cp $TMP_DIR/boot/bzImage $TARGET/rootcd/boot
   2.746 -		fi
   2.747 -		status
   2.748 -		echo -n "Copying isolinux files..."
   2.749 -		cp -a $TMP_DIR/boot/isolinux $TARGET/rootcd/boot
   2.750 -		for i in $(ls $TMP_DIR); do
   2.751 -			[ "$i" = "boot" ] && continue
   2.752 -			cp -a $TMP_DIR/$i $TARGET/rootcd
   2.753 -		done
   2.754 -		status
   2.755 -		if [ -d $TMP_DIR/boot/syslinux ]; then
   2.756 -			echo -n "Copying syslinux files..."
   2.757 -			cp -a $TMP_DIR/boot/syslinux $TARGET/rootcd/boot
   2.758 -			status
   2.759 -		fi
   2.760 -		if [ -d $TMP_DIR/boot/extlinux ]; then
   2.761 -			echo -n "Copying extlinux files..."
   2.762 -			cp -a $TMP_DIR/boot/extlinux $TARGET/rootcd/boot
   2.763 -			status
   2.764 -		fi
   2.765 -		if [ -d $TMP_DIR/boot/grub ]; then
   2.766 -			echo -n "Copying GRUB files..."
   2.767 -			cp -a $TMP_DIR/boot/grub $TARGET/rootcd/boot
   2.768 -			status
   2.769 -		fi
   2.770 -		
   2.771 -		echo -n "Copying the rootfs..."
   2.772 -		cp $TMP_DIR/boot/rootfs.?z $TARGET/rootcd/boot
   2.773 -		status
   2.774 -		# Extract initramfs.
   2.775 -		cd $TARGET/rootfs
   2.776 -		echo -n "Extracting the rootfs... "
   2.777 -		extract_rootfs ../rootcd/boot/rootfs.gz $TARGET/rootfs
   2.778 -		# unpack /usr
   2.779 -		for i in etc/tazlito/*.extract; do
   2.780 -			[ -f "$i" ] && . $i ../rootcd
   2.781 -		done
   2.782 -		# Umount and remove temp directory and cd to $TARGET to get stats.
   2.783 -		umount $TMP_DIR && rm -rf $TMP_DIR
   2.784 -		cd ..
   2.785 -		echo ""
   2.786 -		echo "================================================================================"
   2.787 -		echo "Extracted       : `basename $ISO_IMAGE` ($isosize)"
   2.788 -		echo "Distro tree     : `pwd`"
   2.789 -		echo "Rootfs size     : `du -sh rootfs`"
   2.790 -		echo "Rootcd size     : `du -sh rootcd`"
   2.791 -		echo "================================================================================"
   2.792 -		echo ""
   2.793 -		;;
   2.794 -	list-flavors)
   2.795 -		# Show available flavors.
   2.796 -		if [ ! -s /etc/tazlito/flavors.list -o "$2" == "--recharge" ]; then
   2.797 -			download flavors.list -O - > /etc/tazlito/flavors.list
   2.798 -		fi
   2.799 -		echo ""
   2.800 -		echo -e "\033[1mList of flavors\033[0m"
   2.801 -		echo "================================================================================"
   2.802 -		cat /etc/tazlito/flavors.list
   2.803 -		echo ""
   2.804 -		;;
   2.805 -	show-flavor)
   2.806 -		# Show flavor description.
   2.807 -		FLAVOR=${2%.flavor}
   2.808 -		if [ ! -f "$FLAVOR.flavor" ]; then
   2.809 -			echo "File $FLAVOR.flavor not found."
   2.810 -			exit 1
   2.811 -		fi
   2.812 -		mkdir $TMP_DIR
   2.813 -		zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i 2> /dev/null)
   2.814 -		if [ "$3" = "--brief" ]; then
   2.815 -			if [ "$4" != "--noheader" ]; then
   2.816 -				echo "Name              ISO   Rootfs  Description"
   2.817 -				echo "================================================================================"
   2.818 -			fi
   2.819 -			printf "%-16.16s %6.6s %6.6s %s\n" "$FLAVOR" \
   2.820 -				"$(field ISO $TMP_DIR/$FLAVOR.desc)" \
   2.821 -				"$(field 'Rootfs size' $TMP_DIR/$FLAVOR.desc)" \
   2.822 -				"$(grep ^Description $TMP_DIR/$FLAVOR.desc | cut -d: -f2)"
   2.823 -		else
   2.824 -			echo "================================================================================"
   2.825 -			cat $TMP_DIR/$FLAVOR.desc
   2.826 -		fi
   2.827 -		rm -Rf $TMP_DIR
   2.828 -		;;
   2.829 -	gen-liveflavor)
   2.830 -		# Generate a new flavor form the live system.
   2.831 -		FLAVOR=${2%.flavor}
   2.832 -		DESC=""
   2.833 -		case "$FLAVOR" in
   2.834 -		'')	echo -n "Flavor name : "
   2.835 -			read FLAVOR
   2.836 -			[ -z "$FLAVOR" ] && exit 1;;
   2.837 -		-?|-h*|--help) echo -e "
   2.838 -
   2.839 -SliTaz Live Tool - Version: $VERSION
   2.840 -\033[1mUsage: \033[0m `basename $0` gen-liveflavor flavor-name [flavor-patch-file]
   2.841 -\033[1mflavor-patch-file format: \033[0m
   2.842 -code	data
   2.843 -+	package to add
   2.844 --	package to remove
   2.845 -!	non-free package to add
   2.846 -?	display message
   2.847 -@	flavor description
   2.848 -
   2.849 -\033[1mExample: \033[0m
   2.850 -@	Developer tools for slitaz maintainers
   2.851 -+	slitaz-toolchain
   2.852 -+	mercurial
   2.853 -"
   2.854 -			exit 1;;
   2.855 -		esac
   2.856 -		mv /etc/tazlito/distro-packages.list \
   2.857 -		   /etc/tazlito/distro-packages.list.$$ 2> /dev/null
   2.858 -		rm -f distro-packages.list non-free.list 2> /dev/null
   2.859 -		tazpkg recharge
   2.860 -		[ -n "$3" ] && while read action pkg; do
   2.861 -			case "$action" in
   2.862 -			+)	yes | tazpkg get-install $pkg;;
   2.863 -			-)	yes | tazpkg remove $pkg;;
   2.864 -			!)	echo $pkg >> non-free.list;;
   2.865 -			@)	DESC="$pkg";;
   2.866 -			\?)	echo -en "$pkg"; read action;;
   2.867 -			esac
   2.868 -		done < $3
   2.869 -		yes '' | tazlito gen-distro
   2.870 -		echo "$DESC" | tazlito gen-flavor "$FLAVOR"
   2.871 -		mv /etc/tazlito/distro-packages.list.$$ \
   2.872 -		   /etc/tazlito/distro-packages.list 2> /dev/null
   2.873 -		;;
   2.874 -	gen-flavor)
   2.875 -		# Generate a new flavor from the last iso image generated.
   2.876 -		FLAVOR=${2%.flavor}
   2.877 -		echo ""
   2.878 -		echo -e "\033[1mFlavor generation\033[0m"
   2.879 -		echo "================================================================================"
   2.880 -		if [ -z "$FLAVOR" ]; then
   2.881 -			echo -n "Flavor name : "
   2.882 -			read FLAVOR
   2.883 -			[ -z "$FLAVOR" ] && exit 1
   2.884 -		fi
   2.885 -		check_rootfs
   2.886 -		FILES="$FLAVOR.pkglist"
   2.887 -		echo -n "Creating file $FLAVOR.flavor..."
   2.888 -		for i in rootcd rootfs; do
   2.889 -			if [ -d "$ADDFILES/$i" ] ; then
   2.890 -				FILES="$FILES\n$FLAVOR.$i"
   2.891 -				( cd "$ADDFILES/$i"; find . | \
   2.892 -				  cpio -o -H newc 2> /dev/null | gzip -9 ) > $FLAVOR.$i
   2.893 -			fi
   2.894 -		done
   2.895 -		status
   2.896 -		answer=`grep -s ^Description $FLAVOR.desc`
   2.897 -		answer=${answer#Description     : }
   2.898 -		if [ -z "$answer" ]; then
   2.899 -			echo -n "Description : "
   2.900 -			read answer
   2.901 -		fi
   2.902 -		echo -n "Compressing flavor $FLAVOR..."
   2.903 -		echo "Flavor          : $FLAVOR" > $FLAVOR.desc
   2.904 -		echo "Description     : $answer" >> $FLAVOR.desc
   2.905 -		( cd $DISTRO; distro_sizes) >> $FLAVOR.desc
   2.906 -		\rm -f $FLAVOR.pkglist $FLAVOR.nonfree 2> /dev/null
   2.907 -		for i in $(ls $ROOTFS$INSTALLED); do
   2.908 -			eval $(grep ^VERSION= $ROOTFS$INSTALLED/$i/receipt)
   2.909 -			EXTRAVERSION=""
   2.910 -			eval $(grep ^EXTRAVERSION= $ROOTFS$INSTALLED/$i/receipt)
   2.911 -			eval $(grep ^CATEGORY= $ROOTFS$INSTALLED/$i/receipt)
   2.912 -			if [ "$CATEGORY" = "non-free" -a "${i%%-*}" != "get" ]
   2.913 -			then
   2.914 -				echo "$i" >> $FLAVOR.nonfree
   2.915 -			else
   2.916 -				echo "$i-$VERSION$EXTRAVERSION" >> $FLAVOR.pkglist
   2.917 -			fi
   2.918 -		done
   2.919 -		[ -s $FLAVOR.nonfree ] && $FILES="$FILES\n$FLAVOR.nonfree"
   2.920 -		for i in $LOCALSTATE/undigest/*/mirror ; do
   2.921 -			[ -s $i ] && cat $i >> $FLAVOR.mirrors
   2.922 -		done
   2.923 -		[ -s $FLAVOR.mirrors ] && $FILES="$FILES\n$FLAVOR.mirrors"
   2.924 -		echo -e "$FLAVOR.desc\n$FILES" | cpio -o -H newc 2>/dev/null | \
   2.925 -			gzip -9 > $FLAVOR.flavor
   2.926 -		rm `echo -e $FILES`
   2.927 -		status
   2.928 -		echo "================================================================================"
   2.929 -		echo "Flavor size : `du -sh $FLAVOR.flavor`"
   2.930 -		echo ""
   2.931 -		;;
   2.932 -	upgrade-flavor)
   2.933 -		# Update package list to the lastest versions available.
   2.934 -		FLAVOR=${2%.flavor}
   2.935 -		if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
   2.936 -			mkdir $TMP_DIR
   2.937 -			zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i >/dev/null )
   2.938 -			echo -n "Updating $FLAVOR package list..."
   2.939 -			[ -s /var/lib/tazpkg/packages.list ] || tazpkg recharge
   2.940 -			packed_size=0; unpacked_size=0
   2.941 -			while read org; do
   2.942 -				i=0
   2.943 -				pkg=$org
   2.944 -				while ! grep -q ^$pkg$ /var/lib/tazpkg/packages.txt; do
   2.945 -					pkg=${pkg%-*}
   2.946 -					i=$(($i + 1))
   2.947 -					[ $i -gt 5 ] && break;
   2.948 -				done
   2.949 -				set -- $(get_size $pkg)
   2.950 -				packed_size=$(( $packed_size + $1 ))
   2.951 -				unpacked_size=$(( $unpacked_size + $2 ))
   2.952 -				for i in $(grep ^$pkg /var/lib/tazpkg/packages.list); do
   2.953 -					echo $i
   2.954 -					break
   2.955 -				done
   2.956 -			done <  $TMP_DIR/$FLAVOR.pkglist \
   2.957 -			     > $TMP_DIR/$FLAVOR.pkglist.$$
   2.958 -			mv -f $TMP_DIR/$FLAVOR.pkglist.$$ $TMP_DIR/$FLAVOR.pkglist
   2.959 -			if [ -s $TMP_DIR/$FLAVOR.rootfs ]; then
   2.960 -				packed_size=$(($packed_size \
   2.961 -					+ $(cat $TMP_DIR/$FLAVOR.rootfs | wc -c ) / 100 ))
   2.962 -				unpacked_size=$(($unpacked_size \
   2.963 -					+ $(zcat $TMP_DIR/$FLAVOR.rootfs | wc -c ) / 100 ))
   2.964 -			fi
   2.965 -			# Estimate lzma
   2.966 -			packed_size=$(($packed_size * 2 / 3))
   2.967 -			iso_size=$(( $packed_size + 26000 ))
   2.968 -			if [ -s $TMP_DIR/$FLAVOR.rootcd ]; then
   2.969 -				iso_size=$(($iso_size \
   2.970 -					+ $(zcat $TMP_DIR/$FLAVOR.rootcd | wc -c ) / 100 ))
   2.971 -			fi
   2.972 -			sed -i -e '/Image is ready/d' \
   2.973 -			       -e "s/Rootfs size\( *:\) \(.*\)/Rootfs size\1 $(cent2human $unpacked_size)  (estimated)/" \
   2.974 -			       -e "s/Initramfs size\( *:\) \(.*\)/Initramfs size\1 $(cent2human $packed_size)  (estimated)/" \
   2.975 -			       -e "s/ISO image size\( *:\) \(.*\)/ISO image size\1 $(cent2human $iso_size)  (estimated)/" \
   2.976 -			       -e "s/date\( *:\) \(.*\)/date\1 $(date +%Y%m%d\ \at\ \%H:%M:%S)/" \
   2.977 -					$TMP_DIR/$FLAVOR.desc
   2.978 -			( cd $TMP_DIR ; ls | cpio -o -H newc ) | gzip -9 > \
   2.979 -				$FLAVOR.flavor
   2.980 -			status
   2.981 -			rm -Rf $TMP_DIR
   2.982 -		fi
   2.983 -		;;
   2.984 -	extract-flavor)
   2.985 -		# Extract a flavor into $FLAVORS_REPOSITORY.
   2.986 -		FLAVOR=${2%.flavor}
   2.987 -		if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
   2.988 -			mkdir $TMP_DIR
   2.989 -			zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i >/dev/null )
   2.990 -			echo -n "Extracting $FLAVOR..."
   2.991 -			rm -rf $FLAVORS_REPOSITORY/$FLAVOR 2> /dev/null
   2.992 -			mkdir -p $FLAVORS_REPOSITORY/$FLAVOR
   2.993 -			echo "FLAVOR=\"$FLAVOR\"" > $FLAVORS_REPOSITORY/$FLAVOR/receipt
   2.994 -			grep ^Description $TMP_DIR/$FLAVOR.desc | \
   2.995 -				sed 's/.*: \(.*\)$/SHORT_DESC="\1"/' >> \
   2.996 -				$FLAVORS_REPOSITORY/$FLAVOR/receipt
   2.997 -			grep -q '^Rootfs list' $TMP_DIR/$FLAVOR.desc && \
   2.998 -			grep '^Rootfs list' $TMP_DIR/$FLAVOR.desc | \
   2.999 -				sed 's/.*: \(.*\)$/ROOTFS_SELECTION="\1"/' >> \
  2.1000 -				$FLAVORS_REPOSITORY/$FLAVOR/receipt
  2.1001 -			grep '^Rootfs size' $TMP_DIR/$FLAVOR.desc | \
  2.1002 -				sed 's/.*: \(.*\)$/ROOTFS_SIZE="\1"/' >> \
  2.1003 -				$FLAVORS_REPOSITORY/$FLAVOR/receipt
  2.1004 -			grep ^Initramfs $TMP_DIR/$FLAVOR.desc | \
  2.1005 -				sed 's/.*: \(.*\)$/INITRAMFS_SIZE="\1"/' >> \
  2.1006 -				$FLAVORS_REPOSITORY/$FLAVOR/receipt
  2.1007 -			grep ^ISO $TMP_DIR/$FLAVOR.desc | \
  2.1008 -				sed 's/.*: \(.*\)$/ISO_SIZE="\1"/' >> \
  2.1009 -				$FLAVORS_REPOSITORY/$FLAVOR/receipt
  2.1010 -			for i in rootcd rootfs; do
  2.1011 -				[ -f $TMP_DIR/$FLAVOR.$i ] || continue
  2.1012 -				mkdir $FLAVORS_REPOSITORY/$FLAVOR/$i
  2.1013 -				zcat $TMP_DIR/$FLAVOR.$i | \
  2.1014 -				  (cd $FLAVORS_REPOSITORY/$FLAVOR/$i; \
  2.1015 -				   cpio -idm > /dev/null)
  2.1016 -			done
  2.1017 -			[ -s $TMP_DIR/$FLAVOR.mirrors ] &&
  2.1018 -				cp $TMP_DIR/$FLAVOR.mirrors \
  2.1019 -					$FLAVORS_REPOSITORY/$FLAVOR/mirrors
  2.1020 -			[ -s /var/lib/tazpkg/packages.list ] || tazpkg recharge
  2.1021 -			while read org; do
  2.1022 -				i=0
  2.1023 -				pkg=$org
  2.1024 -				while ! grep -q ^$pkg$ /var/lib/tazpkg/packages.txt; do
  2.1025 -					pkg=${pkg%-*}
  2.1026 -					i=$(($i + 1))
  2.1027 -					[ $i -gt 5 ] && break;
  2.1028 -				done
  2.1029 -				echo $pkg
  2.1030 -			done <  $TMP_DIR/$FLAVOR.pkglist \
  2.1031 -			     > $FLAVORS_REPOSITORY/$FLAVOR/packages.list
  2.1032 -			status
  2.1033 -			rm -Rf $TMP_DIR
  2.1034 -		fi
  2.1035 -		;;
  2.1036 -	pack-flavor)
  2.1037 -		# Create a flavor from $FLAVORS_REPOSITORY.
  2.1038 -		FLAVOR=${2%.flavor}
  2.1039 -		if [ -s $FLAVORS_REPOSITORY/$FLAVOR/receipt ]; then
  2.1040 -			mkdir $TMP_DIR
  2.1041 -			echo -n "Creating flavor $FLAVOR..."
  2.1042 -			[ -s /var/lib/tazpkg/packages.list ] || tazpkg recharge
  2.1043 -			if [ -s $FLAVORS_REPOSITORY/$FLAVOR/mirrors ]; then
  2.1044 -				cp $FLAVORS_REPOSITORY/$FLAVOR/mirrors \
  2.1045 -					$TMP_DIR/$FLAVOR.mirrors
  2.1046 -				for i in $(cat $TMP_DIR/$FLAVOR.mirrors); do
  2.1047 -					wget -O - $i/packages.list >> $TMP_DIR/packages.list
  2.1048 -				done
  2.1049 -			fi
  2.1050 -			[ -s $FLAVORS_REPOSITORY/$FLAVOR/packages.list ] &&
  2.1051 -			get_pkglist $FLAVOR > $TMP_DIR/$FLAVOR.pkglist
  2.1052 -			if grep -q ^ROOTFS_SELECTION \
  2.1053 -				$FLAVORS_REPOSITORY/$FLAVOR/receipt; then
  2.1054 -				. $FLAVORS_REPOSITORY/$FLAVOR/receipt
  2.1055 -				set -- $ROOTFS_SELECTION
  2.1056 -				[ -n "$FRUGAL_RAM" ] || FRUGAL_RAM=$1
  2.1057 -				[ -f $FLAVORS_REPOSITORY/$2/packages.list ] ||
  2.1058 -					tazlito extract-flavor $2
  2.1059 -				get_pkglist $2 > $TMP_DIR/$FLAVOR.pkglist
  2.1060 -			fi
  2.1061 -			for i in rootcd rootfs; do
  2.1062 -				[ -d $FLAVORS_REPOSITORY/$FLAVOR/$i ] || \
  2.1063 -					continue
  2.1064 -				( cd $FLAVORS_REPOSITORY/$FLAVOR/$i ; find . | \
  2.1065 -				cpio -o -H newc 2> /dev/null ) | \
  2.1066 -				gzip -9 >$TMP_DIR/$FLAVOR.$i
  2.1067 -			done
  2.1068 -			if [ -s $TMP_DIR/$FLAVOR.rootfs ]; then
  2.1069 -				packed_size=$(($packed_size \
  2.1070 -					+ $(cat $TMP_DIR/$FLAVOR.rootfs | wc -c ) / 100 ))
  2.1071 -				unpacked_size=$(($unpacked_size \
  2.1072 -					+ $(zcat $TMP_DIR/$FLAVOR.rootfs | wc -c ) / 100 ))
  2.1073 -			fi
  2.1074 -			# Estimate lzma
  2.1075 -			packed_size=$(($packed_size * 2 / 3))
  2.1076 -			iso_size=$(( $packed_size + 26000 ))
  2.1077 -			if [ -s $TMP_DIR/$FLAVOR.rootcd ]; then
  2.1078 -				iso_size=$(($iso_size \
  2.1079 -					+ $(zcat $TMP_DIR/$FLAVOR.rootcd | wc -c ) / 100 ))
  2.1080 -			fi
  2.1081 -			VERSION=""
  2.1082 -			MAINTAINER=""
  2.1083 -			ROOTFS_SELECTION=""
  2.1084 -			ROOTFS_SIZE="$(cent2human $unpacked_size) (estimated)"
  2.1085 -			INITRAMFS_SIZE="$(cent2human $packed_size) (estimated)"
  2.1086 -			ISO_SIZE="$(cent2human $iso_size) (estimated)"
  2.1087 -			. $FLAVORS_REPOSITORY/$FLAVOR/receipt
  2.1088 -			cat > $TMP_DIR/$FLAVOR.desc <<EOT
  2.1089 -Flavor          : $FLAVOR
  2.1090 -Description     : $SHORT_DESC
  2.1091 -EOT
  2.1092 -			[ -n "$VERSION" ] && cat >> $TMP_DIR/$FLAVOR.desc <<EOT
  2.1093 -Version         : $VERSION
  2.1094 -EOT
  2.1095 -			[ -n "$MAINTAINER" ] && cat >> $TMP_DIR/$FLAVOR.desc <<EOT
  2.1096 -Maintainer      : $MAINTAINER
  2.1097 -EOT
  2.1098 -			[ -n "$FRUGAL_RAM" ] && cat >> $TMP_DIR/$FLAVOR.desc <<EOT
  2.1099 -LiveCD RAM size : $FRUGAL_RAM
  2.1100 -EOT
  2.1101 -			[ -n "$ROOTFS_SELECTION" ] && cat >> $TMP_DIR/$FLAVOR.desc <<EOT
  2.1102 -Rootfs list     : $ROOTFS_SELECTION
  2.1103 -EOT
  2.1104 -			cat >> $TMP_DIR/$FLAVOR.desc <<EOT
  2.1105 -Build date      : $(date +%Y%m%d\ \at\ \%H:%M:%S)
  2.1106 -Packages        : $(grep -v ^# $TMP_DIR/$FLAVOR.pkglist | wc -l)
  2.1107 -Rootfs size     : $ROOTFS_SIZE
  2.1108 -Initramfs size  : $INITRAMFS_SIZE
  2.1109 -ISO image size  : $ISO_SIZE
  2.1110 -================================================================================
  2.1111 -
  2.1112 -EOT
  2.1113 -			rm -f $TMP_DIR/packages.list
  2.1114 -			( cd $TMP_DIR ; ls | cpio -o -H newc 2> /dev/null) | \
  2.1115 -				gzip -9 > $FLAVOR.flavor
  2.1116 -			status
  2.1117 -			rm -Rf $TMP_DIR
  2.1118 -		else
  2.1119 -			echo "No $FLAVOR flavor in $FLAVORS_REPOSITORY."
  2.1120 -		fi
  2.1121 -		;;
  2.1122 -	get-flavor)
  2.1123 -		# Get a flavor's files and prepare for gen-distro.
  2.1124 -		FLAVOR=${2%.flavor}
  2.1125 -		echo ""
  2.1126 -		if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
  2.1127 -			echo -n "Cleaning $DISTRO..."
  2.1128 -			rm -R $DISTRO 2> /dev/null
  2.1129 -			mkdir -p $DISTRO
  2.1130 -			status
  2.1131 -			mkdir $TMP_DIR
  2.1132 -			echo -n "Extracting flavor $FLAVOR.flavor... "
  2.1133 -			zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i 2>/dev/null )
  2.1134 -			echo -n "Creating distro-packages.list..."
  2.1135 -			mv $TMP_DIR/$FLAVOR.nonfree non-free.list 2> /dev/null
  2.1136 -			mv $TMP_DIR/$FLAVOR.pkglist distro-packages.list
  2.1137 -			status
  2.1138 -			for i in rootcd rootfs; do
  2.1139 -				if [ -f $TMP_DIR/$FLAVOR.$i ]; then
  2.1140 -					echo -n "Adding $i... "
  2.1141 -					mkdir -p "$ADDFILES/$i"
  2.1142 -					zcat $TMP_DIR/$FLAVOR.$i | \
  2.1143 -						( cd "$ADDFILES/$i"; cpio -id 2> /dev/null)
  2.1144 -				fi
  2.1145 -			done
  2.1146 -			if [ -s $TMP_DIR/$FLAVOR.mirrors ]; then
  2.1147 -				n=""
  2.1148 -				while read line; do
  2.1149 -					mkdir -p $LOCALSTATE/undigest/$FLAVOR$n
  2.1150 -					echo "$line" > $LOCALSTATE/undigest/$FLAVOR$n/mirror
  2.1151 -					n=$(( $n + 1 ))
  2.1152 -				done < $TMP_DIR/$FLAVOR.mirrors
  2.1153 -				tazpkg recharge
  2.1154 -			fi
  2.1155 -			rm -f /etc/tazlito/rootfs.list
  2.1156 -			grep -q '^Rootfs list' $TMP_DIR/$FLAVOR.desc &&
  2.1157 -				grep '^Rootfs list' $TMP_DIR/$FLAVOR.desc | \
  2.1158 -				sed 's/.*: \(.*\)$/\1/' > /etc/tazlito/rootfs.list
  2.1159 -			echo -n "Updating tazlito.conf..."
  2.1160 -			[ -f tazlito.conf ] || cp /etc/tazlito/tazlito.conf .
  2.1161 -			cat tazlito.conf | grep -v "^#VOLUM_NAME" | \
  2.1162 -			sed "s/^VOLUM_NA/VOLUM_NAME=\"SliTaz $FLAVOR\"\\n#VOLUM_NA/" \
  2.1163 -				> tazlito.conf.$$ && mv tazlito.conf.$$ tazlito.conf
  2.1164 -			sed -i "s/ISO_NAME=.*/ISO_NAME=\"slitaz-$FLAVOR\"/" tazlito.conf
  2.1165 -			status
  2.1166 -			rm -Rf $TMP_DIR
  2.1167 -		fi
  2.1168 -		echo ""
  2.1169 -		;;
  2.1170 -	check-list)
  2.1171 -		# Use current packages list in $PWD by default.
  2.1172 -		DISTRO_PKGS_LIST=distro-packages.list
  2.1173 -		[ -d "$2" ] && DISTRO_PKGS_LIST=$2/distro-packages.list
  2.1174 -		[ -f "$2" ] && DISTRO_PKGS_LIST=$2
  2.1175 -		[ ! -f $DISTRO_PKGS_LIST ] && echo "No packages list found." && exit 0
  2.1176 -		echo ""
  2.1177 -		echo -e "\033[1mLiveCD packages list check\033[0m"
  2.1178 -		echo "================================================================================"
  2.1179 -		for pkg in `cat $DISTRO_PKGS_LIST`
  2.1180 -		do
  2.1181 -			if ! grep -q "$pkg" /var/lib/tazpkg/packages.list; then
  2.1182 -				echo "Update: $pkg"
  2.1183 -				up=$(($up + 1))
  2.1184 -			fi
  2.1185 -		done
  2.1186 -		[ -z $up ] && echo -e "List is up-to-date\n" && exit 0
  2.1187 -		echo "================================================================================"
  2.1188 -		echo -e "Updates: $up\n" ;;
  2.1189 -	gen-distro)
  2.1190 -		# Generate a live distro tree with a set of packages.
  2.1191 -		#
  2.1192 -		check_root
  2.1193 -		
  2.1194 -		# Check if a package list was specified on cmdline.
  2.1195 -		LIST_NAME="distro-packages.list"
  2.1196 -		CDROM=""
  2.1197 -		while [ -n "$2" ]; do
  2.1198 -			case "$2" in
  2.1199 -			--iso=*)
  2.1200 -				CDROM="-o loop ${2#--iso=}"
  2.1201 -				;;
  2.1202 -			--cdrom)
  2.1203 -				CDROM="/dev/cdrom"
  2.1204 -				;;
  2.1205 -			--force)
  2.1206 -				DELETE_ROOTFS="true"
  2.1207 -				;;
  2.1208 -			*)	if [ ! -f "$2" ] ; then
  2.1209 -					echo -e "\nUnable to find the specified packages list."
  2.1210 -					echo -e "List name : $2\n"
  2.1211 -					exit 1
  2.1212 -				fi
  2.1213 -				LIST_NAME=$2
  2.1214 -				;;
  2.1215 -			esac
  2.1216 -			shift
  2.1217 -		done
  2.1218 -		 
  2.1219 -		if [ -d $ROOTFS ] ; then
  2.1220 -			# Delete $ROOTFS if --force is set on command line
  2.1221 -			if [ ! -z $DELETE_ROOTFS ]; then
  2.1222 -				rm -rf $ROOTFS
  2.1223 -				unset $DELETE_ROOTFS
  2.1224 -			else
  2.1225 -				echo -e "\nA rootfs exists in : $DISTRO"
  2.1226 -				echo -e "Please clean the distro tree or change directory path.\n"
  2.1227 -				exit 0
  2.1228 -			fi
  2.1229 -		fi
  2.1230 -		if [ ! -f "$LIST_NAME" -a -d $INSTALLED ] ; then
  2.1231 -		# Build list with installed packages
  2.1232 -			for i in $(ls $INSTALLED); do
  2.1233 -				eval $(grep ^VERSION= $INSTALLED/$i/receipt)
  2.1234 -				EXTRAVERSION=""
  2.1235 -				eval $(grep ^EXTRAVERSION= $INSTALLED/$i/receipt)
  2.1236 -				echo "$i-$VERSION$EXTRAVERSION" >> $LIST_NAME
  2.1237 -			done
  2.1238 -		fi
  2.1239 -		# Exit if no list name.
  2.1240 -		if [ ! -f "$LIST_NAME" ]; then
  2.1241 -			echo -e "\nNo packages list found or specified. Please read the docs.\n"
  2.1242 -			exit 0
  2.1243 -		fi
  2.1244 -		# Start generation.
  2.1245 -		echo ""
  2.1246 -		echo -e "\033[1mTazlito generating a distro\033[0m"
  2.1247 -		echo "================================================================================"
  2.1248 -		# Misc checks
  2.1249 -		[ -n "$PACKAGES_REPOSITORY" ] || PACKAGES_REPOSITORY="."
  2.1250 -		[ -d $PACKAGES_REPOSITORY ] || mkdir -p $PACKAGES_REPOSITORY
  2.1251 -		# Get the list of packages using cat for a file list.
  2.1252 -		LIST=`cat $LIST_NAME`
  2.1253 -		# Verify if all packages in list are present in $PACKAGES_REPOSITORY.
  2.1254 -		REPACK=""
  2.1255 -		DOWNLOAD=""
  2.1256 -		for pkg in $LIST
  2.1257 -		do
  2.1258 -			[ "$pkg" = "" ] && continue
  2.1259 -			pkg=${pkg%.tazpkg}
  2.1260 -			[ -f $PACKAGES_REPOSITORY/$pkg.tazpkg ] && continue
  2.1261 -			PACKAGE=$(installed_package_name $pkg)
  2.1262 -			[ -n "$PACKAGE" -a "$REPACK" = "y" ] && continue
  2.1263 -			[ -z "$PACKAGE" -a -n "$DOWNLOAD" ] && continue
  2.1264 -			echo -e "\nUnable to find $pkg in the repository."
  2.1265 -			echo -e "Path : $PACKAGES_REPOSITORY\n"
  2.1266 -			if [ -n "$PACKAGE" -a -z "$REPACK" ]; then
  2.1267 -				yesorno "Repack packages from rootfs (y/N) ? "
  2.1268 -				REPACK="$answer"
  2.1269 -				[ "$answer" = "y" ] || REPACK="n"
  2.1270 -				[ "$DOWNLOAD" = "y" ] && break
  2.1271 -			fi
  2.1272 -			if [ -f $MIRROR -a -z "$DOWNLOAD" ]; then
  2.1273 -				yesorno "Download packages from mirror (Y/n) ? "
  2.1274 -				DOWNLOAD="$answer"
  2.1275 -				if [ "$answer" = "n" ]; then
  2.1276 -					[ -z "$PACKAGE" ] && exit 1
  2.1277 -				else
  2.1278 -					DOWNLOAD="y"
  2.1279 -					[ -n "$REPACK" ] && break
  2.1280 -				fi
  2.1281 -			fi
  2.1282 -			[ "$REPACK" = "n" -a "$DOWNLOAD" = "n" ] && exit 1
  2.1283 -		done
  2.1284 -		
  2.1285 -		# Mount cdrom to be able to repack boot-loader packages
  2.1286 -		if [ ! -e /boot -a -n "$CDROM" ]; then
  2.1287 -			mkdir $TMP_MNT
  2.1288 -			if mount -r $CDROM $TMP_MNT 2> /dev/null; then
  2.1289 -				ln -s $TMP_MNT/boot /
  2.1290 -				if [ ! -d "$ADDFILES/rootcd" ] ; then
  2.1291 -					mkdir -p $ADDFILES/rootcd
  2.1292 -					for i in $(ls $TMP_MNT); do
  2.1293 -						[ "$i" = "boot" ] && continue
  2.1294 -						cp -a $TMP_MNT/$i $ADDFILES/rootcd
  2.1295 -					done
  2.1296 -				fi
  2.1297 -			else
  2.1298 -				rmdir $TMP_MNT
  2.1299 -			fi
  2.1300 -		fi
  2.1301 -
  2.1302 -		# Root fs stuff.
  2.1303 -		echo "Preparing the rootfs directory..."
  2.1304 -		mkdir -p $ROOTFS
  2.1305 -		sleep 2
  2.1306 -		for pkg in $LIST
  2.1307 -		do
  2.1308 -			[ "$pkg" = "" ] && continue
  2.1309 -			# First copy and extract the package in tmp dir.
  2.1310 -			pkg=${pkg%.tazpkg}
  2.1311 -			PACKAGE=$(installed_package_name $pkg)
  2.1312 -			mkdir -p $TMP_DIR
  2.1313 -			if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
  2.1314 -				# Look for package in cache
  2.1315 -				if [ -f $CACHE_DIR/$pkg.tazpkg ]; then
  2.1316 -					ln -s $CACHE_DIR/$pkg.tazpkg $PACKAGES_REPOSITORY
  2.1317 -				# Look for package in running distribution
  2.1318 -				elif [ -n "$PACKAGE" -a "$REPACK" = "y" ]; then
  2.1319 -					tazpkg repack $PACKAGE && \
  2.1320 -					  mv $pkg.tazpkg $PACKAGES_REPOSITORY 
  2.1321 -				fi
  2.1322 -			fi
  2.1323 -			if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
  2.1324 -				# Get package from mirror
  2.1325 -				[ "$DOWNLOAD" = "y" ] && \
  2.1326 -				download $pkg.tazpkg && \
  2.1327 -				mv $pkg.tazpkg $PACKAGES_REPOSITORY
  2.1328 -			fi
  2.1329 -			if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
  2.1330 -				echo "Missing package $pkg."
  2.1331 -				cleanup
  2.1332 -				exit 1
  2.1333 -			fi
  2.1334 -		done
  2.1335 -		if [ -f non-free.list ]; then
  2.1336 -			echo "Preparing non-free packages..."
  2.1337 -			cp non-free.list $ROOTFS/etc/tazlito/non-free.list
  2.1338 -			for pkg in $(cat non-free.list); do
  2.1339 -				if [ ! -d $INSTALLED/$pkg ]; then
  2.1340 -					if [ ! -d $INSTALLED/get-$pkg ]; then
  2.1341 -						tazpkg get-install get-$pkg
  2.1342 -					fi
  2.1343 -					get-$pkg
  2.1344 -				fi
  2.1345 -				tazpkg repack $pkg
  2.1346 -				pkg=$(ls $pkg*.tazpkg)
  2.1347 -				grep -q "^$pkg$" $LIST_NAME || \
  2.1348 -					echo $pkg >>$LIST_NAME
  2.1349 -				mv $pkg $PACKAGES_REPOSITORY 
  2.1350 -			done
  2.1351 -		fi
  2.1352 -		echo ""
  2.1353 -		cp $LIST_NAME $DISTRO/distro-packages.list
  2.1354 -		sed 's/\(.*\)/\1.tazpkg/' < $DISTRO/distro-packages.list > $DISTRO/list-packages
  2.1355 -		cd $PACKAGES_REPOSITORY
  2.1356 -		yes y | tazpkg install-list \
  2.1357 -			$DISTRO/list-packages --root=$ROOTFS
  2.1358 -		cd $DISTRO
  2.1359 -		cp distro-packages.list $ROOTFS/etc/tazlito
  2.1360 -		# Copy all files from $ADDFILES/rootfs to the rootfs.
  2.1361 -		if [ -d "$ADDFILES/rootfs" ] ; then
  2.1362 -			echo -n "Copying addfiles content to the rootfs... "
  2.1363 -			cp -a $ADDFILES/rootfs/* $ROOTFS
  2.1364 -			status
  2.1365 -		fi
  2.1366 -		echo "Root file system is generated..."
  2.1367 -		# Root CD part.
  2.1368 -		echo -n "Preparing the rootcd directory..."
  2.1369 -		mkdir -p $ROOTCD
  2.1370 -		status
  2.1371 -		# Move the boot dir with the Linux kernel from rootfs.
  2.1372 -		# The boot dir goes directly on the CD.
  2.1373 -		if [ -d "$ROOTFS/boot" ] ; then
  2.1374 -			echo -n "Moving the boot directory..."
  2.1375 -			mv $ROOTFS/boot $ROOTCD
  2.1376 -			cd $ROOTCD/boot
  2.1377 -			ln vmlinuz-* bzImage
  2.1378 -			status
  2.1379 -		fi
  2.1380 -		cd $DISTRO
  2.1381 -		# Copy all files from $ADDFILES/rootcd to the rootcd.
  2.1382 -		if [ -d "$ADDFILES/rootcd" ] ; then
  2.1383 -			echo -n "Copying addfiles content to the rootcd... "
  2.1384 -			cp -a $ADDFILES/rootcd/* $ROOTCD
  2.1385 -			status
  2.1386 -		fi
  2.1387 -		# Execute the distro script (used to perform tasks in the rootfs
  2.1388 -		# before compression. Give rootfs path in arg
  2.1389 -		[ -z $DISTRO_SCRIPT ] && DISTRO_SCRIPT=$TOP_DIR/distro.sh
  2.1390 -		if [ -x $DISTRO_SCRIPT ]; then
  2.1391 -			echo "Executing distro script..."
  2.1392 -			sh $DISTRO_SCRIPT $DISTRO
  2.1393 -		fi
  2.1394 -		if [ -s /etc/tazlito/rootfs.list ]; then
  2.1395 -			[ -f $ROOTCD/boot/isolinux/ifmem.c32 ] ||
  2.1396 -			cp /boot/isolinux/ifmem.c32 $ROOTCD/boot/isolinux
  2.1397 -			n=0
  2.1398 -			last=$ROOTFS
  2.1399 -			while read flavor; do
  2.1400 -				n=$(($n+1))
  2.1401 -				echo "Building $flavor rootfs..."
  2.1402 -				download $flavor.flavor
  2.1403 -				zcat $flavor.flavor | cpio -i $flavor.pkglist
  2.1404 -				sed 's/.*/&.tazpkg/' < $flavor.pkglist \
  2.1405 -					> $DISTRO/list-packages0$n
  2.1406 -				mkdir ${ROOTFS}0$n
  2.1407 -				cd $PACKAGES_REPOSITORY
  2.1408 -				yes y | tazpkg install-list \
  2.1409 -					$DISTRO/list-packages0$n --root=${ROOTFS}0$n
  2.1410 -				rm -rf ${ROOTFS}0$n/boot
  2.1411 -				status
  2.1412 -				cd $DISTRO
  2.1413 -				mv $flavor.pkglist ${ROOTFS}0$n/etc/tazlito/distro-packages.list
  2.1414 -				rm -f $flavor.flavor install-list
  2.1415 -				mergefs ${ROOTFS}0$n $last
  2.1416 -				last=${ROOTFS}0$n
  2.1417 -			done <<EOT
  2.1418 -$(awk '{ for (i = 4; i <= NF; i+=2) print $i; }' < /etc/tazlito/rootfs.list)
  2.1419 -EOT
  2.1420 -			i=$(($n+1))
  2.1421 -			while [ $n -gt 0 ]; do
  2.1422 -				mv ${ROOTFS}0$n ${ROOTFS}$i
  2.1423 -				echo "Compression ${ROOTFS}0$n ($(du -hs ${ROOTFS}$i | awk '{ print $1 }')) ..."
  2.1424 -				gen_initramfs ${ROOTFS}$i
  2.1425 -				n=$(($n-1))
  2.1426 -				i=$(($i-1))
  2.1427 -			done
  2.1428 -			mv $ROOTFS ${ROOTFS}$i
  2.1429 -			gen_initramfs ${ROOTFS}$i
  2.1430 -			update_bootconfig $ROOTCD/boot/isolinux \
  2.1431 -				"$(cat /etc/tazlito/rootfs.list)"
  2.1432 -		else
  2.1433 -			# Initramfs and ISO image stuff.
  2.1434 -			gen_initramfs $ROOTFS
  2.1435 -		fi
  2.1436 -		gen_livecd_isolinux
  2.1437 -		distro_stats
  2.1438 -		cleanup
  2.1439 -		;;
  2.1440 -	clean-distro)
  2.1441 -		# Remove old distro tree.
  2.1442 -		#
  2.1443 -		check_root
  2.1444 -		echo ""
  2.1445 -		echo -e "\033[1mCleaning :\033[0m $DISTRO"
  2.1446 -		echo "================================================================================"
  2.1447 -		if [ -d "$DISTRO" ] ; then
  2.1448 -			if [ -d "$ROOTFS" ] ; then
  2.1449 -				echo -n "Removing the rootfs..."
  2.1450 -				rm -f $DISTRO/$INITRAMFS
  2.1451 -				rm -rf $ROOTFS
  2.1452 -				status
  2.1453 -			fi
  2.1454 -			if [ -d "$ROOTCD" ] ; then
  2.1455 -				echo -n "Removing the rootcd..."
  2.1456 -				rm -rf $ROOTCD
  2.1457 -				status
  2.1458 -			fi
  2.1459 -			echo -n "Removing eventual ISO image..."
  2.1460 -			rm -f $DISTRO/$ISO_NAME.iso
  2.1461 -			rm -f $DISTRO/$ISO_NAME.md5
  2.1462 -			status
  2.1463 -		fi
  2.1464 -		echo "================================================================================"
  2.1465 -		echo ""
  2.1466 -		;;
  2.1467 -	check-distro)
  2.1468 -		# Check for a few LiveCD needed files not installed by packages.
  2.1469 -		#
  2.1470 -		check_rootfs
  2.1471 -		echo ""
  2.1472 -		echo -e "\033[1mChecking distro :\033[0m $ROOTFS"
  2.1473 -		echo "================================================================================"
  2.1474 -		# SliTaz release info.
  2.1475 -		if [ ! -f "$ROOTFS/etc/slitaz-release" ]; then
  2.1476 -			echo "Missing release info : /etc/slitaz-release"
  2.1477 -		else
  2.1478 -			release=`cat $ROOTFS/etc/slitaz-release`
  2.1479 -			echo -n "Release      : $release"
  2.1480 -			status
  2.1481 -		fi
  2.1482 -		# Tazpkg mirror.
  2.1483 -		if [ ! -f "$ROOTFS/var/lib/tazpkg/mirror" ]; then
  2.1484 -			echo -n "Mirror URL   : Missing /var/lib/tazpkg/mirror"
  2.1485 -			todomsg
  2.1486 -		else
  2.1487 -			echo -n "Mirror configuration exists..."
  2.1488 -			status
  2.1489 -		fi
  2.1490 -		# Isolinux msg	
  2.1491 -		if grep -q "cooking-XXXXXXXX" /$ROOTCD/boot/isolinux/isolinux.msg; then
  2.1492 -			echo -n "Isolinux msg : Missing cooking date XXXXXXXX (ex `date +%Y%m%d`)"
  2.1493 -			todomsg
  2.1494 -		else
  2.1495 -			echo -n "Isolinux message seems good..."
  2.1496 -			status
  2.1497 -		fi
  2.1498 -		echo "================================================================================"
  2.1499 -		echo ""
  2.1500 -		;;
  2.1501 -	writeiso)
  2.1502 -				# Writefs to ISO image including /home unlike gen-distro we dont use
  2.1503 -		# packages to generate a rootfs, we build a compressed rootfs with all 
  2.1504 -		# the current filesystem similar to 'tazusb writefs'.
  2.1505 -		#
  2.1506 -		DISTRO="/home/slitaz/distro"
  2.1507 -		ROOTCD="$DISTRO/rootcd"
  2.1508 -		if [ -z $2 ]; then
  2.1509 -			COMPRESSION=none
  2.1510 -		else
  2.1511 -			COMPRESSION=$2
  2.1512 -		fi
  2.1513 -		if [ -z $3 ]; then
  2.1514 -			ISO_NAME="slitaz"
  2.1515 -		else
  2.1516 -			ISO_NAME="$3"
  2.1517 -		fi
  2.1518 -		check_root
  2.1519 -		# Start info
  2.1520 -		echo ""
  2.1521 -		echo -e "\033[1mWrite filesystem to ISO\033[0m
  2.1522 -===============================================================================
  2.1523 -The command writeiso will write the current filesystem into a suitable cpio 
  2.1524 -archive (rootfs.gz) and generate a bootable ISO image (slitaz.iso). 
  2.1525 -
  2.1526 -Archive compression: $COMPRESSION"
  2.1527 -		echo ""
  2.1528 -		
  2.1529 -		# Save some space
  2.1530 -		rm /var/cache/tazpkg/* -r -f
  2.1531 -		rm -rf /home/slitaz/distro
  2.1532 -
  2.1533 -		# Optionally remove sound card selection and screen resolution.
  2.1534 -		echo "Do you wish to remove the sound card and screen config ? "
  2.1535 -		echo -n "Press ENTER to keep or anser (No|yes|exit): "
  2.1536 -		read anser
  2.1537 -		case $anser in
  2.1538 -			e|E|"exit"|Exit)
  2.1539 -				exit 0 ;;
  2.1540 -			y|Y|yes|Yes)
  2.1541 -				echo -n "Removing current sound card and screen configuration..."
  2.1542 -				rm -f /var/lib/sound-card-driver
  2.1543 -				rm -f /etc/asound.state
  2.1544 -				rm -f /etc/X11/screen.conf 
  2.1545 -				rm -f /etc/X11/xorg.conf ;;
  2.1546 -			*)
  2.1547 -				echo -n "Keeping current sound card and screen configuration..." ;;
  2.1548 -		esac
  2.1549 -		status
  2.1550 -		
  2.1551 -		# Create list of files including default user files since it is defined in /etc/passwd
  2.1552 -		# and some new users might have been added.
  2.1553 -		find /bin /etc /init /sbin /var /dev /lib /root /usr /home >/tmp/list
  2.1554 -
  2.1555 -		for dir in /proc /sys /tmp /mnt /media /media/cdrom /media/flash /media/usbdisk
  2.1556 -		do
  2.1557 -			echo $dir >>/tmp/list
  2.1558 -		done
  2.1559 -
  2.1560 -		# Generate initramfs with specified compression and display rootf
  2.1561 -		# size in realtime.
  2.1562 -		rm -f /tmp/rootfs
  2.1563 -		write_initramfs &
  2.1564 -		sleep 2
  2.1565 -		echo -en "\nFilesystem size:"
  2.1566 -		while [ ! -f /tmp/rootfs ]
  2.1567 -		do
  2.1568 -			sleep 1
  2.1569 -			echo -en "\\033[18G`du -sh /rootfs.gz | awk '{print $1}'`    "
  2.1570 -		done
  2.1571 -		echo -e "\n"
  2.1572 -
  2.1573 -		# Move freshly generated rootfs to the cdrom.
  2.1574 -		mkdir -p $ROOTCD/boot
  2.1575 -		mv -f /rootfs.gz $ROOTCD/boot
  2.1576 -		
  2.1577 -		# Now we need the kernel and isolinux files.
  2.1578 -		if mount /dev/cdrom /media/cdrom 2>/dev/null; then
  2.1579 -			cp /media/cdrom/boot/bzImage $ROOTCD/boot
  2.1580 -			cp -a /media/cdrom/boot/isolinux $ROOTCD/boot
  2.1581 -			umount /media/cdrom
  2.1582 -		else
  2.1583 -			echo -e "
  2.1584 -Unable to mount the cdrom to copy the Kernel and needed files. When SliTaz
  2.1585 -is running in RAM the kernel and bootloader files are keeped on the cdrom.
  2.1586 -Please insert a LiveCD or unmount curent cdrom to let Tazlito handle the media.\n"
  2.1587 -			echo -en "----\nENTER to continue..."; read i
  2.1588 -			exit 1
  2.1589 -		fi
  2.1590 -		
  2.1591 -		# Generate the iso image.
  2.1592 -		cd $DISTRO
  2.1593 -		echo "Generating ISO image..."
  2.1594 -		genisoimage -R -o $ISO_NAME.iso -b boot/isolinux/isolinux.bin \
  2.1595 -		-c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
  2.1596 -		-V "SliTaz" -input-charset iso8859-1 -boot-info-table $ROOTCD
  2.1597 -		if [ -x /usr/bin/isohybrid ]; then
  2.1598 -			echo -n "Creating hybrid ISO..."
  2.1599 -			/usr/bin/isohybrid $ISO_NAME.iso 2> /dev/null
  2.1600 -			status
  2.1601 -		fi
  2.1602 -		echo -n "Creating the ISO md5sum..."
  2.1603 -		md5sum $ISO_NAME.iso > $ISO_NAME.md5
  2.1604 -		status
  2.1605 -
  2.1606 -		echo "==============================================================================="
  2.1607 -		echo "ISO image: `du -sh /home/slitaz/distro/$ISO_NAME.iso`"
  2.1608 -		echo ""
  2.1609 -		echo -n "Exit or burn ISO to cdrom (Exit|burn)? "; read anser
  2.1610 -		case $anser in
  2.1611 -			burn)
  2.1612 -				eject
  2.1613 -				echo -n "Please insert a blank cdrom and press ENTER..."
  2.1614 -				read i && sleep 2
  2.1615 -				tazlito burn-iso /home/slitaz/distro/$ISO_NAME.iso
  2.1616 -				echo -en "----\nENTER to continue..."; read i ;;
  2.1617 -			*)
  2.1618 -				exit 0 ;;
  2.1619 -		esac ;;
  2.1620 -	burn-iso)
  2.1621 -		# Guess cdrom device, ask user and burn the ISO.
  2.1622 -		#
  2.1623 -		check_root
  2.1624 -		DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
  2.1625 -		DRIVE_SPEED=`cat /proc/sys/dev/cdrom/info | grep "drive speed" | cut -f 3`
  2.1626 -		# We can specify an alternative ISO from the cmdline.
  2.1627 -		if [ -n "$2" ] ; then
  2.1628 -			iso=$2
  2.1629 -		else
  2.1630 -			iso=$DISTRO/$ISO_NAME.iso
  2.1631 -		fi
  2.1632 -		if [ ! -f "$iso" ]; then
  2.1633 -			echo -e "\nUnable to find ISO : $iso\n"
  2.1634 -			exit 0
  2.1635 -		fi
  2.1636 -		echo ""
  2.1637 -		echo -e "\033[1mTazlito burn ISO\033[0m "
  2.1638 -		echo "================================================================================"
  2.1639 -		echo "Cdrom device  : /dev/$DRIVE_NAME"
  2.1640 -		echo "Drive speed   : $DRIVE_SPEED"
  2.1641 -		echo "ISO image     : $iso"
  2.1642 -		echo "================================================================================"
  2.1643 -		echo ""
  2.1644 -		yesorno "Burn ISO image (y/N) ? "
  2.1645 -		if [ "$answer" == "y" ]; then
  2.1646 -			echo ""
  2.1647 -			echo "Starting Wodim to burn the iso..." && sleep 2
  2.1648 -			echo "================================================================================"
  2.1649 -			wodim speed=$DRIVE_SPEED dev=/dev/$DRIVE_NAME $iso
  2.1650 -			echo "================================================================================"
  2.1651 -			echo "ISO image is burned to cdrom."
  2.1652 -		else
  2.1653 -			echo -e "\nExiting. No ISO burned."
  2.1654 -		fi
  2.1655 -		echo ""
  2.1656 -		;;
  2.1657 -	merge)
  2.1658 -		# Merge multiple rootfs into one iso.
  2.1659 -		#
  2.1660 -		if [ -z "$2" ]; then
  2.1661 -			cat << EOT
  2.1662 -Usage: tazlito merge size1 iso size2 rootfs2 [sizeN rootfsN]...
  2.1663 -
  2.1664 -Merge multiple rootfs into one iso. Rootfs are like russian dolls
  2.1665 -i.e: rootfsN is a subset of rootfsN-1
  2.1666 -rootfs1 is found in iso, sizeN is the RAM size need to launch rootfsN.
  2.1667 -The boot loader will select the rootfs according to the RAM size detected.
  2.1668 -
  2.1669 -Example: 
  2.1670 -$ tazlito merge 160M slitaz-core.iso 96M rootfs-justx.gz 32M rootfs-base.gz
  2.1671 -
  2.1672 -Will start slitaz-core with 160M+ RAM, slitaz-justX with 96M-160M RAM,
  2.1673 -slitaz-base with 32M-96M RAM and display an error message if RAM < 32M.
  2.1674 -EOT
  2.1675 -			exit 2
  2.1676 -		fi
  2.1677 -
  2.1678 -		shift	# skip merge
  2.1679 -		append="$1 slitaz1"
  2.1680 -		shift	# skip size1
  2.1681 -		mkdir -p $TMP_DIR/mnt $TMP_DIR/rootfs1
  2.1682 -
  2.1683 -		ISO=$1.merged
  2.1684 -		# Extract filesystems
  2.1685 -		echo -n "Mounting $1"
  2.1686 -		mount -o loop,ro $1 $TMP_DIR/mnt 2> /dev/null
  2.1687 -		status || cleanup_merge
  2.1688 -		cp -a $TMP_DIR/mnt $TMP_DIR/iso
  2.1689 -		rm -f $TMP_DIR/iso/boot/bzImage
  2.1690 -		ln $TMP_DIR/iso/boot/vmlinuz* $TMP_DIR/iso/boot/bzImage
  2.1691 -		umount -d $TMP_DIR/mnt
  2.1692 -		if [ -f $TMP_DIR/iso/boot/rootfs1.gz ]; then
  2.1693 -			echo "$1 is already a merged iso. Aborting."
  2.1694 -			cleanup_merge
  2.1695 -		fi
  2.1696 -		if [ ! -f $TMP_DIR/iso/boot/isolinux/ifmem.c32 ]; then
  2.1697 -			if [ ! -f /boot/isolinux/ifmem.c32 ]; then
  2.1698 -				cat <<EOT
  2.1699 -No file /boot/isolinux/ifmem.c32
  2.1700 -Please install syslinux package !
  2.1701 -EOT
  2.1702 -				rm -rf $TMP_DIR
  2.1703 -				exit 1
  2.1704 -			fi
  2.1705 -			cp /boot/isolinux/ifmem.c32 $TMP_DIR/iso/boot/isolinux
  2.1706 -		fi
  2.1707 -		
  2.1708 -		echo -n "Extracting iso/rootfs.gz"
  2.1709 -		extract_rootfs $TMP_DIR/iso/boot/rootfs.gz $TMP_DIR/rootfs1 &&
  2.1710 -		[ -d $TMP_DIR/rootfs1/etc ]
  2.1711 -		status || cleanup_merge
  2.1712 -		n=1
  2.1713 -		while [ -n "$2" ]; do
  2.1714 -			shift	# skip rootfs N-1
  2.1715 -			p=$n
  2.1716 -			n=$(($n + 1))
  2.1717 -			append="$append $1 slitaz$n"
  2.1718 -			shift	# skip size N
  2.1719 -			mkdir -p $TMP_DIR/rootfs$n
  2.1720 -			echo -n "Extracting $1"
  2.1721 -			extract_rootfs $1 $TMP_DIR/rootfs$n &&
  2.1722 -			[ -d $TMP_DIR/rootfs$n/etc ]
  2.1723 -			status || cleanup_merge
  2.1724 -			mergefs $TMP_DIR/rootfs$n $TMP_DIR/rootfs$p
  2.1725 -			echo "Creating rootfs$p.gz"
  2.1726 -			pack_rootfs $TMP_DIR/rootfs$p $TMP_DIR/iso/boot/rootfs$p.gz
  2.1727 -			status
  2.1728 -		done
  2.1729 -		echo "Creating rootfs$n.gz"
  2.1730 -		pack_rootfs $TMP_DIR/rootfs$n $TMP_DIR/iso/boot/rootfs$n.gz
  2.1731 -		status
  2.1732 -		rm -f $TMP_DIR/iso/boot/rootfs.gz
  2.1733 -		update_bootconfig $TMP_DIR/iso/boot/isolinux "$append"
  2.1734 -		echo "Generating $ISO"
  2.1735 -		create_iso $ISO $TMP_DIR/iso
  2.1736 -		rm -rf $TMP_DIR
  2.1737 -		;;
  2.1738 -
  2.1739 -	repack)
  2.1740 -		# Repack an iso with maximum lzma compression ratio.
  2.1741 -		#
  2.1742 -
  2.1743 -		ISO=$2
  2.1744 -
  2.1745 -		mkdir -p $TMP_DIR/mnt
  2.1746 -		# Extract filesystems
  2.1747 -		echo -n "Mounting $ISO"
  2.1748 -		mount -o loop,ro $ISO $TMP_DIR/mnt 2> /dev/null
  2.1749 -		status || cleanup_merge
  2.1750 -		cp -a $TMP_DIR/mnt $TMP_DIR/iso
  2.1751 -		umount -d $TMP_DIR/mnt
  2.1752 -		
  2.1753 -		for i in $TMP_DIR/iso/boot/rootfs* ; do
  2.1754 -			echo -n "Repacking $(basename $i)"
  2.1755 -			(zcat $i || unlzma -c $i || cat $i) \
  2.1756 -				2>/dev/null > $TMP_DIR/rootfs
  2.1757 -			lzma e $TMP_DIR/rootfs $i \
  2.1758 -				 $(lzma_switches $TMP_DIR/rootfs)
  2.1759 -			status
  2.1760 -		done
  2.1761 -		
  2.1762 -		echo "Generating $ISO"
  2.1763 -		create_iso $ISO $TMP_DIR/iso
  2.1764 -		rm -rf $TMP_DIR ;;
  2.1765 -	
  2.1766 -	frugal-install|-fi)
  2.1767 -		ISO_IMAGE="$2"
  2.1768 -		echo ""
  2.1769 -		mkdir -p /boot/frugal
  2.1770 -		if [ -f "$ISO_IMAGE" ]; then
  2.1771 -			echo -n "Using ISO image: $ISO_IMAGE"
  2.1772 -			mkdir -p /tmp/iso && mount -o loop $ISO_IMAGE /tmp/iso
  2.1773 -			status
  2.1774 -			echo -n "Installing the Kernel and rootfs..."
  2.1775 -			cp -a /tmp/iso/boot/bzImage /boot/frugal
  2.1776 -			cp -a /tmp/iso/boot/rootfs.gz /boot/frugal
  2.1777 -			umount /tmp/iso
  2.1778 -			status
  2.1779 -		else
  2.1780 -			echo -n "Using distro: $DISTRO"
  2.1781 -			cd $DISTRO && status
  2.1782 -			echo -n "Installing the Kernel and rootfs..."
  2.1783 -			cp -a $DISTRO/rootcd/boot/bzImage /boot/frugal
  2.1784 -			cp -a $DISTRO/rootcd/boot/rootfs.gz /boot/frugal
  2.1785 -			status
  2.1786 -		fi
  2.1787 -		# Grub entry
  2.1788 -		if ! grep -q "^kernel /boot/frugal/bzImage" /boot/grub/menu.lst; then
  2.1789 -			echo -n "Configuring GRUB menu list..."
  2.1790 -			cat >> /boot/grub/menu.lst << EOT
  2.1791 -title SliTaz GNU/Linux (frugal)
  2.1792 -root (hd0,0)
  2.1793 -kernel /boot/frugal/bzImage root=/dev/null
  2.1794 -initrd /boot/frugal/rootfs.gz
  2.1795 -EOT
  2.1796 -		else
  2.1797 -			echo -n "GRUB menu list is up-to-date..."
  2.1798 -		fi
  2.1799 -		status
  2.1800 -		echo "" ;;
  2.1801 -	
  2.1802 -	emu-iso)
  2.1803 -		# Emulate an ISO image with Qemu.
  2.1804 -		if [ -n "$2" ] ; then
  2.1805 -			iso=$2
  2.1806 -		else
  2.1807 -			iso=$DISTRO/$ISO_NAME.iso
  2.1808 -		fi
  2.1809 -		if [ ! -f "$iso" ]; then
  2.1810 -			echo -e "\nUnable to find ISO : $iso\n"
  2.1811 -			exit 0
  2.1812 -		fi
  2.1813 -		if [ ! -x "/usr/bin/qemu" ]; then
  2.1814 -			echo -e "\nUnable to find Qemu binary. Please install: qemu\n"
  2.1815 -			exit 0
  2.1816 -		fi
  2.1817 -		echo -e "\nStarting Qemu emulator:\n"
  2.1818 -		echo -e "qemu $QEMU_OPTS $iso\n"
  2.1819 -		qemu $QEMU_OPTS $iso ;;
  2.1820 -
  2.1821 -	usage|*)
  2.1822 -		# Clear and print usage also for all unknown commands.
  2.1823 -		#
  2.1824 -		clear
  2.1825 -		usage ;;
  2.1826 -esac
  2.1827 -
  2.1828 -exit 0
     3.1 --- a/core/rootfs/usr/bin/tazlitobox	Thu Feb 11 14:39:04 2010 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,445 +0,0 @@
     3.4 -#!/bin/sh
     3.5 -# 
     3.6 -# Gtkdialog box for Tazlito - SliTaz Live Tool.
     3.7 -# Tabs are used for ident ans all action should go into functions to
     3.8 -# separate GUI and commands.
     3.9 -#
    3.10 -# (C) GNU gpl v3 - SliTaz GNU/Linux 2010.
    3.11 -#
    3.12 -VERSION=2.2
    3.13 -
    3.14 -export BIN=$0
    3.15 -
    3.16 -# Check if user is root.
    3.17 -check_root()
    3.18 -{
    3.19 -	if test $(id -u) != 0 ; then
    3.20 -		echo -e "
    3.21 -You must be root to run `basename $0`. Please type 'su' and 
    3.22 -root password to become super-user.\n"
    3.23 -		exit 0
    3.24 -	fi
    3.25 -}
    3.26 -
    3.27 -# We need to parse flavors.list for GTK tree.
    3.28 -list_flavors()
    3.29 -{
    3.30 -	tazlito list-flavors | grep ^[a-z] | while read line
    3.31 -	do		
    3.32 -		info=`echo -n $line | awk '{print $1 " " $2 " " $3}'`
    3.33 -		printinfo=`echo -n $line | awk '{print $1 "|" $2 "|" $3}'`
    3.34 -		echo "$printinfo|`echo $line | sed s/\"$info\"//`"
    3.35 -	done
    3.36 -}
    3.37 -
    3.38 -recharge_list()
    3.39 -{
    3.40 -	xterm -geometry 90x14 \
    3.41 -		-title "list-flavors --recharge" \
    3.42 -		-e "tazlito list-flavors --recharge | grep ^[a-z] && sleep 2"
    3.43 -}
    3.44 -
    3.45 -# When using gen-liveflavor, gen-flavor or gen-distro, user can put some
    3.46 -# addfiles copied into the rootfs.
    3.47 -addfiles_action()
    3.48 -{
    3.49 -	cd /home/slitaz
    3.50 -	mkdir -p distro/addfiles/rootfs/usr/share/images
    3.51 -	mkdir -p distro/addfiles/rootcd
    3.52 -	file-manager distro/addfiles &
    3.53 -}
    3.54 -
    3.55 -writeiso_action()
    3.56 -{
    3.57 -	xterm -geometry 80x16 \
    3.58 -		-title "writeiso" \
    3.59 -		-e "tazlito writeiso $COMPRESSION"
    3.60 -}
    3.61 -
    3.62 -gen_liveflavor_action()
    3.63 -{
    3.64 -	cd /home/slitaz
    3.65 -	sed -i "s/ISO_NAME=.*/ISO_NAME=\"slitaz-$GEN_LIVEFLAVOR_NAME\"/" \
    3.66 -		/etc/tazlito/tazlito.conf
    3.67 -	xterm -geometry 80x16 \
    3.68 -		-title "gen-liveflavor" \
    3.69 -		-e "tazlito gen-liveflavor $GEN_LIVEFLAVOR_NAME && echo -e \"----\nENTER to continue...\" && read close"
    3.70 -}
    3.71 -
    3.72 -clean_distro_action()
    3.73 -{
    3.74 -	cd /home/slitaz
    3.75 -	xterm -geometry 80x16 \
    3.76 -		-title "clean-distro" \
    3.77 -		-e "tazlito clean-distro && sleep 1"
    3.78 -}
    3.79 -
    3.80 -get_flavor_action()
    3.81 -{
    3.82 -	cd /home/slitaz
    3.83 -	xterm -geometry 80x16 \
    3.84 -		-title "get-flavor $COMMUNITY_FLAVOR" \
    3.85 -		-e "tazlito get-flavor $COMMUNITY_FLAVOR && echo -e \"----\nENTER to continue...\" && read close"
    3.86 -}
    3.87 -
    3.88 -gen_distro_action()
    3.89 -{
    3.90 -	cd /home/slitaz
    3.91 -	xterm -geometry 80x16 \
    3.92 -		-title "gen-distro" \
    3.93 -		-e "tazlito gen-distro && echo -e \"----\nENTER to continue...\" && read close"
    3.94 -}
    3.95 -
    3.96 -gen_flavor_action()
    3.97 -{
    3.98 -	cd /home/slitaz
    3.99 -	xterm -geometry 80x16 \
   3.100 -		-title "gen-flavor $GEN_FLAVOR_NAME" \
   3.101 -		-e "tazlito gen-flavor $GEN_FLAVOR_NAME && echo -e \"----\nENTER to continue...\" && read close"
   3.102 -}
   3.103 -
   3.104 -edit_distro_script()
   3.105 -{
   3.106 -	[ ! -f $DISTRO_SCRIPT ] && echo "#!/bin/sh" > $DISTRO_SCRIPT
   3.107 -	chmod +x $DISTRO_SCRIPT
   3.108 -	editor $DISTRO_SCRIPT
   3.109 -}
   3.110 -
   3.111 -# Boxes
   3.112 -
   3.113 -export HELP='
   3.114 -<window title="Tazlito Box - Help" icon-name="media-cdrom">
   3.115 -<vbox>
   3.116 -	<text use-markup="true">
   3.117 -		<label>"
   3.118 -<b>Tazlito Box - Help</b>"
   3.119 -		</label>
   3.120 -	</text>
   3.121 -	
   3.122 -	<frame Overview>
   3.123 -		<text wrap="true" width-chars="52" use-markup="true">
   3.124 -			<label>
   3.125 -"
   3.126 -Tazlito Box is a tiny interface to the SliTaz Live Tool aka Tazlito.
   3.127 -You can simply generate a LiveCD in a few minutes, using your
   3.128 -own flavor or one from the SliTaz community. Tazlito can also 
   3.129 -generate a LiveCD flavor using all of the currently installed 
   3.130 -packages. Tazlito commands are executed in a XTerm, you can 
   3.131 -press ENTER or the mouse to close the window.
   3.132 -"
   3.133 -			</label>
   3.134 -		</text>
   3.135 -	</frame>
   3.136 -	
   3.137 -	<frame Default paths>
   3.138 -		<text wrap="true" width-chars="50" use-markup="true">
   3.139 -			<label>
   3.140 -"
   3.141 -Distro      : /home/slitaz/distro
   3.142 -Flavors    : /home/slitaz/flavors
   3.143 -Packages : /home/slitaz/packages
   3.144 -"
   3.145 -			</label>
   3.146 -		</text>
   3.147 -	</frame>
   3.148 -	
   3.149 -	<hbox>
   3.150 -		<button>
   3.151 -			<input file icon="exit"></input>
   3.152 -			<action type="closewindow">HELP</action>
   3.153 -		</button>
   3.154 -	</hbox>
   3.155 -
   3.156 -</vbox>
   3.157 -</window>
   3.158 -'
   3.159 -
   3.160 -# List all flavors on the mirror.
   3.161 -export LIST_FLAVORS_BOX='
   3.162 -<window title="Community flavors list" icon-name="tazlito">
   3.163 -<vbox>
   3.164 -	<tree>
   3.165 -		<width>500</width><height>200</height>
   3.166 -		<variable>COMMUNITY_FLAVOR</variable>
   3.167 -		<label>Name|ISO|Rootfs|Description</label>
   3.168 -		<input exported_column="0">$BIN list_flavors</input>
   3.169 -	</tree>
   3.170 -	<hbox>
   3.171 -		<button>
   3.172 -			<label>Recharge list</label>
   3.173 -			<input file icon="reload"></input>
   3.174 -			<action>$BIN recharge_list</action>
   3.175 -			<action>refresh:COMMUNITY_FLAVOR</action>
   3.176 -		</button>
   3.177 -		<button>
   3.178 -			<label>Exit</label>
   3.179 -			<input file icon="exit"></input>
   3.180 -			<action type="closewindow">LIST_FLAVORS_BOX</action>
   3.181 -		</button>
   3.182 -	</hbox>
   3.183 -</vbox>
   3.184 -</window>'
   3.185 -
   3.186 -# Execute tazlito commands in a XTerm. Notebook: tab-pos="GTK_POS_LEFT"
   3.187 -export TAZLITO_BOX='
   3.188 -<window title="Tazlito Box" icon-name="media-cdrom">
   3.189 -<vbox>
   3.190 -
   3.191 -	<hbox>
   3.192 -	<text use-markup="true">
   3.193 -		<label>"<b>SliTaz Live Tool</b>"</label>
   3.194 -	</text>
   3.195 -	<pixmap>
   3.196 -		<input file>/usr/share/pixmaps/tazlito.png</input>
   3.197 -	</pixmap>
   3.198 -	</hbox>
   3.199 -
   3.200 -	<notebook labels="Writeiso|Live flavor|Flavors list|Gen flavor|Configuration">
   3.201 -
   3.202 -	<frame Filesystem to ISO>
   3.203 -
   3.204 -	<text wrap="true" width-chars="60" use-markup="true">
   3.205 -		<label>
   3.206 -"
   3.207 -Writeiso will generate an ISO image of the current filesystem as
   3.208 -is, including the /home directory. It is an easy way to remaster a
   3.209 -SliTaz Live system, you just have to: boot, modify, writeiso.
   3.210 -"
   3.211 -		</label>
   3.212 -	</text>
   3.213 -
   3.214 -	<hbox>
   3.215 -		<text use-markup="true">
   3.216 -			<label>"<b>Compression (gzip,lzma,none):</b>"</label>
   3.217 -		</text>
   3.218 -		<entry>
   3.219 -			<default>gzip</default>
   3.220 -			<variable>COMPRESSION</variable>
   3.221 -		</entry>
   3.222 -	</hbox>
   3.223 -
   3.224 -	<hbox>
   3.225 -		<button>
   3.226 -			<label>Writeiso</label>
   3.227 -			<input file icon="forward"></input>
   3.228 -			<action>$BIN writeiso_action</action>
   3.229 -		</button>
   3.230 -	</hbox>
   3.231 -	
   3.232 -	</frame>
   3.233 -	
   3.234 -	<frame Current packages selection>
   3.235 -	
   3.236 -	<text wrap="true" width-chars="60" use-markup="true">
   3.237 -		<label>
   3.238 -"
   3.239 -Gen Live flavor will create a LiveCD based on all the currently
   3.240 -installed packages. To build the rootfs and ISO image it will use
   3.241 -original SliTaz packages. Some addfiles can be copied before
   3.242 -gen distro.
   3.243 -"
   3.244 -		</label>
   3.245 -	</text>
   3.246 -
   3.247 -	<hbox>
   3.248 -		<text use-markup="true">
   3.249 -			<label>"<b>Flavor name :</b>"</label>
   3.250 -		</text>
   3.251 -		<entry>
   3.252 -			<default>slitaz</default>
   3.253 -			<variable>GEN_LIVEFLAVOR_NAME</variable>
   3.254 -		</entry>
   3.255 -	</hbox>
   3.256 -
   3.257 -	<hbox>
   3.258 -		<button>
   3.259 -			<label>Addfiles</label>
   3.260 -			<input file icon="gtk-open"></input>
   3.261 -			<action>$BIN addfiles_action</action>
   3.262 -		</button>
   3.263 -		<button>
   3.264 -			<label>Gen distro</label>
   3.265 -			<input file icon="forward"></input>
   3.266 -			<action>$BIN gen_liveflavor_action</action>
   3.267 -		</button>
   3.268 -		<button>
   3.269 -			<label>Clean distro</label>
   3.270 -			<input file icon="edit-clear"></input>
   3.271 -			<action>$BIN clean_distro_action</action>
   3.272 -		</button>
   3.273 -	</hbox>
   3.274 -
   3.275 -	</frame>
   3.276 -	
   3.277 -	<frame Community and personal flavors>
   3.278 -	
   3.279 -	<text wrap="true" width-chars="60" use-markup="true">
   3.280 -		<label>
   3.281 -"
   3.282 -Get and build preconfigured flavors from the community. Flavors
   3.283 -llist can be recharged from SliTaz mirror. Some addfiles can be
   3.284 -copied before generating the distro.
   3.285 -"
   3.286 -		</label>
   3.287 -	</text>
   3.288 -
   3.289 -	<hbox>
   3.290 -		<text use-markup="true">
   3.291 -			<label>"<b>Flavor :</b>"</label>
   3.292 -		</text>
   3.293 -		<entry>
   3.294 -			<default>core</default>
   3.295 -			<variable>COMMUNITY_FLAVOR</variable>
   3.296 -		</entry>
   3.297 -		<button>
   3.298 -			<label>List flavors</label>
   3.299 -			<input file icon="media-cdrom"></input>
   3.300 -			<action type="launch">LIST_FLAVORS_BOX</action>
   3.301 -		</button>
   3.302 -	</hbox>
   3.303 -
   3.304 -	<hbox>
   3.305 -		<button>
   3.306 -			<label>Get flavor</label>
   3.307 -			<input file icon="forward"></input>
   3.308 -			<action>$BIN get_flavor_action</action>
   3.309 -		</button>
   3.310 -		<button>
   3.311 -			<label>Addfiles</label>
   3.312 -			<input file icon="gtk-open"></input>
   3.313 -			<action>$BIN addfiles_action</action>
   3.314 -		</button>
   3.315 -		<button>
   3.316 -			<label>Gen distro</label>
   3.317 -			<input file icon="forward"></input>
   3.318 -			<action>$BIN gen_distro_action</action>
   3.319 -		</button>
   3.320 -		<button>
   3.321 -			<label>Clean distro</label>
   3.322 -			<input file icon="edit-clear"></input>
   3.323 -			<action>$BIN clean_distro_action</action>
   3.324 -		</button>
   3.325 -	</hbox>
   3.326 -
   3.327 -	</frame>
   3.328 -	<frame Generate a flavor>
   3.329 -
   3.330 -	<text wrap="true" width-chars="60" use-markup="true">
   3.331 -		<label>
   3.332 -"
   3.333 -Gen Flavor will generate a new flavor file based on rootfs in 
   3.334 -/home/slitaz/distro. All addfiles will be included in the flavor file.
   3.335 -"
   3.336 -		</label>
   3.337 -	</text>
   3.338 -
   3.339 -	<hbox>
   3.340 -		<text use-markup="true">
   3.341 -			<label>"<b>New flavor :</b>"</label>
   3.342 -		</text>
   3.343 -		<entry>
   3.344 -			<default>slitaz</default>
   3.345 -			<variable>GEN_FLAVOR_NAME</variable>
   3.346 -		</entry>
   3.347 -	</hbox>
   3.348 -	
   3.349 -	<hbox>
   3.350 -		<button>
   3.351 -			<label>Addfiles</label>
   3.352 -			<input file icon="gtk-open"></input>
   3.353 -			<action>$BIN addfiles_action</action>
   3.354 -		</button>
   3.355 -		<button>
   3.356 -			<label>Gen new flavor</label>
   3.357 -			<input file icon="forward"></input>
   3.358 -			<action>$BIN gen_flavor_action</action>
   3.359 -		</button>
   3.360 -	</hbox>
   3.361 -
   3.362 -	</frame>
   3.363 -	
   3.364 -	<frame Flavor config and packages list>
   3.365 -
   3.366 -	<text wrap="true" width-chars="60" use-markup="true">
   3.367 -		<label>
   3.368 -"
   3.369 -Before editing files you must have a flavor description. Distro
   3.370 -script can be used to perform actions into the rootfs before
   3.371 -compression.
   3.372 -"
   3.373 -		</label>
   3.374 -	</text>
   3.375 -
   3.376 -	<hbox>
   3.377 -		<text use-markup="true">
   3.378 -			<label>"<b>Flavor config :</b>"</label>
   3.379 -		</text>
   3.380 -		<entry>
   3.381 -			<default>/home/slitaz/tazlito.conf</default>
   3.382 -			<variable>CONFIG_FILE</variable>
   3.383 -		</entry>
   3.384 -		<button>
   3.385 -			<input file icon="accessories-text-editor"></input>
   3.386 -			<action>editor $CONFIG_FILE</action>
   3.387 -		</button>
   3.388 -	</hbox>
   3.389 -
   3.390 -	<hbox>
   3.391 -		<text use-markup="true">
   3.392 -			<label>"<b>Packages list :</b>"</label>
   3.393 -		</text>
   3.394 -		<entry>
   3.395 -			<default>/home/slitaz/distro-packages.list</default>
   3.396 -			<variable>PKGS_LIST</variable>
   3.397 -		</entry>
   3.398 -		<button>
   3.399 -			<input file icon="accessories-text-editor"></input>
   3.400 -			<action>editor $PKGS_LIST</action>
   3.401 -		</button>
   3.402 -	</hbox>
   3.403 -
   3.404 -	<hbox>
   3.405 -		<text use-markup="true">
   3.406 -			<label>"<b>Distro script :</b> "</label>
   3.407 -		</text>
   3.408 -		<entry>
   3.409 -			<default>/home/slitaz/distro.sh</default>
   3.410 -			<variable>DISTRO_SCRIPT</variable>
   3.411 -		</entry>
   3.412 -		<button>
   3.413 -			<input file icon="accessories-text-editor"></input>
   3.414 -			<action>$BIN edit_distro_script</action>
   3.415 -		</button>
   3.416 -	</hbox>
   3.417 -
   3.418 -	</frame>
   3.419 -
   3.420 -	</notebook>
   3.421 -
   3.422 -	<hbox>
   3.423 -		<button help>
   3.424 -			<input file icon="help-browser"></input>
   3.425 -			<action type="launch">HELP</action>
   3.426 -		</button>
   3.427 -		<button>
   3.428 -			<label>Exit</label>
   3.429 -			<input file icon="exit"></input>
   3.430 -			<action type="exit">Exit</action>
   3.431 -		</button>
   3.432 -	</hbox>
   3.433 -
   3.434 -</vbox>
   3.435 -</window>
   3.436 -'
   3.437 -
   3.438 -case $1 in
   3.439 -	*_*)
   3.440 -		# Exec all function called by args (must have an underscore).
   3.441 -		$1 ;;
   3.442 -	*)
   3.443 -		# Tazlitobox action.
   3.444 -		check_root
   3.445 -		gtkdialog --center --program=TAZLITO_BOX ;;
   3.446 -esac
   3.447 -
   3.448 -exit 0
     4.1 --- a/core/rootfs/usr/share/applications/tazlito-doc.desktop	Thu Feb 11 14:39:04 2010 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,9 +0,0 @@
     4.4 -[Desktop Entry]
     4.5 -Name=Tazlito manual
     4.6 -Name[fr]=Manuel de Tazlito
     4.7 -Comment=SliTaz LiveCD generator and editor
     4.8 -Comment[fr]=Manuel de l'outil de génération et édition de LiveCD
     4.9 -Exec=browser file:///usr/share/doc/tazlito/tazlito.html
    4.10 -Icon=text-html
    4.11 -Type=Application
    4.12 -Categories=Documentation;
     5.1 --- a/core/rootfs/usr/share/applications/tazlitobox.desktop	Thu Feb 11 14:39:04 2010 +0100
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,8 +0,0 @@
     5.4 -[Desktop Entry]
     5.5 -Encoding=UTF-8
     5.6 -Name=Create a LiveCD
     5.7 -Name[fr]=Créer un LiveCD
     5.8 -Exec=subox tazlitobox
     5.9 -Icon=tazlito
    5.10 -Type=Application
    5.11 -Categories=System;
     6.1 --- a/core/rootfs/usr/share/applications/tazpkg-doc.desktop	Thu Feb 11 14:39:04 2010 +0100
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,9 +0,0 @@
     6.4 -[Desktop Entry]
     6.5 -Name=Tazpkg manual
     6.6 -Name[fr]=Manuel de Tazpkg
     6.7 -Comment=SliTaz packages manager manual
     6.8 -Comment[fr]=Manuel du gestionnaire de paquets SliTaz
     6.9 -Exec=browser file:///usr/share/doc/tazpkg/tazpkg.html
    6.10 -Icon=text-html
    6.11 -Type=Application
    6.12 -Categories=Documentation;