It happened to me in the past that I ran "extrapkg" by mistake on a
package that had not been updated. It still ended up in ~/staging/extra
on gerolde, and when I ran "/arch/db-update extra" it died in the middle
of the process of updating a dozen packages. I had to clean the mess by
hand.

This patch avoids this situation by checking, before starting the update
process, whether any pkg in the staging dir is actually already present
in the ftp repo, and in such a case removing it from the staging dir.

F

>From 317f8b184f56c544a4f358c2c46f66a463655358 Mon Sep 17 00:00:00 2001
From: Francois Charette <[email protected]>
Date: Tue, 15 Sep 2009 09:20:14 +0200
Subject: [PATCH] Remove pkg from $stagedir if already in FTP repo

---
 db-update |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/db-update b/db-update
index aa1cb95..c68cf84 100755
--- a/db-update
+++ b/db-update
@@ -74,6 +74,29 @@ die() {
 trap ctrl_c 2
 trap cleanup 0
 
+# Remove any package from $stagedir that is already in the FTP repository
+for f in $stagedir/*-any$PKGEXT; do
+	bf=$(basename $f)
+	ftppath_any="$FTP_BASE/$reponame/os/any"
+	if [[ -f $ftppath_any/$bf ]]; then
+		echo "    WARNING: Package file $bf already exists in FTP repo"
+		echo "    Removing from $stagedir"
+		/bin/rm $f
+	fi
+done
+
+for current_arch in ${arch...@]}; do
+	ftppath="$FTP_BASE/$reponame/os/$current_arch"
+	for f in $stagedir/*-$current_arch$PKGEXT; do
+		bf=$(basename $f)
+		if [[ -f $ftppath/$bf ]]; then
+			echo "    WARNING: Package file $bf already exists in FTP repo"
+			echo "    Removing from $stagedir"
+			/bin/rm $f
+		fi
+	done
+done
+
 # Process architecture-independent packages first.
 if [ -d "$stagedir" ]; then
 	ANYPKGS="$(/bin/ls $stagedir/*-any$PKGEXT 2>/dev/null)"
-- 
1.6.4.3


Reply via email to