tazpkg view modules/recompress @ rev 955

modules/search: allow search file with dash at start: tazpkg -sf "-spi"
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Dec 22 00:02:54 2017 +0200 (2017-12-22)
parents d6cbd0c5f273
children
line source
1 #!/bin/sh
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
3 # recompress - TazPkg module
4 # Recompress .tazpkg cpio archive with lzma
7 # Connect function libraries
8 . /lib/libtaz.sh
10 # Get TazPkg working environment
11 . @@MODULES@@/getenv
16 # Extract a package with cpio and gzip/lzma.
18 extract_package() {
19 action 'Extracting package...'
20 cpio -idm --quiet < "${PACKAGE_FILE##*/}" && rm -f "${PACKAGE_FILE##*/}"
21 if [ -f fs.cpio.lzma ]; then
22 unlzma < fs.cpio.lzma | cpio -idm --quiet && rm fs.cpio.lzma
23 elif [ -f fs.cpio.gz ]; then
24 zcat fs.cpio.gz | cpio -idm --quiet && rm fs.cpio.gz
25 fi
26 status
27 }
30 PACKAGE_FILE="$1"
32 title 'Recompressing package "%s"' "$(basename "$PACKAGE_FILE" .tazpkg)"
33 TMP_DIR="$(mktemp -d)"
35 action "Copying original package..."
36 cp "$PACKAGE_FILE" "$TMP_DIR"
37 status
39 cd "$TMP_DIR"
40 extract_package
42 action "Recompressing the FS..."
43 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
44 rm -rf fs
45 status
47 action "Creating new package..."
48 find | cpio -o -H newc --quiet > "$PACKAGE_FILE"
49 status
51 rm -rf "$TMP_DIR"
52 separator; newline