tazlito view tazlito @ rev 105

Add tazlito upgrade-flavor
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Aug 19 23:14:06 2009 +0200 (2009-08-19)
parents 78b1b9a2e4fe
children b322fa520f21
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-2009 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 doc"
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
65 #####################
66 # Tazlito functions #
67 #####################
69 # Print the usage.
70 usage ()
71 {
72 echo -e "\nSliTaz Live Tool - Version: $VERSION\n
73 \033[1mUsage: \033[0m `basename $0` [command] [list|iso|flavor] [dir]
74 \033[1mCommands: \033[0m\n
75 usage Print this short usage.
76 stats View Tazlito and distro configuration statistics.
77 gen-config Generate a new configuration file for a distro.
78 configure Configure the main config file or a specific tazlito.conf.
79 gen-iso Generate a new ISO from a distro tree.
80 gen-initiso Generate a new initramfs and ISO from the distro tree.
81 list-flavors List all available package lists on the mirror.
82 gen-flavor Generate a new live-CD description.
83 gen-liveflavor Generate a live-CD description from current system.
84 show-flavor Show live-CD description.
85 get-flavor Get a flavor's list of packages.
86 upgrade-flavor Update package list to the latest available versions.
87 check-list Check a distro-packages.list for updates.
88 extract-distro Extract an ISO to a directory and rebuild LiveCD tree.
89 gen-distro Generate a Live distro and ISO from a list of packages.
90 clean-distro Remove all files generated by gen-distro.
91 check-distro Help to check if distro is ready to release.
92 merge Merge multiple rootfs into one iso.
93 repack Recompress rootfs into iso with maximum ratio.
94 burn-iso Burn ISO image to a cdrom using Wodim.\n"
95 }
97 # Status function.
98 status()
99 {
100 local CHECK=$?
101 echo -en "\\033[70G[ "
102 if [ $CHECK = 0 ]; then
103 echo -en "\\033[1;33mOK"
104 else
105 echo -en "\\033[1;31mFailed"
106 fi
107 echo -e "\\033[0;39m ]"
108 return $CHECK
109 }
111 yesorno()
112 {
113 echo -n "$1"
114 case "$DEFAULT_ANSWER" in
115 Y|y) answer="y";;
116 N|n) answer="n";;
117 *) read answer;;
118 esac
119 }
121 field()
122 {
123 grep "^$1" "$2" | sed 's/.*: \([0-9KMG\.]*\).*/\1/'
124 }
126 todomsg()
127 {
128 echo -e "\\033[70G[ \\033[1;31mTODO\\033[0;39m ]"
129 }
131 # Download a file from this mirror
132 download_from()
133 {
134 local i
135 local mirrors
136 mirrors="$1"
137 shift
138 for i in $mirrors; do
139 case "$i" in
140 http://*|ftp://*) wget -c $i$@ && break;;
141 *) cp $i/$1 . && break;;
142 esac
143 done
144 }
146 # Download a file trying all mirrors
147 download()
148 {
149 local i
150 for i in $(cat $MIRROR $LOCALSTATE/undigest/*/mirror 2> /dev/null); do
151 download_from "$i" "$@" && break
152 done
153 }
155 # Execute hooks provided by some packages
156 genisohooks()
157 {
158 local here=`pwd`
159 cd $ROOTFS
160 for i in $(ls etc/tazlito/*.$1 2> /dev/null); do
161 . $i $ROOTCD
162 done
163 cd $here
164 }
166 cleanup()
167 {
168 if [ -d $TMP_MNT ]; then
169 umount $TMP_MNT
170 rmdir $TMP_MNT
171 rm -f /boot
172 fi
173 }
175 # Echo the package name if the tazpkg is already installed
176 installed_package_name()
177 {
178 local tazpkg
179 local package
180 local VERSION
181 local EXTRAVERSION
182 tazpkg=$1
183 # Try to find package name and version to be able
184 # to repack it from installation
185 # A dash (-) can exist in name *and* in version
186 package=${tazpkg%-*}
187 i=$package
188 while true; do
189 VERSION=""
190 eval $(grep -s ^VERSION= $INSTALLED/$i/receipt)
191 EXTRAVERSION=""
192 eval $(grep -s ^EXTRAVERSION= $INSTALLED/$i/receipt)
193 if [ "$i-$VERSION$EXTRAVERSION" = "$tazpkg" ]; then
194 echo $i
195 break
196 fi
197 case "$i" in
198 *-*);;
199 *) break;;
200 esac
201 i=${i%-*}
202 done
203 }
205 # Check if user is root.
206 check_root()
207 {
208 if test $(id -u) != 0 ; then
209 echo -e "\nYou must be root to run `basename $0` with this option."
210 echo -e "Please type 'su' and root password to become super-user.\n"
211 exit 0
212 fi
213 }
215 # Check for the rootfs tree.
216 check_rootfs()
217 {
218 if [ ! -d "$ROOTFS/etc" ] ; then
219 echo -e "\nUnable to find a distro rootfs...\n"
220 exit 0
221 fi
222 }
224 # Check for the boot dir into the root CD tree.
225 verify_rootcd()
226 {
227 if [ ! -d "$ROOTCD/boot" ] ; then
228 echo -e "\nUnable to find the rootcd boot directory...\n"
229 exit 0
230 fi
231 }
233 create_iso()
234 {
235 genisoimage -R -o $1 -b boot/isolinux/isolinux.bin \
236 -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
237 -V "$VOLUM_NAME" -p "$PREPARED" -input-charset iso8859-1 \
238 -boot-info-table $2
239 if [ -x /usr/bin/isohybrid ]; then
240 echo -n "Create hybrid ISO..."
241 /usr/bin/isohybrid $1 2> /dev/null
242 status
243 fi
244 }
246 # Generate a new ISO image using isolinux.
247 gen_livecd_isolinux()
248 {
249 # Some packages may want to alter iso
250 genisohooks iso
251 if [ ! -f "$ROOTCD/boot/isolinux/isolinux.bin" ]; then
252 echo -e "\nUnable to find isolinux binary.\n"
253 cleanup
254 exit 0
255 fi
256 # Set date for boot msg.
257 if grep -q 'XXXXXXXX' $ROOTCD/boot/isolinux/isolinux.msg; then
258 DATE=`date +%Y%m%d`
259 echo -n "Setting build date to: $DATE..."
260 sed -i s/'XXXXXXXX'/"$DATE"/ $ROOTCD/boot/isolinux/isolinux.msg
261 status
262 fi
263 cd $ROOTCD
264 echo -n "Computing md5..."
265 find * -type f ! -name md5sum -exec md5sum {} \; > md5sum
266 status
267 cd $DISTRO
268 echo ""
269 echo -e "\033[1mGenerating ISO image\033[0m"
270 echo "================================================================================"
271 create_iso $ISO_NAME.iso $ROOTCD
272 echo -n "Creating the ISO md5sum..."
273 md5sum $ISO_NAME.iso > $ISO_NAME.md5
274 status
275 echo "================================================================================"
276 # Some packages may want to alter final iso
277 genisohooks final
278 }
280 lzma_history_bits()
281 {
282 local n
283 local sz
284 n=20 # 1Mb
285 sz=$(du -sk $1 | cut -f1)
286 while [ $sz -gt 1024 -a $n -lt 28 ]; do
287 n=$(( $n + 1 ))
288 sz=$(( $sz / 2 ))
289 done
290 echo $n
291 }
293 # Pack rootfs
294 pack_rootfs()
295 {
296 ( cd $1 ; find . -print | cpio -o -H newc ) | \
297 if [ "$COMPRESSION" = "none" ]; then
298 echo -n "Generating uncompressed initramfs... "
299 cat > $2
300 elif [ -x /usr/bin/lzma -a "$COMPRESSION" != "gzip" ]; then
301 echo -n "Generating lzma'ed initramfs... "
302 lzma e -si -so -d$(lzma_history_bits $1) > $2
303 else
304 echo -n "Generating gziped initramfs... "
305 gzip -9 > $2
306 fi
307 }
309 # Generate a new initramfs from the root filesystem.
310 gen_initramfs()
311 {
312 # Just in case CTRL+c
313 rm -f $DISTRO/gen
314 # Some packages may want to alter rootfs
315 genisohooks rootfs
316 cd $ROOTFS
317 echo ""
319 # Link duplicate files
320 find . -type f -size +0c -exec stat -c '%s-%a-%u-%g %i %h %n' {} \; | \
321 sort | ( save=0; old_attr=""; old_inode=""; old_link=""; old_file=""
322 while read attr inode link file; do
323 if [ "$attr" = "$old_attr" -a "$inode" != "$old_inode" ]; then
324 if cmp "$file" "$old_file" >/dev/null; then
325 rm -f "$file"
326 ln "$old_file" "$file"
327 inode="$old_inode"
328 [ "$link" = "1" ] && save="$(expr $save + ${attr%%-*})"
329 fi
330 fi
331 old_attr="$attr" ; old_inode="$inode" ; old_file="$file"
332 done
333 echo "$save bytes saved in duplicate files."
334 )
336 # Use lzma if installed
337 pack_rootfs . $DISTRO/$INITRAMFS
338 cd $DISTRO
339 mv $INITRAMFS $ROOTCD/boot
340 }
342 distro_sizes()
343 {
344 echo "Build date : `date +%Y%m%d\ \at\ \%H:%M:%S`"
345 echo "Packages : `ls -1 $ROOTFS$INSTALLED | wc -l`"
346 echo "Rootfs size : `du -sh $ROOTFS | awk '{ print $1 }'`"
347 echo "Initramfs size : `du -sh $ROOTCD/boot/$INITRAMFS | awk '{ print $1 }'`"
348 echo "ISO image size : `du -sh $ISO_NAME.iso | awk '{ print $1 }'`"
349 echo "================================================================================"
350 echo "Image is ready: $ISO_NAME.iso"
351 echo ""
352 }
354 # Print ISO and rootfs size.
355 distro_stats()
356 {
357 echo ""
358 echo -e "\033[1mDistro statistics\033[0m ($DISTRO)"
359 echo "================================================================================"
360 distro_sizes
361 }
363 # Create an empty configuration file.
364 empty_config_file()
365 {
366 cat >> tazlito.conf << "EOF"
367 # tazlito.conf: Tazlito (SliTaz Live Tool)
368 # configuration file.
369 #
371 # Name of the ISO image to generate.
372 ISO_NAME=""
374 # ISO image volume name.
375 VOLUM_NAME="SliTaz"
377 # Name of the preparer.
378 PREPARED="$USER"
380 # Path to the packages repository and the packages.list.
381 PACKAGES_REPOSITORY=""
383 # Path to the distro tree to gen-distro from a
384 # list of packages.
385 DISTRO=""
387 # Path to the directory containing additional files
388 # to copy into the rootfs and rootcd of the LiveCD.
389 ADDFILES="$DISTRO/addfiles"
391 # Default answer for binary question (Y or N)
392 DEFAULT_ANSWER="ASK"
394 # Compression utility (lzma, gzip or none)
395 COMPRESSION="lzma"
396 EOF
397 }
399 # extract rootfs.gz somewhere
400 extract_rootfs()
401 {
402 (zcat $1 || unlzma -c $1 || cat $1) 2>/dev/null | \
403 (cd $2; cpio -idm > /dev/null)
404 }
406 # Remove duplicate files
407 mergefs()
408 {
409 # merge symlinks files and devices
410 ( cd $1; find ) | while read file; do
411 if [ -L $1/$file ]; then
412 [ -L $2/$file ] &&
413 [ "$(readlink $1/$file)" == "$(readlink $2/$file)" ] &&
414 rm -f $2/$file
415 elif [ -f $1/$file ]; then
416 [ -f $2/$file ] &&
417 cmp $1/$file $2/$file > /dev/null 2>&1 && rm -f $2/$file
418 [ -f $2/$file ] &&
419 [ "$(basename $file)" == "volatile.cpio.gz" ] &&
420 [ "$(dirname $(dirname $file))" == \
421 "./var/lib/tazpkg/installed" ] && rm -f $2/$file
422 elif [ -b $1/$file ]; then
423 [ -b $2/$file ] && rm -f $2/$file
424 elif [ -c $1/$file ]; then
425 [ -c $2/$file ] && rm -f $2/$file
426 fi
427 done
429 # cleanup directories
430 ( cd $1; find ) | while read file; do
431 if [ -d $1/$file ]; then
432 [ -d $2/$file ] && rmdir $2/$file 2> /dev/null
433 fi
434 done
435 true
436 }
438 cleanup_merge()
439 {
440 rm -rf $TMP_DIR
441 exit 1
442 }
444 ####################
445 # Tazlito commands #
446 ####################
448 case "$COMMAND" in
449 stats)
450 # Tazlito general statistics from the config file.
451 #
452 echo ""
453 echo -e "\033[1mTazlito statistics\033[0m
454 ===============================================================================
455 Config file : $CONFIG_FILE
456 ISO name : $ISO_NAME.iso
457 Volume name : $VOLUM_NAME
458 Prepared : $PREPARED
459 Packages repository : $PACKAGES_REPOSITORY
460 Distro directory : $DISTRO"
461 if [ ! "$ADDFILES" = "" ] ; then
462 echo -e "Additional files : $ADDFILES"
463 fi
464 echo "================================================================================"
465 echo ""
466 ;;
467 gen-config)
468 # Generate a new config file in the current dir or the specified
469 # directory by $2.
470 #
471 if [ -n "$2" ] ; then
472 mkdir -p $2 && cd $2
473 fi
474 echo -n "Generating empty tazlito.conf..."
475 empty_config_file
476 status
477 echo ""
478 if [ -f "tazlito.conf" ] ; then
479 echo "Configuration file is ready to edit."
480 echo "File location : `pwd`/tazlito.conf"
481 echo ""
482 fi
483 ;;
484 configure)
485 # Configure a tazlito.conf config file. Start by getting
486 # a empty config file and sed it.
487 #
488 if [ -f "tazlito.conf" ] ; then
489 rm tazlito.conf
490 else
491 if test $(id -u) = 0 ; then
492 cd /etc
493 else
494 echo "You must be root to configure the main config file or in"
495 echo "the same directory of the file you want to configure."
496 exit 0
497 fi
498 fi
499 empty_config_file
500 echo""
501 echo -e "\033[1mConfiguring :\033[0m `pwd`/tazlito.conf"
502 echo "================================================================================"
503 # ISO name.
504 echo -n "ISO name : " ; read answer
505 sed -i s#'ISO_NAME=\"\"'#"ISO_NAME=\"$answer\""# tazlito.conf
506 # Volume name.
507 echo -n "Volume name : " ; read answer
508 sed -i s/'VOLUM_NAME=\"SliTaz\"'/"VOLUM_NAME=\"$answer\""/ tazlito.conf
509 # Packages repository.
510 echo -n "Packages repository : " ; read answer
511 sed -i s#'PACKAGES_REPOSITORY=\"\"'#"PACKAGES_REPOSITORY=\"$answer\""# tazlito.conf
512 # Distro path.
513 echo -n "Distro path : " ; read answer
514 sed -i s#'DISTRO=\"\"'#"DISTRO=\"$answer\""# tazlito.conf
515 echo "================================================================================"
516 echo "Config file is ready to use."
517 echo "You can now extract an ISO or generate a distro."
518 echo ""
519 ;;
520 gen-iso)
521 # Simply generate a new iso.
522 #
523 check_root
524 verify_rootcd
525 gen_livecd_isolinux
526 distro_stats
527 ;;
528 gen-initiso)
529 # Simply generate a new initramfs with a new iso.
530 #
531 check_root
532 verify_rootcd
533 gen_initramfs
534 gen_livecd_isolinux
535 distro_stats
536 ;;
537 extract-distro)
538 # Extract an ISO image to a directory and rebuild the LiveCD tree.
539 #
540 check_root
541 ISO_IMAGE=$2
542 if [ -z "$ISO_IMAGE" ] ; then
543 echo -e "\nPlease specify the path to the ISO image."
544 echo -e "Example : `basename $0` image.iso /path/target\n"
545 exit 0
546 fi
547 # Set the distro path by checking for $3 on cmdline.
548 if [ -n "$3" ] ; then
549 TARGET=$3
550 else
551 TARGET=$DISTRO
552 fi
553 # Exit if existing distro is found.
554 if [ -d "$TARGET/rootfs" ] ; then
555 echo -e "\nA rootfs exists in : $TARGET"
556 echo -e "Please clean the distro tree or change directory path.\n"
557 exit 0
558 fi
559 echo ""
560 echo -e "\033[1mTazlito extracting :\033[0m `basename $ISO_IMAGE`"
561 echo "================================================================================"
562 # Start to mount the ISO.
563 echo ""
564 echo "Mounting ISO image..."
565 mkdir -p $TMP_DIR
566 # Get ISO file size.
567 isosize=`du -sh $ISO_IMAGE | cut -f1`
568 mount -o loop $ISO_IMAGE $TMP_DIR
569 sleep 2
570 # Prepare target dir, copy the kernel and the rootfs.
571 mkdir -p $TARGET/rootfs
572 mkdir -p $TARGET/rootcd/boot
573 echo -n "Copying the Linux kernel..."
574 if cp $TMP_DIR/boot/vmlinuz* $TARGET/rootcd/boot 2> /dev/null; then
575 ln $TARGET/rootcd/boot/vmlinuz* $TARGET/rootcd/boot/bzImage
576 else
577 cp $TMP_DIR/boot/bzImage $TARGET/rootcd/boot
578 fi
579 status
580 echo -n "Copying isolinux files..."
581 cp -a $TMP_DIR/boot/isolinux $TARGET/rootcd/boot
582 for i in $(ls $TMP_DIR); do
583 [ "$i" = "boot" ] && continue
584 cp -a $TMP_DIR/$i $TARGET/rootcd
585 done
586 status
587 if [ -d $TMP_DIR/boot/syslinux ]; then
588 echo -n "Copying syslinux files..."
589 cp -a $TMP_DIR/boot/syslinux $TARGET/rootcd/boot
590 status
591 fi
592 if [ -d $TMP_DIR/boot/extlinux ]; then
593 echo -n "Copying extlinux files..."
594 cp -a $TMP_DIR/boot/extlinux $TARGET/rootcd/boot
595 status
596 fi
597 if [ -d $TMP_DIR/boot/grub ]; then
598 echo -n "Copying GRUB files..."
599 cp -a $TMP_DIR/boot/grub $TARGET/rootcd/boot
600 status
601 fi
603 echo -n "Copying the rootfs..."
604 cp $TMP_DIR/boot/rootfs.?z $TARGET/rootcd/boot
605 status
606 # Extract initramfs.
607 cd $TARGET/rootfs
608 echo -n "Extracting the rootfs... "
609 extract_rootfs ../rootcd/boot/rootfs.gz $TARGET/rootfs
610 # unpack /usr
611 for i in etc/tazlito/*.extract; do
612 [ -f "$i" ] && . $i ../rootcd
613 done
614 # Umount and remove temp directory and cd to $TARGET to get stats.
615 umount $TMP_DIR && rm -rf $TMP_DIR
616 cd ..
617 echo ""
618 echo "================================================================================"
619 echo "Extracted : `basename $ISO_IMAGE` ($isosize)"
620 echo "Distro tree : `pwd`"
621 echo "Rootfs size : `du -sh rootfs`"
622 echo "Rootcd size : `du -sh rootcd`"
623 echo "================================================================================"
624 echo ""
625 ;;
626 list-flavors)
627 # Show available flavors.
628 if [ ! -s /etc/tazlito/flavors.list -o "$2" == "--recharge" ]; then
629 download flavors.list -O - > /etc/tazlito/flavors.list
630 fi
631 echo ""
632 echo -e "\033[1mList of flavors\033[0m"
633 echo "================================================================================"
634 cat /etc/tazlito/flavors.list
635 echo ""
636 ;;
637 show-flavor)
638 # Show flavor description.
639 FLAVOR=$2
640 if [ ! -f "$FLAVOR.flavor" ]; then
641 echo "File $FLAVOR.flavor not found."
642 exit 1
643 fi
644 mkdir $TMP_DIR
645 zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i 2> /dev/null )
646 if [ "$3" = "--brief" ]; then
647 if [ "$4" != "--noheader" ]; then
648 echo "Name Sizes Description"
649 echo "================================================================================"
650 fi
651 printf "%-15.15s %5.5s/%5.5s %-51s\n" "$FLAVOR" \
652 "$(field ISO $TMP_DIR/$FLAVOR.desc)" \
653 "$(field Rootfs $TMP_DIR/$FLAVOR.desc)" \
654 "$(grep ^Description $TMP_DIR/$FLAVOR.desc | cut -d: -f2)"
655 else
656 echo "================================================================================"
657 cat $TMP_DIR/$FLAVOR.desc
658 fi
659 rm -Rf $TMP_DIR
660 ;;
661 gen-liveflavor)
662 # Generate a new flavor form the live system.
663 FLAVOR=$2
664 DESC=""
665 case "$FLAVOR" in
666 '') echo -n "Flavor name : "
667 read FLAVOR
668 [ -z "$FLAVOR" ] && exit 1;;
669 -?|-h*|--help) echo -e "
671 SliTaz Live Tool - Version: $VERSION
672 \033[1mUsage: \033[0m `basename $0` gen-liveflavor flavor-name [flavor-patch-file]
673 \033[1mflavor-patch-file format: \033[0m
674 code data
675 + package to add
676 - package to remove
677 ! non-free package to add
678 ? display message
679 @ flavor description
681 \033[1mExample: \033[0m
682 @ Developer tools for slitaz maintainers
683 + slitaz-toolchain
684 + mercurial
685 "
686 exit 1;;
687 esac
688 mv /etc/tazlito/distro-packages.list \
689 /etc/tazlito/distro-packages.list.$$ 2> /dev/null
690 rm -f distro-packages.list non-free.list 2> /dev/null
691 tazpkg recharge
692 [ -n "$3" ] && while read action pkg; do
693 case "$action" in
694 +) yes | tazpkg get-install $pkg;;
695 -) yes | tazpkg remove $pkg;;
696 !) echo $pkg >> non-free.list;;
697 @) DESC="$pkg";;
698 \?) echo -en "$pkg"; read action;;
699 esac
700 done < $3
701 yes '' | tazlito gen-distro
702 echo "$DESC" | tazlito gen-flavor "$FLAVOR"
703 mv /etc/tazlito/distro-packages.list.$$ \
704 /etc/tazlito/distro-packages.list 2> /dev/null
705 ;;
706 gen-flavor)
707 # Generate a new flavor from the last iso image generated.
708 FLAVOR=$2
709 echo ""
710 echo -e "\033[1mFlavor generation\033[0m"
711 echo "================================================================================"
712 if [ -z "$FLAVOR" ]; then
713 echo -n "Flavor name : "
714 read FLAVOR
715 [ -z "$FLAVOR" ] && exit 1
716 fi
717 check_rootfs
718 FILES="$FLAVOR.pkglist"
719 echo -n "Creating file $FLAVOR.flavor..."
720 for i in rootcd rootfs; do
721 if [ -d "$ADDFILES/$i" ] ; then
722 FILES="$FILES\n$FLAVOR.$i"
723 ( cd "$ADDFILES/$i"; find . | \
724 cpio -o -H newc 2> /dev/null | gzip -9 ) > $FLAVOR.$i
725 fi
726 done
727 status
728 answer=`grep -s ^Description $FLAVOR.desc`
729 answer=${answer#Description : }
730 if [ -z "$answer" ]; then
731 echo -n "Description : "
732 read answer
733 fi
734 echo -n "Compressing flavor $FLAVOR..."
735 echo "Flavor : $FLAVOR" > $FLAVOR.desc
736 echo "Description : $answer" >> $FLAVOR.desc
737 ( cd $DISTRO; distro_sizes) >> $FLAVOR.desc
738 \rm -f $FLAVOR.pkglist $FLAVOR.nonfree 2> /dev/null
739 for i in $(ls $ROOTFS$INSTALLED); do
740 eval $(grep ^VERSION= $ROOTFS$INSTALLED/$i/receipt)
741 EXTRAVERSION=""
742 eval $(grep ^EXTRAVERSION= $ROOTFS$INSTALLED/$i/receipt)
743 eval $(grep ^CATEGORY= $ROOTFS$INSTALLED/$i/receipt)
744 if [ "$CATEGORY" = "non-free" -a "${i%%-*}" != "get" ]
745 then
746 echo "$i" >> $FLAVOR.nonfree
747 else
748 echo "$i-$VERSION$EXTRAVERSION" >> $FLAVOR.pkglist
749 fi
750 done
751 [ -s $FLAVOR.nonfree ] && $FILES="$FILES\n$FLAVOR.nonfree"
752 echo -e "$FLAVOR.desc\n$FILES" | cpio -o -H newc 2>/dev/null | \
753 gzip -9 > $FLAVOR.flavor
754 rm `echo -e $FILES`
755 status
756 echo "================================================================================"
757 echo "Flavor size : `du -sh $FLAVOR.flavor`"
758 echo ""
759 ;;
760 upgrade-flavor)
761 # Update package list to the lastest versions available.
762 FLAVOR=$2
763 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
764 mkdir $TMP_DIR
765 zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i 2>/dev/null )
766 echo -n "Update $FLAVOR package list..."
767 sed -i -e 's/size\( *:\) \(.*\)/size\1 unknown/' \
768 -e 's/is ready/not built yet/' \
769 -e 's/date\( *:\) \(.*\)/date\1 not built yet/' \
770 $TMP_DIR/$FLAVOR.desc
771 [ -s /var/lib/tazpkg/packages.list ] || tazpkg recharge
772 while read org; do
773 i=0
774 pkg=$org
775 while ! grep -q ^$pkg /var/lib/tazpkg/packages.list; do
776 pkg=${pkg%-*}
777 i=$(($i + 1))
778 [ $i -gt 5 ] && break;
779 done
780 for i in $(grep ^$pkg /var/lib/tazpkg/packages.list); do
781 echo $i
782 break
783 done
784 done < $TMP_DIR/$FLAVOR.pkglist \
785 > $TMP_DIR/$FLAVOR.pkglist.$$
786 mv -f $TMP_DIR/$FLAVOR.pkglist.$$ $TMP_DIR/$FLAVOR.pkglist
787 ( cd $TMP_DIR ; ls | cpio -o -H newc ) | gzip -9 > \
788 $FLAVOR.flavor
789 status
790 rm -Rf $TMP_DIR
791 fi
792 ;;
793 get-flavor)
794 # Get a flavor's files and prepare for gen-distro.
795 FLAVOR=$2
796 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
797 echo -n "Cleaning $DISTRO..."
798 rm -R $DISTRO 2> /dev/null
799 mkdir -p $DISTRO
800 status
801 mkdir $TMP_DIR
802 zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i 2>/dev/null )
803 echo -n "Create distro-packages.list..."
804 mv $TMP_DIR/$FLAVOR.nonfree non-free.list 2> /dev/null
805 mv $TMP_DIR/$FLAVOR.pkglist distro-packages.list
806 status
807 for i in rootcd rootfs; do
808 if [ -f $TMP_DIR/$FLAVOR.$i ]; then
809 mkdir -p "$ADDFILES/$i"
810 zcat $TMP_DIR/$FLAVOR.$i | \
811 ( cd "$ADDFILES/$i"; cpio -id 2> /dev/null)
812 fi
813 done
814 echo -n "Update tazlito.conf..."
815 [ -f tazlito.conf ] || cp /etc/tazlito/tazlito.conf .
816 cat tazlito.conf | grep -v "^#VOLUM_NAME" | \
817 sed "s/^VOLUM_NA/VOLUM_NAME=\"SliTaz $FLAVOR\"\\n#VOLUM_NA/" \
818 > tazlito.conf.$$ && mv tazlito.conf.$$ tazlito.conf
819 status
820 rm -Rf $TMP_DIR
821 fi
822 ;;
823 check-list)
824 # Use current packages list in $PWD by default.
825 DISTRO_PKGS_LIST=distro-packages.list
826 [ -d "$2" ] && DISTRO_PKGS_LIST=$2/distro-packages.list
827 [ -f "$2" ] && DISTRO_PKGS_LIST=$2
828 [ ! -f $DISTRO_PKGS_LIST ] && echo "No packages list found." && exit 0
829 echo ""
830 echo -e "\033[1mLiveCD packages list check\033[0m"
831 echo "================================================================================"
832 for pkg in `cat $DISTRO_PKGS_LIST`
833 do
834 if ! grep -q "$pkg" /var/lib/tazpkg/packages.list; then
835 echo "Update: $pkg"
836 up=$(($up + 1))
837 fi
838 done
839 [ -z $up ] && echo -e "List is up-to-date\n" && exit 0
840 echo "================================================================================"
841 echo -e "Updates: $up\n" ;;
842 gen-distro)
843 # Generate a live distro tree with a set of packages.
844 #
845 check_root
847 # Check if a package list was specified on cmdline.
848 LIST_NAME="distro-packages.list"
849 CDROM=""
850 while [ -n "$2" ]; do
851 case "$2" in
852 --iso=*)
853 CDROM="-o loop ${2#--iso=}"
854 ;;
855 --cdrom)
856 CDROM="/dev/cdrom"
857 ;;
858 --force)
859 DELETE_ROOTFS="true"
860 ;;
861 *) if [ ! -f "$2" ] ; then
862 echo -e "\nUnable to find the specified packages list."
863 echo -e "List name : $2\n"
864 exit 1
865 fi
866 LIST_NAME=$2
867 ;;
868 esac
869 shift
870 done
872 if [ -d $ROOTFS ] ; then
873 # Delete $ROOTFS if --force is set on command line
874 if [ ! -z $DELETE_ROOTFS ]; then
875 rm -rf $ROOTFS
876 unset $DELETE_ROOTFS
877 else
878 echo -e "\nA rootfs exists in : $DISTRO"
879 echo -e "Please clean the distro tree or change directory path.\n"
880 exit 0
881 fi
882 fi
883 if [ ! -f "$LIST_NAME" -a -d $INSTALLED ] ; then
884 # Build list with installed packages
885 for i in $(ls $INSTALLED); do
886 eval $(grep ^VERSION= $INSTALLED/$i/receipt)
887 EXTRAVERSION=""
888 eval $(grep ^EXTRAVERSION= $INSTALLED/$i/receipt)
889 echo "$i-$VERSION$EXTRAVERSION" >> $LIST_NAME
890 done
891 fi
892 # Exit if no list name.
893 if [ ! -f "$LIST_NAME" ]; then
894 echo -e "\nNo packages list found or specified. Please read the docs.\n"
895 exit 0
896 fi
897 # Start generation.
898 echo ""
899 echo -e "\033[1mTazlito generating a distro\033[0m"
900 echo "================================================================================"
901 # Misc checks
902 [ -n "$PACKAGES_REPOSITORY" ] || PACKAGES_REPOSITORY="."
903 [ -d $PACKAGES_REPOSITORY ] || mkdir -p $PACKAGES_REPOSITORY
904 # Get the list of packages using cat for a file list.
905 LIST=`cat $LIST_NAME`
906 # Verify if all packages in list are present in $PACKAGES_REPOSITORY.
907 REPACK=""
908 DOWNLOAD=""
909 for pkg in $LIST
910 do
911 [ "$pkg" = "" ] && continue
912 pkg=${pkg%.tazpkg}
913 [ -f $PACKAGES_REPOSITORY/$pkg.tazpkg ] && continue
914 PACKAGE=$(installed_package_name $pkg)
915 [ -n "$PACKAGE" -a "$REPACK" = "y" ] && continue
916 [ -z "$PACKAGE" -a -n "$DOWNLOAD" ] && continue
917 echo -e "\nUnable to find $pkg in the repository."
918 echo -e "Path : $PACKAGES_REPOSITORY\n"
919 if [ -n "$PACKAGE" -a -z "$REPACK" ]; then
920 yesorno "Repack packages from rootfs (y/N) ? "
921 REPACK="$answer"
922 [ "$answer" = "y" ] || REPACK="n"
923 [ "$DOWNLOAD" = "y" ] && break
924 fi
925 if [ -f $MIRROR -a -z "$DOWNLOAD" ]; then
926 yesorno "Download packages from mirror (Y/n) ? "
927 DOWNLOAD="$answer"
928 if [ "$answer" = "n" ]; then
929 [ -z "$PACKAGE" ] && exit 1
930 else
931 DOWNLOAD="y"
932 [ -n "$REPACK" ] && break
933 fi
934 fi
935 [ "$REPACK" = "n" -a "$DOWNLOAD" = "n" ] && exit 1
936 done
938 # Mount cdrom to be able to repack boot-loader packages
939 if [ ! -e /boot -a -n "$CDROM" ]; then
940 mkdir $TMP_MNT
941 if mount -r $CDROM $TMP_MNT 2> /dev/null; then
942 ln -s $TMP_MNT/boot /
943 if [ ! -d "$ADDFILES/rootcd" ] ; then
944 mkdir -p $ADDFILES/rootcd
945 for i in $(ls $TMP_MNT); do
946 [ "$i" = "boot" ] && continue
947 cp -a $TMP_MNT/$i $ADDFILES/rootcd
948 done
949 fi
950 else
951 rmdir $TMP_MNT
952 fi
953 fi
955 # Root fs stuff.
956 echo "Preparing the rootfs directory..."
957 mkdir -p $ROOTFS
958 sleep 2
959 for pkg in $LIST
960 do
961 [ "$pkg" = "" ] && continue
962 # First copy and extract the package in tmp dir.
963 pkg=${pkg%.tazpkg}
964 PACKAGE=$(installed_package_name $pkg)
965 mkdir -p $TMP_DIR
966 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
967 # Look for package in cache
968 if [ -f $CACHE_DIR/$pkg.tazpkg ]; then
969 ln -s $CACHE_DIR/$pkg.tazpkg $PACKAGES_REPOSITORY
970 # Look for package in running distribution
971 elif [ -n "$PACKAGE" -a "$REPACK" = "y" ]; then
972 tazpkg repack $PACKAGE && \
973 mv $pkg.tazpkg $PACKAGES_REPOSITORY
974 fi
975 fi
976 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
977 # Get package from mirror
978 [ "$DOWNLOAD" = "y" ] && \
979 download $pkg.tazpkg && \
980 mv $pkg.tazpkg $PACKAGES_REPOSITORY
981 fi
982 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
983 echo "Missing package $pkg."
984 cleanup
985 exit 1
986 fi
987 done
988 if [ -f non-free.list ]; then
989 echo "Preparing non-free packages..."
990 cp non-free.list $ROOTFS/etc/tazlito/non-free.list
991 for pkg in $(cat non-free.list); do
992 if [ ! -d $INSTALLED/$pkg ]; then
993 if [ ! -d $INSTALLED/get-$pkg ]; then
994 tazpkg get-install get-$pkg
995 fi
996 get-$pkg
997 fi
998 tazpkg repack $pkg
999 pkg=$(ls $pkg*.tazpkg)
1000 grep -q "^$pkg$" $LIST_NAME || \
1001 echo $pkg >>$LIST_NAME
1002 mv $pkg $PACKAGES_REPOSITORY
1003 done
1004 fi
1005 echo ""
1006 cp $LIST_NAME $DISTRO/distro-packages.list
1007 sed 's/\(.*\)/\1.tazpkg/' < $DISTRO/distro-packages.list > $DISTRO/list-packages
1008 cd $PACKAGES_REPOSITORY
1009 yes y | tazpkg install-list \
1010 $DISTRO/list-packages --root=$ROOTFS
1011 cd $DISTRO
1012 cp distro-packages.list $ROOTFS/etc/tazlito
1013 # Copy all files from $ADDFILES/rootfs to the rootfs.
1014 if [ -d "$ADDFILES/rootfs" ] ; then
1015 echo -n "Copying addfiles content to the rootfs... "
1016 cp -a $ADDFILES/rootfs/* $ROOTFS
1017 status
1018 fi
1019 echo "Root file system is generated..."
1020 # Root CD part.
1021 echo -n "Preparing the rootcd directory..."
1022 mkdir -p $ROOTCD
1023 status
1024 # Move the boot dir with the Linux kernel from rootfs.
1025 # The boot dir goes directly on the CD.
1026 if [ -d "$ROOTFS/boot" ] ; then
1027 echo -n "Moving the boot directory..."
1028 mv $ROOTFS/boot $ROOTCD
1029 cd $ROOTCD/boot
1030 ln vmlinuz-* bzImage
1031 status
1032 fi
1033 cd $DISTRO
1034 # Copy all files from $ADDFILES/rootcd to the rootcd.
1035 if [ -d "$ADDFILES/rootcd" ] ; then
1036 echo -n "Copying addfiles content to the rootcd... "
1037 cp -a $ADDFILES/rootcd/* $ROOTCD
1038 status
1039 fi
1040 # Execute the distro script (used to perform tasks in the rootfs
1041 # before compression. Give rootfs path in arg
1042 [ -z $DISTRO_SCRIPT ] && DISTRO_SCRIPT=$TOP_DIR/distro.sh
1043 if [ -x $DISTRO_SCRIPT ]; then
1044 echo "Executing distro script..."
1045 sh $DISTRO_SCRIPT $DISTRO
1046 fi
1047 # Initramfs and ISO image stuff.
1048 gen_initramfs
1049 gen_livecd_isolinux
1050 distro_stats
1051 cleanup
1052 ;;
1053 clean-distro)
1054 # Remove old distro tree.
1056 check_root
1057 echo ""
1058 echo -e "\033[1mCleaning :\033[0m $DISTRO"
1059 echo "================================================================================"
1060 if [ -d "$DISTRO" ] ; then
1061 if [ -d "$ROOTFS" ] ; then
1062 echo -n "Removing the rootfs..."
1063 rm -f $DISTRO/$INITRAMFS
1064 rm -rf $ROOTFS
1065 status
1066 fi
1067 if [ -d "$ROOTCD" ] ; then
1068 echo -n "Removing the rootcd..."
1069 rm -rf $ROOTCD
1070 status
1071 fi
1072 echo -n "Removing eventual ISO image..."
1073 rm -f $DISTRO/$ISO_NAME.iso
1074 rm -f $DISTRO/$ISO_NAME.md5
1075 status
1076 fi
1077 echo "================================================================================"
1078 echo ""
1079 ;;
1080 check-distro)
1081 # Check for a few LiveCD needed files not installed by packages.
1083 check_rootfs
1084 echo ""
1085 echo -e "\033[1mChecking distro :\033[0m $ROOTFS"
1086 echo "================================================================================"
1087 # SliTaz release info.
1088 if [ ! -f "$ROOTFS/etc/slitaz-release" ]; then
1089 echo "Missing release info : /etc/slitaz-release"
1090 else
1091 release=`cat $ROOTFS/etc/slitaz-release`
1092 echo -n "Release : $release"
1093 status
1094 fi
1095 # Tazpkg mirror.
1096 if [ ! -f "$ROOTFS/var/lib/tazpkg/mirror" ]; then
1097 echo -n "Mirror URL : Missing /var/lib/tazpkg/mirror"
1098 todomsg
1099 else
1100 echo -n "Mirror configuration exist..."
1101 status
1102 fi
1103 # Isolinux msg
1104 if grep -q "cooking-XXXXXXXX" /$ROOTCD/boot/isolinux/isolinux.msg; then
1105 echo -n "Isolinux msg : Missing cooking date XXXXXXXX (ex `date +%Y%m%d`)"
1106 todomsg
1107 else
1108 echo -n "Isolinux message seems good..."
1109 status
1110 fi
1111 echo "================================================================================"
1112 echo ""
1113 ;;
1114 burn-iso)
1115 # Guess cdrom device, ask user and burn the ISO.
1117 check_root
1118 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
1119 DRIVE_SPEED=`cat /proc/sys/dev/cdrom/info | grep "drive speed" | cut -f 3`
1120 # We can specify an alternative ISO from the cmdline.
1121 if [ -n "$2" ] ; then
1122 iso=$2
1123 else
1124 iso=$DISTRO/$ISO_NAME.iso
1125 fi
1126 if [ ! -f "$iso" ]; then
1127 echo -e "\nUnable to find ISO : $iso\n"
1128 exit 0
1129 fi
1130 echo ""
1131 echo -e "\033[1mTazlito burn ISO\033[0m "
1132 echo "================================================================================"
1133 echo "Cdrom device : /dev/$DRIVE_NAME"
1134 echo "Drive speed : $DRIVE_SPEED"
1135 echo "ISO image : $iso"
1136 echo "================================================================================"
1137 echo ""
1138 yesorno "Burn ISO image (y/N) ? "
1139 if [ "$answer" == "y" ]; then
1140 echo ""
1141 echo "Starting Wodim to burn the iso..." && sleep 2
1142 echo "================================================================================"
1143 wodim speed=$DRIVE_SPEED dev=/dev/$DRIVE_NAME $iso
1144 echo "================================================================================"
1145 echo "ISO image is burned to cdrom."
1146 else
1147 echo -e "\nExiting. No ISO burned."
1148 fi
1149 echo ""
1150 ;;
1151 merge)
1152 # Merge multiple rootfs into one iso.
1154 if [ -z "$2" ]; then
1155 cat << EOT
1156 Usage: tazlito merge size1 iso size2 rootfs2 [sizeN rootfsN]...
1158 Merge multiple rootfs into one iso. Rootfs are like russian dolls
1159 i.e: rootfsN is a subset of rootfsN-1
1160 rootfs1 is found in iso, sizeN is the RAM size need to launch rootfsN.
1161 The boot loader will select the rootfs according to the RAM size detected.
1163 Example:
1164 $ tazlito merge 160M slitaz-core.iso 96M rootfs-justx.gz 32M rootfs-base.gz
1166 Will start slitaz-core with 160M+ RAM, slitaz-justX with 96M-160M RAM,
1167 slitaz-base with 32M-96M RAM and display an error message if RAM < 32M.
1168 EOT
1169 exit 2
1170 fi
1172 shift # skip merge
1173 append="append $(( (${1%M} - 3) * 1024 )) slitaz1"
1174 shift # skip size1
1175 mkdir -p $TMP_DIR/mnt $TMP_DIR/rootfs1
1177 ISO=$1.merged
1178 # Extract filesystems
1179 echo -n "Mount $1"
1180 mount -o loop,ro $1 $TMP_DIR/mnt 2> /dev/null
1181 status || cleanup_merge
1182 cp -a $TMP_DIR/mnt $TMP_DIR/iso
1183 rm -f $TMP_DIR/iso/boot/bzImage
1184 ln $TMP_DIR/iso/boot/vmlinuz* $TMP_DIR/iso/boot/bzImage
1185 umount -d $TMP_DIR/mnt
1186 if [ -f $TMP_DIR/iso/boot/rootfs1.gz ]; then
1187 echo "$1 is already a merged iso. Abort."
1188 cleanup_merge
1189 fi
1190 if [ ! -f $TMP_DIR/iso/boot/isolinux/ifmem.c32 ]; then
1191 if [ ! -f /boot/isolinux/ifmem.c32 ]; then
1192 cat <<EOT
1193 No file /boot/isolinux/ifmem.c32
1194 Please install syslinux package !
1195 EOT
1196 rm -rf $TMP_DIR
1197 exit 1
1198 fi
1199 cp /boot/isolinux/ifmem.c32 $TMP_DIR/iso/boot/isolinux
1200 fi
1202 echo -n "Extract iso/rootfs.gz"
1203 extract_rootfs $TMP_DIR/iso/boot/rootfs.gz $TMP_DIR/rootfs1 &&
1204 [ -d $TMP_DIR/rootfs1/etc ]
1205 status || cleanup_merge
1206 n=1
1207 while [ -n "$2" ]; do
1208 shift # skip rootfs N-1
1209 p=$n
1210 n=$(($n + 1))
1211 append="$append $(( (${1%M} - 3) * 1024 )) slitaz$n"
1212 shift # skip size N
1213 mkdir -p $TMP_DIR/rootfs$n
1214 echo -n "Extract $1"
1215 extract_rootfs $1 $TMP_DIR/rootfs$n &&
1216 [ -d $TMP_DIR/rootfs$n/etc ]
1217 status || cleanup_merge
1218 echo -n "Merge rootfs$n into rootfs$p"
1219 mergefs $TMP_DIR/rootfs$n $TMP_DIR/rootfs$p
1220 status
1221 echo "Create rootfs$p.gz"
1222 pack_rootfs $TMP_DIR/rootfs$p $TMP_DIR/iso/boot/rootfs$p.gz
1223 status
1224 done
1225 echo "Create rootfs$n.gz"
1226 pack_rootfs $TMP_DIR/rootfs$n $TMP_DIR/iso/boot/rootfs$n.gz
1227 status
1228 rm -f $TMP_DIR/iso/boot/rootfs.gz
1230 echo -n "Update boot files"
1231 grep -l 'include common' $TMP_DIR/iso/boot/isolinux/*.cfg | \
1232 while read file ; do
1233 awk -v n=$n '{
1234 if (/label/) label=$0;
1235 else if (/kernel/) kernel=$0;
1236 else if (/append/) {
1237 i=index($0,"rootfs.gz");
1238 append=substr($0,i+9);
1240 else if (/include/) {
1241 for (i = 1; i <= n; i++) {
1242 print label i
1243 print kernel;
1244 initrd="initrd=/boot/rootfs" n ".gz"
1245 for (j = n - 1; j >= i; j--) {
1246 initrd=initrd ",/boot/rootfs" j ".gz";
1248 printf "\tappend %s%s\n",initrd,append;
1249 print "";
1251 print;
1253 else print;
1254 }' < $file > $file.$$
1255 mv -f $file.$$ $file
1256 done
1257 cat >> $TMP_DIR/iso/boot/isolinux/common.cfg <<EOT
1258 label slitaz
1259 kernel /boot/isolinux/ifmem.c32
1260 $append noram
1262 label noram
1263 config noram.cfg
1265 EOT
1266 cat >> $TMP_DIR/iso/boot/isolinux/noram.cfg <<EOT
1267 display isolinux.msg
1268 say Not enough RAM to boot slitaz.
1269 default reboot
1270 label reboot
1271 com32 reboot.c32
1273 implicit 0
1274 prompt 1
1275 timeout 80
1276 F1 help.txt
1277 F2 options.txt
1278 F3 isolinux.msg
1279 F4 display.txt
1280 F5 enhelp.txt
1281 F6 enopts.txt
1282 EOT
1283 status
1284 echo "Generate $ISO"
1285 create_iso $ISO $TMP_DIR/iso
1286 rm -rf $TMP_DIR
1287 ;;
1289 repack)
1290 # Repack an iso with maximum lzma compression ratio.
1293 ISO=$2
1295 mkdir -p $TMP_DIR/mnt
1296 # Extract filesystems
1297 echo -n "Mount $ISO"
1298 mount -o loop,ro $ISO $TMP_DIR/mnt 2> /dev/null
1299 status || cleanup_merge
1300 cp -a $TMP_DIR/mnt $TMP_DIR/iso
1301 umount -d $TMP_DIR/mnt
1303 for i in $TMP_DIR/iso/boot/rootfs* ; do
1304 echo -n "Repack $(basename $i)"
1305 (zcat $i || unlzma -c $i || cat $i) \
1306 2>/dev/null > $TMP_DIR/rootfs
1307 lzma e $TMP_DIR/rootfs $i \
1308 -d$(lzma_history_bits $TMP_DIR/rootfs)
1309 status
1310 done
1312 echo "Generate $ISO"
1313 create_iso $ISO $TMP_DIR/iso
1314 rm -rf $TMP_DIR
1315 ;;
1317 usage|*)
1318 # Clear and print usage also for all unknown commands.
1320 clear
1321 usage
1322 ;;
1324 esac
1326 exit 0