From d21c84ef995248661da4d9d8b8e12499144f37f5 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 8 Oct 2014 19:42:22 +0200 Subject: make tests.d/testing2x work Signed-off-by: Florian Pritz --- db-functions | 26 ++++++++++++++++++++ db-move | 15 +----------- test/test.d/testing2x.sh | 2 +- testing2x | 62 +++++++++++++++++++++++------------------------- 4 files changed, 58 insertions(+), 47 deletions(-) diff --git a/db-functions b/db-functions index c637b35..83f1732 100644 --- a/db-functions +++ b/db-functions @@ -552,6 +552,32 @@ arch_db_remove() { done } +arch_db_move() { + local repo_from=$1 + local repo_to=$2 + local arch=$3 + local pkgnames=(${@:4}) + + + local ftppath_from="${FTP_BASE}/${repo_from}/os/" + + for pkgname in "${pkgnames[@]}"; do + 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" + return 1 + fi + + for pkg in "${pkgs[@]}"; do + pkgname=$(getpkgname "$pkg") + arch_db_add "${repo_to}" "$arch" "${pkg##*/}" + arch_db_remove "${repo_from}" "$arch" "$pkgname" + done + done +} + arch_history_add() { local repo="$1" local pkgfile="$2" diff --git a/db-move b/db-move index 59c40e9..1c288ee 100755 --- a/db-move +++ b/db-move @@ -40,20 +40,7 @@ msg "Moving packages from [${repo_from}] to [${repo_to}]..." 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 - - for pkg in "${pkgs[@]}"; do - pkgname=$(getpkgname "$pkg") - arch_db_add "${repo_to}" "$arch" "${pkg##*/}" - arch_db_remove "${repo_from}" "$arch" "$pkgname" - done + arch_db_move "${repo_from}" "${repo_to}" "${arch}" "${pkgname}" done done diff --git a/test/test.d/testing2x.sh b/test/test.d/testing2x.sh index 31d85b4..586ce40 100755 --- a/test/test.d/testing2x.sh +++ b/test/test.d/testing2x.sh @@ -10,7 +10,7 @@ testTesting2xAnyPackage() { pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD arch_svn commit -q -m"update pkg to pkgrel=2" >/dev/null - sudo extra-i686-build + sudo chronic extra-i686-build mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" popd >/dev/null diff --git a/testing2x b/testing2x index 369857f..48f2bb2 100755 --- a/testing2x +++ b/testing2x @@ -4,58 +4,56 @@ . "$(dirname $0)/db-functions" if [ $# -lt 1 ]; then - msg "usage: ${0##*/} ..." + msg "usage: ${0##*/} ..." exit 1 fi # Lock everything to reduce possibility of interfering task between the different repo-updates script_lock -for repo in ${TESTING_REPO} ${STABLE_REPOS[@]}; do +for repo in ${TESTING_REPO} ${STABLE_REPOS[@]}; do for pkgarch in ${ARCHES[@]}; do repo_lock ${repo} ${pkgarch} || exit 1 done done -declare -A pkgs - -for pkgbase in $*; do - if [ ! -d "${WORKDIR}/${pkgbase}" ]; then - arch_svn export -q "${SVNREPO}/${pkgbase}/repos" "${WORKDIR}/${pkgbase}" >/dev/null +for pkgname in "$@"; do + msg "Moving $pkgname" + for pkgarch in ${ARCHES[@]}; do + repo_from="" + repo_to="" found_source=false - for pkgarch in ${ARCHES[@]} 'any'; do - svnrepo_from="${WORKDIR}/${pkgbase}/${TESTING_REPO}-${pkgarch}" - if [ -r "${svnrepo_from}/PKGBUILD" ]; then - found_source=true + found_target=false + + path="${HISTORYREPO}/${TESTING_REPO}/${pkgarch}/${pkgname}" + if [ -e "${path}" ]; then + found_source=true + repo_from="${TESTING_REPO}" + fi + ${found_source} || continue + + for repo in ${STABLE_REPOS[@]}; do + path="${HISTORYREPO}/${repo}/${pkgarch}/${pkgname}" + if [ -e "${path}" ]; then + found_target=true + repo_to="${repo}" + + msg2 "$pkgarch $repo_from -> $repo_to" + arch_db_move "$repo_from" "$repo_to" "$pkgarch" "$pkgname" break fi done - ${found_source} || die "${pkgbase} not found in [${TESTING_REPO}]" - found_target=false - for pkgarch in ${ARCHES[@]} 'any'; do - for repo in ${STABLE_REPOS[@]}; 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} not found in any of these repos: ${STABLE_REPOS[@]}" - fi + ${found_target} || warning "${pkgname} not found in any of these repos: ${STABLE_REPOS[@]}. skipping" + done + ${found_source} || warning "${pkgname} not found in [${TESTING_REPO}]. skipping" done -for pkgarch in ${ARCHES[@]}; do - repo_unlock ${TESTING_REPO} ${pkgarch} -done -for repo in ${STABLE_REPOS[@]}; do +arch_history_commit "testing2x: $@" + +for repo in ${TESTING_REPO} ${STABLE_REPOS[@]}; do for pkgarch in ${ARCHES[@]}; do repo_unlock ${repo} ${pkgarch} done - if [ -n "${pkgs[${repo}]}" ]; then - "$(dirname $0)/db-move" ${TESTING_REPO} "${repo}" ${pkgs[${repo}]} - fi done script_unlock -- cgit v1.2.3-24-g4f1b