tazpkg diff modules/pack @ rev 842

tazpkg: internal command 'call ...' to call tazpkg functions from modules (to share functions between tazpkg and its modules)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Sep 02 03:31:47 2015 +0300 (2015-09-02)
parents
children d6cbd0c5f273
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/pack	Wed Sep 02 03:31:47 2015 +0300
     1.3 @@ -0,0 +1,73 @@
     1.4 +#!/bin/sh
     1.5 +# TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
     1.6 +# pack - TazPkg module
     1.7 +# Create SliTaz package archive using cpio and lzma
     1.8 +
     1.9 +
    1.10 +# Connect function libraries
    1.11 +. /lib/libtaz.sh
    1.12 +
    1.13 +# Get TazPkg working environment
    1.14 +. @@MODULES@@/getenv
    1.15 +
    1.16 +
    1.17 +
    1.18 +
    1.19 +PACKAGE="$1"
    1.20 +cd "$PACKAGE"
    1.21 +if [ ! -f 'receipt' ]; then
    1.22 +	_ 'Receipt is missing. Please read the documentation.'
    1.23 +	exit 0
    1.24 +fi
    1.25 +
    1.26 +title 'Packing package "%s"' "$PACKAGE"
    1.27 +
    1.28 +# Create files.list with redirecting find output.
    1.29 +action 'Creating the list of files...'
    1.30 +cd fs
    1.31 +find . -type f -print > ../files.list
    1.32 +find . -type l -print >> ../files.list
    1.33 +cd ..; sed -i s/'^.'/''/ files.list
    1.34 +status
    1.35 +
    1.36 +action 'Creating %s of files...' "$CHECKSUM"
    1.37 +while read file; do
    1.38 +	[ -L "fs$file" ] && continue
    1.39 +	[ -f "fs$file" ] || continue
    1.40 +	case "$file" in
    1.41 +		/lib/modules/*/modules.*|*.pyc) continue;;
    1.42 +	esac
    1.43 +	$CHECKSUM "fs$file" | sed 's/  fs/  /'
    1.44 +done < files.list > $CHECKSUM
    1.45 +status
    1.46 +
    1.47 +UNPACKED_SIZE=$(du -chs fs receipt files.list $CHECKSUM description.txt 2>/dev/null | awk 'END {print $1}')
    1.48 +
    1.49 +# Build cpio archives.
    1.50 +action 'Compressing the FS...'
    1.51 +find fs | cpio -o -H newc --quiet | case "$TAZPKG_PACK" in
    1.52 +	gzip) gzip -9 > fs.cpio.gz ;;
    1.53 +	*) lzma e fs.cpio.lzma -si ;;
    1.54 +esac
    1.55 +rm -rf fs
    1.56 +status
    1.57 +
    1.58 +PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list $CHECKSUM description.txt 2>/dev/null | awk 'END {print $1}')
    1.59 +
    1.60 +action 'Updating receipt sizes...'
    1.61 +sed -i s/^PACKED_SIZE.*$// receipt
    1.62 +sed -i s/^UNPACKED_SIZE.*$// receipt
    1.63 +sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
    1.64 +status
    1.65 +
    1.66 +action 'Creating full cpio archive...'
    1.67 +find . -print | cpio -o -H newc --quiet > "../$PACKAGE.tazpkg"
    1.68 +status
    1.69 +
    1.70 +action 'Restoring original package tree...'
    1.71 +unlzma < fs.cpio.lzma | cpio -idm --quiet
    1.72 +status
    1.73 +
    1.74 +rm fs.cpio.lzma && cd ..
    1.75 +footer "$(_ 'Package "%s" compressed successfully.' "$PACKAGE")"
    1.76 +_ 'Size: %s' "$(ls -lh "$PACKAGE.tazpkg" | awk '{print $5}')"