tazlito rev 106

Add tazlito extract/pack
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Aug 21 10:23:10 2009 +0200 (2009-08-21)
parents 5d8cf2ac0c6a
children c13aac05efdc
files tazlito
line diff
     1.1 --- a/tazlito	Wed Aug 19 23:14:06 2009 +0200
     1.2 +++ b/tazlito	Fri Aug 21 10:23:10 2009 +0200
     1.3 @@ -61,6 +61,7 @@
     1.4  # configuration variable.
     1.5  ROOTFS=$DISTRO/rootfs
     1.6  ROOTCD=$DISTRO/rootcd
     1.7 +FLAVORS_REPOSITORY=/home/slitaz/flavors
     1.8  
     1.9  #####################
    1.10  # Tazlito functions #
    1.11 @@ -84,6 +85,8 @@
    1.12    show-flavor     Show live-CD description.
    1.13    get-flavor      Get a flavor's list of packages.
    1.14    upgrade-flavor  Update package list to the latest available versions.
    1.15 +  extract-flavor  Extract a (*.flavor) flavor into $FLAVORS_REPOSITORY.
    1.16 +  pack-flavor     Pack (and update) a flavor from $FLAVORS_REPOSITORY.
    1.17    check-list      Check a distro-packages.list for updates.
    1.18    extract-distro  Extract an ISO to a directory and rebuild LiveCD tree.
    1.19    gen-distro      Generate a Live distro and ISO from a list of packages.
    1.20 @@ -636,7 +639,7 @@
    1.21  		;;
    1.22  	show-flavor)
    1.23  		# Show flavor description.
    1.24 -		FLAVOR=$2
    1.25 +		FLAVOR=${2%.flavor}
    1.26  		if [ ! -f "$FLAVOR.flavor" ]; then
    1.27  			echo "File $FLAVOR.flavor not found."
    1.28  			exit 1
    1.29 @@ -660,7 +663,7 @@
    1.30  		;;
    1.31  	gen-liveflavor)
    1.32  		# Generate a new flavor form the live system.
    1.33 -		FLAVOR=$2
    1.34 +		FLAVOR=${2%.flavor}
    1.35  		DESC=""
    1.36  		case "$FLAVOR" in
    1.37  		'')	echo -n "Flavor name : "
    1.38 @@ -705,7 +708,7 @@
    1.39  		;;
    1.40  	gen-flavor)
    1.41  		# Generate a new flavor from the last iso image generated.
    1.42 -		FLAVOR=$2
    1.43 +		FLAVOR=${2%.flavor}
    1.44  		echo ""
    1.45  		echo -e "\033[1mFlavor generation\033[0m"
    1.46  		echo "================================================================================"
    1.47 @@ -759,10 +762,10 @@
    1.48  		;;
    1.49  	upgrade-flavor)
    1.50  		# Update package list to the lastest versions available.
    1.51 -		FLAVOR=$2
    1.52 +		FLAVOR=${2%.flavor}
    1.53  		if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
    1.54  			mkdir $TMP_DIR
    1.55 -			zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i 2>/dev/null )
    1.56 +			zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i >/dev/null )
    1.57  			echo -n "Update $FLAVOR package list..."
    1.58  			sed -i -e 's/size\( *:\) \(.*\)/size\1 unknown/' \
    1.59  			       -e 's/is ready/not built yet/' \
    1.60 @@ -772,7 +775,7 @@
    1.61  			while read org; do
    1.62  				i=0
    1.63  				pkg=$org
    1.64 -				while ! grep -q ^$pkg /var/lib/tazpkg/packages.list; do
    1.65 +				while ! grep -q ^$pkg$ /var/lib/tazpkg/packages.txt; do
    1.66  					pkg=${pkg%-*}
    1.67  					i=$(($i + 1))
    1.68  					[ $i -gt 5 ] && break;
    1.69 @@ -790,9 +793,81 @@
    1.70  			rm -Rf $TMP_DIR
    1.71  		fi
    1.72  		;;
    1.73 +	extract-flavor)
    1.74 +		# Extract a flavor into $FLAVORS_REPOSITORY.
    1.75 +		FLAVOR=${2%.flavor}
    1.76 +		if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
    1.77 +			mkdir $TMP_DIR
    1.78 +			zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i >/dev/null )
    1.79 +			echo -n "Extract $FLAVOR..."
    1.80 +			rm -rf $FLAVORS_REPOSITORY/$FLAVOR 2> /dev/null
    1.81 +			mkdir -p $FLAVORS_REPOSITORY/$FLAVOR
    1.82 +			grep ^Description $TMP_DIR/$FLAVOR.desc | \
    1.83 +				sed 's/.*: \(.*\)$/\1/' > \
    1.84 +				$FLAVORS_REPOSITORY/$FLAVOR/desc.txt
    1.85 +			for i in rootcd rootfs; do
    1.86 +				[ -f $TMP_DIR/$FLAVOR.$i ] || continue
    1.87 +				mkdir $FLAVORS_REPOSITORY/$FLAVOR/$i
    1.88 +				zcat $TMP_DIR/$FLAVOR.$i | \
    1.89 +				  (cd $FLAVORS_REPOSITORY/$FLAVOR/$i; \
    1.90 +				   cpio -idm > /dev/null)
    1.91 +			done
    1.92 +			[ -s /var/lib/tazpkg/packages.list ] || tazpkg recharge
    1.93 +			while read org; do
    1.94 +				i=0
    1.95 +				pkg=$org
    1.96 +				while ! grep -q ^$pkg$ /var/lib/tazpkg/packages.txt; do
    1.97 +					pkg=${pkg%-*}
    1.98 +					i=$(($i + 1))
    1.99 +					[ $i -gt 5 ] && break;
   1.100 +				done
   1.101 +				echo $pkg
   1.102 +			done <  $TMP_DIR/$FLAVOR.pkglist \
   1.103 +			     > $FLAVORS_REPOSITORY/$FLAVOR/pkglist.txt
   1.104 +			status
   1.105 +			rm -Rf $TMP_DIR
   1.106 +		fi
   1.107 +		;;
   1.108 +	pack-flavor)
   1.109 +		# Create a flavor from $FLAVORS_REPOSITORY.
   1.110 +		FLAVOR=${2%.flavor}
   1.111 +		if [ -s $FLAVORS_REPOSITORY/$FLAVOR/desc.txt ]; then
   1.112 +			mkdir $TMP_DIR
   1.113 +			echo -n "Create $FLAVOR..."
   1.114 +			cat > $TMP_DIR/$FLAVOR.desc <<EOT
   1.115 +Flavor          : $FLAVOR
   1.116 +Description     : $(grep -v ^# $FLAVORS_REPOSITORY/$FLAVOR/desc.txt)
   1.117 +Build date      : $(date +%Y%m%d\ \at\ \%H:%M:%S)
   1.118 +Packages        : $(grep -v ^# $FLAVORS_REPOSITORY/$FLAVOR/pkglist.txt | wc -l)
   1.119 +Rootfs size     : unknown
   1.120 +Initramfs size  : unknown
   1.121 +ISO image size  : unknown
   1.122 +================================================================================
   1.123 +
   1.124 +EOT
   1.125 +			[ -s /var/lib/tazpkg/packages.list ] || tazpkg recharge
   1.126 +			grep -v ^#  $FLAVORS_REPOSITORY/$FLAVOR/pkglist.txt | \
   1.127 +			while read pkg; do
   1.128 +				for i in $(grep ^$pkg /var/lib/tazpkg/packages.list); do
   1.129 +					echo $i
   1.130 +					break
   1.131 +				done
   1.132 +			done > $TMP_DIR/$FLAVOR.pkglist
   1.133 +			for i in rootcd rootfs; do
   1.134 +				[ -d $FLAVORS_REPOSITORY/$FLAVOR/$i ] || \
   1.135 +					continue
   1.136 +				( cd $FLAVORS_REPOSITORY/$FLAVOR/$i ; find . | \
   1.137 +				cpio -o -H newc ) | gzip -9 >$TMP_DIR/$FLAVOR.$i
   1.138 +			done
   1.139 +			( cd $TMP_DIR ; ls | cpio -o -H newc ) | gzip -9 > \
   1.140 +				$FLAVOR.flavor
   1.141 +			status
   1.142 +			rm -Rf $TMP_DIR
   1.143 +		fi
   1.144 +		;;
   1.145  	get-flavor)
   1.146  		# Get a flavor's files and prepare for gen-distro.
   1.147 -		FLAVOR=$2
   1.148 +		FLAVOR=${2%.flavor}
   1.149  		if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
   1.150  			echo -n "Cleaning $DISTRO..."
   1.151  			rm -R $DISTRO 2> /dev/null