tazlito rev 285
Add tazlito deduplicate
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Jul 09 11:50:22 2012 +0200 (2012-07-09) |
parents | 060492ce4431 |
children | f9f9ab92b556 |
files | tazlito |
line diff
1.1 --- a/tazlito Fri Jul 06 11:08:43 2012 +0000 1.2 +++ b/tazlito Mon Jul 09 11:50:22 2012 +0200 1.3 @@ -101,6 +101,7 @@ 1.4 check-distro Help to check if distro is ready to release. 1.5 writeiso Use running system to generate a bootable ISO (with /home). 1.6 merge Merge multiple rootfs into one iso. 1.7 + deduplicate Deduplicate files in a tree. 1.8 repack Recompress rootfs into iso with maximum ratio. 1.9 build-loram Generate a live-CD for low ram systems. 1.10 frugal-install Frugal install in /boot/frugal from a distro or ISO. 1.11 @@ -357,18 +358,10 @@ 1.12 echo 1 > /tmp/rootfs 1.13 } 1.14 1.15 -# Generate a new initramfs from the root filesystem. 1.16 -gen_initramfs() 1.17 +# Deduplicate files (MUST be on the same filesystem). 1.18 +deduplicate() 1.19 { 1.20 - # Just in case CTRL+c 1.21 - rm -f $DISTRO/gen 1.22 - 1.23 - # Some packages may want to alter rootfs 1.24 - genisohooks rootfs 1.25 - cd $1 1.26 - 1.27 - # Link duplicate files 1.28 - find . -type f -size +0c -exec stat -c '%s-%a-%u-%g %i %h %n' {} \; | \ 1.29 + find "$@" -type f -size +0c -exec stat -c '%s-%a-%u-%g %i %h %n' {} \; | \ 1.30 sort | ( save=0; old_attr=""; old_inode=""; old_link=""; old_file="" 1.31 while read attr inode link file; do 1.32 if [ "$attr" = "$old_attr" -a "$inode" != "$old_inode" ]; then 1.33 @@ -383,6 +376,20 @@ 1.34 done 1.35 echo "$save bytes saved in duplicate files." 1.36 ) 1.37 +} 1.38 + 1.39 +# Generate a new initramfs from the root filesystem. 1.40 +gen_initramfs() 1.41 +{ 1.42 + # Just in case CTRL+c 1.43 + rm -f $DISTRO/gen 1.44 + 1.45 + # Some packages may want to alter rootfs 1.46 + genisohooks rootfs 1.47 + cd $1 1.48 + 1.49 + # Link duplicate files 1.50 + deduplicate . 1.51 1.52 # Use lzma if installed. Display rootfs size in realtime. 1.53 rm -f /tmp/rootfs 1.54 @@ -2600,6 +2607,10 @@ 1.55 echo -e "qemu $QEMU_OPTS $iso\n" 1.56 qemu $QEMU_OPTS $iso ;; 1.57 1.58 + deduplicate) 1.59 + # Deduplicate files in a tree 1.60 + shift 1.61 + deduplicate "$@" ;; 1.62 usage|*) 1.63 # Clear and print usage also for all unknown commands. 1.64 #