tazlito diff tazlito @ rev 11
pave the road to flavors. Misc fixes: lzma, typos
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Dec 11 19:14:12 2007 +0100 (2007-12-11) |
parents | 8f27e43358c0 |
children | 15a98c96f18f |
line diff
1.1 --- a/tazlito Tue Dec 04 12:35:53 2007 +0100 1.2 +++ b/tazlito Tue Dec 11 19:14:12 2007 +0100 1.3 @@ -20,6 +20,8 @@ 1.4 TOP_DIR=`pwd` 1.5 INITRAMFS=rootfs.gz 1.6 LZMA_INITRAMFS=rootfs.lz 1.7 +LOCALSTATE=/var/lib/tazpkg 1.8 +INSTALLED=$LOCALSTATE/installed 1.9 1.10 # Try to include config file, continue if command is gen-config or exit. 1.11 # The main config used by default is in /etc/tazlito. 1.12 @@ -98,6 +100,15 @@ 1.13 fi 1.14 } 1.15 1.16 +# Check for the rootfs tree. 1.17 +check_rootfs() 1.18 +{ 1.19 + if [ ! -d "$ROOTFS" ] ; then 1.20 + echo -e "\nUnable to find a distro rootfs to check.\n" 1.21 + exit 0 1.22 + fi 1.23 +} 1.24 + 1.25 # Check for the boot dir into the root CD tree. 1.26 verify_rootcd() 1.27 { 1.28 @@ -133,11 +144,9 @@ 1.29 # Use lzma if installed 1.30 if [ -x /usr/bin/lzma ]; then 1.31 echo -n "Generating cpio archive... " 1.32 - find . -print | cpio -o -H newc > ../rootfs.cpio 1.33 + find . -print | cpio -o -H newc | lzma e -si -so > $DISTRO/$LZMA_INITRAMFS 1.34 cd $DISTRO 1.35 - lzma e $ROOTFS.cpio $LZMA_INITRAMFS 1.36 - rm rootfs.cpio 1.37 - cp $LZMA_INITRAMFS $ROOTCD/boot 1.38 + mv $LZMA_INITRAMFS $ROOTCD/boot 1.39 # Remove eventual gziped initramfs and sed isolinux.cfg for the path 1.40 # to lzma rootfs ($LZMA_INITRAMFS) 1.41 rm -f $ROOTCD/boot/$INITRAMFS 1.42 @@ -146,7 +155,7 @@ 1.43 echo -n "Generating gziped initramfs... " 1.44 find . -print | cpio -o -H newc | gzip -9 > $DISTRO/$INITRAMFS 1.45 cd $DISTRO 1.46 - cp $INITRAMFS $ROOTCD/boot 1.47 + mv $INITRAMFS $ROOTCD/boot 1.48 fi 1.49 } 1.50 1.51 @@ -160,9 +169,9 @@ 1.52 echo "Packages : `ls -1 $ROOTFS/var/lib/tazpkg/installed | wc -l`" 1.53 echo "Rootfs size : `du -sh $ROOTFS`" 1.54 if [ -f $LZMA_INITRAMFS ]; then 1.55 - echo "Initramfs size : `du -sh $LZMA_INITRAMFS`" 1.56 + echo "Initramfs size : `du -sh $ROOTCD/boot/$LZMA_INITRAMFS`" 1.57 else 1.58 - echo "Initramfs size : `du -sh $INITRAMFS`" 1.59 + echo "Initramfs size : `du -sh $ROOTCD/boot/$INITRAMFS`" 1.60 fi 1.61 echo "ISO image size : `du -sh $ISO_NAME.iso`" 1.62 echo "================================================================================" 1.63 @@ -244,7 +253,6 @@ 1.64 # a empty config file and sed it. 1.65 # 1.66 if [ -f "tazlito.conf" ] ; then 1.67 - continue 1.68 rm tazlito.conf 1.69 else 1.70 if test $(id -u) = 0 ; then 1.71 @@ -260,17 +268,17 @@ 1.72 echo -e "\033[1mConfiguring :\033[0m `pwd`/tazlito.conf" 1.73 echo "================================================================================" 1.74 # ISO name. 1.75 - echo -n "ISO name : " ; read anser 1.76 - sed -i s#'ISO_NAME=\"\"'#"ISO_NAME=\"$anser\""# tazlito.conf 1.77 + echo -n "ISO name : " ; read answer 1.78 + sed -i s#'ISO_NAME=\"\"'#"ISO_NAME=\"$answer\""# tazlito.conf 1.79 # Volum name. 1.80 - echo -n "Volum name : " ; read anser 1.81 - sed -i s/'VOLUM_NAME=\"SliTaz\"'/"VOLUM_NAME=\"$anser\""/ tazlito.conf 1.82 + echo -n "Volum name : " ; read answer 1.83 + sed -i s/'VOLUM_NAME=\"SliTaz\"'/"VOLUM_NAME=\"$answer\""/ tazlito.conf 1.84 # Packages repository. 1.85 - echo -n "Packages repository : " ; read anser 1.86 - sed -i s#'PACKAGES_REPOSITORY=\"\"'#"PACKAGES_REPOSITORY=\"$anser\""# tazlito.conf 1.87 + echo -n "Packages repository : " ; read answer 1.88 + sed -i s#'PACKAGES_REPOSITORY=\"\"'#"PACKAGES_REPOSITORY=\"$answer\""# tazlito.conf 1.89 # Distro path. 1.90 - echo -n "Distro path : " ; read anser 1.91 - sed -i s#'DISTRO=\"\"'#"DISTRO=\"$anser\""# tazlito.conf 1.92 + echo -n "Distro path : " ; read answer 1.93 + sed -i s#'DISTRO=\"\"'#"DISTRO=\"$answer\""# tazlito.conf 1.94 echo "================================================================================" 1.95 echo "Config file is ready to use." 1.96 echo "You can now extract an ISO or generate a distro." 1.97 @@ -336,14 +344,13 @@ 1.98 cp -a $TMP_DIR/boot/isolinux $TARGET/rootcd/boot 1.99 status 1.100 echo -n "Copying the rootfs..." 1.101 - cp $TMP_DIR/boot/rootfs.gz $TARGET/rootcd/boot 1.102 - cp $TMP_DIR/boot/rootfs.gz $TARGET/rootfs 1.103 + cp $TMP_DIR/boot/rootfs.?z $TARGET/rootcd/boot 1.104 status 1.105 # Exract initramfs. 1.106 cd $TARGET/rootfs 1.107 echo -n "Extracting the rootfs... " 1.108 - gzip -d rootfs.gz && cpio -id < rootfs 1.109 - rm rootfs 1.110 + ( zcat ../rootcd/boot/rootfs.gz 2>/dev/null || \ 1.111 + lzma d ../rootcd/boot/rootfs.lz -so ) | cpio -id 1.112 # Umount and remove temp directory and cd to $TARGET to get stats. 1.113 umount $TMP_DIR && rm -rf $TMP_DIR 1.114 cd .. 1.115 @@ -410,6 +417,7 @@ 1.116 sleep 2 1.117 for pkg in $LIST 1.118 do 1.119 + local here=`pwd` 1.120 # First copy and extract the package in tmp dir. 1.121 pkg=${pkg%.tazpkg} 1.122 mkdir -p $TMP_DIR 1.123 @@ -417,21 +425,21 @@ 1.124 echo "" 1.125 echo -n "Installing $PACKAGE... " 1.126 cpio -id < $pkg.tazpkg && rm -f $pkg.tazpkg 1.127 - gzip -d fs.cpio.gz 1.128 echo -n "Extracting the file system... " 1.129 - cpio -id < fs.cpio && rm fs.cpio 1.130 + zcat fs.cpio.gz | cpio -id && rm fs.cpio.gz 1.131 # Copy all packages fs and receipt to the rootfs. 1.132 echo -n "Copying files to the rootfs..." 1.133 cp -a fs/* $ROOTFS 1.134 . $PWD/receipt 1.135 - mkdir -p $ROOTFS/var/lib/tazpkg/installed/$PACKAGE 1.136 + mkdir -p $ROOTFS$INSTALLED/$PACKAGE 1.137 # Copy the receipt, list of files and description if exist. 1.138 - cp receipt $ROOTFS/var/lib/tazpkg/installed/$PACKAGE 1.139 - cp files.list $ROOTFS/var/lib/tazpkg/installed/$PACKAGE 1.140 + cp receipt $ROOTFS$INSTALLED/$PACKAGE 1.141 + cp files.list $ROOTFS$INSTALLED/$PACKAGE 1.142 if [ -f "description.txt" ] ; then 1.143 - cp description.txt $ROOTFS/var/lib/tazpkg/installed/$PACKAGE 1.144 + cp description.txt $ROOTFS$INSTALLED/$PACKAGE 1.145 fi 1.146 status 1.147 + cd $here 1.148 # Remove tmp dir to get a empty one for the next package. 1.149 rm -rf $TMP_DIR 1.150 done 1.151 @@ -440,7 +448,8 @@ 1.152 # Copy all files from $ADDFILES/rootfs to the rootfs. 1.153 if [ -d "$ADDFILES/rootfs" ] ; then 1.154 echo -n "Copying addfiles content to the rootfs... " 1.155 - cp -a $ADDFILES/rootfs/* $ROOTFS && status 1.156 + cp -a $ADDFILES/rootfs/* $ROOTFS 1.157 + status 1.158 fi 1.159 echo "Root file system is generated..." 1.160 # Root CD part. 1.161 @@ -453,14 +462,15 @@ 1.162 echo -n "Moving the boot directory..." 1.163 mv $ROOTFS/boot $ROOTCD 1.164 cd $ROOTCD/boot 1.165 - mv vmlinuz-* bzImage 1.166 + ln vmlinuz-* bzImage 1.167 status 1.168 fi 1.169 cd $DISTRO 1.170 # Copy all files from $ADDFILES/rootcd to the rootcd. 1.171 if [ -d "$ADDFILES/rootcd" ] ; then 1.172 echo -n "Copying addfiles content to the rootcd... " 1.173 - cp -a $ADDFILES/rootcd/* $ROOTCD && status 1.174 + cp -a $ADDFILES/rootcd/* $ROOTCD 1.175 + status 1.176 fi 1.177 # Initramfs and ISO image stuff. 1.178 gen_initramfs 1.179 @@ -479,14 +489,17 @@ 1.180 echo -n "Removing the rootfs..." 1.181 rm -f $DISTRO/$INITRAMFS 1.182 rm -f $DISTRO/$LZMA_INITRAMFS 1.183 - rm -rf $ROOTFS && status 1.184 + rm -rf $ROOTFS 1.185 + status 1.186 fi 1.187 if [ -d "$ROOTCD" ] ; then 1.188 echo -n "Removing the rootcd..." 1.189 - rm -rf $ROOTCD && status 1.190 + rm -rf $ROOTCD 1.191 + status 1.192 fi 1.193 echo -n "Removing eventual ISO image..." 1.194 - rm -f $DISTRO/$ISO_NAME.iso && status 1.195 + rm -f $DISTRO/$ISO_NAME.iso 1.196 + status 1.197 fi 1.198 echo "================================================================================" 1.199 echo "" 1.200 @@ -541,16 +554,13 @@ 1.201 check-distro) 1.202 # Check for a few LiveCD needed files not installed by packages. 1.203 # 1.204 - if [ ! -d "$ROOTFS" ] ; then 1.205 - echo -e "\nUnable to find a distro rootfs to check.\n" 1.206 - exit 0 1.207 - fi 1.208 + check_rootfs 1.209 echo "" 1.210 echo -e "\033[1mChecking distro :\033[0m $ROOTFS" 1.211 echo "================================================================================" 1.212 # SliTaz release info. 1.213 if [ ! -f "$ROOTFS/etc/slitaz-release" ]; then 1.214 - echo "Missing release info : /var/lib/tazpkg/mirror" 1.215 + echo "Missing release info : /etc/slitaz-release" 1.216 else 1.217 release=`cat $ROOTFS/etc/slitaz-release` 1.218 echo -n "Release : $release" 1.219 @@ -599,8 +609,8 @@ 1.220 echo "ISO image : $iso" 1.221 echo "================================================================================" 1.222 echo "" 1.223 - echo -n "Burn ISO image (y/N) ? "; read anser 1.224 - if [ "$anser" == "y" ]; then 1.225 + echo -n "Burn ISO image (y/N) ? "; read answer 1.226 + if [ "$answer" == "y" ]; then 1.227 echo "" 1.228 echo "Starting Wodim to burn the iso..." && sleep 2 1.229 echo "================================================================================"