tazlito rev 22 1.3

Add flavor support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Dec 21 16:50:24 2007 +0100 (2007-12-21)
parents 419393a073b5
children 139cac5dd84c
files doc/tazlito.html tazlito
line diff
     1.1 --- a/doc/tazlito.html	Mon Dec 17 16:45:56 2007 +0000
     1.2 +++ b/doc/tazlito.html	Fri Dec 21 16:50:24 2007 +0100
     1.3 @@ -36,7 +36,7 @@
     1.4  
     1.5  <h2>SYNTAXE</h2>
     1.6  <pre>
     1.7 -tazlito [command] [list|iso] [dir]
     1.8 +tazlito [command] [list|iso|flavor] [dir]
     1.9  </pre>
    1.10  
    1.11  <h2>DESCRIPTION</h2>
    1.12 @@ -118,6 +118,44 @@
    1.13  <pre>
    1.14   # tazlito gen-initiso
    1.15  </pre>
    1.16 +<h3><font color="#6c0023">list-flavors</font></h3>
    1.17 +<p>
    1.18 +La commande 'list-flavors' télécharge si nécessaire et affiche la liste des
    1.19 +différentes saveurs disponibles. On peut forcer le téléchargement avec
    1.20 +'--recharge'.
    1.21 +</p>
    1.22 +<pre>
    1.23 + # tazlito list-flavors
    1.24 + # tazlito list-flavors --recharge
    1.25 +</pre>
    1.26 +<h3><font color="#6c0023">get-flavor</font></h3>
    1.27 +<p>
    1.28 +La commande 'get-flavor' télécharge si nécessaire et prépare les fichiers
    1.29 +nécessaires à 'gen-distro' pour refabriquer une saveur. 
    1.30 +</p>
    1.31 +<pre>
    1.32 + # tazlito get-flavor saveur-particuliere 
    1.33 +</pre>
    1.34 +<h3><font color="#6c0023">show-flavor</font></h3>
    1.35 +<p>
    1.36 +La commande 'show-flavor' affiche les caractéristiques d'une saveur et ses
    1.37 +dimensions après refabrication. Les options '--brief' et '--noheader' réduisent
    1.38 +l'affichage produit.
    1.39 +</p>
    1.40 +<pre>
    1.41 + # tazlito show-flavor saveur-particuliere 
    1.42 + # tazlito show-flavor saveur-particuliere --brief
    1.43 + # tazlito show-flavor saveur-particuliere --brief --noheader
    1.44 +</pre>
    1.45 +<h3><font color="#6c0023">gen-flavor</font></h3>
    1.46 +<p>
    1.47 +La commande 'gen-flavor' crée un fichier de description d'une nouvelle saveur
    1.48 +à partir des résultats de fabrication de 'gen-distro'. Le fichier .flavor
    1.49 +produit pourra être ensuite envoyé à slitaz.org.
    1.50 +</p>
    1.51 +<pre>
    1.52 + # tazlito gen-flavor nouvelle-saveur
    1.53 +</pre>
    1.54  <h3><font color="#6c0023">extract-distro</font></h3>
    1.55  <p>
    1.56  La commande 'extract-iso' sert à extraire les fichiers d'une images ISO du
    1.57 @@ -135,12 +173,19 @@
    1.58  système Live et une image ISO via une liste de paquets. Pour fonctionner, cette
    1.59  commande a besoin d'une liste de paquets, d'un répertoire contenant tous les
    1.60  paquets (.tazpkg) de la liste et d'un répertoire pour générer la distribution.
    1.61 +La liste de paquets peut être extraite d'une saveur par la commande get-flavor.
    1.62 +Si l'on utilise le Live-CD, les options --cdrom et --iso=<image-iso> permettent
    1.63 +de refabriquer les packets qui placent des fichiers dans /boot sans être obligé
    1.64 +de les télécharger et récupère les fichiers additionnels du Live-CD.
    1.65  Le chemin vers les différents répertoires sont à configurer dans le fichier de
    1.66  configuration utilisé et les paquets peuvent être téléchargés depuis les
    1.67  miroirs de SliTaz ou générés par Tazwok. Pour générer une distro :
    1.68  </p>
    1.69  <pre>
    1.70   # tazlito gen-distro
    1.71 + # tazlito gen-distro --cdrom
    1.72 + # tazlito gen-distro --iso=slitaz.iso
    1.73 + # tazlito gen-distro package-list
    1.74  </pre>
    1.75  <h3><font color="#6c0023">clean-distro</font></h3>
    1.76  <p>
     2.1 --- a/tazlito	Mon Dec 17 16:45:56 2007 +0000
     2.2 +++ b/tazlito	Fri Dec 21 16:50:24 2007 +0100
     2.3 @@ -59,7 +59,7 @@
     2.4  usage ()
     2.5  {
     2.6  	echo -e "\nSliTaz Live Tool - Version: $VERSION\n
     2.7 -\033[1mUsage: \033[0m `basename $0` [command] [list|iso] [dir]
     2.8 +\033[1mUsage: \033[0m `basename $0` [command] [list|iso|flavor] [dir]
     2.9  \033[1mCommands: \033[0m\n
    2.10    usage           Print this short usage.
    2.11    stats           View Tazlito and distro configuration statistics.
    2.12 @@ -67,6 +67,10 @@
    2.13    configure       Configure the main config file or a specific tazlito.conf.
    2.14    gen-iso         Generate a new ISO from a distro tree.
    2.15    gen-initiso     Generate a new initramfs and ISO from the distro tree.
    2.16 +  list-flavors    List all available package lists on the mirror.
    2.17 +  gen-flavor      Generate a new live-CD description.
    2.18 +  show-flavor     Show live-CD description.
    2.19 +  get-flavor      Get a flavor's list of packages.
    2.20    extract-distro  Extract and ISO to a directory and rebuild LiveCD tree.
    2.21    gen-distro      Generated a Live distro and ISO from a list of packages.
    2.22    clean-distro    Remove all files generated by gen-distro.
    2.23 @@ -98,6 +102,11 @@
    2.24  	esac
    2.25  }
    2.26  
    2.27 +field()
    2.28 +{
    2.29 +	grep "^$1" "$2" | sed 's/.*: \([0-9KMG\.]*\).*/\1/'
    2.30 +}
    2.31 +
    2.32  todomsg()
    2.33  {
    2.34  	echo -e "\\033[70G[ \\033[1;31mTODO\\033[0;39m ]"
    2.35 @@ -226,12 +235,8 @@
    2.36  	mv $INITRAMFS $ROOTCD/boot
    2.37  }
    2.38  
    2.39 -# Print ISO and rootfs size.
    2.40 -distro_stats()
    2.41 +distro_sizes()
    2.42  {
    2.43 -	echo ""
    2.44 -	echo -e "\033[1mDistro statistics\033[0m"
    2.45 -	echo "================================================================================"
    2.46  	echo "Build date      : `date +%Y%m%d\ \at\ \%H:%M:%S`"
    2.47  	echo "Packages        : `ls -1 $ROOTFS$INSTALLED | wc -l`"
    2.48  	echo "Rootfs size     : `du -sh $ROOTFS`"
    2.49 @@ -241,6 +246,15 @@
    2.50  	echo ""
    2.51  }
    2.52  
    2.53 +# Print ISO and rootfs size.
    2.54 +distro_stats()
    2.55 +{
    2.56 +	echo ""
    2.57 +	echo -e "\033[1mDistro statistics\033[0m"
    2.58 +	echo "================================================================================"
    2.59 +	distro_sizes
    2.60 +}
    2.61 +
    2.62  # Creat an empty configuration file.
    2.63  empty_config_file()
    2.64  {
    2.65 @@ -436,6 +450,103 @@
    2.66  		echo "================================================================================"
    2.67  		echo ""
    2.68  		;;
    2.69 +	list-flavors)
    2.70 +		# Show available flavors.
    2.71 +		if [ ! -s /etc/tazlito/flavors.list -o "$2" == "--recharge" ]; then
    2.72 +			download flavors.list -O - > /etc/tazlito/flavors.list
    2.73 +		fi
    2.74 +		cat /etc/tazlito/flavors.list
    2.75 +		;;
    2.76 +	show-flavor)
    2.77 +		# Show flavor description.
    2.78 +		FLAVOR=$2
    2.79 +		if [ ! -f "$FLAVOR.flavor" ]; then
    2.80 +			echo "File $FLAVOR.flavor not found."
    2.81 +			exit 1
    2.82 +		fi
    2.83 +		mkdir $TMP_DIR
    2.84 +		zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i 2> /dev/null )
    2.85 +		if [ "$3" = "--brief" ]; then
    2.86 +			if [ "$4" != "--noheader" ]; then
    2.87 +				echo "Name            Sizes        Description"
    2.88 +				echo "================================================================================"
    2.89 +			fi
    2.90 +			printf "%-15.15s %5.5s/%5.5s %-51s\n" "$FLAVOR" \
    2.91 +				"$(field ISO $TMP_DIR/$FLAVOR.desc)" \
    2.92 +				"$(field Rootfs $TMP_DIR/$FLAVOR.desc)" \
    2.93 +				"$(grep ^Description $TMP_DIR/$FLAVOR.desc | cut -d: -f2)"
    2.94 +		else
    2.95 +			echo "================================================================================"
    2.96 +			cat $TMP_DIR/$FLAVOR.desc
    2.97 +		fi
    2.98 +		rm -Rf $TMP_DIR
    2.99 +		;;
   2.100 +	gen-flavor)
   2.101 +		# Generate a new flavor form then last iso image generation.
   2.102 +		FLAVOR=$2
   2.103 +		if [ -z "$FLAVOR" ]; then
   2.104 +			echo -n "Flavor name : "
   2.105 +			read FLAVOR
   2.106 +			[ -z "$FLAVOR" ] && exit 1
   2.107 +		fi
   2.108 +		check_rootfs
   2.109 +		FILES="$FLAVOR.pkglist"
   2.110 +		echo -n "Creating file $FLAVOR.flavor..."
   2.111 +		for i in rootcd rootfs; do
   2.112 +			if [ -d "$ADDFILES/$i" ] ; then
   2.113 +				FILES="$FILES\n$FLAVOR.$i"
   2.114 +				( cd "$ADDFILES/$i"; find . | \
   2.115 +				  cpio -o -H newc 2> /dev/null | gzip -9 ) > $FLAVOR.$i
   2.116 +			fi
   2.117 +		done
   2.118 +		answer=`grep -s ^Description $FLAVOR.desc`
   2.119 +		answer=${answer#Description     : }
   2.120 +		if [ -z "$answer" ]; then
   2.121 +			echo -en "\nDescription : "
   2.122 +			read answer
   2.123 +		fi
   2.124 +		echo "Flavor          : $FLAVOR" > $FLAVOR.desc
   2.125 +		echo "Description     : $answer" >> $FLAVOR.desc
   2.126 +		( cd $DISTRO; distro_sizes) >> $FLAVOR.desc
   2.127 +		\rm -f $FLAVOR.pkglist 2> /dev/null
   2.128 +		for i in $(ls $ROOTFS$INSTALLED); do
   2.129 +			eval $(grep ^VERSION= $ROOTFS$INSTALLED/$i/receipt)
   2.130 +			echo "$i-$VERSION" >> $FLAVOR.pkglist
   2.131 +		done
   2.132 +		echo -e "$FLAVOR.desc\n$FILES" | cpio -o -H newc 2>/dev/null | \
   2.133 +			gzip -9 > $FLAVOR.flavor
   2.134 +		rm `echo -e $FILES`
   2.135 +		status
   2.136 +		;;
   2.137 +	get-flavor)
   2.138 +		# Get a flavor's files and prepare for gen-distro.
   2.139 +		FLAVOR=$2
   2.140 +		if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
   2.141 +			echo -n "Cleaning $DISTRO..."
   2.142 +			rm -R $DISTRO 2> /dev/null
   2.143 +			mkdir -p $DISTRO
   2.144 +			status
   2.145 +			mkdir $TMP_DIR
   2.146 +			zcat $FLAVOR.flavor | ( cd $TMP_DIR; cpio -i 2>/dev/null )
   2.147 +			echo -n "Create distro-packages.list..."
   2.148 +			mv $TMP_DIR/$FLAVOR.pkglist distro-packages.list
   2.149 +			status
   2.150 +			for i in rootcd rootfs; do
   2.151 +				if [ -f $TMP_DIR/$FLAVOR.$i ]; then
   2.152 +					mkdir -p "$ADDFILES/$i"
   2.153 +					zcat $TMP_DIR/$FLAVOR.$i | \
   2.154 +						( cd "$ADDFILES/$i"; cpio -id 2> /dev/null)
   2.155 +				fi
   2.156 +			done
   2.157 +			echo -n "Update tazlito.conf..."
   2.158 +			[ -f tazlito.conf ] || cp /etc/tazlito/tazlito.conf .
   2.159 +			cat tazlito.conf | grep -v "^#VOLUM_NAME" | \
   2.160 +			sed "s/^VOLUM_NA/VOLUM_NAME=\"SliTaz $FLAVOR\"\\n#VOLUM_NA/" \
   2.161 +				> tazlito.conf.$$ && mv tazlito.conf.$$ tazlito.conf
   2.162 +			status
   2.163 +			rm -Rf $TMP_DIR
   2.164 +		fi
   2.165 +		;;
   2.166  	gen-distro)
   2.167  		# Generate a live distro tree with a set of packages.
   2.168  		#