tazpkg view modules/extract @ rev 896
Module 'convert': support .pet packages without *pet.specs inside
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Mon Dec 21 01:45:15 2015 +0200 (2015-12-21) |
parents | |
children |
line source
1 #!/bin/sh
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
3 # extract - TazPkg module
4 # Extract .tazpkg cpio archive into a directory
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 < "$1" && rm -f "$1"
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 }
32 PACKAGE_FILE="$1"
33 TARGET_DIR="$2"
34 PACKAGE="$(basename "$PACKAGE_FILE" .tazpkg)"
36 title 'Extracting package "%s"' "$PACKAGE"
38 # If no directory destination is found on the cmdline
39 # we create one in the current dir using the package name.
40 if [ -n "$TARGET_DIR" ]; then
41 DESTDIR="$TARGET_DIR/$PACKAGE"
42 else
43 DESTDIR="$PACKAGE"
44 fi
45 mkdir -p "$DESTDIR"
47 action 'Copying original package...'
48 cp "$PACKAGE_FILE" "$DESTDIR"
49 status
51 cd "$DESTDIR"
52 extract_package "${PACKAGE_FILE##*/}"
54 [ -e "receipt" ] && footer "$(_ 'Package "%s" is extracted to "%s"' "$PACKAGE" "$DESTDIR")"