Aaron Griffin wrote:
> On Wed, Apr 29, 2009 at 2:02 PM, Firmicus <[email protected]> wrote:
>   
>> OK, I've just git-cloned dbscripts and devtools. BTW I notice that the
>> summary, shortlog and log links on projects.archlinux.org give a garbled
>> display. Only the "tree"s are displayed properly.
>>     
>
> Erm, sounds like a font issue on your end. Everything looks fine from here
>   
Certainly not. But never mind. The problem disappeared the next day.

OK, back to topic. First of all, the git repo you gave me does not have
the patches from Abhishek. I finally figured out that I had to pull his
branch any-arch from github.

I have fixed quite a few bugs in db-update and rewritten some sections
(patch attached).

Then I have tested it quite intensively with all possible scenarios,
and, as far as I can tell, it works fine!

BTW, the script convert-to-any is quite broken. I have first tried to
fix it but soon realized it is actually not a good idea to rely on it at
all. Better to create clean packages for arch=any instead.

Looking forward to seeing the official adoption of arch=any in our repos!

Best,
F

diff --git a/db-update b/db-update
index 3e9fbcf..926faef 100755
--- a/db-update
+++ b/db-update
@@ -12,9 +12,11 @@ source_makepkg
 reponame="$1"
 current_arch=""
 
+repo_lock $reponame "all"
+
 [ "$UID" = "" ] && UID=$(uid)
 
-WORKDIR="$TMPDIR/db-update.$svnrepo.$UID"
+WORKDIR="$TMPDIR/db-update.$reponame.$UID"
 ADDPKGS=""
 ANYPKGS=""
 
@@ -58,7 +60,7 @@ getpkgname() {
 cleanup() {
     trap '' 0 2
 	# unlock
-	repo_unlock $reponame $current_arch
+	repo_unlock $reponame "all"
 	rm -rf "$WORKDIR"
 	[ "$1" ] && exit $1
 }
@@ -77,46 +79,69 @@ trap ctrl_c 2
 trap cleanup 0
 
 # Process architecture-independent packages first.
-if [ -d "$stagedir" ]; then
+instaging=`/bin/ls $stagedir/*$PKGEXT 2>/dev/null | wc -l`
+instaging_any=`/bin/ls $stagedir/*-any$PKGEXT 2>/dev/null | wc -l`
+instaging_i686=`/bin/ls $stagedir/*-i686$PKGEXT 2>/dev/null | wc -l`
+instaging_x86_64=`/bin/ls $stagedir/*-x86_64$PKGEXT 2>/dev/null | wc -l`
+
+if [ $instaging != 0 ]; then
 	ANYPKGS="$(/bin/ls $stagedir/*-any$PKGEXT 2>/dev/null)"
+else 
+	die "$stagedir is empty!"
 fi
 
-echo "==> Processing new/updated arch-independent packages for '$reponame'..." >&2
+/bin/mkdir -p "$WORKDIR" 
 cd "$WORKDIR"
+echo "Found $instaging packages in $stagedir:"
+echo "       any: $instaging_any package(s)"
+echo "      i686: $instaging_i686 package(s)"
+echo "    x86_64: $instaging_x86_64 package(s)"
+
 svnpath="$(get_svnpath $reponame)"
 /usr/bin/svn checkout -N $svnpath checkout
 cd checkout
-to_add_any=""
-if [ -n "$ANYPKGS" ]; then
-	for pkg in $ANYPKGS; do
-		_pkgfile=$(basename $pkg)
-		_pkgname="$(getpkgname $pkg)"
-		svnrepo="$reponame-any"
-		echo "    Validating package arch (any) $_pkgname"
-		if ! check_pkg_arch "$pkg" "any"; then
-			echo "   ERROR: $_pkgfile is not architecture independent!"
-		else
-			echo "    Checking SVN for $_pkgname"
-			/usr/bin/svn up -q $_pkgname
-			if [ -d "$_pkgname/repos/$svnrepo" ]; then
-				. "$_pkgname/repos/$svnrepo/$BUILDSCRIPT"
-				if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-any$PKGEXT" ]; then
-					to_add_any="$to_add_any $pkg"
+if [ $instaging_any != 0 ]; then
+	echo "==> Processing $instaging_any new/updated arch-independent packages for '$reponame'..." >&2
+	to_add_any=""
+	if [ -n "$ANYPKGS" ]; then
+		for pkg in $ANYPKGS; do
+			_pkgfile=$(basename $pkg)
+			_pkgname="$(getpkgname $pkg)"
+			svnrepo="$reponame-any"
+			echo -n "    Validating package arch (any) $_pkgname"
+			if ! check_pkg_arch "$pkg" "any"; then
+				echo "  "
+				echo "  ERROR: $_pkgfile is not architecture-independent!"
+			else
+				echo " : OK" 
+				echo "    Checking SVN for $_pkgname"
+				/usr/bin/svn up -q $_pkgname
+				if [ -d "$_pkgname/repos/$svnrepo" ]; then
+					. "$_pkgname/repos/$svnrepo/$BUILDSCRIPT"
+					if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-any$PKGEXT" ]; then
+						to_add_any="$to_add_any $pkg"
+					else
+						echo "    WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo"
+					fi
 				else
-					echo "    WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo"
+					echo "    WARNING: Package $_pkgname not found in $svnrepo"
 				fi
-			else
-				echo "    WARNING: Package $_pkgname not found in $svnrepo"
 			fi
-		fi
-	done
+		done
+	fi
 fi
 
 for A in ${arch...@]}; do
 	current_arch="$A"
+	eval instaging_arch=\$instaging_$current_arch
 
