Verified Commit 9dcd82a6 authored by Johannes Löthberg's avatar Johannes Löthberg Committed by Jelle van der Waa
Browse files

db-move: Check that the specified repositories are ones dbscripts was configured for



Otherwise if you use the dbscripts for core/extra for community repos,
or vice versa, you'll get an error saying that you don't have
permissions to move packages from or to the given repositories, which
can be confusing if you don't immediately notice your mistake.
Signed-off-by: Johannes Löthberg's avatarJohannes Löthberg <johannes@kyriasis.com>
parent 40f09826
...@@ -404,6 +404,15 @@ chk_license() { ...@@ -404,6 +404,15 @@ chk_license() {
return 1 return 1
} }
check_repo_configured() {
local repo=$1
local count=$(printf '%s\n' "${PKGREPOS[@]}" | grep --count --line-regexp "$repo")
[[ $count -gt 0 ]] && return 0
return 1
}
check_repo_permission() { check_repo_permission() {
local repo=$1 local repo=$1
......
...@@ -19,6 +19,12 @@ if in_array "${repo_from}" "${STAGING_REPOS[@]}" && in_array "${repo_to}" "${STA ...@@ -19,6 +19,12 @@ if in_array "${repo_from}" "${STAGING_REPOS[@]}" && in_array "${repo_to}" "${STA
check_leapfrog=true check_leapfrog=true
fi fi
if ! check_repo_configured "$repo_from"; then
die "%s is not a configured repository" "$repo_from"
elif ! check_repo_configured "$repo_to"; then
die "%s is not a configured repository" "$repo_to"
fi
if ! check_repo_permission "$repo_to" || ! check_repo_permission "$repo_from"; then 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" die "You don't have permission to move packages from %s to %s" "$repo_from" "$repo_to"
fi fi
......
...@@ -123,3 +123,16 @@ load ../lib/common ...@@ -123,3 +123,16 @@ load ../lib/common
checkPackage extra pkg-split-a 1-1 checkPackage extra pkg-split-a 1-1
checkPackage testing pkg-split-b 1-1 checkPackage testing pkg-split-b 1-1
} }
@test "move not configured repo" {
releasePackage extra pkg-any-a
db-update
run db-move extra community pkg-any-a
[ "$status" -ne 0 ]
[[ $output == *'community is not a configured'* ]]
run db-move notconfigured community pkg-any-a
[ "$status" -ne 0 ]
[[ $output == *'notconfigured is not a configured'* ]]
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment