- allow db-move to handle multiple packages
    (or add a script to help moving from community-testing)
We should kill these testing2whatever scripts and unify it completely in
db-move (including the testing2x case where the right repository is
automatically determined). Short-term it would probably suffice to
create community-testing2community.
Ask and ye shall receive. Attached is a patch db-move that incorporates the ability to handle multiple packages and cleans up the whitespaces. I know the whitespace patch should technically be separate but I had such a hard time reading db-move when I was editing it that I had to include it for my own sanity. Note: my patch hasn't been tested beyond echoing output to the screen... but it should work.
diff --git a/db-move b/db-move
index efd54e0..fab8527 100755
--- a/db-move
+++ b/db-move
@@ -1,17 +1,17 @@
 #!/bin/bash
 
-if [ $# -ne 4 ]; then
-       echo "usage: $(basename $0) <pkgname|packagebase> <repo-from> <repo-to> 
<arch>"
-       exit 1
+if [ $# -lt 4 ]; then
+    echo "usage: $(basename $0) <pkgname|packagebase> <repo-from> <repo-to> 
<arch>"
+    exit 1
 fi
 
 . "$(dirname $0)/db-functions"
 . "$(dirname $0)/config"
 
-packagebase="$1"
-repofrom="$2"
-repoto="$3"
-_arch="$4"
+args=($@)
+_arch="${args[${#ar...@]}-1]}" && unset args[${#ar...@]}-1]
+repoto="${args[${#ar...@]}-1]}" && unset args[${#ar...@]}-1]
+repofrom="${args[${#ar...@]}-1]}" && unset args[${#ar...@]}-1]
 
 ftppath_from="$FTP_BASE/$repofrom/os/"
 ftppath_to="$FTP_BASE/$repoto/os/"
@@ -24,100 +24,104 @@ WORKDIR="$TMPDIR/db-move.$svnrepo_from.$svnrepo_to.$UID"
 
 cleanup() {
     trap '' 0 2
-       # unlock
+    # unlock
     repo_unlock $repoto $_arch
     repo_unlock $repofrom $_arch
-       rm -rf "$WORKDIR"
-       [ "$1" ] && exit $1
+    rm -rf "$WORKDIR"
+    [ "$1" ] && exit $1
 }
 
 ctrl_c() {
-       echo "Interrupted" >&2
-       cleanup 0
+    echo "Interrupted" >&2
+    cleanup 0
 }
 
 die() {
-       echo "$*" >&2
-       cleanup 1
+    echo "$*" >&2
+    cleanup 1
 }
 
-trap ctrl_c 2
-trap cleanup 0
+for pkgbase in ${ar...@]}; do
+    echo "==> Moving package '$pkgbase'"
 
-repo_lock $repoto $_arch
-repo_lock $repofrom $_arch
+    trap ctrl_c 2
+    trap cleanup 0
 
-/bin/mkdir -p "$WORKDIR"
+    repo_lock $repoto $_arch
+    repo_lock $repofrom $_arch
 
-cd "$WORKDIR"
-/usr/bin/svn checkout -N $SVNREPO checkout
-cd checkout
+    /bin/mkdir -p "$WORKDIR"
 
-/usr/bin/svn up -q $packagebase
-if [ -d "$packagebase/repos/$svnrepo_from" ]; then
-    . "$packagebase/repos/$svnrepo_from/$BUILDSCRIPT"
+    cd "$WORKDIR"
+    /usr/bin/svn checkout -N $SVNREPO checkout
+    cd checkout
+
+    /usr/bin/svn up -q $packagebase
+    if [ -d "$packagebase/repos/$svnrepo_from" ]; then
+        . "$packagebase/repos/$svnrepo_from/$BUILDSCRIPT"
     
-    for i in ${pkgna...@]}; do
-        _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT"
-        if [ ! -f "$ftppath_from/${_arch}/$_pkgfile" ]; then
-            die "error: package file '$_pkgfile' not found in repo '$repofrom'"
+        for i in ${pkgna...@]}; do
+            _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT"
+            if [ ! -f "$ftppath_from/${_arch}/$_pkgfile" ]; then
+                die "error: package file '$_pkgfile' not found in repo 
'$repofrom'"
+            fi
+        done
+
+        if [ -d "$packagebase/repos/$svnrepo_to" ]; then
+            echo "    Removing existing package from subversion"
+            /usr/bin/svn rm --force -q "$packagebase/repos/$svnrepo_to"
+            /usr/bin/svn commit -q -m "$(basename $0): $packagebase removed by 
$(id -un) for move to $repoto"
         fi
-    done
 
-    if [ -d "$packagebase/repos/$svnrepo_to" ]; then
-        echo "    Removing existing package from subversion"
-        /usr/bin/svn rm --force -q "$packagebase/repos/$svnrepo_to"
-        /usr/bin/svn commit -q -m "$(basename $0): $packagebase removed by 
$(id -un) for move to $repoto"
-    fi
+        echo "    Moving svn entries"
+        /usr/bin/svn mv -r HEAD "$packagebase/repos/$svnrepo_from" 
"$packagebase/repos/$svnrepo_to"
+        /usr/bin/svn commit -m "$(basename $0): moved $packagebase from 
[$repofrom] to [$repoto] ($_arch)"
 
-    echo "    Moving svn entries"
-    /usr/bin/svn mv -r HEAD "$packagebase/repos/$svnrepo_from" 
"$packagebase/repos/$svnrepo_to"
-    /usr/bin/svn commit -m "$(basename $0): moved $packagebase from 
[$repofrom] to [$repoto] ($_arch)"
+        echo "    Moving package file and updating DBs"
+        cd "$WORKDIR"
+        [ -d build/ ] || mkdir build
+        cd build/
 
-    echo "    Moving package file and updating DBs"
-    cd "$WORKDIR"
-    [ -d build/ ] || mkdir build
-    cd build/
-
-       if [ "${_arch}" == "any" ]; then
-               arches="i686 x86_64"
-       else
-               arches="${_arch}"
-       fi
-
-    for architecture in $arches; do
-               # copy the db file into our working area
-               if [ -f "$ftppath_from/$architecture/$repofrom$DBEXT" ]; then
-                   /bin/cp "$ftppath_from/$architecture/$repofrom$DBEXT" .
-                   /usr/bin/repo-remove -q "$repofrom$DBEXT" ${pkgna...@]} || 
die "Error in repo-remove"
-                   #use '*' to move the old DB too
-                   mv $repofrom$DBEXT* "$ftppath_from/$architecture"
-                   echo "    Package files will be cleaned up automatically"
-               fi
-
-               if [ -f "$ftppath_to/$architecture/$repoto$DBEXT" ]; then
-                   /bin/cp "$ftppath_to/$architecture/$repoto$DBEXT" .
-               fi
-
-               for i in ${pkgna...@]}; do
-                       _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT"
-                       /bin/cp "$ftppath_from/$architecture/$_pkgfile" .
-                       /usr/bin/repo-add -q "$repoto$DBEXT" $_pkgfile || die 
"Error in repo-add $_pkgfile"
-               done
-               #use '*' to move the old DB too
-               mv $repoto$DBEXT* $ftppath_to/$architecture
-        for i in ${pkgna...@]}; do
-            _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT"
-            if [ "${_arch}" == "any" ]; then
-                mv ${_pkgfile} $ftppath_to/any
-                ln -s ../any/${_pkgfile} $ftppath_to/$architecture/
-            else
-                mv ${_pkgfile} $ftppath_to/$architecture
+        if [ "${_arch}" == "any" ]; then
+            arches="i686 x86_64"
+        else
+            arches="${_arch}"
+        fi
+
+        for architecture in $arches; do
+            # copy the db file into our working area
+            if [ -f "$ftppath_from/$architecture/$repofrom$DBEXT" ]; then
+                /bin/cp "$ftppath_from/$architecture/$repofrom$DBEXT" .
+                /usr/bin/repo-remove -q "$repofrom$DBEXT" ${pkgna...@]} || die 
"Error in repo-remove"
+                #use '*' to move the old DB too
+                mv $repofrom$DBEXT* "$ftppath_from/$architecture"
+                echo "    Package files will be cleaned up automatically"
             fi
+
+            if [ -f "$ftppath_to/$architecture/$repoto$DBEXT" ]; then
+                /bin/cp "$ftppath_to/$architecture/$repoto$DBEXT" .
+            fi
+
+            for i in ${pkgna...@]}; do
+                _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT"
+                /bin/cp "$ftppath_from/$architecture/$_pkgfile" .
+                /usr/bin/repo-add -q "$repoto$DBEXT" $_pkgfile || die "Error 
in repo-add $_pkgfile"
+            done
+            #use '*' to move the old DB too
+            mv $repoto$DBEXT* $ftppath_to/$architecture
+            for i in ${pkgna...@]}; do
+                _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT"
+                if [ "${_arch}" == "any" ]; then
+                    mv ${_pkgfile} $ftppath_to/any
+                    ln -s ../any/${_pkgfile} $ftppath_to/$architecture/
+                else
+                    mv ${_pkgfile} $ftppath_to/$architecture
+                fi
+            done
         done
-       done
-else
-    die "Error: $packagebase is not in repo $repofrom"
-fi
+    else
+        die "Error: $packagebase is not in repo $repofrom"
+    fi
+done
 
 cleanup

Reply via email to