tazlito view tazlito @ rev 135
Update Makefile
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sat Jan 23 16:36:46 2010 +0100 (2010-01-23) |
parents | ad976dc83619 |
children | 3482249849cf |
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 distro_sizes()
359 {
360 echo "Build date : `date +%Y%m%d\ \at\ \%H:%M:%S`"
361 echo "Packages : `ls -1 $ROOTFS*$INSTALLED/*/receipt | wc -l`"
362 echo "Rootfs size : `du -csh $ROOTFS*/ | awk '{ s=$1 } END { print s }'`"
363 echo "Initramfs size : `du -csh $ROOTCD/boot/rootfs*.gz | awk '{ s=$1 } END { print s }'`"
364 echo "ISO image size : `du -sh $ISO_NAME.iso | awk '{ print $1 }'`"
365 echo "================================================================================"
366 echo "Image is ready: $ISO_NAME.iso"
367 echo ""
368 }
370 # Print ISO and rootfs size.
371 distro_stats()
372 {
373 echo ""
374 echo -e "\033[1mDistro statistics\033[0m ($DISTRO)"
375 echo "================================================================================"
376 distro_sizes
377 }
379 # Create an empty configuration file.
380 empty_config_file()
381 {
382 cat >> tazlito.conf << "EOF"
383 # tazlito.conf: Tazlito (SliTaz Live Tool)
384 # configuration file.
385 #
387 # Name of the ISO image to generate.
388 ISO_NAME=""
390 # ISO image volume name.
391 VOLUM_NAME="SliTaz"
393 # Name of the preparer.
394 PREPARED="$USER"
396 # Path to the packages repository and the packages.list.
397 PACKAGES_REPOSITORY=""
399 # Path to the distro tree to gen-distro from a
400 # list of packages.
401 DISTRO=""
403 # Path to the directory containing additional files
404 # to copy into the rootfs and rootcd of the LiveCD.
405 ADDFILES="$DISTRO/addfiles"
407 # Default answer for binary question (Y or N)
408 DEFAULT_ANSWER="ASK"
410 # Compression utility (lzma, gzip or none)
411 COMPRESSION="lzma"
412 EOF
413 }
415 # extract rootfs.gz somewhere
416 extract_rootfs()
417 {
418 (zcat $1 || unlzma -c $1 || cat $1) 2>/dev/null | \
419 (cd $2; cpio -idm > /dev/null)
420 }
422 # Remove duplicate files
423 mergefs()
424 {
425 echo -n "Merge $(basename $1) ($(du -hs $1 | awk '{ print $1}')) into "
426 echo -n "$(basename $2) ($(du -hs $2 | awk '{ print $1}'))"
427 # merge symlinks files and devices
428 ( cd $1; find ) | while read file; do
429 if [ -L $1/$file ]; then
430 [ -L $2/$file ] &&
431 [ "$(readlink $1/$file)" == "$(readlink $2/$file)" ] &&
432 rm -f $2/$file
433 elif [ -f $1/$file ]; then
434 [ -f $2/$file ] &&
435 cmp $1/$file $2/$file > /dev/null 2>&1 && rm -f $2/$file
436 [ -f $2/$file ] &&
437 [ "$(basename $file)" == "volatile.cpio.gz" ] &&
438 [ "$(dirname $(dirname $file))" == \
439 "./var/lib/tazpkg/installed" ] && rm -f $2/$file
440 elif [ -b $1/$file ]; then
441 [ -b $2/$file ] && rm -f $2/$file
442 elif [ -c $1/$file ]; then
443 [ -c $2/$file ] && rm -f $2/$file
444 fi
445 done
447 # cleanup directories
448 ( cd $1; find ) | while read file; do
449 if [ -d $1/$file ]; then
450 [ -d $2/$file ] && rmdir $2/$file 2> /dev/null
451 fi
452 done
453 true
454 status
455 }
457 cleanup_merge()
458 {
459 rm -rf $TMP_DIR
460 exit 1
461 }
463 human2cent()
464 {
465 case "$1" in
466 *k) echo $1 | sed 's/\(.*\).\(.\)k/\1\2/';;
467 *M) echo $(( $(echo $1 | sed 's/\(.*\).\(.\)M/\1\2/') * 1024));;
468 *G) echo $(( $(echo $1 | sed 's/\(.*\).\(.\)G/\1\2/') * 1024 * 1024));;
469 esac
470 }
472 cent2human()
473 {
474 if [ $1 -lt 10000 ]; then
475 echo "$(($1 / 10)).$(($1 % 10))k"
476 elif [ $1 -lt 10000000 ]; then
477 echo "$(($1 / 10240)).$(( ($1/1024) % 10))M"
478 else
479 echo "$(($1 / 10485760)).$(( ($1/1048576) % 10))G"
480 fi
481 }
483 get_size()
484 {
485 cat /var/lib/tazpkg/packages.list $TMP_DIR/packages.list 2>/dev/null | awk "{ \
486 if (/^$(echo $1 | sed 's/[$+.\]/\\&/g')$/) get=1; \
487 if (/installed/ && get == 1) { print ; get++ } \
488 }
489 END { if (get < 2) print \" 0.0k (0.0k installed)\" }" | \
490 sed 's/ *\(.*\) .\(.*\) installed./\1 \2/' | while read packed unpacked; do
491 echo "$(human2cent $packed) $(human2cent $unpacked)"
492 done
493 }
495 # Display package list with version, set packed_size and unpacked_size
496 get_pkglist()
497 {
498 packed_size=0; unpacked_size=0
499 grep -v ^# $FLAVORS_REPOSITORY/$1/packages.list > $TMP_DIR/flavor.pkg
500 while read pkg; do
501 set -- $(get_size $pkg)
502 packed_size=$(( $packed_size + $1 ))
503 unpacked_size=$(( $unpacked_size + $2 ))
504 for i in $(grep -hs ^$pkg /var/lib/tazpkg/packages.list \
505 $TMP_DIR/packages.list); do
506 echo $i
507 break
508 done
509 done < $TMP_DIR/flavor.pkg
510 rm -f $TMP_DIR/flavor.pkg
511 }
513 # Update isolinux config files for multiple rootfs
514 update_bootconfig()
515 {
516 echo -n "Updating boot config files..."
517 grep -l 'include common' $1/*.cfg | \
518 while read file ; do
519 awk -v n=$(echo $2 | awk '{ print NF/2 }') '{
520 if (/label/) label=$0;
521 else if (/kernel/) kernel=$0;
522 else if (/append/) {
523 i=index($0,"rootfs.gz");
524 append=substr($0,i+9);
525 }
526 else if (/include/) {
527 for (i = 1; i <= n; i++) {
528 print label i
529 print kernel;
530 initrd="initrd=/boot/rootfs" n ".gz"
531 for (j = n - 1; j >= i; j--) {
532 initrd=initrd ",/boot/rootfs" j ".gz";
533 }
534 printf "\tappend %s%s\n",initrd,append;
535 print "";
536 }
537 print;
538 }
539 else print;
540 }' < $file > $file.$$
541 mv -f $file.$$ $file
542 done
543 cat >> $1/common.cfg <<EOT
545 label slitaz
546 kernel /boot/isolinux/ifmem.c32
547 append$(echo $2 | awk '{
548 for (i=1; i<=NF; i++)
549 if (i % 2 == 0) printf " slitaz%d",i/2
550 else printf " %s",$i
551 }') noram
553 label noram
554 config noram.cfg
556 EOT
557 cat > $1/noram.cfg <<EOT
558 display isolinux.msg
559 say Not enough RAM to boot slitaz.
560 default reboot
561 label reboot
562 com32 reboot.c32
564 implicit 0
565 prompt 1
566 timeout 80
567 F1 help.txt
568 F2 options.txt
569 F3 isolinux.msg
570 F4 display.txt
571 F5 enhelp.txt
572 F6 enopts.txt
573 EOT
574 status
575 }
577 ####################
578 # Tazlito commands #
579 ####################
581 case "$COMMAND" in
582 stats)
583 # Tazlito general statistics from the config file.
584 #
585 echo ""
586 echo -e "\033[1mTazlito statistics\033[0m
587 ===============================================================================
588 Config file : $CONFIG_FILE
589 ISO name : $ISO_NAME.iso
590 Volume name : $VOLUM_NAME
591 Prepared : $PREPARED
592 Packages repository : $PACKAGES_REPOSITORY
593 Distro directory : $DISTRO"
594 if [ ! "$ADDFILES" = "" ] ; then
595 echo -e "Additional files : $ADDFILES"
596 fi
597 echo "================================================================================"
598 echo ""
599 ;;
600 list-addfiles)
601 # Simple list of additonal files in the rootfs
602 echo ""
603 cd $ADDFILES
604 find rootfs -type f
605 echo "" ;;
606 gen-config)
607 # Generate a new config file in the current dir or the specified
608 # directory by $2.
609 #
610 if [ -n "$2" ] ; then
611 mkdir -p $2 && cd $2
612 fi
613 echo -n "Generating empty tazlito.conf..."
614 empty_config_file
615 status
616 echo ""
617 if [ -f "tazlito.conf" ] ; then
618 echo "Configuration file is ready to edit."
619 echo "File location : `pwd`/tazlito.conf"
620 echo ""
621 fi
622 ;;
623 configure)
624 # Configure a tazlito.conf config file. Start by getting
625 # a empty config file and sed it.
626 #
627 if [ -f "tazlito.conf" ] ; then
628 rm tazlito.conf
629 else
630 if test $(id -u) = 0 ; then
631 cd /etc
632 else
633 echo "You must be root to configure the main config file or in"
634 echo "the same directory of the file you want to configure."
635 exit 0
636 fi
637 fi
638 empty_config_file
639 echo""
640 echo -e "\033[1mConfiguring :\033[0m `pwd`/tazlito.conf"
641 echo "================================================================================"
642 # ISO name.
643 echo -n "ISO name : " ; read answer
644 sed -i s#'ISO_NAME=\"\"'#"ISO_NAME=\"$answer\""# tazlito.conf
645 # Volume name.
646 echo -n "Volume name : " ; read answer
647 sed -i s/'VOLUM_NAME=\"SliTaz\"'/"VOLUM_NAME=\"$answer\""/ tazlito.conf
648 # Packages repository.
649 echo -n "Packages repository : " ; read answer
650 sed -i s#'PACKAGES_REPOSITORY=\"\"'#"PACKAGES_REPOSITORY=\"$answer\""# tazlito.conf
651 # Distro path.
652 echo -n "Distro path : " ; read answer
653 sed -i s#'DISTRO=\"\"'#"DISTRO=\"$answer\""# tazlito.conf
654 echo "================================================================================"
655 echo "Config file is ready to use."
656 echo "You can now extract an ISO or generate a distro."
657 echo ""
658 ;;
659 gen-iso)
660 # Simply generate a new iso.
661 #
662 check_root
663 verify_rootcd
664 gen_livecd_isolinux
665 distro_stats
666 ;;
667 gen-initiso)
668 # Simply generate a new initramfs with a new iso.
669 #
670 check_root
671 verify_rootcd
672 gen_initramfs $ROOTFS
673 gen_livecd_isolinux
674 distro_stats
675 ;;
676 extract-distro)
677 # Extract an ISO image to a directory and rebuild the LiveCD tree.
678 #
679 check_root
680 ISO_IMAGE=$2
681 if [ -z "$ISO_IMAGE" ] ; then
682 echo -e "\nPlease specify the path to the ISO image."
683 echo -e "Example : `basename $0` image.iso /path/target\n"
684 exit 0
685 fi
686 # Set the distro path by checking for $3 on cmdline.
687 if [ -n "$3" ] ; then
688 TARGET=$3
689 else
690 TARGET=$DISTRO
691 fi
692 # Exit if existing distro is found.
693 if [ -d "$TARGET/rootfs" ] ; then
694 echo -e "\nA rootfs exists in : $TARGET"
695 echo -e "Please clean the distro tree or change directory path.\n"
696 exit 0
697 fi
698 echo ""
699 echo -e "\033[1mTazlito extracting :\033[0m `basename $ISO_IMAGE`"
700 echo "================================================================================"
701 # Start to mount the ISO.
702 echo ""
703 echo "Mounting ISO image..."
704 mkdir -p $TMP_DIR
705 # Get ISO file size.
706 isosize=`du -sh $ISO_IMAGE | cut -f1`
707 mount -o loop $ISO_IMAGE $TMP_DIR
708 sleep 2
709 # Prepare target dir, copy the kernel and the rootfs.
710 mkdir -p $TARGET/rootfs
711 mkdir -p $TARGET/rootcd/boot
712 echo -n "Copying the Linux kernel..."
713 if cp $TMP_DIR/boot/vmlinuz* $TARGET/rootcd/boot 2> /dev/null; then
714 ln $TARGET/rootcd/boot/vmlinuz* $TARGET/rootcd/boot/bzImage
715 else
716 cp $TMP_DIR/boot/bzImage $TARGET/rootcd/boot
717 fi
718 status
719 echo -n "Copying isolinux files..."
720 cp -a $TMP_DIR/boot/isolinux $TARGET/rootcd/boot
721 for i in $(ls $TMP_DIR); do
722 [ "$i" = "boot" ] && continue
723 cp -a $TMP_DIR/$i $TARGET/rootcd
724 done
725 status
726 if [ -d $TMP_DIR/boot/syslinux ]; then
727 echo -n "Copying syslinux files..."
728 cp -a $TMP_DIR/boot/syslinux $TARGET/rootcd/boot
729 status
730 fi
731 if [ -d $TMP_DIR/boot/extlinux ]; then
732 echo -n "Copying extlinux files..."
733 cp -a $TMP_DIR/boot/extlinux $TARGET/rootcd/boot
734 status
735 fi
736 if [ -d $TMP_DIR/boot/grub ]; then
737 echo -n "Copying GRUB files..."
738 cp -a $TMP_DIR/boot/grub $TARGET/rootcd/boot
739 status
740 fi
742 echo -n "Copying the rootfs..."
743 cp $TMP_DIR/boot/rootfs.?z $TARGET/rootcd/boot
744 status
745 # Extract initramfs.
746 cd $TARGET/rootfs
747 echo -n "Extracting the rootfs... "
748 extract_rootfs ../rootcd/boot/rootfs.gz $TARGET/rootfs
749 # unpack /usr
750 for i in etc/tazlito/*.extract; do
751 [ -f "$i" ] && . $i ../rootcd
752 done
753 # Umount and remove temp directory and cd to $TARGET to get stats.
754 umount $TMP_DIR && rm -rf $TMP_DIR
755 cd ..
756 echo ""
757 echo "================================================================================"
758 echo "Extracted : `basename $ISO_IMAGE` ($isosize)"
759 echo "Distro tree : `pwd`"
760 echo "Rootfs size : `du -sh rootfs`"
761 echo "Rootcd size : `du -sh rootcd`"
762 echo "================================================================================"
763 echo ""
764 ;;
765 list-flavors)
766 # Show available flavors.
767 if [ ! -s /etc/tazlito/flavors.list -o "$2" == "--recharge" ]; then
768 download flavors.list -O - > /etc/tazlito/flavors.list
769 fi
770 echo ""
771 echo -e "\033[1mList of flavors\033[0m"
772 echo "================================================================================"
773 cat /etc/tazlito/flavors.list
774 echo ""
775 ;;
776 show-flavor)
777 # Show flavor description.
778 FLAVOR=${2%.flavor}
779 if [ ! -f "$FLAVOR.flavor" ]; then
780 echo "File $FLAVOR.flavor not found."
781 exit 1
782 fi
783 mkdir $TMP_DIR
784 zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i 2> /dev/null)
785 if [ "$3" = "--brief" ]; then
786 if [ "$4" != "--noheader" ]; then
787 echo "Name ISO Rootfs Description"
788 echo "================================================================================"
789 fi
790 printf "%-16.16s %6.6s %6.6s %s\n" "$FLAVOR" \
791 "$(field ISO $TMP_DIR/$FLAVOR.desc)" \
792 "$(field 'Rootfs size' $TMP_DIR/$FLAVOR.desc)" \
793 "$(grep ^Description $TMP_DIR/$FLAVOR.desc | cut -d: -f2)"
794 else
795 echo "================================================================================"
796 cat $TMP_DIR/$FLAVOR.desc
797 fi
798 rm -Rf $TMP_DIR
799 ;;
800 gen-liveflavor)
801 # Generate a new flavor form the live system.
802 FLAVOR=${2%.flavor}
803 DESC=""
804 case "$FLAVOR" in
805 '') echo -n "Flavor name : "
806 read FLAVOR
807 [ -z "$FLAVOR" ] && exit 1;;
808 -?|-h*|--help) echo -e "
810 SliTaz Live Tool - Version: $VERSION
811 \033[1mUsage: \033[0m `basename $0` gen-liveflavor flavor-name [flavor-patch-file]
812 \033[1mflavor-patch-file format: \033[0m
813 code data
814 + package to add
815 - package to remove
816 ! non-free package to add
817 ? display message
818 @ flavor description
820 \033[1mExample: \033[0m
821 @ Developer tools for slitaz maintainers
822 + slitaz-toolchain
823 + mercurial
824 "
825 exit 1;;
826 esac
827 mv /etc/tazlito/distro-packages.list \
828 /etc/tazlito/distro-packages.list.$$ 2> /dev/null
829 rm -f distro-packages.list non-free.list 2> /dev/null
830 tazpkg recharge
831 [ -n "$3" ] && while read action pkg; do
832 case "$action" in
833 +) yes | tazpkg get-install $pkg;;
834 -) yes | tazpkg remove $pkg;;
835 !) echo $pkg >> non-free.list;;
836 @) DESC="$pkg";;
837 \?) echo -en "$pkg"; read action;;
838 esac
839 done < $3
840 yes '' | tazlito gen-distro
841 echo "$DESC" | tazlito gen-flavor "$FLAVOR"
842 mv /etc/tazlito/distro-packages.list.$$ \
843 /etc/tazlito/distro-packages.list 2> /dev/null
844 ;;
845 gen-flavor)
846 # Generate a new flavor from the last iso image generated.
847 FLAVOR=${2%.flavor}
848 echo ""
849 echo -e "\033[1mFlavor generation\033[0m"
850 echo "================================================================================"
851 if [ -z "$FLAVOR" ]; then
852 echo -n "Flavor name : "
853 read FLAVOR
854 [ -z "$FLAVOR" ] && exit 1
855 fi
856 check_rootfs
857 FILES="$FLAVOR.pkglist"
858 echo -n "Creating file $FLAVOR.flavor..."
859 for i in rootcd rootfs; do
860 if [ -d "$ADDFILES/$i" ] ; then
861 FILES="$FILES\n$FLAVOR.$i"
862 ( cd "$ADDFILES/$i"; find . | \
863 cpio -o -H newc 2> /dev/null | gzip -9 ) > $FLAVOR.$i
864 fi
865 done
866 status
867 answer=`grep -s ^Description $FLAVOR.desc`
868 answer=${answer#Description : }
869 if [ -z "$answer" ]; then
870 echo -n "Description : "
871 read answer
872 fi
873 echo -n "Compressing flavor $FLAVOR..."
874 echo "Flavor : $FLAVOR" > $FLAVOR.desc
875 echo "Description : $answer" >> $FLAVOR.desc
876 ( cd $DISTRO; distro_sizes) >> $FLAVOR.desc
877 \rm -f $FLAVOR.pkglist $FLAVOR.nonfree 2> /dev/null
878 for i in $(ls $ROOTFS$INSTALLED); do
879 eval $(grep ^VERSION= $ROOTFS$INSTALLED/$i/receipt)
880 EXTRAVERSION=""
881 eval $(grep ^EXTRAVERSION= $ROOTFS$INSTALLED/$i/receipt)
882 eval $(grep ^CATEGORY= $ROOTFS$INSTALLED/$i/receipt)
883 if [ "$CATEGORY" = "non-free" -a "${i%%-*}" != "get" ]
884 then
885 echo "$i" >> $FLAVOR.nonfree
886 else
887 echo "$i-$VERSION$EXTRAVERSION" >> $FLAVOR.pkglist
888 fi
889 done
890 [ -s $FLAVOR.nonfree ] && $FILES="$FILES\n$FLAVOR.nonfree"
891 for i in $LOCALSTATE/undigest/*/mirror ; do
892 [ -s $i ] && cat $i >> $FLAVOR.mirrors
893 done
894 [ -s $FLAVOR.mirrors ] && $FILES="$FILES\n$FLAVOR.mirrors"
895 echo -e "$FLAVOR.desc\n$FILES" | cpio -o -H newc 2>/dev/null | \
896 gzip -9 > $FLAVOR.flavor
897 rm `echo -e $FILES`
898 status
899 echo "================================================================================"
900 echo "Flavor size : `du -sh $FLAVOR.flavor`"
901 echo ""
902 ;;
903 upgrade-flavor)
904 # Update package list to the lastest versions available.
905 FLAVOR=${2%.flavor}
906 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
907 mkdir $TMP_DIR
908 zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i >/dev/null )
909 echo -n "Updating $FLAVOR package list..."
910 [ -s /var/lib/tazpkg/packages.list ] || tazpkg recharge
911 packed_size=0; unpacked_size=0
912 while read org; do
913 i=0
914 pkg=$org
915 while ! grep -q ^$pkg$ /var/lib/tazpkg/packages.txt; do
916 pkg=${pkg%-*}
917 i=$(($i + 1))
918 [ $i -gt 5 ] && break;
919 done
920 set -- $(get_size $pkg)
921 packed_size=$(( $packed_size + $1 ))
922 unpacked_size=$(( $unpacked_size + $2 ))
923 for i in $(grep ^$pkg /var/lib/tazpkg/packages.list); do
924 echo $i
925 break
926 done
927 done < $TMP_DIR/$FLAVOR.pkglist \
928 > $TMP_DIR/$FLAVOR.pkglist.$$
929 mv -f $TMP_DIR/$FLAVOR.pkglist.$$ $TMP_DIR/$FLAVOR.pkglist
930 if [ -s $TMP_DIR/$FLAVOR.rootfs ]; then
931 packed_size=$(($packed_size \
932 + $(cat $TMP_DIR/$FLAVOR.rootfs | wc -c ) / 100 ))
933 unpacked_size=$(($unpacked_size \
934 + $(zcat $TMP_DIR/$FLAVOR.rootfs | wc -c ) / 100 ))
935 fi
936 # Estimate lzma
937 packed_size=$(($packed_size * 2 / 3))
938 iso_size=$(( $packed_size + 26000 ))
939 if [ -s $TMP_DIR/$FLAVOR.rootcd ]; then
940 iso_size=$(($iso_size \
941 + $(zcat $TMP_DIR/$FLAVOR.rootcd | wc -c ) / 100 ))
942 fi
943 sed -i -e '/Image is ready/d' \
944 -e "s/Rootfs size\( *:\) \(.*\)/Rootfs size\1 $(cent2human $unpacked_size) (estimated)/" \
945 -e "s/Initramfs size\( *:\) \(.*\)/Initramfs size\1 $(cent2human $packed_size) (estimated)/" \
946 -e "s/ISO image size\( *:\) \(.*\)/ISO image size\1 $(cent2human $iso_size) (estimated)/" \
947 -e "s/date\( *:\) \(.*\)/date\1 $(date +%Y%m%d\ \at\ \%H:%M:%S)/" \
948 $TMP_DIR/$FLAVOR.desc
949 ( cd $TMP_DIR ; ls | cpio -o -H newc ) | gzip -9 > \
950 $FLAVOR.flavor
951 status
952 rm -Rf $TMP_DIR
953 fi
954 ;;
955 extract-flavor)
956 # Extract a flavor into $FLAVORS_REPOSITORY.
957 FLAVOR=${2%.flavor}
958 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
959 mkdir $TMP_DIR
960 zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i >/dev/null )
961 echo -n "Extracting $FLAVOR..."
962 rm -rf $FLAVORS_REPOSITORY/$FLAVOR 2> /dev/null
963 mkdir -p $FLAVORS_REPOSITORY/$FLAVOR
964 echo "FLAVOR=\"$FLAVOR\"" > $FLAVORS_REPOSITORY/$FLAVOR/receipt
965 grep ^Description $TMP_DIR/$FLAVOR.desc | \
966 sed 's/.*: \(.*\)$/SHORT_DESC="\1"/' >> \
967 $FLAVORS_REPOSITORY/$FLAVOR/receipt
968 grep -q '^Rootfs list' $TMP_DIR/$FLAVOR.desc && \
969 grep '^Rootfs list' $TMP_DIR/$FLAVOR.desc | \
970 sed 's/.*: \(.*\)$/ROOTFS_SELECTION="\1"/' >> \
971 $FLAVORS_REPOSITORY/$FLAVOR/receipt
972 grep '^Rootfs size' $TMP_DIR/$FLAVOR.desc | \
973 sed 's/.*: \(.*\)$/ROOTFS_SIZE="\1"/' >> \
974 $FLAVORS_REPOSITORY/$FLAVOR/receipt
975 grep ^Initramfs $TMP_DIR/$FLAVOR.desc | \
976 sed 's/.*: \(.*\)$/INITRAMFS_SIZE="\1"/' >> \
977 $FLAVORS_REPOSITORY/$FLAVOR/receipt
978 grep ^ISO $TMP_DIR/$FLAVOR.desc | \
979 sed 's/.*: \(.*\)$/ISO_SIZE="\1"/' >> \
980 $FLAVORS_REPOSITORY/$FLAVOR/receipt
981 for i in rootcd rootfs; do
982 [ -f $TMP_DIR/$FLAVOR.$i ] || continue
983 mkdir $FLAVORS_REPOSITORY/$FLAVOR/$i
984 zcat $TMP_DIR/$FLAVOR.$i | \
985 (cd $FLAVORS_REPOSITORY/$FLAVOR/$i; \
986 cpio -idm > /dev/null)
987 done
988 [ -s $TMP_DIR/$FLAVOR.mirrors ] &&
989 cp $TMP_DIR/$FLAVOR.mirrors \
990 $FLAVORS_REPOSITORY/$FLAVOR/mirrors
991 [ -s /var/lib/tazpkg/packages.list ] || tazpkg recharge
992 while read org; do
993 i=0
994 pkg=$org
995 while ! grep -q ^$pkg$ /var/lib/tazpkg/packages.txt; do
996 pkg=${pkg%-*}
997 i=$(($i + 1))
998 [ $i -gt 5 ] && break;
999 done
1000 echo $pkg
1001 done < $TMP_DIR/$FLAVOR.pkglist \
1002 > $FLAVORS_REPOSITORY/$FLAVOR/packages.list
1003 status
1004 rm -Rf $TMP_DIR
1005 fi
1006 ;;
1007 pack-flavor)
1008 # Create a flavor from $FLAVORS_REPOSITORY.
1009 FLAVOR=${2%.flavor}
1010 if [ -s $FLAVORS_REPOSITORY/$FLAVOR/receipt ]; then
1011 mkdir $TMP_DIR
1012 echo -n "Creating flavor $FLAVOR..."
1013 [ -s /var/lib/tazpkg/packages.list ] || tazpkg recharge
1014 if [ -s $FLAVORS_REPOSITORY/$FLAVOR/mirrors ]; then
1015 cp $FLAVORS_REPOSITORY/$FLAVOR/mirrors \
1016 $TMP_DIR/$FLAVOR.mirrors
1017 for i in $(cat $TMP_DIR/$FLAVOR.mirrors); do
1018 wget -O - $i/packages.list >> $TMP_DIR/packages.list
1019 done
1020 fi
1021 [ -s $FLAVORS_REPOSITORY/$FLAVOR/packages.list ] &&
1022 get_pkglist $FLAVOR > $TMP_DIR/$FLAVOR.pkglist
1023 if grep -q ^ROOTFS_SELECTION \
1024 $FLAVORS_REPOSITORY/$FLAVOR/receipt; then
1025 . $FLAVORS_REPOSITORY/$FLAVOR/receipt
1026 set -- $ROOTFS_SELECTION
1027 [ -n "$FRUGAL_RAM" ] || FRUGAL_RAM=$1
1028 [ -f $FLAVORS_REPOSITORY/$2/packages.list ] ||
1029 tazlito extract-flavor $2
1030 get_pkglist $2 > $TMP_DIR/$FLAVOR.pkglist
1031 fi
1032 for i in rootcd rootfs; do
1033 [ -d $FLAVORS_REPOSITORY/$FLAVOR/$i ] || \
1034 continue
1035 ( cd $FLAVORS_REPOSITORY/$FLAVOR/$i ; find . | \
1036 cpio -o -H newc 2> /dev/null ) | \
1037 gzip -9 >$TMP_DIR/$FLAVOR.$i
1038 done
1039 if [ -s $TMP_DIR/$FLAVOR.rootfs ]; then
1040 packed_size=$(($packed_size \
1041 + $(cat $TMP_DIR/$FLAVOR.rootfs | wc -c ) / 100 ))
1042 unpacked_size=$(($unpacked_size \
1043 + $(zcat $TMP_DIR/$FLAVOR.rootfs | wc -c ) / 100 ))
1044 fi
1045 # Estimate lzma
1046 packed_size=$(($packed_size * 2 / 3))
1047 iso_size=$(( $packed_size + 26000 ))
1048 if [ -s $TMP_DIR/$FLAVOR.rootcd ]; then
1049 iso_size=$(($iso_size \
1050 + $(zcat $TMP_DIR/$FLAVOR.rootcd | wc -c ) / 100 ))
1051 fi
1052 VERSION=""
1053 MAINTAINER=""
1054 ROOTFS_SELECTION=""
1055 ROOTFS_SIZE="$(cent2human $unpacked_size) (estimated)"
1056 INITRAMFS_SIZE="$(cent2human $packed_size) (estimated)"
1057 ISO_SIZE="$(cent2human $iso_size) (estimated)"
1058 . $FLAVORS_REPOSITORY/$FLAVOR/receipt
1059 cat > $TMP_DIR/$FLAVOR.desc <<EOT
1060 Flavor : $FLAVOR
1061 Description : $SHORT_DESC
1062 EOT
1063 [ -n "$VERSION" ] && cat >> $TMP_DIR/$FLAVOR.desc <<EOT
1064 Version : $VERSION
1065 EOT
1066 [ -n "$MAINTAINER" ] && cat >> $TMP_DIR/$FLAVOR.desc <<EOT
1067 Maintainer : $MAINTAINER
1068 EOT
1069 [ -n "$FRUGAL_RAM" ] && cat >> $TMP_DIR/$FLAVOR.desc <<EOT
1070 LiveCD RAM size : $FRUGAL_RAM
1071 EOT
1072 [ -n "$ROOTFS_SELECTION" ] && cat >> $TMP_DIR/$FLAVOR.desc <<EOT
1073 Rootfs list : $ROOTFS_SELECTION
1074 EOT
1075 cat >> $TMP_DIR/$FLAVOR.desc <<EOT
1076 Build date : $(date +%Y%m%d\ \at\ \%H:%M:%S)
1077 Packages : $(grep -v ^# $TMP_DIR/$FLAVOR.pkglist | wc -l)
1078 Rootfs size : $ROOTFS_SIZE
1079 Initramfs size : $INITRAMFS_SIZE
1080 ISO image size : $ISO_SIZE
1081 ================================================================================
1083 EOT
1084 rm -f $TMP_DIR/packages.list
1085 ( cd $TMP_DIR ; ls | cpio -o -H newc 2> /dev/null) | \
1086 gzip -9 > $FLAVOR.flavor
1087 status
1088 rm -Rf $TMP_DIR
1089 else
1090 echo "No $FLAVOR flavor in $FLAVORS_REPOSITORY."
1091 fi
1092 ;;
1093 get-flavor)
1094 # Get a flavor's files and prepare for gen-distro.
1095 FLAVOR=${2%.flavor}
1096 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
1097 echo -n "Cleaning $DISTRO..."
1098 rm -R $DISTRO 2> /dev/null
1099 mkdir -p $DISTRO
1100 status
1101 mkdir $TMP_DIR
1102 zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i 2>/dev/null )
1103 echo -n "Creating distro-packages.list..."
1104 mv $TMP_DIR/$FLAVOR.nonfree non-free.list 2> /dev/null
1105 mv $TMP_DIR/$FLAVOR.pkglist distro-packages.list
1106 status
1107 for i in rootcd rootfs; do
1108 if [ -f $TMP_DIR/$FLAVOR.$i ]; then
1109 echo -n "Adding $i..."
1110 mkdir -p "$ADDFILES/$i"
1111 zcat $TMP_DIR/$FLAVOR.$i | \
1112 ( cd "$ADDFILES/$i"; cpio -id 2> /dev/null)
1113 status
1114 fi
1115 done
1116 if [ -s $TMP_DIR/$FLAVOR.mirrors ]; then
1117 n=""
1118 while read line; do
1119 mkdir -p $LOCALSTATE/undigest/$FLAVOR$n
1120 echo "$line" > $LOCALSTATE/undigest/$FLAVOR$n/mirror
1121 n=$(( $n + 1 ))
1122 done < $TMP_DIR/$FLAVOR.mirrors
1123 tazpkg recharge
1124 fi
1125 rm -f /etc/tazlito/rootfs.list
1126 grep -q '^Rootfs list' $TMP_DIR/$FLAVOR.desc &&
1127 grep '^Rootfs list' $TMP_DIR/$FLAVOR.desc | \
1128 sed 's/.*: \(.*\)$/\1/' > /etc/tazlito/rootfs.list
1129 echo -n "Updating tazlito.conf..."
1130 [ -f tazlito.conf ] || cp /etc/tazlito/tazlito.conf .
1131 cat tazlito.conf | grep -v "^#VOLUM_NAME" | \
1132 sed "s/^VOLUM_NA/VOLUM_NAME=\"SliTaz $FLAVOR\"\\n#VOLUM_NA/" \
1133 > tazlito.conf.$$ && mv tazlito.conf.$$ tazlito.conf
1134 sed -i "s/ISO_NAME=.*/ISO_NAME=\"slitaz-$FLAVOR\"/" tazlito.conf
1135 status
1136 rm -Rf $TMP_DIR
1137 fi
1138 ;;
1139 check-list)
1140 # Use current packages list in $PWD by default.
1141 DISTRO_PKGS_LIST=distro-packages.list
1142 [ -d "$2" ] && DISTRO_PKGS_LIST=$2/distro-packages.list
1143 [ -f "$2" ] && DISTRO_PKGS_LIST=$2
1144 [ ! -f $DISTRO_PKGS_LIST ] && echo "No packages list found." && exit 0
1145 echo ""
1146 echo -e "\033[1mLiveCD packages list check\033[0m"
1147 echo "================================================================================"
1148 for pkg in `cat $DISTRO_PKGS_LIST`
1149 do
1150 if ! grep -q "$pkg" /var/lib/tazpkg/packages.list; then
1151 echo "Update: $pkg"
1152 up=$(($up + 1))
1153 fi
1154 done
1155 [ -z $up ] && echo -e "List is up-to-date\n" && exit 0
1156 echo "================================================================================"
1157 echo -e "Updates: $up\n" ;;
1158 gen-distro)
1159 # Generate a live distro tree with a set of packages.
1160 #
1161 check_root
1163 # Check if a package list was specified on cmdline.
1164 LIST_NAME="distro-packages.list"
1165 CDROM=""
1166 while [ -n "$2" ]; do
1167 case "$2" in
1168 --iso=*)
1169 CDROM="-o loop ${2#--iso=}"
1170 ;;
1171 --cdrom)
1172 CDROM="/dev/cdrom"
1173 ;;
1174 --force)
1175 DELETE_ROOTFS="true"
1176 ;;
1177 *) if [ ! -f "$2" ] ; then
1178 echo -e "\nUnable to find the specified packages list."
1179 echo -e "List name : $2\n"
1180 exit 1
1181 fi
1182 LIST_NAME=$2
1183 ;;
1184 esac
1185 shift
1186 done
1188 if [ -d $ROOTFS ] ; then
1189 # Delete $ROOTFS if --force is set on command line
1190 if [ ! -z $DELETE_ROOTFS ]; then
1191 rm -rf $ROOTFS
1192 unset $DELETE_ROOTFS
1193 else
1194 echo -e "\nA rootfs exists in : $DISTRO"
1195 echo -e "Please clean the distro tree or change directory path.\n"
1196 exit 0
1197 fi
1198 fi
1199 if [ ! -f "$LIST_NAME" -a -d $INSTALLED ] ; then
1200 # Build list with installed packages
1201 for i in $(ls $INSTALLED); do
1202 eval $(grep ^VERSION= $INSTALLED/$i/receipt)
1203 EXTRAVERSION=""
1204 eval $(grep ^EXTRAVERSION= $INSTALLED/$i/receipt)
1205 echo "$i-$VERSION$EXTRAVERSION" >> $LIST_NAME
1206 done
1207 fi
1208 # Exit if no list name.
1209 if [ ! -f "$LIST_NAME" ]; then
1210 echo -e "\nNo packages list found or specified. Please read the docs.\n"
1211 exit 0
1212 fi
1213 # Start generation.
1214 echo ""
1215 echo -e "\033[1mTazlito generating a distro\033[0m"
1216 echo "================================================================================"
1217 # Misc checks
1218 [ -n "$PACKAGES_REPOSITORY" ] || PACKAGES_REPOSITORY="."
1219 [ -d $PACKAGES_REPOSITORY ] || mkdir -p $PACKAGES_REPOSITORY
1220 # Get the list of packages using cat for a file list.
1221 LIST=`cat $LIST_NAME`
1222 # Verify if all packages in list are present in $PACKAGES_REPOSITORY.
1223 REPACK=""
1224 DOWNLOAD=""
1225 for pkg in $LIST
1226 do
1227 [ "$pkg" = "" ] && continue
1228 pkg=${pkg%.tazpkg}
1229 [ -f $PACKAGES_REPOSITORY/$pkg.tazpkg ] && continue
1230 PACKAGE=$(installed_package_name $pkg)
1231 [ -n "$PACKAGE" -a "$REPACK" = "y" ] && continue
1232 [ -z "$PACKAGE" -a -n "$DOWNLOAD" ] && continue
1233 echo -e "\nUnable to find $pkg in the repository."
1234 echo -e "Path : $PACKAGES_REPOSITORY\n"
1235 if [ -n "$PACKAGE" -a -z "$REPACK" ]; then
1236 yesorno "Repack packages from rootfs (y/N) ? "
1237 REPACK="$answer"
1238 [ "$answer" = "y" ] || REPACK="n"
1239 [ "$DOWNLOAD" = "y" ] && break
1240 fi
1241 if [ -f $MIRROR -a -z "$DOWNLOAD" ]; then
1242 yesorno "Download packages from mirror (Y/n) ? "
1243 DOWNLOAD="$answer"
1244 if [ "$answer" = "n" ]; then
1245 [ -z "$PACKAGE" ] && exit 1
1246 else
1247 DOWNLOAD="y"
1248 [ -n "$REPACK" ] && break
1249 fi
1250 fi
1251 [ "$REPACK" = "n" -a "$DOWNLOAD" = "n" ] && exit 1
1252 done
1254 # Mount cdrom to be able to repack boot-loader packages
1255 if [ ! -e /boot -a -n "$CDROM" ]; then
1256 mkdir $TMP_MNT
1257 if mount -r $CDROM $TMP_MNT 2> /dev/null; then
1258 ln -s $TMP_MNT/boot /
1259 if [ ! -d "$ADDFILES/rootcd" ] ; then
1260 mkdir -p $ADDFILES/rootcd
1261 for i in $(ls $TMP_MNT); do
1262 [ "$i" = "boot" ] && continue
1263 cp -a $TMP_MNT/$i $ADDFILES/rootcd
1264 done
1265 fi
1266 else
1267 rmdir $TMP_MNT
1268 fi
1269 fi
1271 # Root fs stuff.
1272 echo "Preparing the rootfs directory..."
1273 mkdir -p $ROOTFS
1274 sleep 2
1275 for pkg in $LIST
1276 do
1277 [ "$pkg" = "" ] && continue
1278 # First copy and extract the package in tmp dir.
1279 pkg=${pkg%.tazpkg}
1280 PACKAGE=$(installed_package_name $pkg)
1281 mkdir -p $TMP_DIR
1282 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
1283 # Look for package in cache
1284 if [ -f $CACHE_DIR/$pkg.tazpkg ]; then
1285 ln -s $CACHE_DIR/$pkg.tazpkg $PACKAGES_REPOSITORY
1286 # Look for package in running distribution
1287 elif [ -n "$PACKAGE" -a "$REPACK" = "y" ]; then
1288 tazpkg repack $PACKAGE && \
1289 mv $pkg.tazpkg $PACKAGES_REPOSITORY
1290 fi
1291 fi
1292 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
1293 # Get package from mirror
1294 [ "$DOWNLOAD" = "y" ] && \
1295 download $pkg.tazpkg && \
1296 mv $pkg.tazpkg $PACKAGES_REPOSITORY
1297 fi
1298 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
1299 echo "Missing package $pkg."
1300 cleanup
1301 exit 1
1302 fi
1303 done
1304 if [ -f non-free.list ]; then
1305 echo "Preparing non-free packages..."
1306 cp non-free.list $ROOTFS/etc/tazlito/non-free.list
1307 for pkg in $(cat non-free.list); do
1308 if [ ! -d $INSTALLED/$pkg ]; then
1309 if [ ! -d $INSTALLED/get-$pkg ]; then
1310 tazpkg get-install get-$pkg
1311 fi
1312 get-$pkg
1313 fi
1314 tazpkg repack $pkg
1315 pkg=$(ls $pkg*.tazpkg)
1316 grep -q "^$pkg$" $LIST_NAME || \
1317 echo $pkg >>$LIST_NAME
1318 mv $pkg $PACKAGES_REPOSITORY
1319 done
1320 fi
1321 echo ""
1322 cp $LIST_NAME $DISTRO/distro-packages.list
1323 sed 's/\(.*\)/\1.tazpkg/' < $DISTRO/distro-packages.list > $DISTRO/list-packages
1324 cd $PACKAGES_REPOSITORY
1325 yes y | tazpkg install-list \
1326 $DISTRO/list-packages --root=$ROOTFS
1327 cd $DISTRO
1328 cp distro-packages.list $ROOTFS/etc/tazlito
1329 # Copy all files from $ADDFILES/rootfs to the rootfs.
1330 if [ -d "$ADDFILES/rootfs" ] ; then
1331 echo -n "Copying addfiles content to the rootfs... "
1332 cp -a $ADDFILES/rootfs/* $ROOTFS
1333 status
1334 fi
1335 echo "Root file system is generated..."
1336 # Root CD part.
1337 echo -n "Preparing the rootcd directory..."
1338 mkdir -p $ROOTCD
1339 status
1340 # Move the boot dir with the Linux kernel from rootfs.
1341 # The boot dir goes directly on the CD.
1342 if [ -d "$ROOTFS/boot" ] ; then
1343 echo -n "Moving the boot directory..."
1344 mv $ROOTFS/boot $ROOTCD
1345 cd $ROOTCD/boot
1346 ln vmlinuz-* bzImage
1347 status
1348 fi
1349 cd $DISTRO
1350 # Copy all files from $ADDFILES/rootcd to the rootcd.
1351 if [ -d "$ADDFILES/rootcd" ] ; then
1352 echo -n "Copying addfiles content to the rootcd... "
1353 cp -a $ADDFILES/rootcd/* $ROOTCD
1354 status
1355 fi
1356 # Execute the distro script (used to perform tasks in the rootfs
1357 # before compression. Give rootfs path in arg
1358 [ -z $DISTRO_SCRIPT ] && DISTRO_SCRIPT=$TOP_DIR/distro.sh
1359 if [ -x $DISTRO_SCRIPT ]; then
1360 echo "Executing distro script..."
1361 sh $DISTRO_SCRIPT $DISTRO
1362 fi
1363 if [ -s /etc/tazlito/rootfs.list ]; then
1364 [ -f $ROOTCD/boot/isolinux/ifmem.c32 ] ||
1365 cp /boot/isolinux/ifmem.c32 $ROOTCD/boot/isolinux
1366 n=0
1367 last=$ROOTFS
1368 while read flavor; do
1369 n=$(($n+1))
1370 echo "Building $flavor rootfs..."
1371 download $flavor.flavor
1372 zcat $flavor.flavor | cpio -i $flavor.pkglist
1373 sed 's/.*/&.tazpkg/' < $flavor.pkglist \
1374 > $DISTRO/list-packages0$n
1375 mkdir ${ROOTFS}0$n
1376 cd $PACKAGES_REPOSITORY
1377 yes y | tazpkg install-list \
1378 $DISTRO/list-packages0$n --root=${ROOTFS}0$n
1379 rm -rf ${ROOTFS}0$n/boot
1380 status
1381 cd $DISTRO
1382 mv $flavor.pkglist ${ROOTFS}0$n/etc/tazlito/distro-packages.list
1383 rm -f $flavor.flavor install-list
1384 mergefs ${ROOTFS}0$n $last
1385 last=${ROOTFS}0$n
1386 done <<EOT
1387 $(awk '{ for (i = 4; i <= NF; i+=2) print $i; }' < /etc/tazlito/rootfs.list)
1388 EOT
1389 i=$(($n+1))
1390 while [ $n -gt 0 ]; do
1391 mv ${ROOTFS}0$n ${ROOTFS}$i
1392 echo "Compression ${ROOTFS}0$n ($(du -hs ${ROOTFS}$i | awk '{ print $1 }')) ..."
1393 gen_initramfs ${ROOTFS}$i
1394 n=$(($n-1))
1395 i=$(($i-1))
1396 done
1397 mv $ROOTFS ${ROOTFS}$i
1398 gen_initramfs ${ROOTFS}$i
1399 update_bootconfig $ROOTCD/boot/isolinux \
1400 "$(cat /etc/tazlito/rootfs.list)"
1401 else
1402 # Initramfs and ISO image stuff.
1403 gen_initramfs $ROOTFS
1404 fi
1405 gen_livecd_isolinux
1406 distro_stats
1407 cleanup
1408 ;;
1409 clean-distro)
1410 # Remove old distro tree.
1411 #
1412 check_root
1413 echo ""
1414 echo -e "\033[1mCleaning :\033[0m $DISTRO"
1415 echo "================================================================================"
1416 if [ -d "$DISTRO" ] ; then
1417 if [ -d "$ROOTFS" ] ; then
1418 echo -n "Removing the rootfs..."
1419 rm -f $DISTRO/$INITRAMFS
1420 rm -rf $ROOTFS
1421 status
1422 fi
1423 if [ -d "$ROOTCD" ] ; then
1424 echo -n "Removing the rootcd..."
1425 rm -rf $ROOTCD
1426 status
1427 fi
1428 echo -n "Removing eventual ISO image..."
1429 rm -f $DISTRO/$ISO_NAME.iso
1430 rm -f $DISTRO/$ISO_NAME.md5
1431 status
1432 fi
1433 echo "================================================================================"
1434 echo ""
1435 ;;
1436 check-distro)
1437 # Check for a few LiveCD needed files not installed by packages.
1438 #
1439 check_rootfs
1440 echo ""
1441 echo -e "\033[1mChecking distro :\033[0m $ROOTFS"
1442 echo "================================================================================"
1443 # SliTaz release info.
1444 if [ ! -f "$ROOTFS/etc/slitaz-release" ]; then
1445 echo "Missing release info : /etc/slitaz-release"
1446 else
1447 release=`cat $ROOTFS/etc/slitaz-release`
1448 echo -n "Release : $release"
1449 status
1450 fi
1451 # Tazpkg mirror.
1452 if [ ! -f "$ROOTFS/var/lib/tazpkg/mirror" ]; then
1453 echo -n "Mirror URL : Missing /var/lib/tazpkg/mirror"
1454 todomsg
1455 else
1456 echo -n "Mirror configuration exists..."
1457 status
1458 fi
1459 # Isolinux msg
1460 if grep -q "cooking-XXXXXXXX" /$ROOTCD/boot/isolinux/isolinux.msg; then
1461 echo -n "Isolinux msg : Missing cooking date XXXXXXXX (ex `date +%Y%m%d`)"
1462 todomsg
1463 else
1464 echo -n "Isolinux message seems good..."
1465 status
1466 fi
1467 echo "================================================================================"
1468 echo ""
1469 ;;
1470 writeiso)
1471 # Writefs to ISO image including /home unlike gen-distro we dont use
1472 # packages to generate a rootfs, we build a compressed rootfs with all
1473 # the current filesystem similar to 'tazusb writefs'.
1474 #
1475 DISTRO="/home/slitaz/distro"
1476 ROOTCD="$DISTRO/rootcd"
1477 if [ -z $2 ]; then
1478 COMPRESSION=none
1479 else
1480 COMPRESSION=$2
1481 fi
1482 if [ -z $3 ]; then
1483 ISO_NAME="slitaz"
1484 else
1485 ISO_NAME="$3"
1486 fi
1487 check_root
1488 # Start info
1489 echo ""
1490 echo -e "\033[1mWrite filesystem to ISO\033[0m
1491 ===============================================================================
1492 The command writeiso will write the current filesystem into a suitable cpio
1493 archive (rootfs.gz) and generate a bootable ISO image (slitaz.iso).
1495 Archive compression: $COMPRESSION"
1496 echo ""
1498 # Save some space
1499 rm /var/cache/tazpkg/* -r -f
1500 rm -rf /home/slitaz/distro
1502 # Optionally remove sound card selection
1503 echo -n "Do you wish to remove the sound card selection (No/yes/exit) ? "
1504 read anser
1505 case $anser in
1506 e|E|"exit"|Exit)
1507 exit 0 ;;
1508 y|Y|yes|Yes)
1509 echo -n "Removing current sound card selection..."
1510 rm -f /var/lib/sound-card-driver
1511 rm -f /etc/asound.state ;;
1512 *)
1513 echo -n "Keeping current sound card selection..." ;;
1514 esac
1515 status
1517 # Optionally remove screen resolution
1518 echo -n "Do you wish to remove the screen resolution (No/yes/exit) ? "
1519 read anser
1520 case $anser in
1521 e|E|"exit"|Exit)
1522 exit 0 ;;
1523 y|Y|yes|Yes)
1524 echo -n "Removing current screen resolution..."
1525 rm -f /etc/X11/screen.conf
1526 rm -f /etc/X11/xorg.conf ;;
1527 *)
1528 echo -n "Keeping current screen resolution..." ;;
1529 esac
1530 status
1532 # Create list of files including default user files since it is defined in /etc/passwd
1533 # and some new users might have been added.
1534 find /bin /etc /init /sbin /var /dev /lib /root /usr /home >/tmp/list
1536 for dir in /proc /sys /tmp /mnt /media /media/cdrom /media/flash /media/usbdisk
1537 do
1538 echo $dir >>/tmp/list
1539 done
1541 # Generate initramfs with specified compression
1542 if [ "$COMPRESSION" = "lzma" ]; then
1543 echo -n "Creating rootfs.gz with lzma compression... "
1544 cat /tmp/list | cpio -o -H newc | lzma e -si -so > /rootfs.gz
1546 elif [ "$COMPRESSION" = "gzip" ]; then
1547 echo -n "Creating rootfs.gz with gzip compression... "
1548 cat /tmp/list | cpio -o -H newc | gzip -9 > /rootfs.gz
1550 else
1551 echo -n "Creating rootfs.gz without compression... "
1552 cat /tmp/list | cpio -o -H newc > /rootfs.gz
1553 fi
1554 status
1556 # Move freshly generated rootfs to the cdrom.
1557 mkdir -p $ROOTCD/boot
1558 mv /rootfs.gz $ROOTCD/boot
1560 # Now we need the kernel and isolinux files.
1561 if mount /dev/cdrom /media/cdrom 2>/dev/null; then
1562 cp /media/cdrom/boot/bzImage $ROOTCD/boot
1563 cp -a /media/cdrom/boot/isolinux $ROOTCD/boot
1564 umount /media/cdrom
1565 else
1566 echo -e "\nUnable to mount the cdrom to copy the Kernel and needed files.\n"
1567 exit 1
1568 fi
1570 # Generate the iso image.
1571 cd $DISTRO
1572 echo "Generating ISO image..."
1573 genisoimage -R -o $ISO_NAME.iso -b boot/isolinux/isolinux.bin \
1574 -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
1575 -V "SliTaz" -input-charset iso8859-1 -boot-info-table $ROOTCD
1576 if [ -x /usr/bin/isohybrid ]; then
1577 echo -n "Creating hybrid ISO..."
1578 /usr/bin/isohybrid $ISO_NAME.iso 2> /dev/null
1579 status
1580 fi
1581 echo -n "Creating the ISO md5sum..."
1582 md5sum $ISO_NAME.iso > $ISO_NAME.md5
1583 status
1585 echo "==============================================================================="
1586 echo "ISO image: `du -sh /home/slitaz/distro/$ISO_NAME.iso`"
1587 echo ""
1588 echo -n "Exit or burn ISO to cdrom (Exit|burn)? "; read anser
1589 case $anser in
1590 burn)
1591 eject
1592 echo -n "Please insert a blank cdrom and press ENTER..."
1593 read i && sleep 2
1594 tazlito burn-iso /home/slitaz/distro/$ISO_NAME.iso
1595 echo -en "----\nENTER to continue..."; read i ;;
1596 *)
1597 exit 0 ;;
1598 esac ;;
1599 burn-iso)
1600 # Guess cdrom device, ask user and burn the ISO.
1601 #
1602 check_root
1603 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
1604 DRIVE_SPEED=`cat /proc/sys/dev/cdrom/info | grep "drive speed" | cut -f 3`
1605 # We can specify an alternative ISO from the cmdline.
1606 if [ -n "$2" ] ; then
1607 iso=$2
1608 else
1609 iso=$DISTRO/$ISO_NAME.iso
1610 fi
1611 if [ ! -f "$iso" ]; then
1612 echo -e "\nUnable to find ISO : $iso\n"
1613 exit 0
1614 fi
1615 echo ""
1616 echo -e "\033[1mTazlito burn ISO\033[0m "
1617 echo "================================================================================"
1618 echo "Cdrom device : /dev/$DRIVE_NAME"
1619 echo "Drive speed : $DRIVE_SPEED"
1620 echo "ISO image : $iso"
1621 echo "================================================================================"
1622 echo ""
1623 yesorno "Burn ISO image (y/N) ? "
1624 if [ "$answer" == "y" ]; then
1625 echo ""
1626 echo "Starting Wodim to burn the iso..." && sleep 2
1627 echo "================================================================================"
1628 wodim speed=$DRIVE_SPEED dev=/dev/$DRIVE_NAME $iso
1629 echo "================================================================================"
1630 echo "ISO image is burned to cdrom."
1631 else
1632 echo -e "\nExiting. No ISO burned."
1633 fi
1634 echo ""
1635 ;;
1636 merge)
1637 # Merge multiple rootfs into one iso.
1638 #
1639 if [ -z "$2" ]; then
1640 cat << EOT
1641 Usage: tazlito merge size1 iso size2 rootfs2 [sizeN rootfsN]...
1643 Merge multiple rootfs into one iso. Rootfs are like russian dolls
1644 i.e: rootfsN is a subset of rootfsN-1
1645 rootfs1 is found in iso, sizeN is the RAM size need to launch rootfsN.
1646 The boot loader will select the rootfs according to the RAM size detected.
1648 Example:
1649 $ tazlito merge 160M slitaz-core.iso 96M rootfs-justx.gz 32M rootfs-base.gz
1651 Will start slitaz-core with 160M+ RAM, slitaz-justX with 96M-160M RAM,
1652 slitaz-base with 32M-96M RAM and display an error message if RAM < 32M.
1653 EOT
1654 exit 2
1655 fi
1657 shift # skip merge
1658 append="$1 slitaz1"
1659 shift # skip size1
1660 mkdir -p $TMP_DIR/mnt $TMP_DIR/rootfs1
1662 ISO=$1.merged
1663 # Extract filesystems
1664 echo -n "Mounting $1"
1665 mount -o loop,ro $1 $TMP_DIR/mnt 2> /dev/null
1666 status || cleanup_merge
1667 cp -a $TMP_DIR/mnt $TMP_DIR/iso
1668 rm -f $TMP_DIR/iso/boot/bzImage
1669 ln $TMP_DIR/iso/boot/vmlinuz* $TMP_DIR/iso/boot/bzImage
1670 umount -d $TMP_DIR/mnt
1671 if [ -f $TMP_DIR/iso/boot/rootfs1.gz ]; then
1672 echo "$1 is already a merged iso. Aborting."
1673 cleanup_merge
1674 fi
1675 if [ ! -f $TMP_DIR/iso/boot/isolinux/ifmem.c32 ]; then
1676 if [ ! -f /boot/isolinux/ifmem.c32 ]; then
1677 cat <<EOT
1678 No file /boot/isolinux/ifmem.c32
1679 Please install syslinux package !
1680 EOT
1681 rm -rf $TMP_DIR
1682 exit 1
1683 fi
1684 cp /boot/isolinux/ifmem.c32 $TMP_DIR/iso/boot/isolinux
1685 fi
1687 echo -n "Extracting iso/rootfs.gz"
1688 extract_rootfs $TMP_DIR/iso/boot/rootfs.gz $TMP_DIR/rootfs1 &&
1689 [ -d $TMP_DIR/rootfs1/etc ]
1690 status || cleanup_merge
1691 n=1
1692 while [ -n "$2" ]; do
1693 shift # skip rootfs N-1
1694 p=$n
1695 n=$(($n + 1))
1696 append="$append $1 slitaz$n"
1697 shift # skip size N
1698 mkdir -p $TMP_DIR/rootfs$n
1699 echo -n "Extracting $1"
1700 extract_rootfs $1 $TMP_DIR/rootfs$n &&
1701 [ -d $TMP_DIR/rootfs$n/etc ]
1702 status || cleanup_merge
1703 mergefs $TMP_DIR/rootfs$n $TMP_DIR/rootfs$p
1704 echo "Creating rootfs$p.gz"
1705 pack_rootfs $TMP_DIR/rootfs$p $TMP_DIR/iso/boot/rootfs$p.gz
1706 status
1707 done
1708 echo "Creating rootfs$n.gz"
1709 pack_rootfs $TMP_DIR/rootfs$n $TMP_DIR/iso/boot/rootfs$n.gz
1710 status
1711 rm -f $TMP_DIR/iso/boot/rootfs.gz
1712 update_bootconfig $TMP_DIR/iso/boot/isolinux "$append"
1713 echo "Generating $ISO"
1714 create_iso $ISO $TMP_DIR/iso
1715 rm -rf $TMP_DIR
1716 ;;
1718 repack)
1719 # Repack an iso with maximum lzma compression ratio.
1720 #
1722 ISO=$2
1724 mkdir -p $TMP_DIR/mnt
1725 # Extract filesystems
1726 echo -n "Mounting $ISO"
1727 mount -o loop,ro $ISO $TMP_DIR/mnt 2> /dev/null
1728 status || cleanup_merge
1729 cp -a $TMP_DIR/mnt $TMP_DIR/iso
1730 umount -d $TMP_DIR/mnt
1732 for i in $TMP_DIR/iso/boot/rootfs* ; do
1733 echo -n "Repacking $(basename $i)"
1734 (zcat $i || unlzma -c $i || cat $i) \
1735 2>/dev/null > $TMP_DIR/rootfs
1736 lzma e $TMP_DIR/rootfs $i \
1737 $(lzma_switches $TMP_DIR/rootfs)
1738 status
1739 done
1741 echo "Generating $ISO"
1742 create_iso $ISO $TMP_DIR/iso
1743 rm -rf $TMP_DIR ;;
1745 frugal-install|-fi)
1746 ISO_IMAGE="$2"
1747 echo ""
1748 mkdir -p /boot/frugal
1749 if [ -f "$ISO_IMAGE" ]; then
1750 echo -n "Using ISO image: $ISO_IMAGE"
1751 mkdir -p /tmp/iso && mount -o loop $ISO_IMAGE /tmp/iso
1752 status
1753 echo -n "Installing the Kernel and rootfs..."
1754 cp -a /tmp/iso/boot/bzImage /boot/frugal
1755 cp -a /tmp/iso/boot/rootfs.gz /boot/frugal
1756 umount /tmp/iso
1757 status
1758 else
1759 echo -n "Using distro: $DISTRO"
1760 cd $DISTRO && status
1761 echo -n "Installing the Kernel and rootfs..."
1762 cp -a $DISTRO/rootcd/boot/bzImage /boot/frugal
1763 cp -a $DISTRO/rootcd/boot/rootfs.gz /boot/frugal
1764 status
1765 fi
1766 # Grub entry
1767 if ! grep -q "^kernel /boot/frugal/bzImage" /boot/grub/menu.lst; then
1768 echo -n "Configuring GRUB menu list..."
1769 cat >> /boot/grub/menu.lst << EOT
1770 title SliTaz GNU/Linux (frugal)
1771 root (hd0,0)
1772 kernel /boot/frugal/bzImage root=/dev/null
1773 initrd /boot/frugal/rootfs.gz
1774 EOT
1775 else
1776 echo -n "GRUB menu list is up-to-date..."
1777 fi
1778 status
1779 echo "" ;;
1781 emu-iso)
1782 # Emulate an ISO image with Qemu.
1783 if [ -n "$2" ] ; then
1784 iso=$2
1785 else
1786 iso=$DISTRO/$ISO_NAME.iso
1787 fi
1788 if [ ! -f "$iso" ]; then
1789 echo -e "\nUnable to find ISO : $iso\n"
1790 exit 0
1791 fi
1792 if [ ! -x "/usr/bin/qemu" ]; then
1793 echo -e "\nUnable to find Qemu binary. Please install: qemu\n"
1794 exit 0
1795 fi
1796 echo -e "\nStarting Qemu emulator:\n"
1797 echo -e "qemu $QEMU_OPTS $iso\n"
1798 qemu $QEMU_OPTS $iso ;;
1800 usage|*)
1801 # Clear and print usage also for all unknown commands.
1802 #
1803 clear
1804 usage ;;
1805 esac
1807 exit 0