tazlito view tazlito @ rev 147

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