tazpkg annotate modules/pack @ rev 840
Add a bunch of modules with new-style support of 'root' (not all commands are modules yet); strip and compress resources.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri Aug 28 16:10:34 2015 +0300 (2015-08-28) |
parents | |
children | d6cbd0c5f273 |
rev | line source |
---|---|
al@840 | 1 #!/bin/sh |
al@840 | 2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg |
al@840 | 3 # pack - TazPkg module |
al@840 | 4 # Create SliTaz package archive using cpio and lzma |
al@840 | 5 |
al@840 | 6 |
al@840 | 7 # Connect function libraries |
al@840 | 8 . /lib/libtaz.sh |
al@840 | 9 |
al@840 | 10 # Get TazPkg working environment |
al@840 | 11 . @@MODULES@@/getenv |
al@840 | 12 |
al@840 | 13 |
al@840 | 14 |
al@840 | 15 |
al@840 | 16 PACKAGE="$1" |
al@840 | 17 cd "$PACKAGE" |
al@840 | 18 if [ ! -f 'receipt' ]; then |
al@840 | 19 _ 'Receipt is missing. Please read the documentation.' |
al@840 | 20 exit 0 |
al@840 | 21 fi |
al@840 | 22 |
al@840 | 23 title 'Packing package "%s"' "$PACKAGE" |
al@840 | 24 |
al@840 | 25 # Create files.list with redirecting find output. |
al@840 | 26 action 'Creating the list of files...' |
al@840 | 27 cd fs |
al@840 | 28 find . -type f -print > ../files.list |
al@840 | 29 find . -type l -print >> ../files.list |
al@840 | 30 cd ..; sed -i s/'^.'/''/ files.list |
al@840 | 31 status |
al@840 | 32 |
al@840 | 33 action 'Creating %s of files...' "$CHECKSUM" |
al@840 | 34 while read file; do |
al@840 | 35 [ -L "fs$file" ] && continue |
al@840 | 36 [ -f "fs$file" ] || continue |
al@840 | 37 case "$file" in |
al@840 | 38 /lib/modules/*/modules.*|*.pyc) continue;; |
al@840 | 39 esac |
al@840 | 40 $CHECKSUM "fs$file" | sed 's/ fs/ /' |
al@840 | 41 done < files.list > $CHECKSUM |
al@840 | 42 status |
al@840 | 43 |
al@840 | 44 UNPACKED_SIZE=$(du -chs fs receipt files.list $CHECKSUM description.txt 2>/dev/null | awk 'END {print $1}') |
al@840 | 45 |
al@840 | 46 # Build cpio archives. |
al@840 | 47 action 'Compressing the FS...' |
al@840 | 48 find fs | cpio -o -H newc --quiet | case "$TAZPKG_PACK" in |
al@840 | 49 gzip) gzip -9 > fs.cpio.gz ;; |
al@840 | 50 *) lzma e fs.cpio.lzma -si ;; |
al@840 | 51 esac |
al@840 | 52 rm -rf fs |
al@840 | 53 status |
al@840 | 54 |
al@840 | 55 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list $CHECKSUM description.txt 2>/dev/null | awk 'END {print $1}') |
al@840 | 56 |
al@840 | 57 action 'Updating receipt sizes...' |
al@840 | 58 sed -i s/^PACKED_SIZE.*$// receipt |
al@840 | 59 sed -i s/^UNPACKED_SIZE.*$// receipt |
al@840 | 60 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt |
al@840 | 61 status |
al@840 | 62 |
al@840 | 63 action 'Creating full cpio archive...' |
al@840 | 64 find . -print | cpio -o -H newc --quiet > "../$PACKAGE.tazpkg" |
al@840 | 65 status |
al@840 | 66 |
al@840 | 67 action 'Restoring original package tree...' |
al@840 | 68 unlzma < fs.cpio.lzma | cpio -idm --quiet |
al@840 | 69 status |
al@840 | 70 |
al@840 | 71 rm fs.cpio.lzma && cd .. |
al@840 | 72 footer "$(_ 'Package "%s" compressed successfully.' "$PACKAGE")" |
al@840 | 73 _ 'Size: %s' "$(ls -lh "$PACKAGE.tazpkg" | awk '{print $5}')" |