From 517e420a8a7a2222c3fba25a049cbed694d74ae9 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 6 Oct 2014 21:24:04 +0200 Subject: make test.d/db-move.sh pass Signed-off-by: Florian Pritz --- db-functions | 5 +++-- db-move | 41 +++++++++++++++++++++++++++-------------- test/test.d/db-move.sh | 10 +++++----- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/db-functions b/db-functions index 8e239f1..1ef2901 100644 --- a/db-functions +++ b/db-functions @@ -522,8 +522,9 @@ arch_db_add() { if [[ ! -f "${srcfile}" ]]; then warning "Package file ${pkgfile} not found in ${FTP_BASE}/${PKGPOOL}. skipping" return 0 - else - msg "Adding $pkgfile to [$repo]-$tarch..." + #else + # TODO: echo message in db-add executable so this can be used by db-move without unwanted output + #msg2 "Adding $pkgfile to [$repo]-$tarch..." fi ln -sr "$srcfile" "$dstdir/" diff --git a/db-move b/db-move index 1a69383..59c40e9 100755 --- a/db-move +++ b/db-move @@ -20,33 +20,46 @@ if ! check_repo_permission $repo_to || ! check_repo_permission $repo_from; then die "You don't have permission to move packages from ${repo_from} to ${repo_to}" fi -# TODO: this might lock too much (architectures) -for pkgarch in ${ARCHES[@]}; do +if ! in_array "$arch" "${ARCHES[@]}" "all"; then + die "Invalid arch '$arch'" +fi + +if [[ $arch == "all" ]]; then + arches=(${ARCHES[@]}) +else + arches=($arch) +fi + +for pkgarch in ${arches[@]}; do repo_lock ${repo_to} ${pkgarch} || exit 1 repo_lock ${repo_from} ${pkgarch} || exit 1 done msg "Moving packages from [${repo_from}] to [${repo_to}]..." -for pkgname in "${pkgnames[@]}"; do - pkgentry=$(pkgentry_from_db "$repo_from" "$arch" "$pkgname") - pkgs=($(getpkgfiles "$ftppath_from$arch/$pkgentry"*${PKGEXT})) +for arch in ${arches[@]}; do + for pkgname in "${pkgnames[@]}"; do + msg2 "$arch $pkgname" + + pkgentry=$(pkgentry_from_db "$repo_from" "$arch" "$pkgname") + pkgs=($(getpkgfiles "$ftppath_from$arch/$pkgentry"*${PKGEXT})) - if [[ -z $pkgentry ]]; then - warning "Failed to detect pkgentry for $pkgname" - continue - fi + if [[ -z $pkgentry ]]; then + warning "Failed to detect pkgentry for $pkgname" + continue + fi - for pkg in "${pkgs[@]}"; do - pkgname=$(getpkgname "$pkg") - arch_db_add "${repo_to}" "$arch" "${pkg##*/}" - arch_db_remove "${repo_from}" "$arch" "$pkgname" + for pkg in "${pkgs[@]}"; do + pkgname=$(getpkgname "$pkg") + arch_db_add "${repo_to}" "$arch" "${pkg##*/}" + arch_db_remove "${repo_from}" "$arch" "$pkgname" + done done done arch_history_commit "db-move: $repo_from -> $repo_to: ${pkgnames[@]}" -for pkgarch in ${ARCHES[@]}; do +for pkgarch in ${arches[@]}; do repo_unlock ${repo_from} ${pkgarch} repo_unlock ${repo_to} ${pkgarch} done diff --git a/test/test.d/db-move.sh b/test/test.d/db-move.sh index 890ffc4..2720f59 100755 --- a/test/test.d/db-move.sh +++ b/test/test.d/db-move.sh @@ -17,7 +17,7 @@ testMoveSimplePackages() { ../db-update - ../db-move testing extra pkg-simple-a + ../db-move testing extra all pkg-simple-a for arch in ${arches[@]}; do checkPackage extra pkg-simple-a-1-1-${arch}.pkg.tar.xz ${arch} @@ -41,7 +41,7 @@ testMoveMultiplePackages() { ../db-update - ../db-move testing extra pkg-simple-a pkg-simple-b + ../db-move testing extra all pkg-simple-a pkg-simple-b for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do @@ -65,7 +65,7 @@ testMoveEpochPackages() { ../db-update - ../db-move testing extra pkg-simple-epoch + ../db-move testing extra all pkg-simple-epoch for arch in ${arches[@]}; do checkPackage extra pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz ${arch} @@ -82,7 +82,7 @@ testMoveAnyPackages() { done ../db-update - ../db-move testing extra pkg-any-a + ../db-move testing extra all pkg-any-a checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz checkRemovedAnyPackage testing pkg-any-a @@ -103,7 +103,7 @@ testMoveSplitPackages() { done ../db-update - ../db-move testing extra pkg-split-a + ../db-move testing extra all pkg-split-a1 pkg-split-a2 for arch in ${arches[@]}; do for pkg in "${pkgdir}/pkg-split-a"/*-${arch}${PKGEXT}; do -- cgit v1.2.3-24-g4f1b