flavors view core/rootfs/usr/bin/tazlito @ rev 15

Keep 4 flavors + loram + 3in1 and add tmp addfiles for core
author Christophe Lincoln <pankso@slitaz.org>
date Tue Feb 02 22:26:52 2010 +0100 (2010-02-02)
parents
children
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 "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 echo ""
1123 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
1124 echo -n "Cleaning $DISTRO..."
1125 rm -R $DISTRO 2> /dev/null
1126 mkdir -p $DISTRO
1127 status
1128 mkdir $TMP_DIR
1129 echo -n "Extracting flavor $FLAVOR.flavor... "
1130 zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i 2>/dev/null )
1131 echo -n "Creating distro-packages.list..."
1132 mv $TMP_DIR/$FLAVOR.nonfree non-free.list 2> /dev/null
1133 mv $TMP_DIR/$FLAVOR.pkglist distro-packages.list
1134 status
1135 for i in rootcd rootfs; do
1136 if [ -f $TMP_DIR/$FLAVOR.$i ]; then
1137 echo -n "Adding $i... "
1138 mkdir -p "$ADDFILES/$i"
1139 zcat $TMP_DIR/$FLAVOR.$i | \
1140 ( cd "$ADDFILES/$i"; cpio -id 2> /dev/null)
1141 fi
1142 done
1143 if [ -s $TMP_DIR/$FLAVOR.mirrors ]; then
1144 n=""
1145 while read line; do
1146 mkdir -p $LOCALSTATE/undigest/$FLAVOR$n
1147 echo "$line" > $LOCALSTATE/undigest/$FLAVOR$n/mirror
1148 n=$(( $n + 1 ))
1149 done < $TMP_DIR/$FLAVOR.mirrors
1150 tazpkg recharge
1151 fi
1152 rm -f /etc/tazlito/rootfs.list
1153 grep -q '^Rootfs list' $TMP_DIR/$FLAVOR.desc &&
1154 grep '^Rootfs list' $TMP_DIR/$FLAVOR.desc | \
1155 sed 's/.*: \(.*\)$/\1/' > /etc/tazlito/rootfs.list
1156 echo -n "Updating tazlito.conf..."
1157 [ -f tazlito.conf ] || cp /etc/tazlito/tazlito.conf .
1158 cat tazlito.conf | grep -v "^#VOLUM_NAME" | \
1159 sed "s/^VOLUM_NA/VOLUM_NAME=\"SliTaz $FLAVOR\"\\n#VOLUM_NA/" \
1160 > tazlito.conf.$$ && mv tazlito.conf.$$ tazlito.conf
1161 sed -i "s/ISO_NAME=.*/ISO_NAME=\"slitaz-$FLAVOR\"/" tazlito.conf
1162 status
1163 rm -Rf $TMP_DIR
1164 fi
1165 echo ""
1166 ;;
1167 check-list)
1168 # Use current packages list in $PWD by default.
1169 DISTRO_PKGS_LIST=distro-packages.list
1170 [ -d "$2" ] && DISTRO_PKGS_LIST=$2/distro-packages.list
1171 [ -f "$2" ] && DISTRO_PKGS_LIST=$2
1172 [ ! -f $DISTRO_PKGS_LIST ] && echo "No packages list found." && exit 0
1173 echo ""
1174 echo -e "\033[1mLiveCD packages list check\033[0m"
1175 echo "================================================================================"
1176 for pkg in `cat $DISTRO_PKGS_LIST`
1177 do
1178 if ! grep -q "$pkg" /var/lib/tazpkg/packages.list; then
1179 echo "Update: $pkg"
1180 up=$(($up + 1))
1181 fi
1182 done
1183 [ -z $up ] && echo -e "List is up-to-date\n" && exit 0
1184 echo "================================================================================"
1185 echo -e "Updates: $up\n" ;;
1186 gen-distro)
1187 # Generate a live distro tree with a set of packages.
1189 check_root
1191 # Check if a package list was specified on cmdline.
1192 LIST_NAME="distro-packages.list"
1193 CDROM=""
1194 while [ -n "$2" ]; do
1195 case "$2" in
1196 --iso=*)
1197 CDROM="-o loop ${2#--iso=}"
1198 ;;
1199 --cdrom)
1200 CDROM="/dev/cdrom"
1201 ;;
1202 --force)
1203 DELETE_ROOTFS="true"
1204 ;;
1205 *) if [ ! -f "$2" ] ; then
1206 echo -e "\nUnable to find the specified packages list."
1207 echo -e "List name : $2\n"
1208 exit 1
1209 fi
1210 LIST_NAME=$2
1211 ;;
1212 esac
1213 shift
1214 done
1216 if [ -d $ROOTFS ] ; then
1217 # Delete $ROOTFS if --force is set on command line
1218 if [ ! -z $DELETE_ROOTFS ]; then
1219 rm -rf $ROOTFS
1220 unset $DELETE_ROOTFS
1221 else
1222 echo -e "\nA rootfs exists in : $DISTRO"
1223 echo -e "Please clean the distro tree or change directory path.\n"
1224 exit 0
1225 fi
1226 fi
1227 if [ ! -f "$LIST_NAME" -a -d $INSTALLED ] ; then
1228 # Build list with installed packages
1229 for i in $(ls $INSTALLED); do
1230 eval $(grep ^VERSION= $INSTALLED/$i/receipt)
1231 EXTRAVERSION=""
1232 eval $(grep ^EXTRAVERSION= $INSTALLED/$i/receipt)
1233 echo "$i-$VERSION$EXTRAVERSION" >> $LIST_NAME
1234 done
1235 fi
1236 # Exit if no list name.
1237 if [ ! -f "$LIST_NAME" ]; then
1238 echo -e "\nNo packages list found or specified. Please read the docs.\n"
1239 exit 0
1240 fi
1241 # Start generation.
1242 echo ""
1243 echo -e "\033[1mTazlito generating a distro\033[0m"
1244 echo "================================================================================"
1245 # Misc checks
1246 [ -n "$PACKAGES_REPOSITORY" ] || PACKAGES_REPOSITORY="."
1247 [ -d $PACKAGES_REPOSITORY ] || mkdir -p $PACKAGES_REPOSITORY
1248 # Get the list of packages using cat for a file list.
1249 LIST=`cat $LIST_NAME`
1250 # Verify if all packages in list are present in $PACKAGES_REPOSITORY.
1251 REPACK=""
1252 DOWNLOAD=""
1253 for pkg in $LIST
1254 do
1255 [ "$pkg" = "" ] && continue
1256 pkg=${pkg%.tazpkg}
1257 [ -f $PACKAGES_REPOSITORY/$pkg.tazpkg ] && continue
1258 PACKAGE=$(installed_package_name $pkg)
1259 [ -n "$PACKAGE" -a "$REPACK" = "y" ] && continue
1260 [ -z "$PACKAGE" -a -n "$DOWNLOAD" ] && continue
1261 echo -e "\nUnable to find $pkg in the repository."
1262 echo -e "Path : $PACKAGES_REPOSITORY\n"
1263 if [ -n "$PACKAGE" -a -z "$REPACK" ]; then
1264 yesorno "Repack packages from rootfs (y/N) ? "
1265 REPACK="$answer"
1266 [ "$answer" = "y" ] || REPACK="n"
1267 [ "$DOWNLOAD" = "y" ] && break
1268 fi
1269 if [ -f $MIRROR -a -z "$DOWNLOAD" ]; then
1270 yesorno "Download packages from mirror (Y/n) ? "
1271 DOWNLOAD="$answer"
1272 if [ "$answer" = "n" ]; then
1273 [ -z "$PACKAGE" ] && exit 1
1274 else
1275 DOWNLOAD="y"
1276 [ -n "$REPACK" ] && break
1277 fi
1278 fi
1279 [ "$REPACK" = "n" -a "$DOWNLOAD" = "n" ] && exit 1
1280 done
1282 # Mount cdrom to be able to repack boot-loader packages
1283 if [ ! -e /boot -a -n "$CDROM" ]; then
1284 mkdir $TMP_MNT
1285 if mount -r $CDROM $TMP_MNT 2> /dev/null; then
1286 ln -s $TMP_MNT/boot /
1287 if [ ! -d "$ADDFILES/rootcd" ] ; then
1288 mkdir -p $ADDFILES/rootcd
1289 for i in $(ls $TMP_MNT); do
1290 [ "$i" = "boot" ] && continue
1291 cp -a $TMP_MNT/$i $ADDFILES/rootcd
1292 done
1293 fi
1294 else
1295 rmdir $TMP_MNT
1296 fi
1297 fi
1299 # Root fs stuff.
1300 echo "Preparing the rootfs directory..."
1301 mkdir -p $ROOTFS
1302 sleep 2
1303 for pkg in $LIST
1304 do
1305 [ "$pkg" = "" ] && continue
1306 # First copy and extract the package in tmp dir.
1307 pkg=${pkg%.tazpkg}
1308 PACKAGE=$(installed_package_name $pkg)
1309 mkdir -p $TMP_DIR
1310 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
1311 # Look for package in cache
1312 if [ -f $CACHE_DIR/$pkg.tazpkg ]; then
1313 ln -s $CACHE_DIR/$pkg.tazpkg $PACKAGES_REPOSITORY
1314 # Look for package in running distribution
1315 elif [ -n "$PACKAGE" -a "$REPACK" = "y" ]; then
1316 tazpkg repack $PACKAGE && \
1317 mv $pkg.tazpkg $PACKAGES_REPOSITORY
1318 fi
1319 fi
1320 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
1321 # Get package from mirror
1322 [ "$DOWNLOAD" = "y" ] && \
1323 download $pkg.tazpkg && \
1324 mv $pkg.tazpkg $PACKAGES_REPOSITORY
1325 fi
1326 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
1327 echo "Missing package $pkg."
1328 cleanup
1329 exit 1
1330 fi
1331 done
1332 if [ -f non-free.list ]; then
1333 echo "Preparing non-free packages..."
1334 cp non-free.list $ROOTFS/etc/tazlito/non-free.list
1335 for pkg in $(cat non-free.list); do
1336 if [ ! -d $INSTALLED/$pkg ]; then
1337 if [ ! -d $INSTALLED/get-$pkg ]; then
1338 tazpkg get-install get-$pkg
1339 fi
1340 get-$pkg
1341 fi
1342 tazpkg repack $pkg
1343 pkg=$(ls $pkg*.tazpkg)
1344 grep -q "^$pkg$" $LIST_NAME || \
1345 echo $pkg >>$LIST_NAME
1346 mv $pkg $PACKAGES_REPOSITORY
1347 done
1348 fi
1349 echo ""
1350 cp $LIST_NAME $DISTRO/distro-packages.list
1351 sed 's/\(.*\)/\1.tazpkg/' < $DISTRO/distro-packages.list > $DISTRO/list-packages
1352 cd $PACKAGES_REPOSITORY
1353 yes y | tazpkg install-list \
1354 $DISTRO/list-packages --root=$ROOTFS
1355 cd $DISTRO
1356 cp distro-packages.list $ROOTFS/etc/tazlito
1357 # Copy all files from $ADDFILES/rootfs to the rootfs.
1358 if [ -d "$ADDFILES/rootfs" ] ; then
1359 echo -n "Copying addfiles content to the rootfs... "
1360 cp -a $ADDFILES/rootfs/* $ROOTFS
1361 status
1362 fi
1363 echo "Root file system is generated..."
1364 # Root CD part.
1365 echo -n "Preparing the rootcd directory..."
1366 mkdir -p $ROOTCD
1367 status
1368 # Move the boot dir with the Linux kernel from rootfs.
1369 # The boot dir goes directly on the CD.
1370 if [ -d "$ROOTFS/boot" ] ; then
1371 echo -n "Moving the boot directory..."
1372 mv $ROOTFS/boot $ROOTCD
1373 cd $ROOTCD/boot
1374 ln vmlinuz-* bzImage
1375 status
1376 fi
1377 cd $DISTRO
1378 # Copy all files from $ADDFILES/rootcd to the rootcd.
1379 if [ -d "$ADDFILES/rootcd" ] ; then
1380 echo -n "Copying addfiles content to the rootcd... "
1381 cp -a $ADDFILES/rootcd/* $ROOTCD
1382 status
1383 fi
1384 # Execute the distro script (used to perform tasks in the rootfs
1385 # before compression. Give rootfs path in arg
1386 [ -z $DISTRO_SCRIPT ] && DISTRO_SCRIPT=$TOP_DIR/distro.sh
1387 if [ -x $DISTRO_SCRIPT ]; then
1388 echo "Executing distro script..."
1389 sh $DISTRO_SCRIPT $DISTRO
1390 fi
1391 if [ -s /etc/tazlito/rootfs.list ]; then
1392 [ -f $ROOTCD/boot/isolinux/ifmem.c32 ] ||
1393 cp /boot/isolinux/ifmem.c32 $ROOTCD/boot/isolinux
1394 n=0
1395 last=$ROOTFS
1396 while read flavor; do
1397 n=$(($n+1))
1398 echo "Building $flavor rootfs..."
1399 download $flavor.flavor
1400 zcat $flavor.flavor | cpio -i $flavor.pkglist
1401 sed 's/.*/&.tazpkg/' < $flavor.pkglist \
1402 > $DISTRO/list-packages0$n
1403 mkdir ${ROOTFS}0$n
1404 cd $PACKAGES_REPOSITORY
1405 yes y | tazpkg install-list \
1406 $DISTRO/list-packages0$n --root=${ROOTFS}0$n
1407 rm -rf ${ROOTFS}0$n/boot
1408 status
1409 cd $DISTRO
1410 mv $flavor.pkglist ${ROOTFS}0$n/etc/tazlito/distro-packages.list
1411 rm -f $flavor.flavor install-list
1412 mergefs ${ROOTFS}0$n $last
1413 last=${ROOTFS}0$n
1414 done <<EOT
1415 $(awk '{ for (i = 4; i <= NF; i+=2) print $i; }' < /etc/tazlito/rootfs.list)
1416 EOT
1417 i=$(($n+1))
1418 while [ $n -gt 0 ]; do
1419 mv ${ROOTFS}0$n ${ROOTFS}$i
1420 echo "Compression ${ROOTFS}0$n ($(du -hs ${ROOTFS}$i | awk '{ print $1 }')) ..."
1421 gen_initramfs ${ROOTFS}$i
1422 n=$(($n-1))
1423 i=$(($i-1))
1424 done
1425 mv $ROOTFS ${ROOTFS}$i
1426 gen_initramfs ${ROOTFS}$i
1427 update_bootconfig $ROOTCD/boot/isolinux \
1428 "$(cat /etc/tazlito/rootfs.list)"
1429 else
1430 # Initramfs and ISO image stuff.
1431 gen_initramfs $ROOTFS
1432 fi
1433 gen_livecd_isolinux
1434 distro_stats
1435 cleanup
1436 ;;
1437 clean-distro)
1438 # Remove old distro tree.
1440 check_root
1441 echo ""
1442 echo -e "\033[1mCleaning :\033[0m $DISTRO"
1443 echo "================================================================================"
1444 if [ -d "$DISTRO" ] ; then
1445 if [ -d "$ROOTFS" ] ; then
1446 echo -n "Removing the rootfs..."
1447 rm -f $DISTRO/$INITRAMFS
1448 rm -rf $ROOTFS
1449 status
1450 fi
1451 if [ -d "$ROOTCD" ] ; then
1452 echo -n "Removing the rootcd..."
1453 rm -rf $ROOTCD
1454 status
1455 fi
1456 echo -n "Removing eventual ISO image..."
1457 rm -f $DISTRO/$ISO_NAME.iso
1458 rm -f $DISTRO/$ISO_NAME.md5
1459 status
1460 fi
1461 echo "================================================================================"
1462 echo ""
1463 ;;
1464 check-distro)
1465 # Check for a few LiveCD needed files not installed by packages.
1467 check_rootfs
1468 echo ""
1469 echo -e "\033[1mChecking distro :\033[0m $ROOTFS"
1470 echo "================================================================================"
1471 # SliTaz release info.
1472 if [ ! -f "$ROOTFS/etc/slitaz-release" ]; then
1473 echo "Missing release info : /etc/slitaz-release"
1474 else
1475 release=`cat $ROOTFS/etc/slitaz-release`
1476 echo -n "Release : $release"
1477 status
1478 fi
1479 # Tazpkg mirror.
1480 if [ ! -f "$ROOTFS/var/lib/tazpkg/mirror" ]; then
1481 echo -n "Mirror URL : Missing /var/lib/tazpkg/mirror"
1482 todomsg
1483 else
1484 echo -n "Mirror configuration exists..."
1485 status
1486 fi
1487 # Isolinux msg
1488 if grep -q "cooking-XXXXXXXX" /$ROOTCD/boot/isolinux/isolinux.msg; then
1489 echo -n "Isolinux msg : Missing cooking date XXXXXXXX (ex `date +%Y%m%d`)"
1490 todomsg
1491 else
1492 echo -n "Isolinux message seems good..."
1493 status
1494 fi
1495 echo "================================================================================"
1496 echo ""
1497 ;;
1498 writeiso)
1499 # Writefs to ISO image including /home unlike gen-distro we dont use
1500 # packages to generate a rootfs, we build a compressed rootfs with all
1501 # the current filesystem similar to 'tazusb writefs'.
1503 DISTRO="/home/slitaz/distro"
1504 ROOTCD="$DISTRO/rootcd"
1505 if [ -z $2 ]; then
1506 COMPRESSION=none
1507 else
1508 COMPRESSION=$2
1509 fi
1510 if [ -z $3 ]; then
1511 ISO_NAME="slitaz"
1512 else
1513 ISO_NAME="$3"
1514 fi
1515 check_root
1516 # Start info
1517 echo ""
1518 echo -e "\033[1mWrite filesystem to ISO\033[0m
1519 ===============================================================================
1520 The command writeiso will write the current filesystem into a suitable cpio
1521 archive (rootfs.gz) and generate a bootable ISO image (slitaz.iso).
1523 Archive compression: $COMPRESSION"
1524 echo ""
1526 # Save some space
1527 rm /var/cache/tazpkg/* -r -f
1528 rm -rf /home/slitaz/distro
1530 # Optionally remove sound card selection and screen resolution.
1531 echo "Do you wish to remove the sound card and screen config ? "
1532 echo -n "Press ENTER to keep or anser (No|yes|exit): "
1533 read anser
1534 case $anser in
1535 e|E|"exit"|Exit)
1536 exit 0 ;;
1537 y|Y|yes|Yes)
1538 echo -n "Removing current sound card and screen configuration..."
1539 rm -f /var/lib/sound-card-driver
1540 rm -f /etc/asound.state
1541 rm -f /etc/X11/screen.conf
1542 rm -f /etc/X11/xorg.conf ;;
1543 *)
1544 echo -n "Keeping current sound card and screen configuration..." ;;
1545 esac
1546 status
1548 # Create list of files including default user files since it is defined in /etc/passwd
1549 # and some new users might have been added.
1550 find /bin /etc /init /sbin /var /dev /lib /root /usr /home >/tmp/list
1552 for dir in /proc /sys /tmp /mnt /media /media/cdrom /media/flash /media/usbdisk
1553 do
1554 echo $dir >>/tmp/list
1555 done
1557 # Generate initramfs with specified compression and display rootf
1558 # size in realtime.
1559 rm -f /tmp/rootfs
1560 write_initramfs &
1561 sleep 2
1562 echo -en "\nFilesystem size:"
1563 while [ ! -f /tmp/rootfs ]
1564 do
1565 sleep 1
1566 echo -en "\\033[18G`du -sh /rootfs.gz | awk '{print $1}'` "
1567 done
1568 echo -e "\n"
1570 # Move freshly generated rootfs to the cdrom.
1571 mkdir -p $ROOTCD/boot
1572 mv -f /rootfs.gz $ROOTCD/boot
1574 # Now we need the kernel and isolinux files.
1575 if mount /dev/cdrom /media/cdrom 2>/dev/null; then
1576 cp /media/cdrom/boot/bzImage $ROOTCD/boot
1577 cp -a /media/cdrom/boot/isolinux $ROOTCD/boot
1578 umount /media/cdrom
1579 else
1580 echo -e "
1581 Unable to mount the cdrom to copy the Kernel and needed files. When SliTaz
1582 is running in RAM the kernel and bootloader files are keeped on the cdrom.
1583 Please insert a LiveCD or unmount curent cdrom to let Tazlito handle the media.\n"
1584 echo -en "----\nENTER to continue..."; read i
1585 exit 1
1586 fi
1588 # Generate the iso image.
1589 cd $DISTRO
1590 echo "Generating ISO image..."
1591 genisoimage -R -o $ISO_NAME.iso -b boot/isolinux/isolinux.bin \
1592 -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
1593 -V "SliTaz" -input-charset iso8859-1 -boot-info-table $ROOTCD
1594 if [ -x /usr/bin/isohybrid ]; then
1595 echo -n "Creating hybrid ISO..."
1596 /usr/bin/isohybrid $ISO_NAME.iso 2> /dev/null
1597 status
1598 fi
1599 echo -n "Creating the ISO md5sum..."
1600 md5sum $ISO_NAME.iso > $ISO_NAME.md5
1601 status
1603 echo "==============================================================================="
1604 echo "ISO image: `du -sh /home/slitaz/distro/$ISO_NAME.iso`"
1605 echo ""
1606 echo -n "Exit or burn ISO to cdrom (Exit|burn)? "; read anser
1607 case $anser in
1608 burn)
1609 eject
1610 echo -n "Please insert a blank cdrom and press ENTER..."
1611 read i && sleep 2
1612 tazlito burn-iso /home/slitaz/distro/$ISO_NAME.iso
1613 echo -en "----\nENTER to continue..."; read i ;;
1614 *)
1615 exit 0 ;;
1616 esac ;;
1617 burn-iso)
1618 # Guess cdrom device, ask user and burn the ISO.
1620 check_root
1621 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
1622 DRIVE_SPEED=`cat /proc/sys/dev/cdrom/info | grep "drive speed" | cut -f 3`
1623 # We can specify an alternative ISO from the cmdline.
1624 if [ -n "$2" ] ; then
1625 iso=$2
1626 else
1627 iso=$DISTRO/$ISO_NAME.iso
1628 fi
1629 if [ ! -f "$iso" ]; then
1630 echo -e "\nUnable to find ISO : $iso\n"
1631 exit 0
1632 fi
1633 echo ""
1634 echo -e "\033[1mTazlito burn ISO\033[0m "
1635 echo "================================================================================"
1636 echo "Cdrom device : /dev/$DRIVE_NAME"
1637 echo "Drive speed : $DRIVE_SPEED"
1638 echo "ISO image : $iso"
1639 echo "================================================================================"
1640 echo ""
1641 yesorno "Burn ISO image (y/N) ? "
1642 if [ "$answer" == "y" ]; then
1643 echo ""
1644 echo "Starting Wodim to burn the iso..." && sleep 2
1645 echo "================================================================================"
1646 wodim speed=$DRIVE_SPEED dev=/dev/$DRIVE_NAME $iso
1647 echo "================================================================================"
1648 echo "ISO image is burned to cdrom."
1649 else
1650 echo -e "\nExiting. No ISO burned."
1651 fi
1652 echo ""
1653 ;;
1654 merge)
1655 # Merge multiple rootfs into one iso.
1657 if [ -z "$2" ]; then
1658 cat << EOT
1659 Usage: tazlito merge size1 iso size2 rootfs2 [sizeN rootfsN]...
1661 Merge multiple rootfs into one iso. Rootfs are like russian dolls
1662 i.e: rootfsN is a subset of rootfsN-1
1663 rootfs1 is found in iso, sizeN is the RAM size need to launch rootfsN.
1664 The boot loader will select the rootfs according to the RAM size detected.
1666 Example:
1667 $ tazlito merge 160M slitaz-core.iso 96M rootfs-justx.gz 32M rootfs-base.gz
1669 Will start slitaz-core with 160M+ RAM, slitaz-justX with 96M-160M RAM,
1670 slitaz-base with 32M-96M RAM and display an error message if RAM < 32M.
1671 EOT
1672 exit 2
1673 fi
1675 shift # skip merge
1676 append="$1 slitaz1"
1677 shift # skip size1
1678 mkdir -p $TMP_DIR/mnt $TMP_DIR/rootfs1
1680 ISO=$1.merged
1681 # Extract filesystems
1682 echo -n "Mounting $1"
1683 mount -o loop,ro $1 $TMP_DIR/mnt 2> /dev/null
1684 status || cleanup_merge
1685 cp -a $TMP_DIR/mnt $TMP_DIR/iso
1686 rm -f $TMP_DIR/iso/boot/bzImage
1687 ln $TMP_DIR/iso/boot/vmlinuz* $TMP_DIR/iso/boot/bzImage
1688 umount -d $TMP_DIR/mnt
1689 if [ -f $TMP_DIR/iso/boot/rootfs1.gz ]; then
1690 echo "$1 is already a merged iso. Aborting."
1691 cleanup_merge
1692 fi
1693 if [ ! -f $TMP_DIR/iso/boot/isolinux/ifmem.c32 ]; then
1694 if [ ! -f /boot/isolinux/ifmem.c32 ]; then
1695 cat <<EOT
1696 No file /boot/isolinux/ifmem.c32
1697 Please install syslinux package !
1698 EOT
1699 rm -rf $TMP_DIR
1700 exit 1
1701 fi
1702 cp /boot/isolinux/ifmem.c32 $TMP_DIR/iso/boot/isolinux
1703 fi
1705 echo -n "Extracting iso/rootfs.gz"
1706 extract_rootfs $TMP_DIR/iso/boot/rootfs.gz $TMP_DIR/rootfs1 &&
1707 [ -d $TMP_DIR/rootfs1/etc ]
1708 status || cleanup_merge
1709 n=1
1710 while [ -n "$2" ]; do
1711 shift # skip rootfs N-1
1712 p=$n
1713 n=$(($n + 1))
1714 append="$append $1 slitaz$n"
1715 shift # skip size N
1716 mkdir -p $TMP_DIR/rootfs$n
1717 echo -n "Extracting $1"
1718 extract_rootfs $1 $TMP_DIR/rootfs$n &&
1719 [ -d $TMP_DIR/rootfs$n/etc ]
1720 status || cleanup_merge
1721 mergefs $TMP_DIR/rootfs$n $TMP_DIR/rootfs$p
1722 echo "Creating rootfs$p.gz"
1723 pack_rootfs $TMP_DIR/rootfs$p $TMP_DIR/iso/boot/rootfs$p.gz
1724 status
1725 done
1726 echo "Creating rootfs$n.gz"
1727 pack_rootfs $TMP_DIR/rootfs$n $TMP_DIR/iso/boot/rootfs$n.gz
1728 status
1729 rm -f $TMP_DIR/iso/boot/rootfs.gz
1730 update_bootconfig $TMP_DIR/iso/boot/isolinux "$append"
1731 echo "Generating $ISO"
1732 create_iso $ISO $TMP_DIR/iso
1733 rm -rf $TMP_DIR
1734 ;;
1736 repack)
1737 # Repack an iso with maximum lzma compression ratio.
1740 ISO=$2
1742 mkdir -p $TMP_DIR/mnt
1743 # Extract filesystems
1744 echo -n "Mounting $ISO"
1745 mount -o loop,ro $ISO $TMP_DIR/mnt 2> /dev/null
1746 status || cleanup_merge
1747 cp -a $TMP_DIR/mnt $TMP_DIR/iso
1748 umount -d $TMP_DIR/mnt
1750 for i in $TMP_DIR/iso/boot/rootfs* ; do
1751 echo -n "Repacking $(basename $i)"
1752 (zcat $i || unlzma -c $i || cat $i) \
1753 2>/dev/null > $TMP_DIR/rootfs
1754 lzma e $TMP_DIR/rootfs $i \
1755 $(lzma_switches $TMP_DIR/rootfs)
1756 status
1757 done
1759 echo "Generating $ISO"
1760 create_iso $ISO $TMP_DIR/iso
1761 rm -rf $TMP_DIR ;;
1763 frugal-install|-fi)
1764 ISO_IMAGE="$2"
1765 echo ""
1766 mkdir -p /boot/frugal
1767 if [ -f "$ISO_IMAGE" ]; then
1768 echo -n "Using ISO image: $ISO_IMAGE"
1769 mkdir -p /tmp/iso && mount -o loop $ISO_IMAGE /tmp/iso
1770 status
1771 echo -n "Installing the Kernel and rootfs..."
1772 cp -a /tmp/iso/boot/bzImage /boot/frugal
1773 cp -a /tmp/iso/boot/rootfs.gz /boot/frugal
1774 umount /tmp/iso
1775 status
1776 else
1777 echo -n "Using distro: $DISTRO"
1778 cd $DISTRO && status
1779 echo -n "Installing the Kernel and rootfs..."
1780 cp -a $DISTRO/rootcd/boot/bzImage /boot/frugal
1781 cp -a $DISTRO/rootcd/boot/rootfs.gz /boot/frugal
1782 status
1783 fi
1784 # Grub entry
1785 if ! grep -q "^kernel /boot/frugal/bzImage" /boot/grub/menu.lst; then
1786 echo -n "Configuring GRUB menu list..."
1787 cat >> /boot/grub/menu.lst << EOT
1788 title SliTaz GNU/Linux (frugal)
1789 root (hd0,0)
1790 kernel /boot/frugal/bzImage root=/dev/null
1791 initrd /boot/frugal/rootfs.gz
1792 EOT
1793 else
1794 echo -n "GRUB menu list is up-to-date..."
1795 fi
1796 status
1797 echo "" ;;
1799 emu-iso)
1800 # Emulate an ISO image with Qemu.
1801 if [ -n "$2" ] ; then
1802 iso=$2
1803 else
1804 iso=$DISTRO/$ISO_NAME.iso
1805 fi
1806 if [ ! -f "$iso" ]; then
1807 echo -e "\nUnable to find ISO : $iso\n"
1808 exit 0
1809 fi
1810 if [ ! -x "/usr/bin/qemu" ]; then
1811 echo -e "\nUnable to find Qemu binary. Please install: qemu\n"
1812 exit 0
1813 fi
1814 echo -e "\nStarting Qemu emulator:\n"
1815 echo -e "qemu $QEMU_OPTS $iso\n"
1816 qemu $QEMU_OPTS $iso ;;
1818 usage|*)
1819 # Clear and print usage also for all unknown commands.
1821 clear
1822 usage ;;
1823 esac
1825 exit 0