From ae925feaaad06ea5586cc5a12f1e2cfd36e105f8 Mon Sep 17 00:00:00 2001
From: Xavier Chantry <shiningxc@gmail.com>
Date: Fri, 27 Feb 2009 16:38:16 +0100
Subject: [PATCH 2/2] repo-add : add delta generation

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
---
 scripts/repo-add.sh.in |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 5454fb0..5c7340c 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -28,6 +28,7 @@ myver='@PACKAGE_VERSION@'
 confdir='@sysconfdir@'
 
 QUIET=0
+DELTA=0
 REPO_DB_FILE=
 LOCKFILE=
 CLEAN_LOCK=0
@@ -226,6 +227,14 @@ db_write_entry()
 
 	if [ -d "$pkgname-$pkgver" ]; then
 		warning "$(gettext "An entry for '%s' already existed")" "$pkgname-$pkgver"
+	else
+		if [ $DELTA -eq 1 ]; then
+			pkgentry=$(find_pkgentry $pkgname)
+			if [ -n "$pkgentry" ]; then
+				oldfilename=$(grep -A1 FILENAME $pkgentry/desc | tail -n1)
+				oldfile="$(dirname $1)/$oldfilename"
+			fi
+		fi
 	fi
 
 	# remove an existing entry if it exists, ignore failures
@@ -271,6 +280,12 @@ db_write_entry()
 
 	cd "$startdir"
 
+	# create a delta file
+	if [ -n "$oldfilename" -a -f "$oldfile" ]; then
+		delta=$(pkgdelta $oldfile $1)
+		db_write_delta $delta
+	fi
+
 	return 0
 } # end db_write_entry
 
@@ -444,7 +459,7 @@ success=0
 for arg in "$@"; do
 	case "$arg" in
 		-q|--quiet) QUIET=1;;
-
+		-d|--delta) DELTA=1;;
 		-f|--force)
 			warning "$(gettext "the -f and --force options are no longer recognized")"
 			msg2 "$(gettext "use options=(force) in the PKGBUILD instead")"
-- 
1.6.4.3

