tazlito annotate tazlito @ rev 70

fix duplicates...
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri May 23 08:08:17 2008 +0000 (2008-05-23)
parents e4c1835964af
children e14ba83f1666
rev   line source
pankso@1 1 #!/bin/sh
pankso@1 2 # TazLito - SliTaz Live Tool.
pankso@1 3 #
pankso@1 4 # Tazlito is a tool to help generating and configuring SliTaz LiveCD
pankso@1 5 # ISO images. You can creat a custom distro in one command from a list of
pankso@1 6 # packages, extract a existing ISO image to hack it, creat new initramfs
pankso@1 7 # and/or new ISO. Most commands must be run by root, expect the stats
pankso@1 8 # and the configuration file manipulation.
pankso@1 9 #
pankso@28 10 # (C) 2007-2008 SliTaz - GNU General Public License.
pankso@1 11 #
pankso@28 12 # Authors : Christophe Lincoln <pankso@slitaz.org>
pankso@28 13 # Pascal Bellard <pascal.bellard@slitaz.org>
pankso@28 14 #
pascal@54 15 VERSION=1.6
pankso@1 16
pankso@1 17 # Tazlito configuration variables to be shorter
pankso@1 18 # and to use words rater than numbers.
pankso@1 19 COMMAND=$1
pankso@1 20 LIST_NAME=$2
pankso@1 21 TMP_DIR=/tmp/tazlito-$$-$RANDOM
pascal@19 22 TMP_MNT=/media/tazlito-$$-$RANDOM
pankso@1 23 TOP_DIR=`pwd`
pankso@1 24 INITRAMFS=rootfs.gz
pascal@11 25 LOCALSTATE=/var/lib/tazpkg
pascal@11 26 INSTALLED=$LOCALSTATE/installed
pascal@12 27 CACHE_DIR=/var/cache/tazpkg
pascal@12 28 MIRROR=$LOCALSTATE/mirror
pankso@49 29 DEFAULT_MIRROR="http://download.tuxfamily.org/slitaz/packages/`cat /etc/slitaz-release`/"
pankso@1 30
pankso@1 31 # Try to include config file, continue if command is gen-config or exit.
pankso@4 32 # The main config used by default is in /etc/tazlito.
pankso@4 33 if [ -f "/etc/tazlito/tazlito.conf" ] ; then
pankso@4 34 CONFIG_FILE="/etc/tazlito/tazlito.conf"
pankso@1 35 fi
pankso@1 36 # Specific distro config file can be put in a distro tree.
pankso@1 37 if [ -f "$TOP_DIR/tazlito.conf" ] ; then
pankso@1 38 CONFIG_FILE="$TOP_DIR/tazlito.conf"
pankso@1 39 fi
pankso@1 40 if [ ! "$CONFIG_FILE" = "" ] ; then
pankso@1 41 . $CONFIG_FILE
pankso@1 42 else
pankso@1 43 if [ "$COMMAND" = "gen-config" ] ; then
pankso@1 44 continue
pankso@1 45 else
pankso@1 46 echo "Unable to find any configuration file. Please read the doc"
pankso@1 47 echo "or run '`basename $0` gen-config' to get an empty config file."
pankso@1 48 exit 0
pankso@1 49 fi
pankso@1 50 fi
pankso@1 51
pankso@49 52 # While Tazpkg is not used the default mirror url file does not exist
pankso@49 53 # and user can't recharge the list of flavors.
pankso@49 54 if test $(id -u) = 0 ; then
pankso@49 55 if [ ! -f "$MIRROR" ]; then
pankso@49 56 echo "$DEFAULT_MIRROR" > $MIRROR
pankso@49 57 fi
pankso@49 58 fi
pankso@49 59
pankso@1 60 # Set the rootfs and rootcd path with $DISTRO
pankso@1 61 # configuration variable.
pankso@1 62 ROOTFS=$DISTRO/rootfs
pankso@1 63 ROOTCD=$DISTRO/rootcd
pankso@1 64
pankso@1 65 #####################
pankso@1 66 # Tazlito functions #
pankso@1 67 #####################
pankso@1 68
pankso@1 69 # Print the usage.
pankso@1 70 usage ()
pankso@1 71 {
pankso@1 72 echo -e "\nSliTaz Live Tool - Version: $VERSION\n
pascal@22 73 \033[1mUsage: \033[0m `basename $0` [command] [list|iso|flavor] [dir]
pankso@1 74 \033[1mCommands: \033[0m\n
pankso@1 75 usage Print this short usage.
pankso@1 76 stats View Tazlito and distro configuration statistics.
pankso@1 77 gen-config Generate a new configuration file for a distro.
pankso@1 78 configure Configure the main config file or a specific tazlito.conf.
pankso@1 79 gen-iso Generate a new ISO from a distro tree.
pankso@1 80 gen-initiso Generate a new initramfs and ISO from the distro tree.
pascal@22 81 list-flavors List all available package lists on the mirror.
pascal@22 82 gen-flavor Generate a new live-CD description.
pascal@60 83 gen-liveflavor Generate a live-CD description from current system.
pascal@22 84 show-flavor Show live-CD description.
pascal@22 85 get-flavor Get a flavor's list of packages.
pankso@1 86 extract-distro Extract and ISO to a directory and rebuild LiveCD tree.
pankso@1 87 gen-distro Generated a Live distro and ISO from a list of packages.
pankso@1 88 clean-distro Remove all files generated by gen-distro.
pankso@1 89 addhacker Add Linux User Hacker to the current distro.
pankso@1 90 check-distro Help to check if distro is ready to release.
pankso@1 91 burn-iso Burn ISO image to a cdrom using Wodim.\n"
pankso@1 92 }
pankso@1 93
pankso@1 94 # Status function.
pankso@1 95 status()
pankso@1 96 {
pankso@1 97 local CHECK=$?
pankso@1 98 echo -en "\\033[70G[ "
pankso@1 99 if [ $CHECK = 0 ]; then
pankso@1 100 echo -en "\\033[1;33mOK"
pankso@1 101 else
pankso@1 102 echo -en "\\033[1;31mFailed"
pankso@1 103 fi
pankso@1 104 echo -e "\\033[0;39m ]"
pankso@1 105 }
pascal@12 106
pascal@12 107 yesorno()
pascal@12 108 {
pascal@12 109 echo -n "$1"
pascal@12 110 case "$DEFAULT_ANSWER" in
pascal@12 111 Y|y) answer="y";;
pascal@12 112 N|n) answer="n";;
pascal@12 113 *) read answer;;
pascal@12 114 esac
pascal@12 115 }
pascal@12 116
pascal@22 117 field()
pascal@22 118 {
pascal@22 119 grep "^$1" "$2" | sed 's/.*: \([0-9KMG\.]*\).*/\1/'
pascal@22 120 }
pascal@22 121
pankso@1 122 todomsg()
pankso@1 123 {
pankso@1 124 echo -e "\\033[70G[ \\033[1;31mTODO\\033[0;39m ]"
pankso@1 125 }
pankso@1 126
pascal@12 127 # Download a file trying each mirror
pascal@12 128 download()
pascal@12 129 {
pascal@12 130 for i in $(cat $MIRROR); do
pascal@12 131 wget $i$@
pascal@12 132 done
pascal@12 133 }
pascal@12 134
pascal@13 135 # exec hooks provided by some packages
pascal@13 136 genisohooks()
pascal@13 137 {
pascal@13 138 local here=`pwd`
pascal@13 139 cd $ROOTFS
pascal@13 140 for i in $(ls etc/tazlito/*.$1 2> /dev/null); do
pascal@13 141 . $i $ROOTCD
pascal@13 142 done
pascal@13 143 cd $here
pascal@13 144 }
pascal@13 145
pascal@19 146 cleanup()
pascal@19 147 {
pascal@19 148 if [ -d $TMP_MNT ]; then
pascal@19 149 umount $TMP_MNT
pascal@19 150 rmdir $TMP_MNT
pascal@19 151 rm -f /boot
pascal@19 152 fi
pascal@19 153 }
pascal@19 154
pascal@18 155 # echo the package name if the tazpkg is already installed
pascal@18 156 installed_package_name()
pascal@18 157 {
pascal@18 158 local tazpkg
pascal@18 159 local package
pascal@18 160 local VERSION
pascal@18 161 tazpkg=$1
pascal@18 162 # try du find package name and version to be able
pascal@18 163 # to repack it from installation
pascal@18 164 # a dash (-) can exist in name *and* in version
pascal@18 165 package=${tazpkg%-*}
pascal@18 166 i=$package
pascal@18 167 while true; do
pascal@18 168 VERSION=""
pascal@18 169 eval $(grep -s ^VERSION= $INSTALLED/$i/receipt)
pascal@18 170 if [ "$i-$VERSION" = "$tazpkg" ]; then
pascal@18 171 echo $i
pascal@18 172 break
pascal@18 173 fi
pascal@18 174 case "$i" in
pascal@18 175 *-*);;
pascal@18 176 *) break;;
pascal@18 177 esac
pascal@18 178 i=${i%-*}
pascal@18 179 done
pascal@18 180 }
pascal@18 181
pankso@1 182 # Check if user is root.
pankso@1 183 check_root()
pankso@1 184 {
pankso@1 185 if test $(id -u) != 0 ; then
pankso@1 186 echo -e "\nYou must be root to run `basename $0` with this option."
pankso@1 187 echo -e "Please type 'su' and root password to become super-user.\n"
pankso@1 188 exit 0
pankso@1 189 fi
pankso@1 190 }
pankso@1 191
pascal@11 192 # Check for the rootfs tree.
pascal@11 193 check_rootfs()
pascal@11 194 {
pascal@13 195 if [ ! -d "$ROOTFS/etc" ] ; then
pascal@13 196 echo -e "\nUnable to find a distro rootfs...\n"
pascal@11 197 exit 0
pascal@11 198 fi
pascal@11 199 }
pascal@11 200
pankso@1 201 # Check for the boot dir into the root CD tree.
pankso@1 202 verify_rootcd()
pankso@1 203 {
pankso@1 204 if [ ! -d "$ROOTCD/boot" ] ; then
pankso@1 205 echo -e "\nUnable to find the rootcd boot directory...\n"
pankso@1 206 exit 0
pankso@1 207 fi
pankso@1 208 }
pankso@1 209
pankso@1 210 # Gen a new ISO image using isolinux.
pankso@1 211 gen_livecd_isolinux()
pankso@1 212 {
pascal@13 213 # Some packages may want to alter iso
pascal@13 214 genisohooks iso
pankso@35 215 if [ ! -f "$ROOTCD/boot/isolinux/isolinux.bin" ]; then
pankso@1 216 echo -e "\nUnable to find isolinux binary.\n"
pascal@19 217 cleanup
pankso@1 218 exit 0
pankso@1 219 fi
pankso@35 220 # Set date for boot msg.
pankso@35 221 if grep -q 'XXXXXXXX' $ROOTCD/boot/isolinux/isolinux.msg; then
pankso@35 222 DATE=`date +%Y%m%d`
pascal@56 223 echo -n "Setting build date to: $DATE..."
pankso@35 224 sed -i s/'XXXXXXXX'/"$DATE"/ $ROOTCD/boot/isolinux/isolinux.msg
pankso@35 225 status
pankso@35 226 fi
pascal@51 227 cd $ROOTCD
pascal@51 228 echo -n "Computing md5..."
pascal@66 229 find * -type f ! -name md5sum -exec md5sum {} \; > md5sum
pascal@51 230 status
pankso@1 231 cd $DISTRO
pankso@1 232 echo ""
pankso@1 233 echo -e "\033[1mGenerating ISO image\033[0m"
pankso@1 234 echo "================================================================================"
pankso@1 235 genisoimage -R -o $ISO_NAME.iso -b boot/isolinux/isolinux.bin \
pankso@1 236 -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
pankso@1 237 -V "$VOLUM_NAME" -p "$PREPARED" -input-charset iso8859-1 \
pankso@1 238 -boot-info-table $ROOTCD
pankso@53 239 echo -n "Creating the ISO md5sum..."
pankso@53 240 md5sum $ISO_NAME.iso > $ISO_NAME.md5
pankso@53 241 status
pankso@1 242 echo "================================================================================"
pascal@37 243 # Some packages may want to alter final iso
pascal@37 244 genisohooks final
pankso@1 245 }
pankso@1 246
pankso@1 247 # Gen a new initramfs from the root file system.
pankso@1 248 gen_initramfs()
pankso@1 249 {
pascal@56 250 # Just in case CTRL+c
pascal@56 251 rm -f $DISTRO/gen
pascal@13 252 # Some packages may want to alter rootfs
pascal@13 253 genisohooks rootfs
pankso@1 254 cd $ROOTFS
pankso@1 255 echo ""
pascal@57 256
pascal@57 257 # Link duplicate files
pascal@69 258 find . -type f -size +0c -exec stat -c '%s-%a-%u-%g %i %h %n' {} \; | \
pascal@69 259 sort | ( save=0; old_attr=""; old_inode=""; old_link=""; old_file=""
pascal@69 260 while read attr inode link file; do
pascal@69 261 if [ "$attr" = "$old_attr" -a "$inode" != "$old_inode" ]; then
pascal@57 262 if cmp "$file" "$old_file" >/dev/null; then
pascal@57 263 rm -f "$file"
pascal@57 264 ln "$old_file" "$file"
pascal@70 265 inode="$old_inode"
pascal@69 266 [ "$link" = "1" ] && save="$(expr $save + ${attr%%-*})"
pascal@57 267 fi
pascal@57 268 fi
pascal@69 269 old_attr="$attr" ; old_inode="$inode" ; old_file="$file"
pascal@59 270 done
pascal@59 271 echo "$save bytes saved in duplicate files."
pascal@59 272 )
pascal@69 273
pascal@69 274 # Link duplicate links
pascal@69 275 find . -type l -size +0c -exec stat -c '%s-%a-%u-%g %i %h %n' {} \; | \
pascal@69 276 sort | ( save=0; old_attr=""; old_inode=""; old_link=""; old_file=""
pascal@69 277 while read attr inode link file; do
pascal@69 278 if [ "$attr" = "$old_attr" -a "$inode" != "$old_inode" ]; then
pascal@69 279 if [ "$(readlink $file)" = "$(readlink $old_file)" ]; then
pascal@69 280 rm -f "$file"
pascal@69 281 ln "$old_file" "$file"
pascal@70 282 inode="$old_inode"
pascal@69 283 [ "$link" = "1" ] && save="$(expr $save + ${attr%%-*})"
pascal@69 284 fi
pascal@69 285 fi
pascal@69 286 old_attr="$attr" ; old_inode="$inode" ; old_file="$file"
pascal@69 287 done
pascal@69 288 echo "$save bytes saved in duplicate links."
pascal@69 289 )
pascal@57 290
pankso@7 291 # Use lzma if installed
pascal@34 292 if [ "$COMPRESSION" = "none" ]; then
pascal@34 293 echo -n "Generating uncompressed initramfs... "
pascal@34 294 find . -print | cpio -o -H newc > $DISTRO/$INITRAMFS
pascal@34 295 elif [ -x /usr/bin/lzma -a "$COMPRESSION" != "gzip" ]; then
pascal@14 296 echo -n "Generating lzma'ed initramfs... "
erjo@33 297 find . -print | cpio -o -H newc | lzma e -si -so > $DISTRO/$INITRAMFS
pascal@64 298 echo -n "set uncompressed size... "
pascal@64 299 echo -en "$(lzma d $DISTRO/$INITRAMFS -so 2> /dev/null | wc -c \
pascal@64 300 | awk '{ n=512+$0; for (i=0;i<8;i++) { printf("\\x%02X",n%256); n/=256 }}')" \
pascal@64 301 | dd bs=1 seek=5 conv=notrunc of=$DISTRO/$INITRAMFS 2> /dev/null
pankso@7 302 else
pankso@7 303 echo -n "Generating gziped initramfs... "
pankso@7 304 find . -print | cpio -o -H newc | gzip -9 > $DISTRO/$INITRAMFS
pankso@7 305 fi
pascal@14 306 cd $DISTRO
pascal@14 307 mv $INITRAMFS $ROOTCD/boot
pankso@1 308 }
pankso@1 309
pascal@22 310 distro_sizes()
pankso@1 311 {
pankso@1 312 echo "Build date : `date +%Y%m%d\ \at\ \%H:%M:%S`"
pascal@19 313 echo "Packages : `ls -1 $ROOTFS$INSTALLED | wc -l`"
pankso@1 314 echo "Rootfs size : `du -sh $ROOTFS`"
pascal@14 315 echo "Initramfs size : `du -sh $ROOTCD/boot/$INITRAMFS`"
pankso@1 316 echo "ISO image size : `du -sh $ISO_NAME.iso`"
pankso@1 317 echo "================================================================================"
pankso@1 318 echo ""
pankso@1 319 }
pankso@1 320
pascal@22 321 # Print ISO and rootfs size.
pascal@22 322 distro_stats()
pascal@22 323 {
pascal@22 324 echo ""
pascal@22 325 echo -e "\033[1mDistro statistics\033[0m"
pascal@22 326 echo "================================================================================"
pascal@22 327 distro_sizes
pascal@22 328 }
pascal@22 329
pankso@1 330 # Creat an empty configuration file.
pankso@1 331 empty_config_file()
pankso@1 332 {
pankso@1 333 cat >> tazlito.conf << "EOF"
pankso@1 334 # tazlito.conf: Tazlito (SliTaz Live Tool)
pankso@1 335 # configuration file.
pankso@1 336 #
pankso@1 337
pankso@1 338 # Name of the ISO image to generate.
pankso@1 339 ISO_NAME=""
pankso@1 340
pankso@1 341 # ISO image volum name.
pankso@1 342 VOLUM_NAME="SliTaz"
pankso@1 343
pankso@1 344 # Name of the preparator.
pankso@1 345 PREPARED="$USER"
pankso@1 346
pankso@1 347 # Path to the packages repository and the packages.list.
pankso@1 348 PACKAGES_REPOSITORY=""
pankso@1 349
pankso@1 350 # Path to the distro tree to gen-distro from a
pankso@1 351 # list of packages.
pankso@1 352 DISTRO=""
pankso@1 353
pankso@1 354 # Path to the directory contening additional files
pankso@1 355 # to copy into the rootfs and rootcd of the LiveCD.
pankso@1 356 ADDFILES="$DISTRO/addfiles"
pascal@12 357
pascal@12 358 # Default answer for binary question (Y or N)
pascal@12 359 DEFAULT_ANSWER="ASK"
pascal@21 360
pascal@38 361 # Compression utility (lzma, gzip or none)
pascal@21 362 COMPRESSION="lzma"
pankso@1 363 EOF
pankso@1 364 }
pankso@1 365
pankso@1 366 ####################
pankso@1 367 # Tazlito commands #
pankso@1 368 ####################
pankso@1 369
pankso@1 370 case "$COMMAND" in
pankso@1 371 stats)
pankso@1 372 # Tazlito general statistics from the config file.
pankso@1 373 #
pankso@1 374 echo ""
pankso@1 375 echo -e "\033[1mTazlito statistics\033[0m
pankso@1 376 ===============================================================================
pankso@1 377 Config file : $CONFIG_FILE
pankso@1 378 ISO name : $ISO_NAME.iso
pankso@1 379 Volum name : $VOLUM_NAME
pankso@1 380 Prepared : $PREPARED
pankso@1 381 Packages repository : $PACKAGES_REPOSITORY
pankso@1 382 Distro directory : $DISTRO"
pankso@1 383 if [ ! "$ADDFILES" = "" ] ; then
pankso@1 384 echo -e "Additional files : $ADDFILES"
pankso@1 385 fi
pankso@1 386 echo "================================================================================"
pankso@1 387 echo ""
pankso@1 388 ;;
pankso@1 389 gen-config)
pankso@1 390 # Gen a new config file in the current dir or the specified
pankso@1 391 # directory by $2.
pankso@1 392 #
pankso@1 393 if [ -n "$2" ] ; then
pankso@1 394 mkdir -p $2 && cd $2
pankso@1 395 fi
pankso@1 396 echo -n "Generating empty tazlito.conf..."
pankso@1 397 empty_config_file
pankso@1 398 status
pankso@1 399 echo ""
pankso@1 400 if [ -f "tazlito.conf" ] ; then
pankso@1 401 echo "Configuration file is ready to edit."
pankso@1 402 echo "File location : `pwd`/tazlito.conf"
pankso@1 403 echo ""
pankso@1 404 fi
pankso@1 405 ;;
pankso@1 406 configure)
pankso@1 407 # Configure a tazlito.conf config file. Start by getting
pankso@1 408 # a empty config file and sed it.
pankso@1 409 #
pankso@1 410 if [ -f "tazlito.conf" ] ; then
pankso@1 411 rm tazlito.conf
pankso@1 412 else
pankso@1 413 if test $(id -u) = 0 ; then
pankso@1 414 cd /etc
pankso@1 415 else
pankso@1 416 echo "You must be root to configure the main config file or in"
pankso@1 417 echo "the same directory of the file you want to configure."
pankso@1 418 exit 0
pankso@1 419 fi
pankso@1 420 fi
pankso@1 421 empty_config_file
pankso@1 422 echo""
pankso@1 423 echo -e "\033[1mConfiguring :\033[0m `pwd`/tazlito.conf"
pankso@1 424 echo "================================================================================"
pankso@1 425 # ISO name.
pascal@11 426 echo -n "ISO name : " ; read answer
pascal@11 427 sed -i s#'ISO_NAME=\"\"'#"ISO_NAME=\"$answer\""# tazlito.conf
pascal@14 428 # Volume name.
pascal@14 429 echo -n "Volume name : " ; read answer
pascal@11 430 sed -i s/'VOLUM_NAME=\"SliTaz\"'/"VOLUM_NAME=\"$answer\""/ tazlito.conf
pankso@1 431 # Packages repository.
pascal@11 432 echo -n "Packages repository : " ; read answer
pascal@11 433 sed -i s#'PACKAGES_REPOSITORY=\"\"'#"PACKAGES_REPOSITORY=\"$answer\""# tazlito.conf
pankso@1 434 # Distro path.
pascal@11 435 echo -n "Distro path : " ; read answer
pascal@11 436 sed -i s#'DISTRO=\"\"'#"DISTRO=\"$answer\""# tazlito.conf
pankso@1 437 echo "================================================================================"
pankso@1 438 echo "Config file is ready to use."
pankso@1 439 echo "You can now extract an ISO or generate a distro."
pankso@1 440 echo ""
pankso@1 441 ;;
pankso@1 442 gen-iso)
pankso@1 443 # Simply generated a new iso.
pankso@1 444 #
pankso@1 445 check_root
pankso@1 446 verify_rootcd
pankso@1 447 gen_livecd_isolinux
pankso@1 448 distro_stats
pankso@1 449 ;;
pankso@1 450 gen-initiso)
pankso@1 451 # Simply generated a new initramfs with a new iso.
pankso@1 452 #
pankso@1 453 check_root
pankso@1 454 verify_rootcd
pankso@1 455 gen_initramfs
pankso@1 456 gen_livecd_isolinux
pankso@1 457 distro_stats
pankso@1 458 ;;
pankso@1 459 extract-distro)
pankso@1 460 # Extract a ISO image to a directory and rebuild the LiveCD tree.
pankso@1 461 #
pankso@1 462 check_root
pankso@1 463 ISO_IMAGE=$2
pankso@1 464 if [ -z "$ISO_IMAGE" ] ; then
pankso@1 465 echo -e "\nPlease specify the path to the ISO image."
pankso@1 466 echo -e "Example : `basename $0` image.iso /path/target\n"
pankso@1 467 exit 0
pankso@1 468 fi
pankso@1 469 # Set the distro path by checking for $3 on cmdline.
pankso@1 470 if [ -n "$3" ] ; then
pankso@1 471 TARGET=$3
pankso@1 472 else
pankso@1 473 TARGET=$DISTRO
pankso@1 474 fi
pankso@1 475 # Exit if existing distro is found.
pankso@1 476 if [ -d "$TARGET/rootfs" ] ; then
pankso@1 477 echo -e "\nA rootfs exist in : $TARGET"
pankso@1 478 echo -e "Please clean the distro tree or change directory path.\n"
pankso@1 479 exit 0
pankso@1 480 fi
pankso@1 481 echo ""
pankso@1 482 echo -e "\033[1mTazlito extracting :\033[0m $ISO_IMAGE"
pankso@1 483 echo "================================================================================"
pankso@1 484 # Start to mount the ISO.
pankso@1 485 echo ""
pankso@1 486 echo "Mounting ISO image..."
pankso@1 487 mkdir -p $TMP_DIR
pankso@1 488 # Get ISO file size.
pankso@1 489 isosize=`du -sh $ISO_IMAGE`
pankso@1 490 mount -o loop $ISO_IMAGE $TMP_DIR
pankso@1 491 sleep 2
pankso@1 492 # Prepare target dir, copy the kernel and the rootfs.
pankso@1 493 mkdir -p $TARGET/rootfs
pankso@1 494 mkdir -p $TARGET/rootcd/boot
pankso@1 495 echo -n "Copying the Linux kernel..."
pascal@16 496 if cp $TMP_DIR/boot/vmlinuz* $TARGET/rootcd/boot 2> /dev/null; then
pascal@20 497 ln $TARGET/rootcd/boot/vmlinuz* $TARGET/rootcd/boot/bzImage
pascal@16 498 else
pascal@16 499 cp $TMP_DIR/boot/bzImage $TARGET/rootcd/boot
pascal@16 500 fi
pankso@1 501 status
pankso@1 502 echo -n "Copying isolinux files..."
pankso@1 503 cp -a $TMP_DIR/boot/isolinux $TARGET/rootcd/boot
pascal@41 504 for i in $(ls $TMP_DIR); do
pascal@41 505 [ "$i" = "boot" ] && continue
pascal@41 506 cp -a $TMP_DIR/$i $TARGET/rootcd
pascal@41 507 done
pankso@1 508 status
erjo@31 509 if [ -d $TMP_DIR/boot/syslinux ]; then
erjo@33 510 echo -n "Copying syslinux files..."
erjo@31 511 cp -a $TMP_DIR/boot/syslinux $TARGET/rootcd/boot
erjo@31 512 status
erjo@31 513 fi
erjo@31 514 if [ -d $TMP_DIR/boot/extlinux ]; then
erjo@33 515 echo -n "Copying extlinux files..."
erjo@31 516 cp -a $TMP_DIR/boot/extlinux $TARGET/rootcd/boot
erjo@31 517 status
erjo@31 518 fi
erjo@31 519 if [ -d $TMP_DIR/boot/grub ]; then
erjo@33 520 echo -n "Copying GRUB files..."
erjo@31 521 cp -a $TMP_DIR/boot/grub $TARGET/rootcd/boot
erjo@31 522 status
erjo@31 523 fi
erjo@31 524
pankso@1 525 echo -n "Copying the rootfs..."
pascal@11 526 cp $TMP_DIR/boot/rootfs.?z $TARGET/rootcd/boot
pankso@1 527 status
pankso@1 528 # Exract initramfs.
pankso@1 529 cd $TARGET/rootfs
pankso@1 530 echo -n "Extracting the rootfs... "
pascal@11 531 ( zcat ../rootcd/boot/rootfs.gz 2>/dev/null || \
pascal@38 532 lzma d ../rootcd/boot/rootfs.?z -so 2>/dev/null || \
pascal@38 533 cat ../rootcd/boot/rootfs.gz ) | cpio -id
pascal@38 534 # unpack /usr
pascal@48 535 for i in etc/tazlito/*.extract; do
pascal@50 536 [ -f "$i" ] && . $i ../rootcd
pascal@48 537 done
pankso@1 538 # Umount and remove temp directory and cd to $TARGET to get stats.
pankso@1 539 umount $TMP_DIR && rm -rf $TMP_DIR
pankso@1 540 cd ..
pankso@1 541 echo ""
pankso@1 542 echo "================================================================================"
pankso@1 543 echo "Extracted : $ISO_IMAGE ($isosize)"
pankso@1 544 echo "Distro tree : `pwd`"
pankso@1 545 echo "Rootfs size : `du -sh rootfs`"
pankso@1 546 echo "Rootcd size : `du -sh rootcd`"
pankso@1 547 echo "================================================================================"
pankso@1 548 echo ""
pankso@1 549 ;;
pascal@22 550 list-flavors)
pascal@22 551 # Show available flavors.
pascal@22 552 if [ ! -s /etc/tazlito/flavors.list -o "$2" == "--recharge" ]; then
pascal@22 553 download flavors.list -O - > /etc/tazlito/flavors.list
pascal@22 554 fi
pankso@27 555 echo ""
pankso@27 556 echo -e "\033[1mList of flavors\033[0m"
pankso@27 557 echo "================================================================================"
pascal@22 558 cat /etc/tazlito/flavors.list
pankso@27 559 echo ""
pascal@22 560 ;;
pascal@22 561 show-flavor)
pascal@22 562 # Show flavor description.
pascal@22 563 FLAVOR=$2
pascal@22 564 if [ ! -f "$FLAVOR.flavor" ]; then
pascal@22 565 echo "File $FLAVOR.flavor not found."
pascal@22 566 exit 1
pascal@22 567 fi
pascal@22 568 mkdir $TMP_DIR
pascal@22 569 zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i 2> /dev/null )
pascal@22 570 if [ "$3" = "--brief" ]; then
pascal@22 571 if [ "$4" != "--noheader" ]; then
pascal@22 572 echo "Name Sizes Description"
pascal@22 573 echo "================================================================================"
pascal@22 574 fi
pascal@22 575 printf "%-15.15s %5.5s/%5.5s %-51s\n" "$FLAVOR" \
pascal@22 576 "$(field ISO $TMP_DIR/$FLAVOR.desc)" \
pascal@22 577 "$(field Rootfs $TMP_DIR/$FLAVOR.desc)" \
pascal@22 578 "$(grep ^Description $TMP_DIR/$FLAVOR.desc | cut -d: -f2)"
pascal@22 579 else
pascal@22 580 echo "================================================================================"
pascal@22 581 cat $TMP_DIR/$FLAVOR.desc
pascal@22 582 fi
pascal@22 583 rm -Rf $TMP_DIR
pascal@22 584 ;;
pascal@60 585 gen-liveflavor)
pascal@60 586 # Generate a new flavor form the live system.
pascal@60 587 FLAVOR=$2
pascal@60 588 DESC=""
pascal@60 589 case "$FLAVOR" in
pascal@60 590 '') echo -n "Flavor name : "
pascal@60 591 read FLAVOR
pascal@60 592 [ -z "$FLAVOR" ] && exit 1;;
pascal@65 593 -?|-h*|--help) echo -e "
pascal@60 594
pascal@60 595 SliTaz Live Tool - Version: $VERSION
pascal@60 596 \033[1mUsage: \033[0m `basename $0` gen-liveflavor flavor-name [flavor-patch-file]
pascal@60 597 \033[1mflavor-patch-file format: \033[0m
pascal@60 598 code data
pascal@60 599 + package to add
pascal@60 600 - package to remove
pascal@65 601 ! non-free package to add
pascal@60 602 ? display message
pascal@60 603 @ flavor description
pascal@60 604
pascal@60 605 \033[1mExample: \033[0m
pascal@60 606 @ Developper tools for slitaz maintainers
pascal@60 607 + slitaz-toolchain
pascal@60 608 + mercurial
pascal@65 609 "
pascal@60 610 exit 1;;
pascal@60 611 esac
pascal@60 612 mv /etc/tazlito/distro-packages.list \
pascal@60 613 /etc/tazlito/distro-packages.list.$$ 2> /dev/null
pascal@60 614 rm -f distro-packages.list non-free.list 2> /dev/null
pascal@60 615 tazpkg recharge
pascal@60 616 [ -n "$3" ] && while read action pkg; do
pascal@60 617 case "$action" in
pascal@60 618 +) yes | tazpkg get-install $pkg;;
pascal@60 619 -) yes | tazpkg remove $pkg;;
pascal@65 620 !) echo $pkg >> non-free.list;;
pascal@60 621 @) DESC="$pkg";;
pascal@60 622 \?) echo -en "$pkg"; read action;;
pascal@60 623 esac
pascal@60 624 done < $3
pascal@60 625 yes '' | tazlito gen-distro
pascal@60 626 echo "$DESC" | tazlito gen-flavor "$FLAVOR"
pascal@60 627 mv /etc/tazlito/distro-packages.list.$$ \
pascal@60 628 /etc/tazlito/distro-packages.list 2> /dev/null
pascal@60 629 ;;
pascal@22 630 gen-flavor)
pascal@60 631 # Generate a new flavor from the last iso image generation.
pascal@22 632 FLAVOR=$2
pankso@35 633 echo ""
pankso@35 634 echo -e "\033[1mFlavor generation\033[0m"
pankso@35 635 echo "================================================================================"
pascal@22 636 if [ -z "$FLAVOR" ]; then
pascal@22 637 echo -n "Flavor name : "
pascal@22 638 read FLAVOR
pascal@22 639 [ -z "$FLAVOR" ] && exit 1
pascal@22 640 fi
pascal@22 641 check_rootfs
pascal@68 642 FILES="$FLAVOR.pkglist"
pascal@22 643 echo -n "Creating file $FLAVOR.flavor..."
pascal@22 644 for i in rootcd rootfs; do
pascal@22 645 if [ -d "$ADDFILES/$i" ] ; then
pascal@22 646 FILES="$FILES\n$FLAVOR.$i"
pascal@22 647 ( cd "$ADDFILES/$i"; find . | \
pascal@22 648 cpio -o -H newc 2> /dev/null | gzip -9 ) > $FLAVOR.$i
pascal@22 649 fi
pascal@22 650 done
pankso@35 651 status
pascal@22 652 answer=`grep -s ^Description $FLAVOR.desc`
pascal@22 653 answer=${answer#Description : }
pascal@22 654 if [ -z "$answer" ]; then
pankso@35 655 echo -n "Description : "
pascal@22 656 read answer
pascal@22 657 fi
pankso@35 658 echo -n "Compressing flavor $FLAVOR..."
pascal@22 659 echo "Flavor : $FLAVOR" > $FLAVOR.desc
pascal@22 660 echo "Description : $answer" >> $FLAVOR.desc
pascal@22 661 ( cd $DISTRO; distro_sizes) >> $FLAVOR.desc
pascal@68 662 \rm -f $FLAVOR.pkglist $FLAVOR.nonfree 2> /dev/null
pascal@22 663 for i in $(ls $ROOTFS$INSTALLED); do
pascal@22 664 eval $(grep ^VERSION= $ROOTFS$INSTALLED/$i/receipt)
pascal@61 665 eval $(grep ^CATEGORY= $ROOTFS$INSTALLED/$i/receipt)
pascal@61 666 if [ "$CATEGORY" = "non-free" -a "${i%%-*}" != "get" ]
pascal@61 667 then
pascal@61 668 echo "$i" >> $FLAVOR.nonfree
pascal@61 669 else
pascal@61 670 echo "$i-$VERSION" >> $FLAVOR.pkglist
pascal@61 671 fi
pascal@22 672 done
pascal@68 673 [ -s $FLAVOR.nonfree ] && $FILES="$FILES\n$FLAVOR.nonfree"
pascal@68 674 echo -e "$FLAVOR.desc\n$FILES" | cpio -o -H newc 2>/dev/null | \
pascal@68 675 gzip -9 > $FLAVOR.flavor
pascal@22 676 rm `echo -e $FILES`
pascal@22 677 status
pankso@35 678 echo "================================================================================"
pankso@35 679 echo "Flavor size : `du -sh $FLAVOR.flavor`"
pankso@35 680 echo ""
pascal@22 681 ;;
pascal@22 682 get-flavor)
pascal@22 683 # Get a flavor's files and prepare for gen-distro.
pascal@22 684 FLAVOR=$2
pascal@22 685 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
pascal@22 686 echo -n "Cleaning $DISTRO..."
pascal@22 687 rm -R $DISTRO 2> /dev/null
pascal@22 688 mkdir -p $DISTRO
pascal@22 689 status
pascal@22 690 mkdir $TMP_DIR
pascal@22 691 zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i 2>/dev/null )
pascal@22 692 echo -n "Create distro-packages.list..."
pascal@68 693 mv $TMP_DIR/$FLAVOR.nonfree non-free.list 2> /dev/null
pascal@22 694 mv $TMP_DIR/$FLAVOR.pkglist distro-packages.list
pascal@22 695 status
pascal@22 696 for i in rootcd rootfs; do
pascal@22 697 if [ -f $TMP_DIR/$FLAVOR.$i ]; then
pascal@22 698 mkdir -p "$ADDFILES/$i"
pascal@22 699 zcat $TMP_DIR/$FLAVOR.$i | \
pascal@22 700 ( cd "$ADDFILES/$i"; cpio -id 2> /dev/null)
pascal@22 701 fi
pascal@22 702 done
pascal@22 703 echo -n "Update tazlito.conf..."
pascal@22 704 [ -f tazlito.conf ] || cp /etc/tazlito/tazlito.conf .
pascal@22 705 cat tazlito.conf | grep -v "^#VOLUM_NAME" | \
pascal@22 706 sed "s/^VOLUM_NA/VOLUM_NAME=\"SliTaz $FLAVOR\"\\n#VOLUM_NA/" \
pascal@22 707 > tazlito.conf.$$ && mv tazlito.conf.$$ tazlito.conf
pascal@22 708 status
pascal@22 709 rm -Rf $TMP_DIR
pascal@22 710 fi
pascal@22 711 ;;
pankso@1 712 gen-distro)
pankso@1 713 # Generate a live distro tree with a set of packages.
pankso@1 714 #
pankso@1 715 check_root
pankso@1 716 if [ -d $ROOTFS ] ; then
pankso@1 717 echo "A rootfs exist in : $DISTRO"
pankso@1 718 echo -e "Please clean the distro tree or change directory path.\n"
pankso@1 719 exit 0
pankso@1 720 fi
pascal@19 721 # Check if a package list was specified on cmdline.
pascal@19 722 LIST_NAME="distro-packages.list"
pascal@19 723 CDROM=""
pascal@19 724 while [ -n "$2" ]; do
pascal@19 725 case "$2" in
pascal@19 726 --iso=*)
pascal@19 727 CDROM="-o loop ${2#--iso=}"
pascal@19 728 ;;
pascal@19 729 --cdrom)
pascal@19 730 CDROM="/dev/cdrom"
pascal@19 731 ;;
pascal@19 732 *) if [ ! -f "$2" ] ; then
pascal@19 733 echo -e "\nUnable to find the specified packages list."
pascal@19 734 echo -e "List name : $2\n"
pascal@19 735 exit 1
pascal@19 736 fi
pankso@1 737 LIST_NAME=$2
pascal@19 738 ;;
pascal@19 739 esac
pascal@19 740 shift
pascal@19 741 done
pascal@19 742 if [ ! -f "$LIST_NAME" -a -d $INSTALLED ] ; then
pascal@19 743 # Build list with installed packages
pascal@19 744 for i in $(ls $INSTALLED); do
pascal@19 745 eval $(grep ^VERSION= $INSTALLED/$i/receipt)
pascal@19 746 echo "$i-$VERSION" >> $LIST_NAME
pascal@19 747 done
pankso@1 748 fi
pankso@1 749 # Exit if no list name.
pascal@18 750 if [ ! -f "$LIST_NAME" ]; then
pankso@1 751 echo -e "\nNo packages list found or specified. Please read the doc.\n"
pankso@1 752 exit 0
pankso@1 753 fi
pankso@1 754 # Start generation.
pankso@1 755 echo ""
pankso@1 756 echo -e "\033[1mTazlito generating a distro\033[0m"
pankso@1 757 echo "================================================================================"
pascal@18 758 # Misc checks
pascal@18 759 [ -n "$PACKAGES_REPOSITORY" ] || PACKAGES_REPOSITORY="."
pascal@18 760 [ -d $PACKAGES_REPOSITORY ] || mkdir -p $PACKAGES_REPOSITORY
pankso@1 761 # Get the list of packages using cat for a file list.
pankso@1 762 LIST=`cat $LIST_NAME`
pankso@1 763 # Verify if all packages in list are presents in $PACKAGES_REPOSITORY.
pascal@18 764 REPACK=""
pascal@18 765 DOWNLOAD=""
pankso@1 766 for pkg in $LIST
pankso@1 767 do
pascal@19 768 [ "$pkg" = "" ] && continue
pankso@1 769 pkg=${pkg%.tazpkg}
pascal@18 770 [ -f $PACKAGES_REPOSITORY/$pkg.tazpkg ] && continue
pascal@18 771 PACKAGE=$(installed_package_name $pkg)
pascal@18 772 [ -n "$PACKAGE" -a "$REPACK" = "y" ] && continue
pascal@18 773 [ -z "$PACKAGE" -a -n "$DOWNLOAD" ] && continue
pascal@18 774 echo -e "\nUnable to find $pkg in the repository."
pascal@18 775 echo -e "Path : $PACKAGES_REPOSITORY\n"
pascal@18 776 if [ -n "$PACKAGE" -a -z "$REPACK" ]; then
pascal@18 777 yesorno "Repack packages from rootfs (y/N) ? "
pascal@18 778 REPACK="$answer"
pascal@18 779 [ "$answer" = "y" ] || REPACK="n"
pascal@18 780 [ "$DOWNLOAD" = "y" ] && break
pascal@18 781 fi
pascal@18 782 if [ -f $MIRROR -a -z "$DOWNLOAD" ]; then
pascal@18 783 yesorno "Download packages from mirror (Y/n) ? "
pascal@18 784 DOWNLOAD="$answer"
pascal@18 785 if [ "$answer" = "n" ]; then
pascal@18 786 [ -z "$PACKAGE" ] && exit 1
pascal@18 787 else
pascal@18 788 DOWNLOAD="y"
pascal@18 789 [ -n "$REPACK" ] && break
pascal@12 790 fi
pankso@1 791 fi
pascal@18 792 [ "$REPACK" = "n" -a "$DOWNLOAD" = "n" ] && exit 1
pankso@1 793 done
pascal@19 794
pascal@19 795 # mount cdrom to be able to repack boot-loader packages
pascal@19 796 if [ ! -e /boot -a -n "$CDROM" ]; then
pascal@19 797 mkdir $TMP_MNT
pascal@20 798 if mount -r $CDROM $TMP_MNT 2> /dev/null; then
pascal@19 799 ln -s $TMP_MNT/boot /
pascal@19 800 if [ ! -d "$ADDFILES/rootcd" ] ; then
pascal@19 801 mkdir -p $ADDFILES/rootcd
pascal@19 802 for i in $(ls $TMP_MNT); do
pascal@19 803 [ "$i" = "boot" ] && continue
pascal@19 804 cp -a $TMP_MNT/$i $ADDFILES/rootcd
pascal@19 805 done
pascal@19 806 fi
pascal@19 807 else
pascal@19 808 rmdir $TMP_MNT
pascal@19 809 fi
pascal@19 810 fi
pascal@19 811
pankso@1 812 # Root fs stuff.
pankso@1 813 echo "Preparing the rootfs directory..."
pankso@1 814 mkdir -p $ROOTFS
pankso@1 815 sleep 2
pankso@1 816 for pkg in $LIST
pankso@1 817 do
pascal@19 818 [ "$pkg" = "" ] && continue
pankso@1 819 # First copy and extract the package in tmp dir.
pankso@1 820 pkg=${pkg%.tazpkg}
pascal@18 821 PACKAGE=$(installed_package_name $pkg)
pankso@1 822 mkdir -p $TMP_DIR
pascal@12 823 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
pascal@12 824 # look for package in cache
pascal@12 825 if [ -f $CACHE_DIR/$pkg.tazpkg ]; then
pascal@12 826 ln -s $CACHE_DIR/$pkg.tazpkg $PACKAGES_REPOSITORY
pascal@18 827 # look for package in running distribution
pascal@18 828 elif [ -n "$PACKAGE" -a "$REPACK" = "y" ]; then
pascal@18 829 tazpkg repack $PACKAGE && \
pascal@18 830 mv $pkg.tazpkg $PACKAGES_REPOSITORY
pascal@18 831 fi
pascal@18 832 fi
pascal@18 833 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
pascal@12 834 # get package from mirror
pascal@18 835 [ "$DOWNLOAD" = "y" ] && \
pascal@18 836 download $pkg.tazpkg && \
pascal@18 837 mv $pkg.tazpkg $PACKAGES_REPOSITORY
pascal@12 838 fi
pascal@12 839 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
pascal@12 840 echo "Missing package $pkg."
pascal@19 841 cleanup
pascal@12 842 exit 1
pascal@12 843 fi
pascal@17 844 yes "" | tazpkg install $PACKAGES_REPOSITORY/$pkg.tazpkg --root=$ROOTFS
pankso@1 845 done
pascal@19 846 cp $LIST_NAME $ROOTFS/etc/tazlito/distro-packages.list
pascal@61 847 if [ -f non-free.list ]; then
pascal@61 848 echo "Preparing non-free packages..."
pascal@61 849 cp non-free.list $ROOTFS/etc/tazlito/non-free.list
pascal@61 850 for pkg in $(cat non-free.list); do
pascal@61 851 if [ ! -d $INSTALLED/$pkg ]; then
pascal@61 852 if [ ! -d $INSTALLED/get-$pkg ]; then
pascal@61 853 tazpkg get-install get-$pkg
pascal@61 854 fi
pascal@61 855 get-$pkg
pascal@61 856 fi
pascal@61 857 tazpkg repack $pkg
pascal@61 858 yes "" | tazpkg install $pkg*.tazpkg --root=$ROOTFS
pascal@61 859 mv $pkg*.tazpkg $PACKAGES_REPOSITORY
pascal@61 860 done
pascal@61 861 fi
pankso@1 862 echo ""
pankso@1 863 cd $DISTRO
pankso@1 864 # Copy all files from $ADDFILES/rootfs to the rootfs.
pankso@1 865 if [ -d "$ADDFILES/rootfs" ] ; then
pankso@1 866 echo -n "Copying addfiles content to the rootfs... "
pascal@11 867 cp -a $ADDFILES/rootfs/* $ROOTFS
pascal@11 868 status
pankso@1 869 fi
pankso@1 870 echo "Root file system is generated..."
pankso@1 871 # Root CD part.
pankso@1 872 echo -n "Preparing the rootcd directory..."
pankso@1 873 mkdir -p $ROOTCD
pankso@1 874 status
pankso@1 875 # Move the boot dir with the Linux kernel from rootfs.
pankso@1 876 # The boot dir goes directly on the CD.
pankso@1 877 if [ -d "$ROOTFS/boot" ] ; then
pankso@1 878 echo -n "Moving the boot directory..."
pankso@1 879 mv $ROOTFS/boot $ROOTCD
pankso@1 880 cd $ROOTCD/boot
pascal@11 881 ln vmlinuz-* bzImage
pankso@1 882 status
pankso@1 883 fi
pankso@1 884 cd $DISTRO
pankso@1 885 # Copy all files from $ADDFILES/rootcd to the rootcd.
pankso@1 886 if [ -d "$ADDFILES/rootcd" ] ; then
pankso@1 887 echo -n "Copying addfiles content to the rootcd... "
pascal@11 888 cp -a $ADDFILES/rootcd/* $ROOTCD
pascal@11 889 status
pankso@1 890 fi
pankso@1 891 # Initramfs and ISO image stuff.
pankso@1 892 gen_initramfs
pankso@1 893 gen_livecd_isolinux
pankso@1 894 distro_stats
pascal@19 895 cleanup
pankso@1 896 ;;
pankso@1 897 clean-distro)
pankso@1 898 # Remove old distro tree.
pankso@1 899 #
pankso@1 900 check_root
pankso@1 901 echo ""
pankso@1 902 echo -e "\033[1mCleaning :\033[0m $DISTRO"
pankso@1 903 echo "================================================================================"
pankso@1 904 if [ -d "$DISTRO" ] ; then
pankso@1 905 if [ -d "$ROOTFS" ] ; then
pankso@1 906 echo -n "Removing the rootfs..."
pankso@1 907 rm -f $DISTRO/$INITRAMFS
pascal@11 908 rm -rf $ROOTFS
pascal@11 909 status
pankso@1 910 fi
pankso@1 911 if [ -d "$ROOTCD" ] ; then
pankso@1 912 echo -n "Removing the rootcd..."
pascal@11 913 rm -rf $ROOTCD
pascal@11 914 status
pankso@1 915 fi
pankso@1 916 echo -n "Removing eventual ISO image..."
pascal@11 917 rm -f $DISTRO/$ISO_NAME.iso
pascal@56 918 rm -f $DISTRO/$ISO_NAME.md5
pascal@11 919 status
pankso@1 920 fi
pankso@1 921 echo "================================================================================"
pankso@1 922 echo ""
pankso@1 923 ;;
pankso@1 924 addhacker)
pankso@1 925 # Without /etc/passwd...
pankso@1 926 #
pankso@1 927 check_root
pankso@1 928 echo ""
pankso@1 929 echo -e "\033[1mAdduser hacker to :\033[0m $ROOTFS"
pankso@1 930 echo "================================================================================"
pankso@1 931 if [ ! -d "$ROOTFS/etc" ] ; then
pankso@1 932 echo -e "\nUnable to find : $ROOTFS/etc"
pankso@1 933 echo -e "Users and passwords config files will not be found.\n"
pankso@1 934 exit 0
pankso@1 935 fi
pankso@1 936 # Go for echoing on configuration files if any hacker was found.
pankso@1 937 #
pankso@35 938 if ! grep -q hacker $root/etc/passwd; then
pankso@1 939 echo -n "Configuring $ROOTFS/etc..."
pankso@1 940 echo 'hacker:x:500:500:Linux User,,,:/home/hacker:/bin/ash' >> $ROOTFS/etc/passwd
pankso@1 941 echo 'hacker::13646:0:99999:7:::' >> $ROOTFS/etc/shadow
pankso@1 942 echo 'hacker:x:500:' >> $ROOTFS/etc/group
pankso@1 943 echo 'hacker:!::' >> $ROOTFS/etc/gshadow
pankso@1 944 status
pankso@1 945 else
pankso@1 946 echo "Hacker is already in : $ROOTFS/etc/passwd"
pankso@1 947 fi
pankso@8 948 # Hacker can listen to music
pankso@8 949 #
pankso@35 950 if grep -q audio $root/etc/group; then
pankso@35 951 if ! grep -q "audio:x:20:hacker" $root/etc/group; then
pankso@35 952 sed -i s/'audio:x:20:'/'audio:x:20:hacker'/ $root/etc/group
pankso@35 953 fi
pankso@8 954 fi
pankso@35 955 # /home/hacker directories.
pankso@1 956 #
pankso@1 957 echo -n "Creating default directories... "
pankso@35 958 mkdir -p $fs/home/hacker/Documents \
pankso@35 959 $fs/home/hacker/Downloads \
pankso@35 960 $fs/home/hacker/Templates \
pankso@35 961 $fs/home/hacker/.local/bin \
pankso@35 962 $fs/home/hacker/.local/share
pankso@1 963 status
pankso@1 964 # Change permissions.
pankso@1 965 #
pankso@1 966 echo -n "Chmodig all files in /home/hacker..."
pankso@1 967 chown -R 500.500 $ROOTFS/home/hacker
pankso@1 968 status
pankso@1 969 echo "================================================================================"
pankso@1 970 echo "Linux User Hacker have an account in the distro."
pankso@1 971 echo ""
pankso@1 972 ;;
pankso@1 973 check-distro)
pankso@1 974 # Check for a few LiveCD needed files not installed by packages.
pankso@1 975 #
pascal@11 976 check_rootfs
pankso@1 977 echo ""
pankso@1 978 echo -e "\033[1mChecking distro :\033[0m $ROOTFS"
pankso@1 979 echo "================================================================================"
pankso@1 980 # SliTaz release info.
pankso@1 981 if [ ! -f "$ROOTFS/etc/slitaz-release" ]; then
pascal@11 982 echo "Missing release info : /etc/slitaz-release"
pankso@1 983 else
pankso@1 984 release=`cat $ROOTFS/etc/slitaz-release`
pankso@1 985 echo -n "Release : $release"
pankso@1 986 status
pankso@1 987 fi
pankso@1 988 # Tazpkg mirror.
pankso@1 989 if [ ! -f "$ROOTFS/var/lib/tazpkg/mirror" ]; then
pankso@1 990 echo -n "Mirror URL : Missing /var/lib/tazpkg/mirror"
pankso@1 991 todomsg
pankso@1 992 else
pankso@1 993 echo -n "Mirror configuration exist..."
pankso@1 994 status
pankso@1 995 fi
pankso@1 996 # Isolinux msg
pankso@1 997 if grep -q "cooking-XXXXXXXX" /$ROOTCD/boot/isolinux/isolinux.msg; then
pankso@1 998 echo -n "Isolinux msg : Missing cooking date XXXXXXXX (ex `date +%Y%m%d`)"
pankso@1 999 todomsg
pankso@1 1000 else
pankso@1 1001 echo -n "Isolinux message seems good..."
pankso@1 1002 status
pankso@1 1003 fi
pankso@1 1004 echo "================================================================================"
pankso@1 1005 echo ""
pankso@1 1006 ;;
pankso@1 1007 burn-iso)
pankso@1 1008 # Guess cdrom device, ask user and burn the ISO.
pankso@1 1009 #
pankso@1 1010 check_root
pankso@1 1011 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
pankso@1 1012 DRIVE_SPEED=`cat /proc/sys/dev/cdrom/info | grep "drive speed" | cut -f 3`
pankso@1 1013 # We can specify an alternative ISO from the cmdline.
pankso@1 1014 if [ -n "$2" ] ; then
pankso@1 1015 iso=$2
pankso@1 1016 else
pankso@1 1017 iso=$DISTRO/$ISO_NAME.iso
pankso@1 1018 fi
pankso@1 1019 if [ ! -f "$iso" ]; then
pankso@1 1020 echo -e "\nUnable to find ISO : $iso\n"
pankso@1 1021 exit 0
pankso@1 1022 fi
pankso@1 1023 echo ""
pankso@1 1024 echo -e "\033[1mTazlito burn ISO\033[0m "
pankso@1 1025 echo "================================================================================"
pankso@1 1026 echo "Cdrom device : /dev/$DRIVE_NAME"
pankso@1 1027 echo "Drive speed : $DRIVE_SPEED"
pankso@1 1028 echo "ISO image : $iso"
pankso@1 1029 echo "================================================================================"
pankso@1 1030 echo ""
pascal@12 1031 yesorno "Burn ISO image (y/N) ? "
pascal@11 1032 if [ "$answer" == "y" ]; then
pankso@1 1033 echo ""
pankso@1 1034 echo "Starting Wodim to burn the iso..." && sleep 2
pankso@1 1035 echo "================================================================================"
pankso@25 1036 wodim speed=$DRIVE_SPEED dev=/dev/$DRIVE_NAME $iso
pankso@1 1037 echo "================================================================================"
pankso@1 1038 echo "ISO image is burned to cdrom."
pankso@1 1039 else
pankso@1 1040 echo -e "\nExiting. No ISO burned."
pankso@1 1041 fi
pankso@1 1042 echo ""
pankso@1 1043 ;;
pankso@1 1044 usage|*)
pankso@1 1045 # Clear and print usage also for all unknow commands.
pankso@1 1046 #
pankso@1 1047 clear
pankso@1 1048 usage
pankso@1 1049 ;;
pankso@1 1050
pankso@1 1051 esac
pankso@1 1052
pankso@1 1053 exit 0