tazlito rev 191
tazlito: add iso2flavor command
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Dec 18 17:08:30 2010 +0100 (2010-12-18) |
parents | 0c75c957b322 |
children | 233dc896fb14 |
files | tazlito |
line diff
1.1 --- a/tazlito Wed Dec 15 10:24:06 2010 +0100 1.2 +++ b/tazlito Sat Dec 18 17:08:30 2010 +0100 1.3 @@ -87,6 +87,7 @@ 1.4 upgrade-flavor Update package list to the latest available versions. 1.5 extract-flavor Extract a (*.flavor) flavor into $FLAVORS_REPOSITORY. 1.6 pack-flavor Pack (and update) a flavor from $FLAVORS_REPOSITORY. 1.7 + iso2flavor Create a flavor file from a SliTaz iso image. 1.8 check-list Check a distro-packages.list for updates. 1.9 extract-distro Extract an ISO to a directory and rebuild LiveCD tree. 1.10 gen-distro Generate a Live distro and ISO from a list of packages. 1.11 @@ -992,6 +993,63 @@ 1.12 create_iso $OUTPUT $TMP_DIR/loramiso 1.13 } 1.14 1.15 +# Remove files installed by packages 1.16 +find_flavor_rootfs() 1.17 +{ 1.18 + for i in $1/etc/tazlito/*.extract; do 1.19 + [ -e $i ] || continue 1.20 + chroot $1 /bin/sh ${i#$1} 1.21 + done 1.22 + 1.23 + # Clean hardlinks and files patched by genisofs in /boot 1.24 + for i in isolinux/isolinux.bin isolinux/boot.cat bzImage ; do 1.25 + rm -f $1/boot/$i 1.26 + done 1.27 + 1.28 + # Clean files generated in post_install 1.29 + rm -f $1/lib/modules/*/modules.* $1/etc/mtab \ 1.30 + $1/dev/core $1/dev/fd $1/dev/std* 1.31 + 1.32 + # Verify md5 1.33 + cat $1/var/lib/tazpkg/installed/*/md5sum | \ 1.34 + while read md5 file; do 1.35 + [ -e $1$file ] || continue 1.36 + [ "$(cat $1$file | md5sum)" == "$md5 -" ] && 1.37 + rm -f $1$file 1.38 + done 1.39 + 1.40 + # Check configuration files 1.41 + for i in $1/var/lib/tazpkg/installed/*/volatile.cpio.gz; do 1.42 + [ -e $i ] || continue 1.43 + mkdir /tmp/volatile$$ 1.44 + zcat $i | ( cd /tmp/volatile$$ ; cpio -idmu > /dev/null ) 1.45 + ( cd /tmp/volatile$$ ; find * -type f ) | while read file ; do 1.46 + [ -e $1/$file ] || continue 1.47 + cmp -s /tmp/volatile$$/$file $1/$file && rm -f $1/$file 1.48 + done 1.49 + rm -rf /tmp/volatile$$ 1.50 + done 1.51 + 1.52 + # Remove other files blindly 1.53 + for i in $1/var/lib/tazpkg/installed/*/files.list; do 1.54 + for file in $(cat $i); do 1.55 + [ $1$file -nt $i ] && continue 1.56 + [ -f $1$file -a ! -L $1$file ] && continue 1.57 + [ -d $1$file ] || rm -f $1$file 1.58 + done 1.59 + done 1.60 + 1.61 + # Remove tazpkg date 1.62 + rm -rf $1/var/lib/tazpkg/installed* 1.63 + 1.64 + # Cleanup directory tree 1.65 + cd $1 1.66 + find * -type d | sort -r | while read dir; do 1.67 + rmdir $dir 2> /dev/null 1.68 + done 1.69 + cd - > /dev/null 1.70 +} 1.71 + 1.72 #################### 1.73 # Tazlito commands # 1.74 #################### 1.75 @@ -1570,6 +1628,89 @@ 1.76 fi 1.77 echo "" 1.78 ;; 1.79 + 1.80 + iso2flavor) 1.81 + if [ -z "$3" -o ! -s "$2" ]; then 1.82 + cat <<EOT 1.83 +Usage : tazlito iso2flavor image.iso flavor_name 1.84 + 1.85 +Create a file flavor_name.flavor from the cdrom image file image.iso 1.86 +EOT 1.87 + exit 1 1.88 + fi 1.89 + FLAVOR=${3%.flavor} 1.90 + mkdir -p $TMP_DIR/iso $TMP_DIR/rootfs 1.91 + mount -o loop,ro $2 $TMP_DIR/iso 1.92 + if [ -s $TMP_DIR/iso/boot/rootfs1.gz ]; then 1.93 + echo "META flavors are not supported." 1.94 + umount -d $TMP_DIR/iso 1.95 + elif [ ! -s $TMP_DIR/iso/boot/rootfs.gz ]; then 1.96 + echo "No /boot/rootfs.gz in iso image. Need a SliTaz iso." 1.97 + umount -d $TMP_DIR/iso 1.98 + else 1.99 + ( unlzma -c $TMP_DIR/iso/boot/rootfs.gz || \ 1.100 + zcat $TMP_DIR/iso/boot/rootfs.gz ) | \ 1.101 + ( cd $TMP_DIR/rootfs ; cpio -idmu > /dev/null ) 1.102 + if [ ! -s $TMP_DIR/rootfs/etc/slitaz-release ]; then 1.103 + echo "No file /etc/slitaz-release in /boot/rootfs.gz of iso image. Need a non loram SliTaz iso." 1.104 + umount -d $TMP_DIR/iso 1.105 + else 1.106 + ROOTFS_SIZE=$(du -hs $TMP_DIR/rootfs | awk '{ print $1 }') 1.107 + RAM_SIZE=$(du -s $TMP_DIR/rootfs | awk '{ print 32*int(($1+36000)/32768) "M" }') 1.108 + cp -a $TMP_DIR/iso $TMP_DIR/rootcd 1.109 + ISO_SIZE=$(df -h $TMP_DIR/iso | awk 'END { print $2 }') 1.110 + BUILD_DATE=$(date +%Y%m%d\ \at\ \%H:%M:%S -r $TMP_DIR/iso/md5sum) 1.111 + umount -d $TMP_DIR/iso 1.112 + INITRAMFS_SIZE=$(du -chs $TMP_DIR/rootcd/boot/rootfs.gz | awk '{ s=$1 } END { print $1 }') 1.113 + rm -f $TMP_DIR/rootcd/boot/rootfs.gz $TMP_DIR/rootcd/md5sum 1.114 + mv $TMP_DIR/rootcd/boot $TMP_DIR/rootfs 1.115 + sed 's/.* \(.*\).tazpkg*/\1/' > $TMP_DIR/$FLAVOR.pkglist \ 1.116 + < $TMP_DIR/rootfs/var/lib/tazpkg/installed.md5 1.117 + #[ -s $TMP_DIR/rootfs/etc/tazlito/distro-packages.list ] && 1.118 + # mv $TMP_DIR/rootfs/etc/tazlito/distro-packages.list $TMP_DIR/$FLAVOR.pkglist 1.119 + PKGCNT=$(grep -v ^# $TMP_DIR/$FLAVOR.pkglist | wc -l | awk '{ print $1 }') 1.120 + find_flavor_rootfs $TMP_DIR/rootfs 1.121 + [ -d $TMP_DIR/rootfs/boot ] && mv $TMP_DIR/rootfs/boot $TMP_DIR/rootcd 1.122 + [ -n "$(ls $TMP_DIR/rootfs)" ] && ( cd $TMP_DIR/rootfs ; find * | cpio -o -H newc ) | gzip -9 > $TMP_DIR/$FLAVOR.rootfs 1.123 + [ -n "$(ls $TMP_DIR/rootcd)" ] && ( cd $TMP_DIR/rootcd ; find * | cpio -o -H newc ) | gzip -9 > $TMP_DIR/$FLAVOR.rootcd 1.124 + rm -rf $TMP_DIR/rootcd $TMP_DIR/rootfs 1.125 + VERSION=""; MAINTAINER="" 1.126 + echo -en "Flavor short description \007: "; read -t 30 DESCRIPTION 1.127 + if [ -n "$DESCRIPTION" ]; then 1.128 + echo -en "Flavor version : "; read -t 30 VERSION 1.129 + echo -en "Flavor maintainer (your email) : "; read -t 30 MAINTAINER 1.130 + fi 1.131 + [ -n "$DESCRIPTION" ] || DESCRIPTION="Slitaz $FLAVOR flavor" 1.132 + [ -n "$VERSION" ] || VERSION="1.0" 1.133 + [ -n "$MAINTAINER" ] || MAINTAINER="nobody@slitaz.org" 1.134 + cat > $TMP_DIR/$FLAVOR.desc <<EOT 1.135 +Flavor : $FLAVOR 1.136 +Description : $DESCRIPTION 1.137 +Version : $VERSION 1.138 +Maintainer : $MAINTAINER 1.139 +LiveCD RAM size : $RAM_SIZE 1.140 +Build date : $BUILD_DATE 1.141 +Packages : $PKGCNT 1.142 +Rootfs size : $ROOTFS_SIZE 1.143 +Initramfs size : $INITRAMFS_SIZE 1.144 +ISO image size : $ISO_SIZE 1.145 +================================================================================ 1.146 + 1.147 +EOT 1.148 + ( cd $TMP_DIR ; ls $FLAVOR.* | cpio -o -H newc ) | gzip -9 > $FLAVOR.flavor 1.149 + cat <<EOT 1.150 +Tazlito can't detect each file installed during a package post_install. 1.151 +You should extract this flavor (tazlito extract-flavor $FLAVOR), 1.152 +check the files in /home/slitaz/flavors/$FLAVOR/rootfs tree and remove 1.153 +files generated by post_installs. 1.154 +Check /home/slitaz/flavors/$FLAVOR/receipt too and repack the flavor 1.155 +(tazlito pack-flavor $FLAVOR) 1.156 +EOT 1.157 + fi 1.158 + fi 1.159 + rm -rf $TMP_DIR 1.160 + ;; 1.161 + 1.162 check-list) 1.163 # Use current packages list in $PWD by default. 1.164 DISTRO_PKGS_LIST=distro-packages.list