summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorXavier Chantry <chantry.xavier@gmail.com>2010-10-11 17:08:00 +0200
committerDan McGee <dan@archlinux.org>2010-10-11 20:28:43 -0500
commitc9179b09db405e89093c07756d8e674ff8119ea2 (patch)
tree3953601bcaf3da5b5eb55e2c5092174da20c77d6 /scripts
parent53b41afbe8c47afaa5daf94f4e66cab81bd024cd (diff)
downloadpacman-c9179b09db405e89093c07756d8e674ff8119ea2.tar.gz
pacman-c9179b09db405e89093c07756d8e674ff8119ea2.zip
repo-add: add delta generation
This allows deltas to be generated at repo-add invocation time as opposed to just added to the database. It will generate the delta from the package version currently in the database. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/repo-add.sh.in26
1 files changed, 25 insertions, 1 deletions
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 8ef940d0..51a38c3c 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
@@ -61,7 +62,7 @@ error() {
# print usage instructions
usage() {
printf "repo-add, repo-remove (pacman) %s\n\n" "$myver"
- printf "$(gettext "Usage: repo-add [-q] <path-to-db> <package|delta> ...\n")"
+ printf "$(gettext "Usage: repo-add [-d] [-q] <path-to-db> <package|delta> ...\n")"
printf "$(gettext "Usage: repo-remove [-q] <path-to-db> <packagename|delta> ...\n\n")"
printf "$(gettext "\
repo-add will update a package database by reading a package file.\n\
@@ -73,6 +74,10 @@ packages to remove can be specified on the command line.\n\n")"
printf "$(gettext "\
Use the -q/--quiet flag to minimize output to basic messages, warnings,\n\
and errors\n\n")"
+ printf "$(gettext "\
+Use the -d/--delta flag to automatically generate and add a delta file\n\
+between the old entry and the new one, if the old package file is found\n\
+next to the new one.\n\n")"
echo "$(gettext "Example: repo-add /path/to/repo.db.tar.gz pacman-3.0.0.pkg.tar.gz")"
echo "$(gettext "Example: repo-remove /path/to/repo.db.tar.gz kernel26")"
}
@@ -229,6 +234,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
+ local oldfilename=$(grep -A1 FILENAME $pkgentry/desc | tail -n1)
+ local oldfile="$(dirname $1)/$oldfilename"
+ fi
+ fi
fi
# remove an existing entry if it exists, ignore failures
@@ -275,6 +288,16 @@ db_write_entry()
cd "$startdir"
+ # create a delta file
+ if [ -n "$oldfilename" -a -f "$oldfile" ]; then
+ delta=$(pkgdelta -q $oldfile $1)
+ if [ -f "$delta" ]; then
+ db_write_delta $delta
+ else
+ warning "$(gettext "Old package file not found : %s")" "$oldfilename"
+ fi
+ fi
+
return 0
} # end db_write_entry
@@ -447,6 +470,7 @@ success=0
for arg in "$@"; do
case "$arg" in
-q|--quiet) QUIET=1;;
+ -d|--delta) DELTA=1;;
*)
if [[ -z $REPO_DB_FILE ]]; then
REPO_DB_FILE="$arg"