summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdb-move143
-rwxr-xr-xtest/runTest21
-rwxr-xr-xtesting2x67
3 files changed, 119 insertions, 112 deletions
diff --git a/db-move b/db-move
index 4c18167..ae98958 100755
--- a/db-move
+++ b/db-move
@@ -1,88 +1,97 @@
#!/bin/bash
-if [ $# -ne 4 ]; then
- msg "usage: $(basename $0) <repo-from> <repo-to> <arch> <pkgname|pkgbase> ..."
- exit 1
-fi
-
. "$(dirname $0)/db-functions"
. "$(dirname $0)/config"
-args=(${@})
-repofrom="${args[0]}"
-repoto="${args[1]}"
-arch="${args[2]}"
-# TODO: make db-move arch-independent?
-if [ "${arch}" == 'any' ]; then
- tarches=(${ARCHES[@]})
-else
- tarches=("${arch}")
+if [ $# -lt 3 ]; then
+ msg "usage: $(basename $0) <repo-from> <repo-to> <pkgname|pkgbase> ..."
+ exit 1
fi
-ftppath_from="$FTP_BASE/$repofrom/os/"
-ftppath_to="$FTP_BASE/$repoto/os/"
-svnrepo_from="$repofrom-$arch"
-svnrepo_to="$repoto-$arch"
+args=(${@})
+repo_from="${args[0]}"
+repo_to="${args[1]}"
+ftppath_from="${FTP_BASE}/${repo_from}/os/"
+ftppath_to="${FTP_BASE}/${repo_to}/os/"
-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
+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: add other tests before touch the repos
-repo_lock $repoto $arch || exit 1
-repo_lock $repofrom $arch || exit 1
+/usr/bin/svn checkout -q -N "${SVNREPO}" "${WORKDIR}/svn" >/dev/null
+for pkgbase in ${args[@]:2}; do
+ /usr/bin/svn up -q "${WORKDIR}/svn/${pkgbase}" >/dev/null
+ for pkgarch in ${ARCHES[@]} 'any'; do
+ svnrepo_from="${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${pkgarch}"
+ if [ -r "${svnrepo_from}/PKGBUILD" ]; then
+ continue 2
+ fi
+ done
+ die "${pkgbase} not found in ${repo_from}"
+done
+
+# TODO: this might lock too much (architectures)
+for pkgarch in ${ARCHES[@]}; do
+ repo_lock ${repo_to} ${pkgarch} || exit 1
+ repo_lock ${repo_from} ${pkgarch} || exit 1
+done
-pushd "$WORKDIR" >/dev/null
-/usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null
-pushd checkout >/dev/null
+msg "Moving packages from [${repo_from}] to [${repo_to}]..."
-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})
+declare -A add_pkgs
+declare -A remove_pkgs
+for pkgbase in ${args[@]:2}; do
+ for pkgarch in ${ARCHES[@]} 'any'; do
+ svnrepo_from="${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${pkgarch}"
+ svnrepo_to="${WORKDIR}/svn/${pkgbase}/repos/${repo_to}-${pkgarch}"
- 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
+ if [ -f "${svnrepo_from}/PKGBUILD" ]; then
+ if [ "${pkgarch}" == 'any' ]; then
+ tarches=(${ARCHES[@]})
+ else
+ tarches=("${pkgarch}")
+ fi
+ msg2 "${pkgbase} ($(echo ${tarches[@]}))"
+ pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]}))
+ pkgver=$(. "${svnrepo_from}/PKGBUILD"; echo "${pkgver}-${pkgrel}")
- /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)"
+ if [ -d "${svnrepo_to}" ]; then
+ /usr/bin/svn rm --force -q "${svnrepo_to}"
+ /usr/bin/svn commit -q "${WORKDIR}/svn/${pkgbase}" -m "$(basename $0): ${pkgbase} removed by $(id -un) for move to [${repo_to}] (${pkgarch})"
+ fi
- for i in ${pkgname[@]}; do
- for tarch in ${tarches[@]}; do
- pkgpath=$(getpkgfile "$ftppath_from/${tarch}/"$i-$pkgver-$pkgrel-$arch$PKGEXT)
- pkgfile=$(basename "${pkgpath}")
+ /usr/bin/svn mv -q -r HEAD "${svnrepo_from}" "${svnrepo_to}"
+ /usr/bin/svn commit -q "${WORKDIR}/svn/${pkgbase}" -m "$(basename $0): moved ${pkgbase} from [${repo_from}] to [${repo_to}] (${pkgarch})"
- # 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}/
+ for pkgname in ${pkgnames[@]}; do
+ for tarch in ${tarches[@]}; do
+ pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${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}/
+ add_pkgs[${tarch}]+="${FTP_BASE}/$(get_pkgpool_for_host)/${pkgfile} "
+ remove_pkgs[${tarch}]+="${pkgname} "
+ done
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
+ fi
+ done
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"
+for tarch in ${ARCHES[@]}; do
+ if [ -n "${add_pkgs[${tarch}]}" ]; then
+ /usr/bin/repo-add -q "${ftppath_to}/${tarch}/${repo_to}${DBEXT}" ${add_pkgs[${tarch}]} >/dev/null \
+ || die "Error in repo-add ${add_pkgs[${tarch}]}"
+ /usr/bin/repo-remove -q "${ftppath_from}/${tarch}/${repo_from}${DBEXT}" ${remove_pkgs[${tarch}]} >/dev/null \
+ || die "Error in repo-remove ${remove_pkgs[${tarch}]}"
+ fi
done
-popd >/dev/null
-popd >/dev/null
-
-repo_unlock $repoto $arch || exit 1
-repo_unlock $repofrom $arch || exit 1
+for pkgarch in ${ARCHES[@]}; do
+ repo_unlock ${repo_from} ${pkgarch}
+ repo_unlock ${repo_to} ${pkgarch}
+done
diff --git a/test/runTest b/test/runTest
index 8c1aa04..03f94c2 100755
--- a/test/runTest
+++ b/test/runTest
@@ -151,9 +151,7 @@ testMoveSimplePackages() {
../db-update
- for arch in ${arches[@]}; do
- ../db-move testing extra ${arch} pkg-simple-a
- done
+ ../db-move testing extra pkg-simple-a
for arch in ${arches[@]}; do
checkPackage extra pkg-simple-a-1-1-${arch}.pkg.tar.xz ${arch}
@@ -172,7 +170,7 @@ testMoveAnyPackages() {
done
../db-update
- ../db-move testing extra any pkg-any-a
+ ../db-move testing extra pkg-any-a
checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz
checkRemovedAnyPackage testing pkg-any-a
@@ -193,10 +191,7 @@ testMoveSplitPackages() {
done
../db-update
-
- for arch in ${arches[@]}; do
- ../db-move testing extra ${arch} pkg-split-a
- done
+ ../db-move testing extra pkg-split-a
for arch in ${arches[@]}; do
for pkg in "${pkgdir}/pkg-split-a"/*-${arch}.pkg.tar.*; do
@@ -336,11 +331,7 @@ testMovePackagesWithoutPool() {
../cron-jobs/ftpdir-cleanup >/dev/null
- for pkgbase in ${pkgs[@]}; do
- for arch in ${arches[@]}; do
- ../db-move testing extra ${arch} ${pkgbase}
- done
- done
+ ../db-move testing extra ${pkgs[@]}
../cron-jobs/ftpdir-cleanup >/dev/null
@@ -377,9 +368,7 @@ testMoveAnyPackagesWithoutPool() {
../cron-jobs/ftpdir-cleanup >/dev/null
- for pkgbase in ${pkgs[@]}; do
- ../db-move testing extra any ${pkgbase}
- done
+ ../db-move testing extra ${pkgs[@]}
../cron-jobs/ftpdir-cleanup >/dev/null
diff --git a/testing2x b/testing2x
index 3626432..83b12fa 100755
--- a/testing2x
+++ b/testing2x
@@ -3,35 +3,44 @@
. "$(dirname $0)/db-functions"
. "$(dirname $0)/config"
-case "$0" in
- *64)
- _arch="x86_64"
- ;;
- *)
- _arch="i686"
- ;;
-esac
+if [ $# -lt 1 ]; then
+ msg "usage: $(basename $0) <pkgname|pkgbase> ..."
+ exit 1
+fi
-cd "${WORKDIR}"
-/usr/bin/svn checkout -N $SVNREPO checkout
-cd checkout
-for pkg in $*; do
- moved=0
- /usr/bin/svn up -q ${pkg}
- if [ -f "${pkg}/repos/testing-${_arch}/PKGBUILD" ]; then
- for repo in core extra; do
- if [ -f "${pkg}/repos/${repo}-${_arch}/PKGBUILD" ]; then
- msg "Moving package '${pkg}': testing-${_arch} -> ${repo}-${_arch}"
- $(dirname $0)/db-move "${pkg}" "testing" "${repo}" "${_arch}"
- moved=1
- break
- fi
- done
- if [ ${moved} -eq 0 ]; then
- warning "${pkg} is only in testing-${_arch}, cannot determine where to move it"
- fi
- else
- warning "${pkg} is not in testing-${_arch}"
- fi
+declare -A pkgs
+
+for pkgbase in $*; do
+ if [ ! -d "${WORKDIR}/${pkgbase}" ]; then
+ /usr/bin/svn export -q "${SVNREPO}/${pkgbase}/repos" "${WORKDIR}/${pkgbase}" >/dev/null
+
+ found_source=false
+ for pkgarch in ${ARCHES[@]} 'any'; do
+ svnrepo_from="${WORKDIR}/${pkgbase}/testing-${pkgarch}"
+ if [ -r "${svnrepo_from}/PKGBUILD" ]; then
+ found_source=true
+ break
+ fi
+ done
+ ${found_source} || die "${pkgbase} not found in [testing]"
+ found_target=false
+ for pkgarch in ${ARCHES[@]} 'any'; do
+ for repo in 'core' 'extra'; do
+ svnrepo_to="${WORKDIR}/${pkgbase}/${repo}-${pkgarch}"
+ if [ -r "${svnrepo_to}/PKGBUILD" ]; then
+ found_target=true
+ pkgs[${repo}]+="${pkgbase} "
+ break 2
+ fi
+ done
+ done
+ ${found_target} || die "${pkgbase} neither found in [core] nor [extra]"
+ fi
+done
+
+for repo in 'core' 'extra'; do
+ if [ -n "${pkgs[${repo}]}" ]; then
+ "$(dirname $0)/db-move" 'testing' "${repo}" ${pkgs[${repo}]}
+ fi
done