tazpkg view modules/repack @ 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 | a02e36d44d06 |
children |
line source
1 #!/bin/sh
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
3 # repack - TazPkg module
4 # Create SliTaz package archive from an installed package
7 # Connect function libraries
8 . /lib/libtaz.sh
10 # Get TazPkg working environment
11 . @@MODULES@@/getenv
14 unset EXTRAVERSION; . "$INSTALLED/$1/receipt"
16 title 'Repacking "%s"' "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg"
18 if grep -qs ^NO_REPACK= "$INSTALLED/$PACKAGE/receipt"; then
19 _ "Can't repack package \"%s\"" "$PACKAGE"
20 exit 1
21 fi
23 if [ -s "$INSTALLED/$PACKAGE/modifiers" ]; then
24 _ "Can't repack, \"%s\" files have been modified by:" "$PACKAGE"
25 sed 's|.*| \0|' "$INSTALLED/$PACKAGE/modifiers"
26 exit 1
27 fi
29 MISSING=''
30 while read i; do
31 [ -e "$i" ] && continue
32 [ -L "$i" ] || MISSING="$MISSING\n $i"
33 done < "$INSTALLED/$PACKAGE/files.list"
34 if [ -n "$MISSING" ]; then
35 _n "Can't repack, the following files are lost:"
36 echo -e "$MISSING"
37 exit 1
38 fi
40 TMP_DIR=$(mktemp -d)
41 cd "$TMP_DIR"
43 FILES="fs.cpio.lzma\n"
44 for i in $(ls "$INSTALLED/$PACKAGE"); do
45 case $i in
46 volatile.cpio.gz|modifiers) ;;
47 *) cp "$INSTALLED/$PACKAGE/$i" .; FILES="$FILES$i\n" ;;
48 esac
49 done
51 ln -s / rootfs
52 mkdir tmp
53 sed 's/^/rootfs/' < files.list | cpio -o -H newc --quiet | \
54 { cd tmp ; cpio -idm --quiet >/dev/null; cd ..; }
55 mv tmp/rootfs fs
57 if [ -f "$INSTALLED/$PACKAGE/volatile.cpio.gz" ]; then
58 zcat "$INSTALLED/$PACKAGE/volatile.cpio.gz" | \
59 { cd fs; cpio -idm --quiet; cd ..; }
60 fi
62 if fgrep -q repack_cleanup "$INSTALLED/$PACKAGE/receipt"; then
63 . "$INSTALLED/$PACKAGE/receipt"
64 repack_cleanup fs
65 fi
67 if [ -f "$INSTALLED/$PACKAGE/$CHECKSUM" ]; then
68 sed 's, , fs,' < "$INSTALLED/$PACKAGE/$CHECKSUM" | $CHECKSUM -s -c || {
69 _ "Can't repack, %s error." "$CHECKSUM"
70 cd "$TOP_DIR"
71 rm -rf "$TMP_DIR"
72 exit 1
73 }
74 fi
76 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
77 echo -e "$FILES" | cpio -o -H newc --quiet > "$TOP_DIR/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg"
78 cd "$TOP_DIR"
79 #\rm -R "$TMP_DIR"
80 _ 'Package "%s" repacked successfully.' "$PACKAGE"
81 _ 'Size: %s' "$(du -sh "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg")"
82 newline