-	ftppath="$FTP_BASE/$reponame/os/$current_arch/"
-	ftppath_any="$FTP_BASE/$reponame/os/any/"
+	if [ $instaging_arch == 0 -a ! -n "$to_add_any" ]; then
+		echo "No packages for arch = $current_arch : skipping"
+		continue
+	fi
+
+	ftppath="$FTP_BASE/$reponame/os/$current_arch"
+	ftppath_any="$FTP_BASE/$reponame/os/any"
 
 	if [ ! -d "$ftppath" ]; then
 		echo "FTP path for this repo ($reponame) is missing"
@@ -128,8 +153,6 @@ for A in ${arch...@]}; do
 	svnpath="$(get_svnpath $reponame)"
 	svnrepo="$reponame-$current_arch"
 
-	repo_lock $reponame $current_arch
-
 	/bin/mkdir -p "$WORKDIR/build"
 	cd "$WORKDIR"
 
@@ -141,20 +164,20 @@ for A in ${arch...@]}; do
 	echo "Updating DB for $svnrepo"
 
 	to_add=""
-	if [ -d "$stagedir" ]; then
-		ADDPKGS="$(/bin/ls $stagedir/*-${current_arch}$PKGEXT 2>/dev/null)"
-	fi
+	ADDPKGS="$(/bin/ls $stagedir/*-${current_arch}$PKGEXT 2>/dev/null)"
+	arch_total=$(echo "$ADDPKGS $to_add_any" | wc -w)
 
-	if [ -n "$ADDPKGS" || -n "$ANYPKGS" ]; then
+	if [ -n "$ADDPKGS" -o -n "$ANYPKGS" ]; then
 
 		echo "==> Copying DB file from '$reponame'..." >&2
 		if [ -f "$ftppath/$reponame.db.tar.$DB_COMPRESSION" ]; then
 			/bin/cp "$ftppath/$reponame.db.tar.$DB_COMPRESSION" build/
 		else
-			touch "build/$reponame.db.tar.$DB_COMPRESSION"
+			## touch "build/$reponame.db.tar.$DB_COMPRESSION"
+			echo "Creating $reponame DB from scratch"
 		fi
 
-		echo "==> Processing new/updated packages for repository '$reponame'..." >&2
+		echo "==> Processing $arch_total new/updated packages for repository '$reponame' ($current_arch}) ..." >&2
 
 		cd "$WORKDIR"
 		/usr/bin/svn checkout -N $svnpath checkout
@@ -165,10 +188,11 @@ for A in ${arch...@]}; do
 				_pkgfile=$(basename $pkg)
 				_pkgname="$(getpkgname $pkg)"
 
-				echo "    Validating package arch ($current_arch) $_pkgname"
+				echo -n "    Validating package arch ($current_arch) $_pkgname"
 				if ! check_pkg_arch "$pkg" "$current_arch"; then
 					echo "   ERROR: $_pkgfile was built for the wrong architecture"
 				else
+					echo " : OK"
 					echo "    Checking SVN for $_pkgname"
 					/usr/bin/svn up -q $_pkgname
 					if [ -d "$_pkgname/repos/$svnrepo" ]; then
@@ -185,7 +209,7 @@ for A in ${arch...@]}; do
 			done
 		fi
 
-		if [ -n "$to_add" || -n "$to_add_any" ]; then
+		if [ -n "$to_add" -o -n "$to_add_any" ]; then
 			cd "$WORKDIR/build/"
 			for f in $to_add $to_add_any; do /bin/cp "$f" .; done
 
@@ -204,20 +228,26 @@ for A in ${arch...@]}; do
 	# if non empty, move all build dirs
 	if [ $(/bin/ls "$WORKDIR/build/" 2>/dev/null | wc -l) != 0 ]; then
 		echo "Copying new files to '$ftppath'"
-		for f in "$WORKDIR/build/"*$current_arch$PKGEXT; do
-			if ! /bin/cp "$f" "$ftppath"; then
-				die "error: failure while copying files to $ftppath"
-			fi
-		done
-		for f in "$WORKDIR/build/"*any.pkg.tar.gz; do
-			if ! /bin/cp "$f" "$ftppath_any"; then
-				die "error: failure while copying files to $ftppath_any"
-			fi
-			if ! ln -s "$ftppath_any/$f" "$ftppath/$f"; then
-				die "error: failed to make link for $f."
-			fi
-		done
-		if ! /bin/cp "$WORKDIR/build/$reponame.db"* "$ftppath"; then
+		if [ $instaging_arch != 0 ]; then
+			for f in $WORKDIR/build/*$current_arch$PKGEXT; do
+				if ! /bin/cp "$f" "$ftppath"; then
+					die "error: failure while copying files to $ftppath"
+				fi
+			done
+	    fi
+		if [ $instaging_any != 0 -a -n "$to_add_any" ]; then
+		echo "Copying new files to '$ftppath_any' and symlinking"
+			for f in $WORKDIR/build/*any$PKGEXT; do
+				if ! /bin/cp "$f" "$ftppath_any"; then
+					die "error: failure while copying files to $ftppath_any"
+				fi
+				bf=$(basename $f)
+				if ! ln -s "$ftppath_any/$bf" "$ftppath/$bf"; then
+					die "error: failed to make link for $bf."
+				fi
+			done
+		fi
+		if ! /bin/cp "$WORKDIR/build/$reponame.db"* "$ftppath/"; then
 			die "failed to move repository $reponame-$A".
 		fi
 	else
@@ -229,9 +259,10 @@ for A in ${arch...@]}; do
 		/bin/rm $to_add
 	fi
 
-	repo_unlock $reponame $current_arch
 done
 
-/bin/rm $to_add_any
+if [ -n "$to_add_any" ]; then
+	/bin/rm $to_add_any
+fi
 cleanup
 # vim: set ts=4 sw=4 noet ft=sh:

Reply via email to