[arch-projects] [PATCH] [dbscripts 2/2] db-repo-{add, remove}: allow specifying multiple packages

Dan McGee dan at archlinux.org
Tue Nov 1 10:55:26 EDT 2011


This allows invoking these commands for more than one package at a time
which is incredibly more efficient as the database doesn't need to be
locked, unpacked, modified, changed, and unlocked for every single
passed package name or file if you have more than one.

Signed-off-by: Dan McGee <dan at archlinux.org>
---
 db-remove      |    4 ++--
 db-repo-add    |   20 +++++++++++---------
 db-repo-remove |   13 +++++++------
 3 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/db-remove b/db-remove
index e7326c0..7e2282a 100755
--- a/db-remove
+++ b/db-remove
@@ -3,8 +3,8 @@
 . "$(dirname $0)/db-functions"
 . "$(dirname $0)/config"
 
-if [ $# -ne 3 ]; then
-	msg "usage: $(basename $0) <repo> <arch> <pkgname|pkgbase>"
+if [ $# -lt 3 ]; then
+	msg "usage: $(basename $0) <repo> <arch> <pkgname|pkgbase> ..."
 	exit 1
 fi
 
diff --git a/db-repo-add b/db-repo-add
index 8d4a56d..9661b91 100755
--- a/db-repo-add
+++ b/db-repo-add
@@ -3,14 +3,14 @@
 . "$(dirname $0)/db-functions"
 . "$(dirname $0)/config"
 
-if [ $# -ne 3 ]; then
-	msg "usage: $(basename $0) <repo> <arch> <pkgfile>"
+if [ $# -lt 3 ]; then
+	msg "usage: $(basename $0) <repo> <arch> <pkgfile> ..."
 	exit 1
 fi
 
 repo="$1"
 arch="$2"
-pkgfile="$3"
+pkgfiles=(${@:3})
 
 ftppath="$FTP_BASE/$repo/os"
 
@@ -28,12 +28,14 @@ for tarch in ${tarches[@]}; do
 	repo_lock $repo $tarch || exit 1
 done
 
-msg "Adding $pkgfile to [$repo]..."
-
 for tarch in ${tarches[@]}; do
-	if [ ! -f "${pkgfile}" ]; then
-		die "Package file ${pkgfile} not found"
-	fi
-	arch_repo_add "${repo}" "${tarch}" ${pkgfile}
+	for pkgfile in ${pkgfiles[@]}; do
+		if [[ ! -f $pkgfile ]]; then
+			die "Package file $pkgfile not found"
+		else
+			msg "Adding $pkgfile to [$repo]..."
+		fi
+	done
+	arch_repo_add "${repo}" "${tarch}" ${pkgfiles[@]}
 	repo_unlock $repo $tarch
 done
diff --git a/db-repo-remove b/db-repo-remove
index e55cd07..4f04ed1 100755
--- a/db-repo-remove
+++ b/db-repo-remove
@@ -3,14 +3,14 @@
 . "$(dirname $0)/db-functions"
 . "$(dirname $0)/config"
 
-if [ $# -ne 3 ]; then
-	msg "usage: $(basename $0) <repo> <arch> <pkgname>"
+if [ $# -lt 3 ]; then
+	msg "usage: $(basename $0) <repo> <arch> <pkgname> ..."
 	exit 1
 fi
 
 repo="$1"
 arch="$2"
-pkgname="$3"
+pkgnames=(${@:3})
 
 ftppath="$FTP_BASE/$repo/os"
 
@@ -28,9 +28,10 @@ for tarch in ${tarches[@]}; do
 	repo_lock $repo $tarch || exit 1
 done
 
-msg "Removing $pkgname from [$repo]..."
-
 for tarch in ${tarches[@]}; do
-	arch_repo_remove "${repo}" "${tarch}" ${pkgname}
+	for pkgname in ${pkgnames[@]}; do
+		msg "Removing $pkgname from [$repo]..."
+	done
+	arch_repo_remove "${repo}" "${tarch}" ${pkgnames[@]}
 	repo_unlock $repo $tarch
 done
-- 
1.7.7.1



More information about the arch-projects mailing list