tazpkg view 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
line source
1 #!/bin/sh
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
3 # pack - TazPkg module
4 # Create SliTaz package archive using cpio and lzma
7 # Connect function libraries
8 . /lib/libtaz.sh
10 # Get TazPkg working environment
11 . @@MODULES@@/getenv
16 PACKAGE="$1"
17 cd "$PACKAGE"
18 if [ ! -f 'receipt' ]; then
19 _ 'Receipt is missing. Please read the documentation.'
20 exit 0
21 fi
23 title 'Packing package "%s"' "$PACKAGE"
25 # Create files.list with redirecting find output.
26 action 'Creating the list of files...'
27 cd fs
28 find . -type f -print > ../files.list
29 find . -type l -print >> ../files.list
30 cd ..; sed -i s/'^.'/''/ files.list
31 status
33 action 'Creating %s of files...' "$CHECKSUM"
34 while read file; do
35 [ -L "fs$file" ] && continue
36 [ -f "fs$file" ] || continue
37 case "$file" in
38 /lib/modules/*/modules.*|*.pyc) continue;;
39 esac
40 $CHECKSUM "fs$file" | sed 's/ fs/ /'
41 done < files.list > $CHECKSUM
42 status
44 UNPACKED_SIZE=$(du -chs fs receipt files.list $CHECKSUM description.txt 2>/dev/null | awk 'END {print $1}')
46 # Build cpio archives.
47 action 'Compressing the FS...'
48 find fs | cpio -o -H newc --quiet | case "$TAZPKG_PACK" in
49 gzip) gzip -9 > fs.cpio.gz ;;
50 *) lzma e fs.cpio.lzma -si ;;
51 esac
52 rm -rf fs
53 status
55 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list $CHECKSUM description.txt 2>/dev/null | awk 'END {print $1}')
57 action 'Updating receipt sizes...'
58 sed -i s/^PACKED_SIZE.*$// receipt
59 sed -i s/^UNPACKED_SIZE.*$// receipt
60 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
61 status
63 action 'Creating full cpio archive...'
64 find . -print | cpio -o -H newc --quiet > "../$PACKAGE.tazpkg"
65 status
67 action 'Restoring original package tree...'
68 unlzma < fs.cpio.lzma | cpio -idm --quiet
69 status
71 rm fs.cpio.lzma && cd ..
72 footer "$(_ 'Package "%s" compressed successfully.' "$PACKAGE")"
73 _ 'Size: %s' "$(ls -lh "$PACKAGE.tazpkg" | awk '{print $5}')"