From fc90918edee5ebfb2cb02f2184ed0eadc4cfd147 Mon Sep 17 00:00:00 2001
From: PyroPeter <abi1789@googlemail.com>
Date: Tue, 11 Jan 2011 23:04:20 +0100
Subject: [PATCH] repo-add: Create/modify pkgfile-db

https://bugs.archlinux.org/task/11302

Signed-off-by: PyroPeter <abi1789@googlemail.com>
---
 doc/repo-add.8.txt     |    5 ++++-
 scripts/repo-add.sh.in |   14 +++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/doc/repo-add.8.txt b/doc/repo-add.8.txt
index 81bf837..299e5d2 100644
--- a/doc/repo-add.8.txt
+++ b/doc/repo-add.8.txt
@@ -10,7 +10,7 @@ repo-add - package database maintenance utility
 
 Synopsis
 --------
-repo-add [-q] <path-to-db> <package1> [<package2> ...]
+repo-add [-q] [-f] <path-to-db> <package1> [<package2> ...]
 
 repo-remove [-q] <path-to-db> <packagename> [<packagename2> ...]
 
@@ -34,6 +34,9 @@ Options
 	Force this program to keep quiet and run silent except for warning and
 	error messages.
 
+*-f, \--files*::
+	Tells repo-add also to create a list of the packages files, as needed to
+	create reponame.files.tar.gz databases for pkgfile.
 
 See Also
 --------
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index d09d1b4..188936b 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -29,6 +29,7 @@ confdir='@sysconfdir@'
 
 QUIET=0
 DELTA=0
+WITHFILES=0
 REPO_DB_FILE=
 LOCKFILE=
 CLEAN_LOCK=0
@@ -62,7 +63,7 @@ error() {
 # print usage instructions
 usage() {
 	printf "repo-add, repo-remove (pacman) %s\n\n" "$myver"
-	printf "$(gettext "Usage: repo-add [-d] [-q] <path-to-db> <package|delta> ...\n")"
+	printf "$(gettext "Usage: repo-add [-d] [-f] [-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\
@@ -78,6 +79,9 @@ and errors\n\n")"
 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")"
+	printf "$(gettext "\
+Use the -f/--files flag to update a files-db (for pkgfile) instead of a\n\
+normal 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")"
 }
@@ -289,6 +293,13 @@ db_write_entry()
 	write_list_entry "PROVIDES" "$_provides" "depends"
 	write_list_entry "OPTDEPENDS" "$_optdepends" "depends"
 
+	# create files file if wanted
+	if (( WITHFILES )); then
+		msg2 "$(gettext "Creating 'files' db entry...")"
+		echo "%FILES%" > files
+		bsdtar --exclude='.*' -tf "$startdir/$pkgfile" >> files
+	fi
+
 	cd "$startdir"
 
 	# create a delta file
@@ -474,6 +485,7 @@ for arg in "$@"; do
 	case "$arg" in
 		-q|--quiet) QUIET=1;;
 		-d|--delta) DELTA=1;;
+		-f|--files) WITHFILES=1;;
 		*)
 			if [[ -z $REPO_DB_FILE ]]; then
 				REPO_DB_FILE="$arg"
-- 
1.7.3.4

