spk rev 112
moved pack to spk-convert for now.
author | Christian Mesh <meshca@clarkson.edu> |
---|---|
date | Sat Jun 09 15:48:33 2012 -0500 (2012-06-09) |
parents | dae62126a6a4 |
children | 45434133a9df |
files | spk-convert |
line diff
1.1 --- a/spk-convert Sat Jun 09 10:22:38 2012 -0500 1.2 +++ b/spk-convert Sat Jun 09 15:48:33 2012 -0500 1.3 @@ -55,6 +55,81 @@ 1.4 1.5 } 1.6 1.7 +# Create SliTaz package archive using cpio and lzma. 1.8 +# TODO: Cook also pack packages, we should share code in libpkg.sh 1.9 +# Usage: pack $package 1.10 +pack() { 1.11 + local package=$1 1.12 + local dir="$2" 1.13 + local fs="$dir/fs" 1.14 + local receipt="$dir/receipt" 1.15 + 1.16 + if [ ! -f "$receipt" ]; then 1.17 + gettext "Receipt is missing. Please read the documentation."; newline 1.18 + exit 0 1.19 + else 1.20 +# cd $dir 1.21 + newline 1.22 + echo $(boldify "Packing :") $package 1.23 + separator 1.24 + 1.25 + # Create files.list with redirecting find outpout. 1.26 + gettext "Creating the list of files..." 1.27 + find $fs -type f -print > $dir/files.list 1.28 + find $fs -type l -print >> $dir/files.list 1.29 + 1.30 + status 1.31 + gettext "Creating $CHECKSUM of files..." 1.32 + local file 1.33 + for file in $(cat $dir/files.list); do 1.34 + [ -L "$fs$file" ] && continue 1.35 + [ -f "$fs$file" ] || continue 1.36 + case "$file" in 1.37 + /lib/modules/*/modules.*|*.pyc) continue;; 1.38 + esac 1.39 + $CHECKSUM "$fs$file" | sed 's/ fs/ /' >> $dir/$CHECKSUM 1.40 + done 1.41 + 1.42 + status 1.43 + UNPACKED_SIZE=$(du -chs $fs $receipt $dir/files.list $dir/$CHECKSUM \ 1.44 + $dir/description.txt 2> /dev/null | \ 1.45 + awk '{ sz=$1 } END { print sz }') 1.46 + 1.47 + # Build cpio archives. 1.48 + gettext "Compressing the fs... " 1.49 + find $fs | cpio -o -H newc --quiet | lzma e $fs.cpio.lzma -si 1.50 + rm -rf $fs 1.51 + status 1.52 + 1.53 + PACKED_SIZE=$(du -chs $fs.cpio.lzma $receipt $dir/files.list \ 1.54 + $dir/$CHECKSUM $dir/description.txt 2> /dev/null | \ 1.55 + awk '{ sz=$1 } END { print sz }') 1.56 + 1.57 + gettext "Updating receipt sizes..." 1.58 + sed -i s/^PACKED_SIZE.*$// $receipt 1.59 + sed -i s/^UNPACKED_SIZE.*$// $receipt 1.60 + sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" $receipt 1.61 + status 1.62 + 1.63 + gettext "Creating full cpio archive... " 1.64 + find $dir -print | cpio -o -H newc --quiet > $dir.tazpkg 1.65 + status 1.66 + 1.67 + gettext "Restoring original package tree... " 1.68 + 1.69 + unlzma -c $fs.cpio.lzma | cpio -idm --quiet $dir 1.70 + status 1.71 + 1.72 + rm $fs.cpio.lzma 1.73 + separator 1.74 + eval_gettext "Package \$package compressed successfully."; newline 1.75 + echo $(gettext "Size") : $(du -sh $dir.tazpkg) 1.76 + newline 1.77 + fi 1.78 +} 1.79 + 1.80 + 1.81 + 1.82 # search dependencies for files 1.83 # Usage: find_depends $fs 1.84 find_depends() { 1.85 @@ -181,9 +256,7 @@ 1.86 1.87 [ -z "$SHORT_DESC" ] || echo $SHORT_DESC > $file/description.txt 1.88 1.89 - cd $tmpdir 1.90 - tazpkg pack $file 1.91 - cd - > /dev/null 1.92 + pack $PACKAGE $file 1.93 1.94 mv $tmpdir/$file.tazpkg . 1.95 ;; 1.96 @@ -233,9 +306,7 @@ 1.97 show_unresolved_lib $tmpdir/$file/receipt 1.98 rm -f $file/fs/.[A-Z]* 1.99 1.100 - cd $tmpdir 1.101 - tazpkg pack $file 1.102 - cd - > /dev/null 1.103 + pack $PACKAGE $file 1.104 1.105 mv $file.tazpkg . 1.106 else 1.107 @@ -300,9 +371,7 @@ 1.108 1.109 rm -rf $fs/install 1.110 1.111 - cd $tmpdir 1.112 - tazpkg pack $file 1.113 - cd - /dev/null 1.114 + pack $PACKAGE $file 1.115 1.116 mv $file.tazpkg . 1.117 else 1.118 @@ -360,9 +429,7 @@ 1.119 # Description.txt 1.120 [ -z "$SHORT_DESC" ] || echo "$SHORT_DESC" > $file/Description.txt 1.121 1.122 - cd $tmpdir 1.123 - tazpkg pack $file 1.124 - cd - > /dev/null 1.125 + pack $PACKAGE $file 1.126 1.127 mv $file.tazpkg . 1.128 ;; 1.129 @@ -422,9 +489,7 @@ 1.130 1.131 show_unresolved_lib $receipt 1.132 1.133 - cd $tmpdir 1.134 - tazpkg pack $file 1.135 - cd - 1.136 + pack $PACKAGE $file 1.137 1.138 mv $file.tazpkg . 1.139