summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDale Ogilvie <pnyli0002@sneakemail.com>2007-05-30 11:48:18 +0100
committerAaron Griffin <aaronmgriffin@gmail.com>2007-05-30 23:58:22 -0500
commita8c552d4770b50da1ed6248000392ac28fe17950 (patch)
tree224fe9553c29f6ceaad23d5bfbc4dff75d90f699 /scripts
parent2ef1c8416f99ae62dc9e6d570ccbaefcc6fc3eed (diff)
Add support for creating xdeltas in makepkg.
Add xdelta option to makepkg.conf Added xfer script to contrib. Signed-off-by: Andrew Fyfe <andrew@neptune-one.net>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/makepkg.in47
1 files changed, 47 insertions, 0 deletions
diff --git a/scripts/makepkg.in b/scripts/makepkg.in
index 00e7b443..8c573461 100644
--- a/scripts/makepkg.in
+++ b/scripts/makepkg.in
@@ -594,6 +594,53 @@ create_package() {
error "$(gettext "Failed to create package file.")"
exit 1 # TODO: error code
fi
+
+ create_xdelta "$pkg_file"
+}
+
+create_xdelta() {
+ if [ "$(check_buildenv xdelta)" != "y" ]; then
+ return
+ fi
+
+ # Check to see if we have any old versions to create deltas with
+ local pkg_file=$1
+ local base_file=""
+ local delta_file=""
+ local cache_dir="/var/cache/pacman/pkg"
+ local latest_version=""
+ local old_versions=( $(ls ${cache_dir}/${pkgname}-*-${CARCH}.${PKGEXT} 2>/dev/null; ls ${PKGDEST}/${pkgname}-*-${CARCH}.${PKGEXT} 2>/dev/null) )
+
+ local old_file dirname filename namend old_version
+ for old_file in "${old_versions[@]}"; do
+ dirname=$(dirname $old_file)
+ filename=$(basename $old_file)
+ namend=${filename#"$pkgname-"}
+ old_version=${namend%-"${CARCH}.${PKGEXT}"}
+
+ # old_version may include the target package, only use the old versions
+ if [ "$old_version" != "$pkgver-$pkgrel" ] && [[ "$old_version" > "$latest_version" ]]; then
+ latest_version=$old_version
+ base_file=$old_file
+ delta_file=$PKGDEST/$pkgname-${old_version}_to_$pkgver-$pkgrel-${CARCH}.delta
+ fi
+ done
+
+ if [ "$delta_file" != "" ]; then
+ msg "Making delta from version $latest_version"
+ # xdelta will decompress base_file & pkg_file into TMP_DIR (or /tmp if TMP_DIR is unset)
+ # then perform the delta on the resulting tars
+ xdelta delta $base_file $pkg_file $delta_file
+ # Generate the final gz using xdelta for compression. xdelta will be our common
+ # denominator compression utility between the packager and the users
+ #
+ # makepkg and pacman must use the same compression algorithm or the delta generated
+ # package may not match, producing md5 checksum errors.
+ #
+ xdelta patch $delta_file $base_file $pkg_file
+ else
+ msg "No previous version found, skipping xdelta"
+ fi
}
create_srcpackage() {