tazpkg view modules/pack @ rev 950

Minor bug fixes due to the change in the behavior of the dot command in Busybox-1.27; support "release checksum" in modules/mkdb.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu Jul 27 13:38:37 2017 +0300 (2017-07-27)
parents d6cbd0c5f273
children
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 TAZPKG_PACK="$2"
19 cd "$PACKAGE"
21 if [ ! -f 'receipt' ]; then
22 _ 'Receipt is missing. Please read the documentation.'
23 exit 0
24 fi
26 title 'Packing package "%s"' "$PACKAGE"
28 # Create files.list with redirecting find output.
29 action 'Creating the list of files...'
30 cd fs
31 find . -type f -print > ../files.list
32 find . -type l -print >> ../files.list
33 cd ..; sed -i s/'^.'/''/ files.list
34 status
36 action 'Creating %s of files...' "$CHECKSUM"
37 while read file; do
38 [ -L "fs$file" ] && continue
39 [ -f "fs$file" ] || continue
40 case "$file" in
41 /lib/modules/*/modules.*|*.pyc) continue;;
42 esac
43 $CHECKSUM "fs$file" | sed 's/ fs/ /'
44 done < files.list > $CHECKSUM
45 status
47 UNPACKED_SIZE=$(du -chs fs receipt files.list $CHECKSUM description.txt 2>/dev/null | awk 'END {print $1}')
49 # Build cpio archives.
50 action 'Compressing the FS...'
51 find fs | cpio -o -H newc --quiet | case "$TAZPKG_PACK" in
52 gzip) gzip -9 > fs.cpio.gz ;;
53 *) lzma e fs.cpio.lzma -si ;;
54 esac
55 rm -rf fs
56 status
58 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list $CHECKSUM description.txt 2>/dev/null | awk 'END {print $1}')
60 action 'Updating receipt sizes...'
61 sed -i s/^PACKED_SIZE.*$// receipt
62 sed -i s/^UNPACKED_SIZE.*$// receipt
63 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
64 status
66 action 'Creating full cpio archive...'
67 find . -print | cpio -o -H newc --quiet > "../$PACKAGE.tazpkg"
68 status
70 action 'Restoring original package tree...'
71 case "$TAZPKG_PACK" in
72 gzip) gzip -d < fs.cpio.gz;;
73 *) unlzma < fs.cpio.lzma;;
74 esac | cpio -idm --quiet
75 status
76 rm fs.cpio.*
78 cd ..
80 footer "$(_ 'Package "%s" compressed successfully.' "$PACKAGE")"
81 _ 'Size: %s' "$(ls -lh "$PACKAGE.tazpkg" | awk '{print $5}')"