diff options
author | Florian Pritz <bluewind@xinu.at> | 2014-10-06 21:24:04 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-05-27 15:46:05 +0200 |
commit | 517e420a8a7a2222c3fba25a049cbed694d74ae9 (patch) | |
tree | 35c7a6c85ccf12b0d3a3dafa4a092e6a5b80b7c9 | |
parent | aa4db02702313cf277b2c56b51ea9eb916de9468 (diff) | |
download | dbscripts-517e420a8a7a2222c3fba25a049cbed694d74ae9.tar.gz dbscripts-517e420a8a7a2222c3fba25a049cbed694d74ae9.tar.xz |
make test.d/db-move.sh pass
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r-- | db-functions | 5 | ||||
-rwxr-xr-x | db-move | 41 | ||||
-rwxr-xr-x | 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/" @@ -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 |