diff options
-rwxr-xr-x | db-move | 87 | ||||
-rwxr-xr-x | test/runTest | 10 |
2 files changed, 53 insertions, 44 deletions
@@ -1,17 +1,18 @@ #!/bin/bash if [ $# -ne 4 ]; then - msg "usage: $(basename $0) <pkgname|pkgbase> <repo-from> <repo-to> <arch>" + msg "usage: $(basename $0) <repo-from> <repo-to> <arch> <pkgname|pkgbase> ..." exit 1 fi . "$(dirname $0)/db-functions" . "$(dirname $0)/config" -packagebase="$1" -repofrom="$2" -repoto="$3" -arch="$4" +args=(${@}) +repofrom="${args[0]}" +repoto="${args[1]}" +arch="${args[2]}" +# TODO: make db-move arch-independent? if [ "${arch}" == 'any' ]; then tarches=(${ARCHES[@]}) else @@ -27,53 +28,61 @@ if ! check_repo_permission $repoto || ! check_repo_permission $repofrom; then error "You don't have permission to move packages from ${repofrom} to ${repoto}" exit 1 fi +# TODO: add other tests before touch the repos repo_lock $repoto $arch || exit 1 repo_lock $repofrom $arch || exit 1 -cd "$WORKDIR" +pushd "$WORKDIR" >/dev/null /usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null -cd checkout +pushd checkout >/dev/null -/usr/bin/svn up -q $packagebase -if [ -d "$packagebase/repos/$svnrepo_from" ]; then - pkgname=($(. "$packagebase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgname[@]})) - pkgver=$(. "$packagebase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgver}) - pkgrel=$(. "$packagebase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgrel}) +add_pkgs=() +remove_pkgs=() +for pkgbase in ${args[@]:3}; do + # TODO: optimize + /usr/bin/svn up -q $pkgbase + if [ -d "$pkgbase/repos/$svnrepo_from" ]; then + pkgname=($(. "$pkgbase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgname[@]})) + pkgver=$(. "$pkgbase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgver}) + pkgrel=$(. "$pkgbase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgrel}) - msg "Moving $packagebase from $repofrom to $repoto..." - if [ -d "$packagebase/repos/$svnrepo_to" ]; then - /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 + msg "Moving $pkgbase from $repofrom to $repoto..." + if [ -d "$pkgbase/repos/$svnrepo_to" ]; then + /usr/bin/svn rm --force -q "$pkgbase/repos/$svnrepo_to" + /usr/bin/svn commit -q -m "$(basename $0): $pkgbase removed by $(id -un) for move to $repoto" + fi - /usr/bin/svn mv -q -r HEAD "$packagebase/repos/$svnrepo_from" "$packagebase/repos/$svnrepo_to" - /usr/bin/svn commit -q -m "$(basename $0): moved $packagebase from [$repofrom] to [$repoto] ($arch)" + /usr/bin/svn mv -q -r HEAD "$pkgbase/repos/$svnrepo_from" "$pkgbase/repos/$svnrepo_to" + /usr/bin/svn commit -q -m "$(basename $0): moved $pkgbase from [$repofrom] to [$repoto] ($arch)" - pkgfiles='' - for i in ${pkgname[@]}; do - for tarch in ${tarches[@]}; do - pkgpath=$(getpkgfile "$ftppath_from/${tarch}/"$i-$pkgver-$pkgrel-$arch$PKGEXT) - pkgfile=$(basename "${pkgpath}") + for i in ${pkgname[@]}; do + for tarch in ${tarches[@]}; do + pkgpath=$(getpkgfile "$ftppath_from/${tarch}/"$i-$pkgver-$pkgrel-$arch$PKGEXT) + pkgfile=$(basename "${pkgpath}") - # copy package to pool if needed - # TODO: can be removed once every package has been moved to the package pool - if [ ! -f $FTP_BASE/$(get_pkgpool_for_host)/$pkgfile ]; then - cp $pkgpath $FTP_BASE/$(get_pkgpool_for_host) - fi - ln -s "../../../$(get_pkgpool_for_host)/${pkgfile}" $ftppath_to/${tarch}/ + # copy package to pool if needed + # TODO: can be removed once every package has been moved to the package pool + if [ ! -f $FTP_BASE/$(get_pkgpool_for_host)/$pkgfile ]; then + cp $pkgpath $FTP_BASE/$(get_pkgpool_for_host) + fi + ln -s "../../../$(get_pkgpool_for_host)/${pkgfile}" $ftppath_to/${tarch}/ + done + add_pkgs[${#add_pkgs[*]}]="$FTP_BASE/$(get_pkgpool_for_host)/${pkgfile}" + remove_pkgs[${#remove_pkgs[*]}]=${i} done + else + die "$pkgbase is not in repo $repofrom" + fi +done - pkgfiles="${pkgfiles} $FTP_BASE/$(get_pkgpool_for_host)/${pkgfile}" - done +for tarch in ${tarches[@]}; do + /usr/bin/repo-add -q "$ftppath_to/${tarch}/$repoto$DBEXT" ${add_pkgs[@]} >/dev/null || die "Error in repo-add" + /usr/bin/repo-remove -q "$ftppath_from/${tarch}/$repofrom$DBEXT" ${remove_pkgs[@]} >/dev/null || die "Error in repo-remove" +done - for tarch in ${tarches[@]}; do - /usr/bin/repo-add -q "$ftppath_to/${tarch}/$repoto$DBEXT" ${pkgfiles} >/dev/null || die "Error in repo-add $pkgfiles" - /usr/bin/repo-remove -q "$ftppath_from/${tarch}/$repofrom$DBEXT" ${pkgname[@]} >/dev/null || die "Error in repo-remove ${pkgname[@]}" - done -else - die "$packagebase is not in repo $repofrom" -fi +popd >/dev/null +popd >/dev/null repo_unlock $repoto $arch || exit 1 repo_unlock $repofrom $arch || exit 1 diff --git a/test/runTest b/test/runTest index 06ca000..8c1aa04 100755 --- a/test/runTest +++ b/test/runTest @@ -152,7 +152,7 @@ testMoveSimplePackages() { ../db-update for arch in ${arches[@]}; do - ../db-move pkg-simple-a testing extra ${arch} + ../db-move testing extra ${arch} pkg-simple-a done for arch in ${arches[@]}; do @@ -172,7 +172,7 @@ testMoveAnyPackages() { done ../db-update - ../db-move pkg-any-a testing extra any + ../db-move testing extra any pkg-any-a checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz checkRemovedAnyPackage testing pkg-any-a @@ -195,7 +195,7 @@ testMoveSplitPackages() { ../db-update for arch in ${arches[@]}; do - ../db-move pkg-split-a testing extra ${arch} + ../db-move testing extra ${arch} pkg-split-a done for arch in ${arches[@]}; do @@ -338,7 +338,7 @@ testMovePackagesWithoutPool() { for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do - ../db-move ${pkgbase} testing extra ${arch} + ../db-move testing extra ${arch} ${pkgbase} done done @@ -378,7 +378,7 @@ testMoveAnyPackagesWithoutPool() { ../cron-jobs/ftpdir-cleanup >/dev/null for pkgbase in ${pkgs[@]}; do - ../db-move ${pkgbase} testing extra any + ../db-move testing extra any ${pkgbase} done ../cron-jobs/ftpdir-cleanup >/dev/null |