> Added some output to the lock/unlock functions to see if it helps
> illustrate the issue better
>
> I also fiddled with the cleanup function in db-update a bit, so it
> only calls repo_unlock on an error. Didnt commit the changes, but lets
> see if that helps
>
>   
I think I fixed it. The thing is that through
    trap cleanup 0
the function cleanup() is called automatically at the end of the script.
And since cleanup in turn calls
    repo_unlock $reponame $current_arch
the latter fails because $current_arch is "x86_64" and we have already
unlocked each repo before the end of the for loop, resulting in a spurious
error message.
Replacing repo_unlock by
    rm -f $TMPDIR/.repolock.$reponame.*
in cleanup() solves this. (It might be actually better to have a function
delete_repolocks() in db-function that does this...)

I have also moved a few lines down within the
    if [ -n "$ANYPKGS" ]; then  <...> fi
construct. Otherwise one would get the message
    ==> Processing 0 new/updated arch-independent packages for
'$reponame'...
even when no package with arch=any is present in staging

See attached patch...

Gute Nacht,
F
>From 04eccb8904d9089f5af10452ccb2c2295d667c28 Mon Sep 17 00:00:00 2001
From: Francois Charette <[email protected]>
Date: Wed, 22 Jul 2009 00:17:29 +0200
Subject: [PATCH] Fix cleanup in db-update

Don't use repo_unlock in cleanup, since it can occur outside
the main FOR loop where the arch-specific repo-locks have been
actually removed already, resulting in a spurious error when
the script successfully exits.
Also moved some lines to within the IF construct for arch-independent
packages, where they belong.
---
 db-update |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/db-update b/db-update
index 338fb5b..475519f 100755
--- a/db-update
+++ b/db-update
@@ -47,7 +47,7 @@ fi
 cleanup() {
     trap '' 0 2
 	# unlock
-	repo_unlock $reponame $current_arch
+	rm -f $TMPDIR/.repolock.$reponame.*
 	rm -rf "$WORKDIR"
 	[ "$1" ] && exit $1
 }
@@ -65,20 +65,22 @@ die() {
 trap ctrl_c 2
 trap cleanup 0
 
+mkdir -p $WORKDIR
+
 # Process architecture-independent packages first.
 if [ -d "$stagedir" ]; then
 	ANYPKGS="$(/bin/ls $stagedir/*-any$PKGEXT 2>/dev/null)"
 fi
 
-pkgtotal=$(echo "$ANYPKGS" | wc -w)
-echo "==> Processing $pkgtotal new/updated arch-independent packages for '$reponame'..." >&2
-mkdir -p $WORKDIR
-cd "$WORKDIR"
-svnpath="$(get_svnpath $reponame)"
-/usr/bin/svn checkout -N $svnpath checkout
-cd checkout
-to_add_any=""
 if [ -n "$ANYPKGS" ]; then
+	pkgtotal=$(echo "$ANYPKGS" | wc -w)
+	echo "==> Processing $pkgtotal new/updated arch-independent packages for '$reponame'..." >&2
+
+	cd "$WORKDIR"
+	svnpath="$(get_svnpath $reponame)"
+	/usr/bin/svn checkout -N $svnpath checkout
+	cd checkout
+	to_add_any=""
 	for pkg in $ANYPKGS; do
 		_pkgfile=$(basename $pkg)
 		_pkgname="$(getpkgname $pkg)"
-- 
1.6.3.3

Reply via email to