tazlito view tazlito @ rev 148

Tiny edits (and merge?)
author Paul Issott <paul@slitaz.org>
date Sun Jan 24 19:16:52 2010 +0000 (2010-01-24)
parents 9813d9ffc480
children 5e7f3f9bf5d7
line source
1 #!/bin/sh
2 # TazLito - SliTaz Live Tool.
3 #
4 # Tazlito is a tool to help generate and configure SliTaz LiveCD
5 # ISO images. You can create a custom distro in one command from a list of
6 # packages, extract an existing ISO image to hack it, create a new initramfs
7 # and/or a new ISO. Most commands must be run by root, except the stats
8 # and the configuration file manipulation.
9 #
10 # (C) 2007-2010 SliTaz - GNU General Public License.
11 #
12 # Authors : Christophe Lincoln <pankso@slitaz.org>
13 # Pascal Bellard <pascal.bellard@slitaz.org>
14 #
15 VERSION=2.0
17 # Tazlito configuration variables to be shorter
18 # and to use words rather than numbers.
19 COMMAND=$1
20 LIST_NAME=$2
21 TMP_DIR=/tmp/tazlito-$$-$RANDOM
22 TMP_MNT=/media/tazlito-$$-$RANDOM
23 TOP_DIR=`pwd`
24 INITRAMFS=rootfs.gz
25 LOCALSTATE=/var/lib/tazpkg
26 INSTALLED=$LOCALSTATE/installed
27 CACHE_DIR=/var/cache/tazpkg
28 MIRROR=$LOCALSTATE/mirror
29 DEFAULT_MIRROR="http://mirror.slitaz.org/packages/`cat /etc/slitaz-release`/"
31 # Try to include config file, continue if command is gen-config or exit.
32 # The main config used by default is in /etc/tazlito.
33 if [ -f "/etc/tazlito/tazlito.conf" ] ; then
34 CONFIG_FILE="/etc/tazlito/tazlito.conf"
35 fi
36 # Specific distro config file can be put in a distro tree.
37 if [ -f "$TOP_DIR/tazlito.conf" ] ; then
38 CONFIG_FILE="$TOP_DIR/tazlito.conf"
39 fi
40 if [ ! "$CONFIG_FILE" = "" ] ; then
41 . $CONFIG_FILE
42 else
43 if [ "$COMMAND" = "gen-config" ] ; then
44 continue
45 else
46 echo "Unable to find any configuration file. Please read the docs"
47 echo "or run '`basename $0` gen-config' to get an empty config file."
48 exit 0
49 fi
50 fi
52 # While Tazpkg is not used the default mirror url file does not exist
53 # and user can't recharge the list of flavors.
54 if test $(id -u) = 0 ; then
55 if [ ! -f "$MIRROR" ]; then
56 echo "$DEFAULT_MIRROR" > $MIRROR
57 fi
58 fi
60 # Set the rootfs and rootcd path with $DISTRO
61 # configuration variable.
62 ROOTFS=$DISTRO/rootfs
63 ROOTCD=$DISTRO/rootcd
64 FLAVORS_REPOSITORY=/home/slitaz/flavors
66 #####################
67 # Tazlito functions #
68 #####################
70 # Print the usage.
71 usage ()
72 {
73 echo -e "\nSliTaz Live Tool - Version: $VERSION\n
74 \033[1mUsage: \033[0m `basename $0` [command] [list|iso|flavor|compression] [dir|iso]
75 \033[1mCommands: \033[0m\n
76 usage Print this short usage.
77 stats View Tazlito and distro configuration statistics.
78 gen-config Generate a new configuration file for a distro.
79 configure Configure the main config file or a specific tazlito.conf.
80 gen-iso Generate a new ISO from a distro tree.
81 gen-initiso Generate a new initramfs and ISO from the distro tree.
82 list-flavors List all available package lists on the mirror.
83 gen-flavor Generate a new live-CD description.
84 gen-liveflavor Generate a live-CD description from current system.
85 show-flavor Show live-CD description.
86 get-flavor Get a flavor's list of packages.
87 upgrade-flavor Update package list to the latest available versions.
88 extract-flavor Extract a (*.flavor) flavor into $FLAVORS_REPOSITORY.
89 pack-flavor Pack (and update) a flavor from $FLAVORS_REPOSITORY.
90 check-list Check a distro-packages.list for updates.
91 extract-distro Extract an ISO to a directory and rebuild LiveCD tree.
92 gen-distro Generate a Live distro and ISO from a list of packages.
93 clean-distro Remove all files generated by gen-distro.
94 check-distro Help to check if distro is ready to release.
95 writeiso Use running system to generate a bootable ISO (with /home).
96 merge Merge multiple rootfs into one iso.
97 repack Recompress rootfs into iso with maximum ratio.
98 frugal-install Frugal install in /boot/frugal from a distro or ISO
99 emu-iso Emulate an ISO image with Qemu.
100 burn-iso Burn ISO image to a cdrom using Wodim.\n"
101 }
103 # Status function.
104 status()
105 {
106 local CHECK=$?
107 echo -en "\\033[70G[ "
108 if [ $CHECK = 0 ]; then
109 echo -en "\\033[1;33mOK"
110 else
111 echo -en "\\033[1;31mFailed"
112 fi
113 echo -e "\\033[0;39m ]"
114 return $CHECK
115 }
117 yesorno()
118 {
119 echo -n "$1"
120 case "$DEFAULT_ANSWER" in
121 Y|y) answer="y";;
122 N|n) answer="n";;
123 *) read answer;;
124 esac
125 }
127 field()
128 {
129 grep "^$1" "$2" | sed 's/.*: \([0-9KMG\.]*\).*/\1/'
130 }
132 todomsg()
133 {
134 echo -e "\\033[70G[ \\033[1;31mTODO\\033[0;39m ]"
135 }
137 # Download a file from this mirror
138 download_from()
139 {
140 local i
141 local mirrors
142 mirrors="$1"
143 shift
144 for i in $mirrors; do
145 case "$i" in
146 http://*|ftp://*) wget -c $i$@ && break;;
147 *) cp $i/$1 . && break;;
148 esac
149 done
150 }
152 # Download a file trying all mirrors
153 download()
154 {
155 local i
156 for i in $(cat $MIRROR $LOCALSTATE/undigest/*/mirror 2> /dev/null); do
157 download_from "$i" "$@" && break
158 done
159 }
161 # Execute hooks provided by some packages
162 genisohooks()
163 {
164 local here=`pwd`
165 for i in $(ls $ROOTFS/etc/tazlito/*.$1 2> /dev/null); do
166 cd $ROOTFS
167 . $i $ROOTCD
168 done
169 cd $here
170 }
172 cleanup()
173 {
174 if [ -d $TMP_MNT ]; then
175 umount $TMP_MNT
176 rmdir $TMP_MNT
177 rm -f /boot
178 fi
179 }
181 # Echo the package name if the tazpkg is already installed
182 installed_package_name()
183 {
184 local tazpkg
185 local package
186 local VERSION
187 local EXTRAVERSION
188 tazpkg=$1
189 # Try to find package name and version to be able
190 # to repack it from installation
191 # A dash (-) can exist in name *and* in version
192 package=${tazpkg%-*}
193 i=$package
194 while true; do
195 VERSION=""
196 eval $(grep -s ^VERSION= $INSTALLED/$i/receipt)
197 EXTRAVERSION=""
198 eval $(grep -s ^EXTRAVERSION= $INSTALLED/$i/receipt)
199 if [ "$i-$VERSION$EXTRAVERSION" = "$tazpkg" ]; then
200 echo $i
201 break
202 fi
203 case "$i" in
204 *-*);;
205 *) break;;
206 esac
207 i=${i%-*}
208 done
209 }
211 # Check if user is root.
212 check_root()
213 {
214 if test $(id -u) != 0 ; then
215 echo -e "\nYou must be root to run `basename $0` with this option."
216 echo -e "Please type 'su' and root password to become super-user.\n"
217 exit 0
218 fi
219 }
221 # Check for the rootfs tree.
222 check_rootfs()
223 {
224 if [ ! -d "$ROOTFS/etc" ] ; then
225 echo -e "\nUnable to find a distro rootfs...\n"
226 exit 0
227 fi
228 }
230 # Check for the boot dir into the root CD tree.
231 verify_rootcd()
232 {
233 if [ ! -d "$ROOTCD/boot" ] ; then
234 echo -e "\nUnable to find the rootcd boot directory...\n"
235 exit 0
236 fi
237 }
239 create_iso()
240 {
241 genisoimage -R -o $1 -b boot/isolinux/isolinux.bin \
242 -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
243 -V "$VOLUM_NAME" -p "$PREPARED" -input-charset iso8859-1 \
244 -boot-info-table $2
245 if [ -x /usr/bin/isohybrid ]; then
246 echo -n "Creating hybrid ISO..."
247 /usr/bin/isohybrid $1 2> /dev/null
248 status
249 fi
250 }
252 # Generate a new ISO image using isolinux.
253 gen_livecd_isolinux()
254 {
255 # Some packages may want to alter iso
256 genisohooks iso
257 if [ ! -f "$ROOTCD/boot/isolinux/isolinux.bin" ]; then
258 echo -e "\nUnable to find isolinux binary.\n"
259 cleanup
260 exit 0
261 fi
262 # Set date for boot msg.
263 if grep -q 'XXXXXXXX' $ROOTCD/boot/isolinux/isolinux.msg; then
264 DATE=`date +%Y%m%d`
265 echo -n "Setting build date to: $DATE..."
266 sed -i s/'XXXXXXXX'/"$DATE"/ $ROOTCD/boot/isolinux/isolinux.msg
267 status
268 fi
269 cd $ROOTCD
270 echo -n "Computing md5..."
271 find * -type f ! -name md5sum -exec md5sum {} \; > md5sum
272 status
273 cd $DISTRO
274 echo ""
275 echo -e "\033[1mGenerating ISO image\033[0m"
276 echo "================================================================================"
277 create_iso $ISO_NAME.iso $ROOTCD
278 echo -n "Creating the ISO md5sum..."
279 md5sum $ISO_NAME.iso > $ISO_NAME.md5
280 status
281 echo "================================================================================"
282 # Some packages may want to alter final iso
283 genisohooks final
284 }
286 lzma_history_bits()
287 {
288 #
289 # This genertae ISO who boot with Qemu but give
290 # rootfs errors in frugal or liveUSB mode.
291 #
292 #local n
293 #local sz
294 #n=20 # 1Mb
295 #sz=$(du -sk $1 | cut -f1)
296 #while [ $sz -gt 1024 -a $n -lt 28 ]; do
297 #n=$(( $n + 1 ))
298 #sz=$(( $sz / 2 ))
299 #done
300 #echo $n
301 echo 24
302 }
304 lzma_switches()
305 {
306 echo "-d$(lzma_history_bits $1) -mt$(grep ^processor < /proc/cpuinfo | wc -l)"
307 }
309 # Pack rootfs
310 pack_rootfs()
311 {
312 ( cd $1 ; find . -print | cpio -o -H newc ) | \
313 if [ "$COMPRESSION" = "none" ]; then
314 echo -n "Generating uncompressed initramfs... "
315 cat > $2
316 elif [ -x /usr/bin/lzma -a "$COMPRESSION" != "gzip" ]; then
317 echo -n "Generating lzma'ed initramfs... "
318 lzma e -si -so $(lzma_switches $1) > $2
319 else
320 echo -n "Generating gziped initramfs... "
321 gzip -9 > $2
322 fi
323 }
325 # Generate a new initramfs from the root filesystem.
326 gen_initramfs()
327 {
328 # Just in case CTRL+c
329 rm -f $DISTRO/gen
330 # Some packages may want to alter rootfs
331 genisohooks rootfs
332 cd $1
333 echo ""
335 # Link duplicate files
336 find . -type f -size +0c -exec stat -c '%s-%a-%u-%g %i %h %n' {} \; | \
337 sort | ( save=0; old_attr=""; old_inode=""; old_link=""; old_file=""
338 while read attr inode link file; do
339 if [ "$attr" = "$old_attr" -a "$inode" != "$old_inode" ]; then
340 if cmp "$file" "$old_file" >/dev/null; then
341 rm -f "$file"
342 ln "$old_file" "$file"
343 inode="$old_inode"
344 [ "$link" = "1" ] && save="$(expr $save + ${attr%%-*})"
345 fi
346 fi
347 old_attr="$attr" ; old_inode="$inode" ; old_file="$file"
348 done
349 echo "$save bytes saved in duplicate files."
350 )
352 # Use lzma if installed
353 pack_rootfs . $DISTRO/$(basename $1).gz
354 cd $DISTRO
355 mv $(basename $1).gz $ROOTCD/boot
356 }
358 # Compression functions for writeiso.
359 write_lzma_initramfs()
360 {
361 echo -n "Creating rootfs.gz with lzma compression... "
362 cat /tmp/list | cpio -o -H newc | lzma e -si -so > /rootfs.gz
363 echo 1 > /tmp/rootfs
364 }
365 write_gzip_initramfs()
366 {
367 echo "Creating rootfs.gz with gzip compression... "
368 cat /tmp/list | cpio -o -H newc | gzip -9 > /rootfs.gz
369 echo 1 > /tmp/rootfs
370 }
371 write_initramfs()
372 {
373 echo "Creating rootfs.gz without compression... "
374 cat /tmp/list | cpio -o -H newc > /rootfs.gz
375 echo 1 > /tmp/rootfs
376 }
378 distro_sizes()
379 {
380 echo "Build date : `date +%Y%m%d\ \at\ \%H:%M:%S`"
381 echo "Packages : `ls -1 $ROOTFS*$INSTALLED/*/receipt | wc -l`"
382 echo "Rootfs size : `du -csh $ROOTFS*/ | awk '{ s=$1 } END { print s }'`"
383 echo "Initramfs size : `du -csh $ROOTCD/boot/rootfs*.gz | awk '{ s=$1 } END { print s }'`"
384 echo "ISO image size : `du -sh $ISO_NAME.iso | awk '{ print $1 }'`"
385 echo "================================================================================"
386 echo "Image is ready: $ISO_NAME.iso"
387 echo ""
388 }
390 # Print ISO and rootfs size.
391 distro_stats()
392 {
393 echo ""
394 echo -e "\033[1mDistro statistics\033[0m ($DISTRO)"
395 echo "================================================================================"
396 distro_sizes
397 }
399 # Create an empty configuration file.
400 empty_config_file()
401 {
402 cat >> tazlito.conf << "EOF"
403 # tazlito.conf: Tazlito (SliTaz Live Tool)
404 # configuration file.
405 #
407 # Name of the ISO image to generate.
408 ISO_NAME=""
410 # ISO image volume name.
411 VOLUM_NAME="SliTaz"
413 # Name of the preparer.
414 PREPARED="$USER"
416 # Path to the packages repository and the packages.list.
417 PACKAGES_REPOSITORY=""
419 # Path to the distro tree to gen-distro from a
420 # list of packages.
421 DISTRO=""
423 # Path to the directory containing additional files
424 # to copy into the rootfs and rootcd of the LiveCD.
425 ADDFILES="$DISTRO/addfiles"
427 # Default answer for binary question (Y or N)
428 DEFAULT_ANSWER="ASK"
430 # Compression utility (lzma, gzip or none)
431 COMPRESSION="lzma"
432 EOF
433 }
435 # extract rootfs.gz somewhere
436 extract_rootfs()
437 {
438 (zcat $1 || unlzma -c $1 || cat $1) 2>/dev/null | \
439 (cd $2; cpio -idm > /dev/null)
440 }
442 # Remove duplicate files
443 mergefs()
444 {
445 echo -n "Merge $(basename $1) ($(du -hs $1 | awk '{ print $1}')) into "
446 echo -n "$(basename $2) ($(du -hs $2 | awk '{ print $1}'))"
447 # merge symlinks files and devices
448 ( cd $1; find ) | while read file; do
449 if [ -L $1/$file ]; then
450 [ -L $2/$file ] &&
451 [ "$(readlink $1/$file)" == "$(readlink $2/$file)" ] &&
452 rm -f $2/$file
453 elif [ -f $1/$file ]; then
454 [ -f $2/$file ] &&
455 cmp $1/$file $2/$file > /dev/null 2>&1 && rm -f $2/$file
456 [ -f $2/$file ] &&
457 [ "$(basename $file)" == "volatile.cpio.gz" ] &&
458 [ "$(dirname $(dirname $file))" == \
459 "./var/lib/tazpkg/installed" ] && rm -f $2/$file
460 elif [ -b $1/$file ]; then
461 [ -b $2/$file ] && rm -f $2/$file
462 elif [ -c $1/$file ]; then
463 [ -c $2/$file ] && rm -f $2/$file
464 fi
465 done
467 # cleanup directories
468 ( cd $1; find ) | while read file; do
469 if [ -d $1/$file ]; then
470 [ -d $2/$file ] && rmdir $2/$file 2> /dev/null
471 fi
472 done
473 true
474 status
475 }
477 cleanup_merge()
478 {
479 rm -rf $TMP_DIR
480 exit 1
481 }
483 human2cent()
484 {
485 case "$1" in
486 *k) echo $1 | sed 's/\(.*\).\(.\)k/\1\2/';;
487 *M) echo $(( $(echo $1 | sed 's/\(.*\).\(.\)M/\1\2/') * 1024));;
488 *G) echo $(( $(echo $1 | sed 's/\(.*\).\(.\)G/\1\2/') * 1024 * 1024));;
489 esac
490 }
492 cent2human()
493 {
494 if [ $1 -lt 10000 ]; then
495 echo "$(($1 / 10)).$(($1 % 10))k"
496 elif [ $1 -lt 10000000 ]; then
497 echo "$(($1 / 10240)).$(( ($1/1024) % 10))M"
498 else
499 echo "$(($1 / 10485760)).$(( ($1/1048576) % 10))G"
500 fi
501 }
503 get_size()
504 {
505 cat /var/lib/tazpkg/packages.list $TMP_DIR/packages.list 2>/dev/null | awk "{ \
506 if (/^$(echo $1 | sed 's/[$+.\]/\\&/g')$/) get=1; \
507 if (/installed/ && get == 1) { print ; get++ } \
508 }
509 END { if (get < 2) print \" 0.0k (0.0k installed)\" }" | \
510 sed 's/ *\(.*\) .\(.*\) installed./\1 \2/' | while read packed unpacked; do
511 echo "$(human2cent $packed) $(human2cent $unpacked)"
512 done
513 }
515 # Display package list with version, set packed_size and unpacked_size
516 get_pkglist()
517 {
518 packed_size=0; unpacked_size=0
519 grep -v ^# $FLAVORS_REPOSITORY/$1/packages.list > $TMP_DIR/flavor.pkg
520 while read pkg; do
521 set -- $(get_size $pkg)
522 packed_size=$(( $packed_size + $1 ))
523 unpacked_size=$(( $unpacked_size + $2 ))
524 for i in $(grep -hs ^$pkg /var/lib/tazpkg/packages.list \
525 $TMP_DIR/packages.list); do
526 echo $i
527 break
528 done
529 done < $TMP_DIR/flavor.pkg
530 rm -f $TMP_DIR/flavor.pkg
531 }
533 # Update isolinux config files for multiple rootfs
534 update_bootconfig()
535 {
536 echo -n "Updating boot config files..."
537 grep -l 'include common' $1/*.cfg | \
538 while read file ; do
539 awk -v n=$(echo $2 | awk '{ print NF/2 }') '{
540 if (/label/) label=$0;
541 else if (/kernel/) kernel=$0;
542 else if (/append/) {
543 i=index($0,"rootfs.gz");
544 append=substr($0,i+9);
545 }
546 else if (/include/) {
547 for (i = 1; i <= n; i++) {
548 print label i
549 print kernel;
550 initrd="initrd=/boot/rootfs" n ".gz"
551 for (j = n - 1; j >= i; j--) {
552 initrd=initrd ",/boot/rootfs" j ".gz";
553 }
554 printf "\tappend %s%s\n",initrd,append;
555 print "";
556 }
557 print;
558 }
559 else print;
560 }' < $file > $file.$$
561 mv -f $file.$$ $file
562 done
563 cat >> $1/common.cfg <<EOT
565 label slitaz
566 kernel /boot/isolinux/ifmem.c32
567 append$(echo $2 | awk '{
568 for (i=1; i<=NF; i++)
569 if (i % 2 == 0) printf " slitaz%d",i/2
570 else printf " %s",$i
571 }') noram
573 label noram
574 config noram.cfg
576 EOT
577 cat > $1/noram.cfg <<EOT
578 display isolinux.msg
579 say Not enough RAM to boot slitaz.
580 default reboot
581 label reboot
582 com32 reboot.c32
584 implicit 0
585 prompt 1
586 timeout 80
587 F1 help.txt
588 F2 options.txt
589 F3 isolinux.msg
590 F4 display.txt
591 F5 enhelp.txt
592 F6 enopts.txt
593 EOT
594 status
595 }
597 ####################
598 # Tazlito commands #
599 ####################
601 case "$COMMAND" in
602 stats)
603 # Tazlito general statistics from the config file.
604 #
605 echo ""
606 echo -e "\033[1mTazlito statistics\033[0m
607 ===============================================================================
608 Config file : $CONFIG_FILE
609 ISO name : $ISO_NAME.iso
610 Volume name : $VOLUM_NAME
611 Prepared : $PREPARED
612 Packages repository : $PACKAGES_REPOSITORY
613 Distro directory : $DISTRO"
614 if [ ! "$ADDFILES" = "" ] ; then
615 echo -e "Additional files : $ADDFILES"
616 fi
617 echo "================================================================================"
618 echo ""
619 ;;
620 list-addfiles)
621 # Simple list of additonal files in the rootfs
622 echo ""
623 cd $ADDFILES
624 find rootfs -type f
625 echo "" ;;
626 gen-config)
627 # Generate a new config file in the current dir or the specified
628 # directory by $2.
629 #
630 if [ -n "$2" ] ; then
631 mkdir -p $2 && cd $2
632 fi
633 echo -n "Generating empty tazlito.conf..."
634 empty_config_file
635 status
636 echo ""
637 if [ -f "tazlito.conf" ] ; then
638 echo "Configuration file is ready to edit."
639 echo "File location : `pwd`/tazlito.conf"
640 echo ""
641 fi
642 ;;
643 configure)
644 # Configure a tazlito.conf config file. Start by getting
645 # a empty config file and sed it.
646 #
647 if [ -f "tazlito.conf" ] ; then
648 rm tazlito.conf
649 else
650 if test $(id -u) = 0 ; then
651 cd /etc
652 else
653 echo "You must be root to configure the main config file or in"
654 echo "the same directory of the file you want to configure."
655 exit 0
656 fi
657 fi
658 empty_config_file
659 echo""
660 echo -e "\033[1mConfiguring :\033[0m `pwd`/tazlito.conf"
661 echo "================================================================================"
662 # ISO name.
663 echo -n "ISO name : " ; read answer
664 sed -i s#'ISO_NAME=\"\"'#"ISO_NAME=\"$answer\""# tazlito.conf
665 # Volume name.
666 echo -n "Volume name : " ; read answer
667 sed -i s/'VOLUM_NAME=\"SliTaz\"'/"VOLUM_NAME=\"$answer\""/ tazlito.conf
668 # Packages repository.
669 echo -n "Packages repository : " ; read answer
670 sed -i s#'PACKAGES_REPOSITORY=\"\"'#"PACKAGES_REPOSITORY=\"$answer\""# tazlito.conf
671 # Distro path.
672 echo -n "Distro path : " ; read answer
673 sed -i s#'DISTRO=\"\"'#"DISTRO=\"$answer\""# tazlito.conf
674 echo "================================================================================"
675 echo "Config file is ready to use."
676 echo "You can now extract an ISO or generate a distro."
677 echo ""
678 ;;
679 gen-iso)
680 # Simply generate a new iso.
681 #
682 check_root
683 verify_rootcd
684 gen_livecd_isolinux
685 distro_stats
686 ;;
687 gen-initiso)
688 # Simply generate a new initramfs with a new iso.
689 #
690 check_root
691 verify_rootcd
692 gen_initramfs $ROOTFS
693 gen_livecd_isolinux
694 distro_stats
695 ;;
696 extract-distro)
697 # Extract an ISO image to a directory and rebuild the LiveCD tree.
698 #
699 check_root
700 ISO_IMAGE=$2
701 if [ -z "$ISO_IMAGE" ] ; then
702 echo -e "\nPlease specify the path to the ISO image."
703 echo -e "Example : `basename $0` image.iso /path/target\n"
704 exit 0
705 fi
706 # Set the distro path by checking for $3 on cmdline.
707 if [ -n "$3" ] ; then
708 TARGET=$3
709 else
710 TARGET=$DISTRO
711 fi
712 # Exit if existing distro is found.
713 if [ -d "$TARGET/rootfs" ] ; then
714 echo -e "\nA rootfs exists in : $TARGET"
715 echo -e "Please clean the distro tree or change directory path.\n"
716 exit 0
717 fi
718 echo ""
719 echo -e "\033[1mTazlito extracting :\033[0m `basename $ISO_IMAGE`"
720 echo "================================================================================"
721 # Start to mount the ISO.
722 echo ""
723 echo "Mounting ISO image..."
724 mkdir -p $TMP_DIR
725 # Get ISO file size.
726 isosize=`du -sh $ISO_IMAGE | cut -f1`
727 mount -o loop $ISO_IMAGE $TMP_DIR
728 sleep 2
729 # Prepare target dir, copy the kernel and the rootfs.
730 mkdir -p $TARGET/rootfs
731 mkdir -p $TARGET/rootcd/boot
732 echo -n "Copying the Linux kernel..."
733 if cp $TMP_DIR/boot/vmlinuz* $TARGET/rootcd/boot 2> /dev/null; then
734 ln $TARGET/rootcd/boot/vmlinuz* $TARGET/rootcd/boot/bzImage
735 else
736 cp $TMP_DIR/boot/bzImage $TARGET/rootcd/boot
737 fi
738 status
739 echo -n "Copying isolinux files..."
740 cp -a $TMP_DIR/boot/isolinux $TARGET/rootcd/boot
741 for i in $(ls $TMP_DIR); do
742 [ "$i" = "boot" ] && continue
743 cp -a $TMP_DIR/$i $TARGET/rootcd
744 done
745 status
746 if [ -d $TMP_DIR/boot/syslinux ]; then
747 echo -n "Copying syslinux files..."
748 cp -a $TMP_DIR/boot/syslinux $TARGET/rootcd/boot
749 status
750 fi
751 if [ -d $TMP_DIR/boot/extlinux ]; then
752 echo -n "Copying extlinux files..."
753 cp -a $TMP_DIR/boot/extlinux $TARGET/rootcd/boot
754 status
755 fi
756 if [ -d $TMP_DIR/boot/grub ]; then
757 echo -n "Copying GRUB files..."
758 cp -a $TMP_DIR/boot/grub $TARGET/rootcd/boot
759 status
760 fi
762 echo -n "Copying the rootfs..."
763 cp $TMP_DIR/boot/rootfs.?z $TARGET/rootcd/boot
764 status
765 # Extract initramfs.
766 cd $TARGET/rootfs
767 echo -n "Extracting the rootfs... "
768 extract_rootfs ../rootcd/boot/rootfs.gz $TARGET/rootfs
769 # unpack /usr
770 for i in etc/tazlito/*.extract; do
771 [ -f "$i" ] && . $i ../rootcd
772 done
773 # Umount and remove temp directory and cd to $TARGET to get stats.
774 umount $TMP_DIR && rm -rf $TMP_DIR
775 cd ..
776 echo ""
777 echo "================================================================================"
778 echo "Extracted : `basename $ISO_IMAGE` ($isosize)"
779 echo "Distro tree : `pwd`"
780 echo "Rootfs size : `du -sh rootfs`"
781 echo "Rootcd size : `du -sh rootcd`"
782 echo "================================================================================"
783 echo ""
784 ;;
785 list-flavors)
786 # Show available flavors.
787 if [ ! -s /etc/tazlito/flavors.list -o "$2" == "--recharge" ]; then
788 download flavors.list -O - > /etc/tazlito/flavors.list
789 fi
790 echo ""
791 echo -e "\033[1mList of flavors\033[0m"
792 echo "================================================================================"
793 cat /etc/tazlito/flavors.list
794 echo ""
795 ;;
796 show-flavor)
797 # Show flavor description.
798 FLAVOR=${2%.flavor}
799 if [ ! -f "$FLAVOR.flavor" ]; then
800 echo "File $FLAVOR.flavor not found."
801 exit 1
802 fi
803 mkdir $TMP_DIR
804 zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i 2> /dev/null)
805 if [ "$3" = "--brief" ]; then
806 if [ "$4" != "--noheader" ]; then
807 echo "Name ISO Rootfs Description"
808 echo "================================================================================"
809 fi
810 printf "%-16.16s %6.6s %6.6s %s\n" "$FLAVOR" \
811 "$(field ISO $TMP_DIR/$FLAVOR.desc)" \
812 "$(field 'Rootfs size' $TMP_DIR/$FLAVOR.desc)" \
813 "$(grep ^Description $TMP_DIR/$FLAVOR.desc | cut -d: -f2)"
814 else
815 echo "================================================================================"
816 cat $TMP_DIR/$FLAVOR.desc
817 fi
818 rm -Rf $TMP_DIR
819 ;;
820 gen-liveflavor)
821 # Generate a new flavor form the live system.
822 FLAVOR=${2%.flavor}
823 DESC=""
824 case "$FLAVOR" in
825 '') echo -n "Flavor name : "
826 read FLAVOR
827 [ -z "$FLAVOR" ] && exit 1;;
828 -?|-h*|--help) echo -e "
830 SliTaz Live Tool - Version: $VERSION
831 \033[1mUsage: \033[0m `basename $0` gen-liveflavor flavor-name [flavor-patch-file]
832 \033[1mflavor-patch-file format: \033[0m
833 code data
834 + package to add
835 - package to remove
836 ! non-free package to add
837 ? display message
838 @ flavor description
840 \033[1mExample: \033[0m
841 @ Developer tools for slitaz maintainers
842 + slitaz-toolchain
843 + mercurial
844 "
845 exit 1;;
846 esac
847 mv /etc/tazlito/distro-packages.list \
848 /etc/tazlito/distro-packages.list.$$ 2> /dev/null
849 rm -f distro-packages.list non-free.list 2> /dev/null
850 tazpkg recharge
851 [ -n "$3" ] && while read action pkg; do
852 case "$action" in
853 +) yes | tazpkg get-install $pkg;;
854 -) yes | tazpkg remove $pkg;;
855 !) echo $pkg >> non-free.list;;
856 @) DESC="$pkg";;
857 \?) echo -en "$pkg"; read action;;
858 esac
859 done < $3
860 yes '' | tazlito gen-distro
861 echo "$DESC" | tazlito gen-flavor "$FLAVOR"
862 mv /etc/tazlito/distro-packages.list.$$ \
863 /etc/tazlito/distro-packages.list 2> /dev/null
864 ;;
865 gen-flavor)
866 # Generate a new flavor from the last iso image generated.
867 FLAVOR=${2%.flavor}
868 echo ""
869 echo -e "\033[1mFlavor generation\033[0m"
870 echo "================================================================================"
871 if [ -z "$FLAVOR" ]; then
872 echo -n "Flavor name : "
873 read FLAVOR
874 [ -z "$FLAVOR" ] && exit 1
875 fi
876 check_rootfs
877 FILES="$FLAVOR.pkglist"
878 echo -n "Creating file $FLAVOR.flavor..."
879 for i in rootcd rootfs; do
880 if [ -d "$ADDFILES/$i" ] ; then
881 FILES="$FILES\n$FLAVOR.$i"
882 ( cd "$ADDFILES/$i"; find . | \
883 cpio -o -H newc 2> /dev/null | gzip -9 ) > $FLAVOR.$i
884 fi
885 done
886 status
887 answer=`grep -s ^Description $FLAVOR.desc`
888 answer=${answer#Description : }
889 if [ -z "$answer" ]; then
890 echo -n "Description : "
891 read answer
892 fi
893 echo -n "Compressing flavor $FLAVOR..."
894 echo "Flavor : $FLAVOR" > $FLAVOR.desc
895 echo "Description : $answer" >> $FLAVOR.desc
896 ( cd $DISTRO; distro_sizes) >> $FLAVOR.desc
897 \rm -f $FLAVOR.pkglist $FLAVOR.nonfree 2> /dev/null
898 for i in $(ls $ROOTFS$INSTALLED); do
899 eval $(grep ^VERSION= $ROOTFS$INSTALLED/$i/receipt)
900 EXTRAVERSION=""
901 eval $(grep ^EXTRAVERSION= $ROOTFS$INSTALLED/$i/receipt)
902 eval $(grep ^CATEGORY= $ROOTFS$INSTALLED/$i/receipt)
903 if [ "$CATEGORY" = "non-free" -a "${i%%-*}" != "get" ]
904 then
905 echo "$i" >> $FLAVOR.nonfree
906 else
907 echo "$i-$VERSION$EXTRAVERSION" >> $FLAVOR.pkglist
908 fi
909 done
910 [ -s $FLAVOR.nonfree ] && $FILES="$FILES\n$FLAVOR.nonfree"
911 for i in $LOCALSTATE/undigest/*/mirror ; do
912 [ -s $i ] && cat $i >> $FLAVOR.mirrors
913 done
914 [ -s $FLAVOR.mirrors ] && $FILES="$FILES\n$FLAVOR.mirrors"
915 echo -e "$FLAVOR.desc\n$FILES" | cpio -o -H newc 2>/dev/null | \
916 gzip -9 > $FLAVOR.flavor
917 rm `echo -e $FILES`
918 status
919 echo "================================================================================"
920 echo "Flavor size : `du -sh $FLAVOR.flavor`"
921 echo ""
922 ;;
923 upgrade-flavor)
924 # Update package list to the lastest versions available.
925 FLAVOR=${2%.flavor}
926 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
927 mkdir $TMP_DIR
928 zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i >/dev/null )
929 echo -n "Updating $FLAVOR package list..."
930 [ -s /var/lib/tazpkg/packages.list ] || tazpkg recharge
931 packed_size=0; unpacked_size=0
932 while read org; do
933 i=0
934 pkg=$org
935 while ! grep -q ^$pkg$ /var/lib/tazpkg/packages.txt; do
936 pkg=${pkg%-*}
937 i=$(($i + 1))
938 [ $i -gt 5 ] && break;
939 done
940 set -- $(get_size $pkg)
941 packed_size=$(( $packed_size + $1 ))
942 unpacked_size=$(( $unpacked_size + $2 ))
943 for i in $(grep ^$pkg /var/lib/tazpkg/packages.list); do
944 echo $i
945 break
946 done
947 done < $TMP_DIR/$FLAVOR.pkglist \
948 > $TMP_DIR/$FLAVOR.pkglist.$$
949 mv -f $TMP_DIR/$FLAVOR.pkglist.$$ $TMP_DIR/$FLAVOR.pkglist
950 if [ -s $TMP_DIR/$FLAVOR.rootfs ]; then
951 packed_size=$(($packed_size \
952 + $(cat $TMP_DIR/$FLAVOR.rootfs | wc -c ) / 100 ))
953 unpacked_size=$(($unpacked_size \
954 + $(zcat $TMP_DIR/$FLAVOR.rootfs | wc -c ) / 100 ))
955 fi
956 # Estimate lzma
957 packed_size=$(($packed_size * 2 / 3))
958 iso_size=$(( $packed_size + 26000 ))
959 if [ -s $TMP_DIR/$FLAVOR.rootcd ]; then
960 iso_size=$(($iso_size \
961 + $(zcat $TMP_DIR/$FLAVOR.rootcd | wc -c ) / 100 ))
962 fi
963 sed -i -e '/Image is ready/d' \
964 -e "s/Rootfs size\( *:\) \(.*\)/Rootfs size\1 $(cent2human $unpacked_size) (estimated)/" \
965 -e "s/Initramfs size\( *:\) \(.*\)/Initramfs size\1 $(cent2human $packed_size) (estimated)/" \
966 -e "s/ISO image size\( *:\) \(.*\)/ISO image size\1 $(cent2human $iso_size) (estimated)/" \
967 -e "s/date\( *:\) \(.*\)/date\1 $(date +%Y%m%d\ \at\ \%H:%M:%S)/" \
968 $TMP_DIR/$FLAVOR.desc
969 ( cd $TMP_DIR ; ls | cpio -o -H newc ) | gzip -9 > \
970 $FLAVOR.flavor
971 status
972 rm -Rf $TMP_DIR
973 fi
974 ;;
975 extract-flavor)
976 # Extract a flavor into $FLAVORS_REPOSITORY.
977 FLAVOR=${2%.flavor}
978 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
979 mkdir $TMP_DIR
980 zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i >/dev/null )
981 echo -n "Extracting $FLAVOR..."
982 rm -rf $FLAVORS_REPOSITORY/$FLAVOR 2> /dev/null
983 mkdir -p $FLAVORS_REPOSITORY/$FLAVOR
984 echo "FLAVOR=\"$FLAVOR\"" > $FLAVORS_REPOSITORY/$FLAVOR/receipt
985 grep ^Description $TMP_DIR/$FLAVOR.desc | \
986 sed 's/.*: \(.*\)$/SHORT_DESC="\1"/' >> \
987 $FLAVORS_REPOSITORY/$FLAVOR/receipt
988 grep -q '^Rootfs list' $TMP_DIR/$FLAVOR.desc && \
989 grep '^Rootfs list' $TMP_DIR/$FLAVOR.desc | \
990 sed 's/.*: \(.*\)$/ROOTFS_SELECTION="\1"/' >> \
991 $FLAVORS_REPOSITORY/$FLAVOR/receipt
992 grep '^Rootfs size' $TMP_DIR/$FLAVOR.desc | \
993 sed 's/.*: \(.*\)$/ROOTFS_SIZE="\1"/' >> \
994 $FLAVORS_REPOSITORY/$FLAVOR/receipt
995 grep ^Initramfs $TMP_DIR/$FLAVOR.desc | \
996 sed 's/.*: \(.*\)$/INITRAMFS_SIZE="\1"/' >> \
997 $FLAVORS_REPOSITORY/$FLAVOR/receipt
998 grep ^ISO $TMP_DIR/$FLAVOR.desc | \
999 sed 's/.*: \(.*\)$/ISO_SIZE="\1"/' >> \
1000 $FLAVORS_REPOSITORY/$FLAVOR/receipt
1001 for i in rootcd rootfs; do
1002 [ -f $TMP_DIR/$FLAVOR.$i ] || continue
1003 mkdir $FLAVORS_REPOSITORY/$FLAVOR/$i
1004 zcat $TMP_DIR/$FLAVOR.$i | \
1005 (cd $FLAVORS_REPOSITORY/$FLAVOR/$i; \
1006 cpio -idm > /dev/null)
1007 done
1008 [ -s $TMP_DIR/$FLAVOR.mirrors ] &&
1009 cp $TMP_DIR/$FLAVOR.mirrors \
1010 $FLAVORS_REPOSITORY/$FLAVOR/mirrors
1011 [ -s /var/lib/tazpkg/packages.list ] || tazpkg recharge
1012 while read org; do
1013 i=0
1014 pkg=$org
1015 while ! grep -q ^$pkg$ /var/lib/tazpkg/packages.txt; do
1016 pkg=${pkg%-*}
1017 i=$(($i + 1))
1018 [ $i -gt 5 ] && break;
1019 done
1020 echo $pkg
1021 done < $TMP_DIR/$FLAVOR.pkglist \
1022 > $FLAVORS_REPOSITORY/$FLAVOR/packages.list
1023 status
1024 rm -Rf $TMP_DIR
1025 fi
1026 ;;
1027 pack-flavor)
1028 # Create a flavor from $FLAVORS_REPOSITORY.
1029 FLAVOR=${2%.flavor}
1030 if [ -s $FLAVORS_REPOSITORY/$FLAVOR/receipt ]; then
1031 mkdir $TMP_DIR
1032 echo -n "Creating flavor $FLAVOR..."
1033 [ -s /var/lib/tazpkg/packages.list ] || tazpkg recharge
1034 if [ -s $FLAVORS_REPOSITORY/$FLAVOR/mirrors ]; then
1035 cp $FLAVORS_REPOSITORY/$FLAVOR/mirrors \
1036 $TMP_DIR/$FLAVOR.mirrors
1037 for i in $(cat $TMP_DIR/$FLAVOR.mirrors); do
1038 wget -O - $i/packages.list >> $TMP_DIR/packages.list
1039 done
1040 fi
1041 [ -s $FLAVORS_REPOSITORY/$FLAVOR/packages.list ] &&
1042 get_pkglist $FLAVOR > $TMP_DIR/$FLAVOR.pkglist
1043 if grep -q ^ROOTFS_SELECTION \
1044 $FLAVORS_REPOSITORY/$FLAVOR/receipt; then
1045 . $FLAVORS_REPOSITORY/$FLAVOR/receipt
1046 set -- $ROOTFS_SELECTION
1047 [ -n "$FRUGAL_RAM" ] || FRUGAL_RAM=$1
1048 [ -f $FLAVORS_REPOSITORY/$2/packages.list ] ||
1049 tazlito extract-flavor $2
1050 get_pkglist $2 > $TMP_DIR/$FLAVOR.pkglist
1051 fi
1052 for i in rootcd rootfs; do
1053 [ -d $FLAVORS_REPOSITORY/$FLAVOR/$i ] || \
1054 continue
1055 ( cd $FLAVORS_REPOSITORY/$FLAVOR/$i ; find . | \
1056 cpio -o -H newc 2> /dev/null ) | \
1057 gzip -9 >$TMP_DIR/$FLAVOR.$i
1058 done
1059 if [ -s $TMP_DIR/$FLAVOR.rootfs ]; then
1060 packed_size=$(($packed_size \
1061 + $(cat $TMP_DIR/$FLAVOR.rootfs | wc -c ) / 100 ))
1062 unpacked_size=$(($unpacked_size \
1063 + $(zcat $TMP_DIR/$FLAVOR.rootfs | wc -c ) / 100 ))
1064 fi
1065 # Estimate lzma
1066 packed_size=$(($packed_size * 2 / 3))
1067 iso_size=$(( $packed_size + 26000 ))
1068 if [ -s $TMP_DIR/$FLAVOR.rootcd ]; then
1069 iso_size=$(($iso_size \
1070 + $(zcat $TMP_DIR/$FLAVOR.rootcd | wc -c ) / 100 ))
1071 fi
1072 VERSION=""
1073 MAINTAINER=""
1074 ROOTFS_SELECTION=""
1075 ROOTFS_SIZE="$(cent2human $unpacked_size) (estimated)"
1076 INITRAMFS_SIZE="$(cent2human $packed_size) (estimated)"
1077 ISO_SIZE="$(cent2human $iso_size) (estimated)"
1078 . $FLAVORS_REPOSITORY/$FLAVOR/receipt
1079 cat > $TMP_DIR/$FLAVOR.desc <<EOT
1080 Flavor : $FLAVOR
1081 Description : $SHORT_DESC
1082 EOT
1083 [ -n "$VERSION" ] && cat >> $TMP_DIR/$FLAVOR.desc <<EOT
1084 Version : $VERSION
1085 EOT
1086 [ -n "$MAINTAINER" ] && cat >> $TMP_DIR/$FLAVOR.desc <<EOT
1087 Maintainer : $MAINTAINER
1088 EOT
1089 [ -n "$FRUGAL_RAM" ] && cat >> $TMP_DIR/$FLAVOR.desc <<EOT
1090 LiveCD RAM size : $FRUGAL_RAM
1091 EOT
1092 [ -n "$ROOTFS_SELECTION" ] && cat >> $TMP_DIR/$FLAVOR.desc <<EOT
1093 Rootfs list : $ROOTFS_SELECTION
1094 EOT
1095 cat >> $TMP_DIR/$FLAVOR.desc <<EOT
1096 Build date : $(date +%Y%m%d\ \at\ \%H:%M:%S)
1097 Packages : $(grep -v ^# $TMP_DIR/$FLAVOR.pkglist | wc -l)
1098 Rootfs size : $ROOTFS_SIZE
1099 Initramfs size : $INITRAMFS_SIZE
1100 ISO image size : $ISO_SIZE
1101 ================================================================================
1103 EOT
1104 rm -f $TMP_DIR/packages.list
1105 ( cd $TMP_DIR ; ls | cpio -o -H newc 2> /dev/null) | \
1106 gzip -9 > $FLAVOR.flavor
1107 status
1108 rm -Rf $TMP_DIR
1109 else
1110 echo "No $FLAVOR flavor in $FLAVORS_REPOSITORY."
1111 fi
1112 ;;
1113 get-flavor)
1114 # Get a flavor's files and prepare for gen-distro.
1115 FLAVOR=${2%.flavor}
1116 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
1117 echo -n "Cleaning $DISTRO..."
1118 rm -R $DISTRO 2> /dev/null
1119 mkdir -p $DISTRO
1120 status
1121 mkdir $TMP_DIR
1122 zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i 2>/dev/null )
1123 echo -n "Creating distro-packages.list..."
1124 mv $TMP_DIR/$FLAVOR.nonfree non-free.list 2> /dev/null
1125 mv $TMP_DIR/$FLAVOR.pkglist distro-packages.list
1126 status
1127 for i in rootcd rootfs; do
1128 if [ -f $TMP_DIR/$FLAVOR.$i ]; then
1129 echo -n "Adding $i..."
1130 mkdir -p "$ADDFILES/$i"
1131 zcat $TMP_DIR/$FLAVOR.$i | \
1132 ( cd "$ADDFILES/$i"; cpio -id 2> /dev/null)
1133 status
1134 fi
1135 done
1136 if [ -s $TMP_DIR/$FLAVOR.mirrors ]; then
1137 n=""
1138 while read line; do
1139 mkdir -p $LOCALSTATE/undigest/$FLAVOR$n
1140 echo "$line" > $LOCALSTATE/undigest/$FLAVOR$n/mirror
1141 n=$(( $n + 1 ))
1142 done < $TMP_DIR/$FLAVOR.mirrors
1143 tazpkg recharge
1144 fi
1145 rm -f /etc/tazlito/rootfs.list
1146 grep -q '^Rootfs list' $TMP_DIR/$FLAVOR.desc &&
1147 grep '^Rootfs list' $TMP_DIR/$FLAVOR.desc | \
1148 sed 's/.*: \(.*\)$/\1/' > /etc/tazlito/rootfs.list
1149 echo -n "Updating tazlito.conf..."
1150 [ -f tazlito.conf ] || cp /etc/tazlito/tazlito.conf .
1151 cat tazlito.conf | grep -v "^#VOLUM_NAME" | \
1152 sed "s/^VOLUM_NA/VOLUM_NAME=\"SliTaz $FLAVOR\"\\n#VOLUM_NA/" \
1153 > tazlito.conf.$$ && mv tazlito.conf.$$ tazlito.conf
1154 sed -i "s/ISO_NAME=.*/ISO_NAME=\"slitaz-$FLAVOR\"/" tazlito.conf
1155 status
1156 rm -Rf $TMP_DIR
1157 fi
1158 ;;
1159 check-list)
1160 # Use current packages list in $PWD by default.
1161 DISTRO_PKGS_LIST=distro-packages.list
1162 [ -d "$2" ] && DISTRO_PKGS_LIST=$2/distro-packages.list
1163 [ -f "$2" ] && DISTRO_PKGS_LIST=$2
1164 [ ! -f $DISTRO_PKGS_LIST ] && echo "No packages list found." && exit 0
1165 echo ""
1166 echo -e "\033[1mLiveCD packages list check\033[0m"
1167 echo "================================================================================"
1168 for pkg in `cat $DISTRO_PKGS_LIST`
1169 do
1170 if ! grep -q "$pkg" /var/lib/tazpkg/packages.list; then
1171 echo "Update: $pkg"
1172 up=$(($up + 1))
1173 fi
1174 done
1175 [ -z $up ] && echo -e "List is up-to-date\n" && exit 0
1176 echo "================================================================================"
1177 echo -e "Updates: $up\n" ;;
1178 gen-distro)
1179 # Generate a live distro tree with a set of packages.
1181 check_root
1183 # Check if a package list was specified on cmdline.
1184 LIST_NAME="distro-packages.list"
1185 CDROM=""
1186 while [ -n "$2" ]; do
1187 case "$2" in
1188 --iso=*)
1189 CDROM="-o loop ${2#--iso=}"
1190 ;;
1191 --cdrom)
1192 CDROM="/dev/cdrom"
1193 ;;
1194 --force)
1195 DELETE_ROOTFS="true"
1196 ;;
1197 *) if [ ! -f "$2" ] ; then
1198 echo -e "\nUnable to find the specified packages list."
1199 echo -e "List name : $2\n"
1200 exit 1
1201 fi
1202 LIST_NAME=$2
1203 ;;
1204 esac
1205 shift
1206 done
1208 if [ -d $ROOTFS ] ; then
1209 # Delete $ROOTFS if --force is set on command line
1210 if [ ! -z $DELETE_ROOTFS ]; then
1211 rm -rf $ROOTFS
1212 unset $DELETE_ROOTFS
1213 else
1214 echo -e "\nA rootfs exists in : $DISTRO"
1215 echo -e "Please clean the distro tree or change directory path.\n"
1216 exit 0
1217 fi
1218 fi
1219 if [ ! -f "$LIST_NAME" -a -d $INSTALLED ] ; then
1220 # Build list with installed packages
1221 for i in $(ls $INSTALLED); do
1222 eval $(grep ^VERSION= $INSTALLED/$i/receipt)
1223 EXTRAVERSION=""
1224 eval $(grep ^EXTRAVERSION= $INSTALLED/$i/receipt)
1225 echo "$i-$VERSION$EXTRAVERSION" >> $LIST_NAME
1226 done
1227 fi
1228 # Exit if no list name.
1229 if [ ! -f "$LIST_NAME" ]; then
1230 echo -e "\nNo packages list found or specified. Please read the docs.\n"
1231 exit 0
1232 fi
1233 # Start generation.
1234 echo ""
1235 echo -e "\033[1mTazlito generating a distro\033[0m"
1236 echo "================================================================================"
1237 # Misc checks
1238 [ -n "$PACKAGES_REPOSITORY" ] || PACKAGES_REPOSITORY="."
1239 [ -d $PACKAGES_REPOSITORY ] || mkdir -p $PACKAGES_REPOSITORY
1240 # Get the list of packages using cat for a file list.
1241 LIST=`cat $LIST_NAME`
1242 # Verify if all packages in list are present in $PACKAGES_REPOSITORY.
1243 REPACK=""
1244 DOWNLOAD=""
1245 for pkg in $LIST
1246 do
1247 [ "$pkg" = "" ] && continue
1248 pkg=${pkg%.tazpkg}
1249 [ -f $PACKAGES_REPOSITORY/$pkg.tazpkg ] && continue
1250 PACKAGE=$(installed_package_name $pkg)
1251 [ -n "$PACKAGE" -a "$REPACK" = "y" ] && continue
1252 [ -z "$PACKAGE" -a -n "$DOWNLOAD" ] && continue
1253 echo -e "\nUnable to find $pkg in the repository."
1254 echo -e "Path : $PACKAGES_REPOSITORY\n"
1255 if [ -n "$PACKAGE" -a -z "$REPACK" ]; then
1256 yesorno "Repack packages from rootfs (y/N) ? "
1257 REPACK="$answer"
1258 [ "$answer" = "y" ] || REPACK="n"
1259 [ "$DOWNLOAD" = "y" ] && break
1260 fi
1261 if [ -f $MIRROR -a -z "$DOWNLOAD" ]; then
1262 yesorno "Download packages from mirror (Y/n) ? "
1263 DOWNLOAD="$answer"
1264 if [ "$answer" = "n" ]; then
1265 [ -z "$PACKAGE" ] && exit 1
1266 else
1267 DOWNLOAD="y"
1268 [ -n "$REPACK" ] && break
1269 fi
1270 fi
1271 [ "$REPACK" = "n" -a "$DOWNLOAD" = "n" ] && exit 1
1272 done
1274 # Mount cdrom to be able to repack boot-loader packages
1275 if [ ! -e /boot -a -n "$CDROM" ]; then
1276 mkdir $TMP_MNT
1277 if mount -r $CDROM $TMP_MNT 2> /dev/null; then
1278 ln -s $TMP_MNT/boot /
1279 if [ ! -d "$ADDFILES/rootcd" ] ; then
1280 mkdir -p $ADDFILES/rootcd
1281 for i in $(ls $TMP_MNT); do
1282 [ "$i" = "boot" ] && continue
1283 cp -a $TMP_MNT/$i $ADDFILES/rootcd
1284 done
1285 fi
1286 else
1287 rmdir $TMP_MNT
1288 fi
1289 fi
1291 # Root fs stuff.
1292 echo "Preparing the rootfs directory..."
1293 mkdir -p $ROOTFS
1294 sleep 2
1295 for pkg in $LIST
1296 do
1297 [ "$pkg" = "" ] && continue
1298 # First copy and extract the package in tmp dir.
1299 pkg=${pkg%.tazpkg}
1300 PACKAGE=$(installed_package_name $pkg)
1301 mkdir -p $TMP_DIR
1302 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
1303 # Look for package in cache
1304 if [ -f $CACHE_DIR/$pkg.tazpkg ]; then
1305 ln -s $CACHE_DIR/$pkg.tazpkg $PACKAGES_REPOSITORY
1306 # Look for package in running distribution
1307 elif [ -n "$PACKAGE" -a "$REPACK" = "y" ]; then
1308 tazpkg repack $PACKAGE && \
1309 mv $pkg.tazpkg $PACKAGES_REPOSITORY
1310 fi
1311 fi
1312 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
1313 # Get package from mirror
1314 [ "$DOWNLOAD" = "y" ] && \
1315 download $pkg.tazpkg && \
1316 mv $pkg.tazpkg $PACKAGES_REPOSITORY
1317 fi
1318 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
1319 echo "Missing package $pkg."
1320 cleanup
1321 exit 1
1322 fi
1323 done
1324 if [ -f non-free.list ]; then
1325 echo "Preparing non-free packages..."
1326 cp non-free.list $ROOTFS/etc/tazlito/non-free.list
1327 for pkg in $(cat non-free.list); do
1328 if [ ! -d $INSTALLED/$pkg ]; then
1329 if [ ! -d $INSTALLED/get-$pkg ]; then
1330 tazpkg get-install get-$pkg
1331 fi
1332 get-$pkg
1333 fi
1334 tazpkg repack $pkg
1335 pkg=$(ls $pkg*.tazpkg)
1336 grep -q "^$pkg$" $LIST_NAME || \
1337 echo $pkg >>$LIST_NAME
1338 mv $pkg $PACKAGES_REPOSITORY
1339 done
1340 fi
1341 echo ""
1342 cp $LIST_NAME $DISTRO/distro-packages.list
1343 sed 's/\(.*\)/\1.tazpkg/' < $DISTRO/distro-packages.list > $DISTRO/list-packages
1344 cd $PACKAGES_REPOSITORY
1345 yes y | tazpkg install-list \
1346 $DISTRO/list-packages --root=$ROOTFS
1347 cd $DISTRO
1348 cp distro-packages.list $ROOTFS/etc/tazlito
1349 # Copy all files from $ADDFILES/rootfs to the rootfs.
1350 if [ -d "$ADDFILES/rootfs" ] ; then
1351 echo -n "Copying addfiles content to the rootfs... "
1352 cp -a $ADDFILES/rootfs/* $ROOTFS
1353 status
1354 fi
1355 echo "Root file system is generated..."
1356 # Root CD part.
1357 echo -n "Preparing the rootcd directory..."
1358 mkdir -p $ROOTCD
1359 status
1360 # Move the boot dir with the Linux kernel from rootfs.
1361 # The boot dir goes directly on the CD.
1362 if [ -d "$ROOTFS/boot" ] ; then
1363 echo -n "Moving the boot directory..."
1364 mv $ROOTFS/boot $ROOTCD
1365 cd $ROOTCD/boot
1366 ln vmlinuz-* bzImage
1367 status
1368 fi
1369 cd $DISTRO
1370 # Copy all files from $ADDFILES/rootcd to the rootcd.
1371 if [ -d "$ADDFILES/rootcd" ] ; then
1372 echo -n "Copying addfiles content to the rootcd... "
1373 cp -a $ADDFILES/rootcd/* $ROOTCD
1374 status
1375 fi
1376 # Execute the distro script (used to perform tasks in the rootfs
1377 # before compression. Give rootfs path in arg
1378 [ -z $DISTRO_SCRIPT ] && DISTRO_SCRIPT=$TOP_DIR/distro.sh
1379 if [ -x $DISTRO_SCRIPT ]; then
1380 echo "Executing distro script..."
1381 sh $DISTRO_SCRIPT $DISTRO
1382 fi
1383 if [ -s /etc/tazlito/rootfs.list ]; then
1384 [ -f $ROOTCD/boot/isolinux/ifmem.c32 ] ||
1385 cp /boot/isolinux/ifmem.c32 $ROOTCD/boot/isolinux
1386 n=0
1387 last=$ROOTFS
1388 while read flavor; do
1389 n=$(($n+1))
1390 echo "Building $flavor rootfs..."
1391 download $flavor.flavor
1392 zcat $flavor.flavor | cpio -i $flavor.pkglist
1393 sed 's/.*/&.tazpkg/' < $flavor.pkglist \
1394 > $DISTRO/list-packages0$n
1395 mkdir ${ROOTFS}0$n
1396 cd $PACKAGES_REPOSITORY
1397 yes y | tazpkg install-list \
1398 $DISTRO/list-packages0$n --root=${ROOTFS}0$n
1399 rm -rf ${ROOTFS}0$n/boot
1400 status
1401 cd $DISTRO
1402 mv $flavor.pkglist ${ROOTFS}0$n/etc/tazlito/distro-packages.list
1403 rm -f $flavor.flavor install-list
1404 mergefs ${ROOTFS}0$n $last
1405 last=${ROOTFS}0$n
1406 done <<EOT
1407 $(awk '{ for (i = 4; i <= NF; i+=2) print $i; }' < /etc/tazlito/rootfs.list)
1408 EOT
1409 i=$(($n+1))
1410 while [ $n -gt 0 ]; do
1411 mv ${ROOTFS}0$n ${ROOTFS}$i
1412 echo "Compression ${ROOTFS}0$n ($(du -hs ${ROOTFS}$i | awk '{ print $1 }')) ..."
1413 gen_initramfs ${ROOTFS}$i
1414 n=$(($n-1))
1415 i=$(($i-1))
1416 done
1417 mv $ROOTFS ${ROOTFS}$i
1418 gen_initramfs ${ROOTFS}$i
1419 update_bootconfig $ROOTCD/boot/isolinux \
1420 "$(cat /etc/tazlito/rootfs.list)"
1421 else
1422 # Initramfs and ISO image stuff.
1423 gen_initramfs $ROOTFS
1424 fi
1425 gen_livecd_isolinux
1426 distro_stats
1427 cleanup
1428 ;;
1429 clean-distro)
1430 # Remove old distro tree.
1432 check_root
1433 echo ""
1434 echo -e "\033[1mCleaning :\033[0m $DISTRO"
1435 echo "================================================================================"
1436 if [ -d "$DISTRO" ] ; then
1437 if [ -d "$ROOTFS" ] ; then
1438 echo -n "Removing the rootfs..."
1439 rm -f $DISTRO/$INITRAMFS
1440 rm -rf $ROOTFS
1441 status
1442 fi
1443 if [ -d "$ROOTCD" ] ; then
1444 echo -n "Removing the rootcd..."
1445 rm -rf $ROOTCD
1446 status
1447 fi
1448 echo -n "Removing eventual ISO image..."
1449 rm -f $DISTRO/$ISO_NAME.iso
1450 rm -f $DISTRO/$ISO_NAME.md5
1451 status
1452 fi
1453 echo "================================================================================"
1454 echo ""
1455 ;;
1456 check-distro)
1457 # Check for a few LiveCD needed files not installed by packages.
1459 check_rootfs
1460 echo ""
1461 echo -e "\033[1mChecking distro :\033[0m $ROOTFS"
1462 echo "================================================================================"
1463 # SliTaz release info.
1464 if [ ! -f "$ROOTFS/etc/slitaz-release" ]; then
1465 echo "Missing release info : /etc/slitaz-release"
1466 else
1467 release=`cat $ROOTFS/etc/slitaz-release`
1468 echo -n "Release : $release"
1469 status
1470 fi
1471 # Tazpkg mirror.
1472 if [ ! -f "$ROOTFS/var/lib/tazpkg/mirror" ]; then
1473 echo -n "Mirror URL : Missing /var/lib/tazpkg/mirror"
1474 todomsg
1475 else
1476 echo -n "Mirror configuration exists..."
1477 status
1478 fi
1479 # Isolinux msg
1480 if grep -q "cooking-XXXXXXXX" /$ROOTCD/boot/isolinux/isolinux.msg; then
1481 echo -n "Isolinux msg : Missing cooking date XXXXXXXX (ex `date +%Y%m%d`)"
1482 todomsg
1483 else
1484 echo -n "Isolinux message seems good..."
1485 status
1486 fi
1487 echo "================================================================================"
1488 echo ""
1489 ;;
1490 writeiso)
1491 # Writefs to ISO image including /home unlike gen-distro we dont use
1492 # packages to generate a rootfs, we build a compressed rootfs with all
1493 # the current filesystem similar to 'tazusb writefs'.
1495 DISTRO="/home/slitaz/distro"
1496 ROOTCD="$DISTRO/rootcd"
1497 if [ -z $2 ]; then
1498 COMPRESSION=none
1499 else
1500 COMPRESSION=$2
1501 fi
1502 if [ -z $3 ]; then
1503 ISO_NAME="slitaz"
1504 else
1505 ISO_NAME="$3"
1506 fi
1507 check_root
1508 # Start info
1509 echo ""
1510 echo -e "\033[1mWrite filesystem to ISO\033[0m
1511 ===============================================================================
1512 The command writeiso will write the current filesystem into a suitable cpio
1513 archive (rootfs.gz) and generate a bootable ISO image (slitaz.iso).
1515 Archive compression: $COMPRESSION"
1516 echo ""
1518 # Save some space
1519 rm /var/cache/tazpkg/* -r -f
1520 rm -rf /home/slitaz/distro
1522 # Optionally remove sound card selection and screen resolution.
1523 echo "Do you wish to remove the sound card and screen configs ? "
1524 echo -n "Press ENTER to keep or answer (No|yes|exit): "
1525 read anser
1526 case $anser in
1527 e|E|"exit"|Exit)
1528 exit 0 ;;
1529 y|Y|yes|Yes)
1530 echo -n "Removing current sound card and screen configurations..."
1531 rm -f /var/lib/sound-card-driver
1532 rm -f /etc/asound.state
1533 rm -f /etc/X11/screen.conf
1534 rm -f /etc/X11/xorg.conf ;;
1535 *)
1536 echo -n "Keeping current sound card and screen configurations..." ;;
1537 esac
1538 status
1540 # Create list of files including default user files since it is defined in /etc/passwd
1541 # and some new users might have been added.
1542 find /bin /etc /init /sbin /var /dev /lib /root /usr /home >/tmp/list
1544 for dir in /proc /sys /tmp /mnt /media /media/cdrom /media/flash /media/usbdisk
1545 do
1546 echo $dir >>/tmp/list
1547 done
1548 rm -f /tmp/rootfs
1550 # Generate initramfs with specified compression and display rootfs
1551 # size in realtime.
1552 if [ "$COMPRESSION" = "lzma" ]; then
1553 write_lzma_initramfs &
1554 elif [ "$COMPRESSION" = "gzip" ]; then
1555 write_gzip_initramfs &
1556 else
1557 write_initramfs &
1558 fi
1559 sleep 2
1560 echo -en "\nFilesystem size:"
1561 while [ ! -f /tmp/rootfs ]
1562 do
1563 sleep 1
1564 echo -en "\\033[18G`du -sh /rootfs.gz | awk '{print $1}'` "
1565 done
1566 echo -e "\n"
1568 # Move freshly generated rootfs to the cdrom.
1569 mkdir -p $ROOTCD/boot
1570 mv -f /rootfs.gz $ROOTCD/boot
1572 # Now we need the kernel and isolinux files.
1573 if mount /dev/cdrom /media/cdrom 2>/dev/null; then
1574 cp /media/cdrom/boot/bzImage $ROOTCD/boot
1575 cp -a /media/cdrom/boot/isolinux $ROOTCD/boot
1576 umount /media/cdrom
1577 else
1578 echo -e "
1579 Unable to mount the cdrom to copy the Kernel and needed files. When SliTaz
1580 is running in RAM the kernel and bootloader files are kept on the cdrom.
1581 Please insert a LiveCD or unmount the current cdrom to let Tazlito handle
1582 the media.\n"
1583 echo -en "----\nENTER to continue..."; read i
1584 exit 1
1585 fi
1587 # Generate the iso image.
1588 cd $DISTRO
1589 echo "Generating ISO image..."
1590 genisoimage -R -o $ISO_NAME.iso -b boot/isolinux/isolinux.bin \
1591 -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
1592 -V "SliTaz" -input-charset iso8859-1 -boot-info-table $ROOTCD
1593 if [ -x /usr/bin/isohybrid ]; then
1594 echo -n "Creating hybrid ISO..."
1595 /usr/bin/isohybrid $ISO_NAME.iso 2> /dev/null
1596 status
1597 fi
1598 echo -n "Creating the ISO md5sum..."
1599 md5sum $ISO_NAME.iso > $ISO_NAME.md5
1600 status
1602 echo "==============================================================================="
1603 echo "ISO image: `du -sh /home/slitaz/distro/$ISO_NAME.iso`"
1604 echo ""
1605 echo -n "Exit or burn ISO to cdrom (Exit|burn)? "; read anser
1606 case $anser in
1607 burn)
1608 eject
1609 echo -n "Please insert a blank cdrom and press ENTER..."
1610 read i && sleep 2
1611 tazlito burn-iso /home/slitaz/distro/$ISO_NAME.iso
1612 echo -en "----\nENTER to continue..."; read i ;;
1613 *)
1614 exit 0 ;;
1615 esac ;;
1616 burn-iso)
1617 # Guess cdrom device, ask user and burn the ISO.
1619 check_root
1620 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
1621 DRIVE_SPEED=`cat /proc/sys/dev/cdrom/info | grep "drive speed" | cut -f 3`
1622 # We can specify an alternative ISO from the cmdline.
1623 if [ -n "$2" ] ; then
1624 iso=$2
1625 else
1626 iso=$DISTRO/$ISO_NAME.iso
1627 fi
1628 if [ ! -f "$iso" ]; then
1629 echo -e "\nUnable to find ISO : $iso\n"
1630 exit 0
1631 fi
1632 echo ""
1633 echo -e "\033[1mTazlito burn ISO\033[0m "
1634 echo "================================================================================"
1635 echo "Cdrom device : /dev/$DRIVE_NAME"
1636 echo "Drive speed : $DRIVE_SPEED"
1637 echo "ISO image : $iso"
1638 echo "================================================================================"
1639 echo ""
1640 yesorno "Burn ISO image (y/N) ? "
1641 if [ "$answer" == "y" ]; then
1642 echo ""
1643 echo "Starting Wodim to burn the iso..." && sleep 2
1644 echo "================================================================================"
1645 wodim speed=$DRIVE_SPEED dev=/dev/$DRIVE_NAME $iso
1646 echo "================================================================================"
1647 echo "ISO image is burned to cdrom."
1648 else
1649 echo -e "\nExiting. No ISO burned."
1650 fi
1651 echo ""
1652 ;;
1653 merge)
1654 # Merge multiple rootfs into one iso.
1656 if [ -z "$2" ]; then
1657 cat << EOT
1658 Usage: tazlito merge size1 iso size2 rootfs2 [sizeN rootfsN]...
1660 Merge multiple rootfs into one iso. Rootfs are like russian dolls
1661 i.e: rootfsN is a subset of rootfsN-1
1662 rootfs1 is found in iso, sizeN is the RAM size need to launch rootfsN.
1663 The boot loader will select the rootfs according to the RAM size detected.
1665 Example:
1666 $ tazlito merge 160M slitaz-core.iso 96M rootfs-justx.gz 32M rootfs-base.gz
1668 Will start slitaz-core with 160M+ RAM, slitaz-justX with 96M-160M RAM,
1669 slitaz-base with 32M-96M RAM and display an error message if RAM < 32M.
1670 EOT
1671 exit 2
1672 fi
1674 shift # skip merge
1675 append="$1 slitaz1"
1676 shift # skip size1
1677 mkdir -p $TMP_DIR/mnt $TMP_DIR/rootfs1
1679 ISO=$1.merged
1680 # Extract filesystems
1681 echo -n "Mounting $1"
1682 mount -o loop,ro $1 $TMP_DIR/mnt 2> /dev/null
1683 status || cleanup_merge
1684 cp -a $TMP_DIR/mnt $TMP_DIR/iso
1685 rm -f $TMP_DIR/iso/boot/bzImage
1686 ln $TMP_DIR/iso/boot/vmlinuz* $TMP_DIR/iso/boot/bzImage
1687 umount -d $TMP_DIR/mnt
1688 if [ -f $TMP_DIR/iso/boot/rootfs1.gz ]; then
1689 echo "$1 is already a merged iso. Aborting."
1690 cleanup_merge
1691 fi
1692 if [ ! -f $TMP_DIR/iso/boot/isolinux/ifmem.c32 ]; then
1693 if [ ! -f /boot/isolinux/ifmem.c32 ]; then
1694 cat <<EOT
1695 No file /boot/isolinux/ifmem.c32
1696 Please install syslinux package !
1697 EOT
1698 rm -rf $TMP_DIR
1699 exit 1
1700 fi
1701 cp /boot/isolinux/ifmem.c32 $TMP_DIR/iso/boot/isolinux
1702 fi
1704 echo -n "Extracting iso/rootfs.gz"
1705 extract_rootfs $TMP_DIR/iso/boot/rootfs.gz $TMP_DIR/rootfs1 &&
1706 [ -d $TMP_DIR/rootfs1/etc ]
1707 status || cleanup_merge
1708 n=1
1709 while [ -n "$2" ]; do
1710 shift # skip rootfs N-1
1711 p=$n
1712 n=$(($n + 1))
1713 append="$append $1 slitaz$n"
1714 shift # skip size N
1715 mkdir -p $TMP_DIR/rootfs$n
1716 echo -n "Extracting $1"
1717 extract_rootfs $1 $TMP_DIR/rootfs$n &&
1718 [ -d $TMP_DIR/rootfs$n/etc ]
1719 status || cleanup_merge
1720 mergefs $TMP_DIR/rootfs$n $TMP_DIR/rootfs$p
1721 echo "Creating rootfs$p.gz"
1722 pack_rootfs $TMP_DIR/rootfs$p $TMP_DIR/iso/boot/rootfs$p.gz
1723 status
1724 done
1725 echo "Creating rootfs$n.gz"
1726 pack_rootfs $TMP_DIR/rootfs$n $TMP_DIR/iso/boot/rootfs$n.gz
1727 status
1728 rm -f $TMP_DIR/iso/boot/rootfs.gz
1729 update_bootconfig $TMP_DIR/iso/boot/isolinux "$append"
1730 echo "Generating $ISO"
1731 create_iso $ISO $TMP_DIR/iso
1732 rm -rf $TMP_DIR
1733 ;;
1735 repack)
1736 # Repack an iso with maximum lzma compression ratio.
1739 ISO=$2
1741 mkdir -p $TMP_DIR/mnt
1742 # Extract filesystems
1743 echo -n "Mounting $ISO"
1744 mount -o loop,ro $ISO $TMP_DIR/mnt 2> /dev/null
1745 status || cleanup_merge
1746 cp -a $TMP_DIR/mnt $TMP_DIR/iso
1747 umount -d $TMP_DIR/mnt
1749 for i in $TMP_DIR/iso/boot/rootfs* ; do
1750 echo -n "Repacking $(basename $i)"
1751 (zcat $i || unlzma -c $i || cat $i) \
1752 2>/dev/null > $TMP_DIR/rootfs
1753 lzma e $TMP_DIR/rootfs $i \
1754 $(lzma_switches $TMP_DIR/rootfs)
1755 status
1756 done
1758 echo "Generating $ISO"
1759 create_iso $ISO $TMP_DIR/iso
1760 rm -rf $TMP_DIR ;;
1762 frugal-install|-fi)
1763 ISO_IMAGE="$2"
1764 echo ""
1765 mkdir -p /boot/frugal
1766 if [ -f "$ISO_IMAGE" ]; then
1767 echo -n "Using ISO image: $ISO_IMAGE"
1768 mkdir -p /tmp/iso && mount -o loop $ISO_IMAGE /tmp/iso
1769 status
1770 echo -n "Installing the Kernel and rootfs..."
1771 cp -a /tmp/iso/boot/bzImage /boot/frugal
1772 cp -a /tmp/iso/boot/rootfs.gz /boot/frugal
1773 umount /tmp/iso
1774 status
1775 else
1776 echo -n "Using distro: $DISTRO"
1777 cd $DISTRO && status
1778 echo -n "Installing the Kernel and rootfs..."
1779 cp -a $DISTRO/rootcd/boot/bzImage /boot/frugal
1780 cp -a $DISTRO/rootcd/boot/rootfs.gz /boot/frugal
1781 status
1782 fi
1783 # Grub entry
1784 if ! grep -q "^kernel /boot/frugal/bzImage" /boot/grub/menu.lst; then
1785 echo -n "Configuring GRUB menu list..."
1786 cat >> /boot/grub/menu.lst << EOT
1787 title SliTaz GNU/Linux (frugal)
1788 root (hd0,0)
1789 kernel /boot/frugal/bzImage root=/dev/null
1790 initrd /boot/frugal/rootfs.gz
1791 EOT
1792 else
1793 echo -n "GRUB menu list is up-to-date..."
1794 fi
1795 status
1796 echo "" ;;
1798 emu-iso)
1799 # Emulate an ISO image with Qemu.
1800 if [ -n "$2" ] ; then
1801 iso=$2
1802 else
1803 iso=$DISTRO/$ISO_NAME.iso
1804 fi
1805 if [ ! -f "$iso" ]; then
1806 echo -e "\nUnable to find ISO : $iso\n"
1807 exit 0
1808 fi
1809 if [ ! -x "/usr/bin/qemu" ]; then
1810 echo -e "\nUnable to find Qemu binary. Please install: qemu\n"
1811 exit 0
1812 fi
1813 echo -e "\nStarting Qemu emulator:\n"
1814 echo -e "qemu $QEMU_OPTS $iso\n"
1815 qemu $QEMU_OPTS $iso ;;
1817 usage|*)
1818 # Clear and print usage also for all unknown commands.
1820 clear
1821 usage ;;
1822 esac
1824 exit 0