Don't allow anomalous testing packages floating around after a rebuild
which are older than stable.

Signed-off-by: Eli Schwartz <eschwa...@archlinux.org>
---
 db-move                 |  9 +++++++++
 test/cases/db-move.bats | 14 ++++++++++++++
 test/lib/common.bash    |  2 ++
 3 files changed, 25 insertions(+)

diff --git a/db-move b/db-move
index 72aa0b35..7ded7de1 100755
--- a/db-move
+++ b/db-move
@@ -14,6 +14,11 @@ repo_to="${args[1]}"
 ftppath_from="${FTP_BASE}/${repo_from}/os/"
 ftppath_to="${FTP_BASE}/${repo_to}/os/"
 
+check_leapfrog=false
+if in_array "${repo_from}" "${STAGING_REPOS}" && in_array "${repo_to}" 
"${STABLE_REPOS}"; then
+       check_leapfrog=true
+fi
+
 if ! check_repo_permission "$repo_to" || ! check_repo_permission "$repo_from"; 
then
        die "You don't have permission to move packages from %s to %s" 
"$repo_from" "$repo_to"
 fi
@@ -42,6 +47,10 @@ for pkgbase in "${args[@]:2}"; do
                                die "Could not read pkgver"
                        fi
 
+                       if [[ ${check_leapfrog} = true ]] && 
leapfrog=$(find_repo_for_package "${pkgbase}" "${pkgarch}" 
"${TESTING_REPOS[@]}"); then
+                               die "Package %s cannnot be moved from %s to %s 
while it exists in %s" "${pkgbase}" "${repo_from}" "${repo_to}" "${leapfrog}"
+                       fi
+
                        for pkgname in "${pkgnames[@]}"; do
                                getpkgfile 
"${ftppath_from}/${pkgarch}/${pkgname}-${pkgver}-${vcsrepo_from##*-}"${PKGEXTS} 
>/dev/null
                        done
diff --git a/test/cases/db-move.bats b/test/cases/db-move.bats
index eb77ef9c..f4407168 100644
--- a/test/cases/db-move.bats
+++ b/test/cases/db-move.bats
@@ -39,6 +39,20 @@ load ../lib/common
        done
 }
 
+@test "move package from staging to extra while a testing package exists 
fails" {
+       releasePackage extra pkg-any-a
+       db-update
+       updatePackage pkg-any-a
+       releasePackage testing pkg-any-a
+       db-update
+       updatePackage pkg-any-a
+       releasePackage staging pkg-any-a
+       db-update
+
+       run db-move staging extra pkg-any-a
+       [ "$status" -ne 0 ]
+}
+
 @test "move single-arch packages" {
        local arches=('i686' 'x86_64')
        local pkgs=('pkg-single-arch' 'pkg-simple-b')
diff --git a/test/lib/common.bash b/test/lib/common.bash
index a92a01ee..03089efc 100644
--- a/test/lib/common.bash
+++ b/test/lib/common.bash
@@ -25,6 +25,8 @@ __isGlobfile() {
        [[ -f $1 ]]
 }
 
+do:() { echo "${@@Q}"; "$@"; }
+
 __buildPackage() {
        local pkgdest=${1:-.}
        local p
-- 
2.19.2

Reply via email to