Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- db-functions-svn | 18 ++++++++++++++++++ db-move | 32 ++++++++++++++------------------ db-remove | 8 ++++---- testing2x | 37 ++++++++++++------------------------- 4 files changed, 48 insertions(+), 47 deletions(-) diff --git a/db-functions-svn b/db-functions-svn index deb4e389..9903f55e 100644 --- a/db-functions-svn +++ b/db-functions-svn @@ -40,3 +40,21 @@ export_from_vcs() { arch_svn export -q "${SVNREPO}/${pkgbase}/${tag}/${src}" "${dest}" 2>/dev/null fi } + +# Which repo is this package in? +find_repo_for_package() { + local pkgbase=${1} + local pkgarch=${2} + local candidates=("${@:3}") + + local repos=($(arch_svn ls "${SVNREPO}/${pkgbase}/repos/" | grep -xFf \ + <(printf '%s\n' "${candidates[@]/%/-${pkgarch}/}" "${candidates[@]/%/-any/}"))) + #TODO: check the PKGBUILD exists? + + if (( ${#repos[@]} > 1 )); then + die "%s is present in multiple repos (%s)" "${pkgbase}" "${repos[*]}" + fi + (( ${#repos[@]} == 1 )) || return $? + + printf '%s\n' "${repos[@]%/}" +} diff --git a/db-move b/db-move index 2a1da68d..4867b41f 100755 --- a/db-move +++ b/db-move @@ -24,38 +24,32 @@ for pkgarch in "${ARCHES[@]}"; do repo_lock "${repo_from}" "${pkgarch}" || exit 1 done -# check if packages to be moved exist in svn and ftp dir -arch_svn checkout -q -N "${SVNREPO}" "${WORKDIR}/svn" >/dev/null +# check if packages to be moved exist in version control and ftp dir for pkgbase in "${args[@]:2}"; do - arch_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 - pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo "${pkgname[@]}")) + found=false + for pkgarch in "${ARCHES[@]}"; do + if vcsrepo_from=$(find_repo_for_package "${pkgbase}" "${pkgarch}" "${repo_from}"); then + #FIXME: abort if PKGBUILD not there + read -rd'\n' pkgver pkgnames < <(source_pkgbuild "${pkgbase}" "repos/${vcsrepo_from}"; \ + get_full_version; echo "${pkgname[@]}") + read -ra pkgnames <<<"$pkgnames" + if (( ${#pkgnames[@]} < 1 )); then die "Could not read pkgname" fi - pkgver=$(. "${svnrepo_from}/PKGBUILD"; get_full_version) if [[ -z ${pkgver} ]]; then die "Could not read pkgver" fi - if [[ "${pkgarch}" = any ]]; then - tarches=("${ARCHES[@]}") - else - tarches=("${pkgarch}") - fi - for pkgname in "${pkgnames[@]}"; do - for tarch in "${tarches[@]}"; do - getpkgfile "${ftppath_from}/${tarch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXTS} >/dev/null - done + getpkgfile "${ftppath_from}/${pkgarch}/${pkgname}-${pkgver}-${vcsrepo_from##*-}"${PKGEXTS} >/dev/null done + found=true continue 2 fi done - die "%s not found in %s" "$pkgbase" "$repo_from" + [[ ${found} = true ]] || die "%s not found in %s" "$pkgbase" "$repo_from" done msg "Moving packages from [%s] to [%s]..." "$repo_from" "$repo_to" @@ -64,7 +58,9 @@ for arch in "${ARCHES[@]}"; do declare -a add_pkgs_$arch declare -a remove_pkgs_$arch done +arch_svn checkout -q -N "${SVNREPO}" "${WORKDIR}/svn" >/dev/null for pkgbase in "${args[@]:2}"; do + arch_svn up -q "${WORKDIR}/svn/${pkgbase}" >/dev/null tag_list="" for pkgarch in "${ARCHES[@]}" 'any'; do svnrepo_from="${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${pkgarch}" diff --git a/db-remove b/db-remove index 3b09bfa1..b0a49cf8 100755 --- a/db-remove +++ b/db-remove @@ -13,7 +13,7 @@ arch="$2" pkgbases=("${@:3}") ftppath="$FTP_BASE/$repo/os" -svnrepo="$repo-$arch" +vcsrepo="$repo-$arch" if ! check_repo_permission "$repo"; then die "You don't have permission to remove packages from %s" "$repo" @@ -33,12 +33,12 @@ remove_pkgs=() for pkgbase in "${pkgbases[@]}"; do msg "Removing %s from [%s]..." "$pkgbase" "$repo" - if remove_pkgs+=($(source_pkgbuild "${pkgbase}" "repos/${svnrepo}" && echo ${pkgname[@]})); then + if remove_pkgs+=($(source_pkgbuild "${pkgbase}" "repos/${vcsrepo}" && echo ${pkgname[@]})); then arch_svn checkout -q "${SVNREPO}/${pkgbase}" "${WORKDIR}/svn/${pkgbase}" >/dev/null - arch_svn rm --force -q "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" + arch_svn rm --force -q "${WORKDIR}/svn/$pkgbase/repos/$vcsrepo" arch_svn commit -q "${WORKDIR}/svn/$pkgbase" -m "${0##*/}: $pkgbase removed by $(id -un)" else - warning "%s not found in %s" "$pkgbase" "$svnrepo" + warning "%s not found in %s" "$pkgbase" "$vcsrepo" warning "Removing only %s from the repo" "$pkgbase" warning "If it was a split package you have to remove the others yourself!" remove_pkgs+=("$pkgbase") diff --git a/testing2x b/testing2x index d3b096b3..14970a9f 100755 --- a/testing2x +++ b/testing2x @@ -19,31 +19,18 @@ done declare -A pkgs for pkgbase in "$@"; do - if [[ ! -d ${WORKDIR}/${pkgbase} ]]; then - arch_svn export -q "${SVNREPO}/${pkgbase}/repos" "${WORKDIR}/${pkgbase}" >/dev/null - - 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 - break - fi - done - [[ $found_source = true ]] || die "%s not found in [%s]" "$pkgbase" "$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 = true ]] || die "%s not found in any of these repos: %s" "$pkgbase" "${STABLE_REPOS[*]}" - fi + for pkgarch in "${ARCHES[@]}"; do + vcsrepo_from="$(find_repo_for_package "${pkgbase}" "${pkgarch[@]}" "${TESTING_REPO}")" + vcsrepo_to="$(find_repo_for_package "${pkgbase}" "${pkgarch[@]}" "${STABLE_REPOS[@]}")" + + if [[ ${vcsrepo_from} && ${vcsrepo_to} ]]; then + move_to="${vcsrepo_to%-@(any|${pkgarch})}" + pkgs[${move_to}]+="${pkgbase} " + break + fi + done + [[ ${vcsrepo_from} ]] || die "%s not found in [%s]" "$pkgbase" "$TESTING_REPO" + [[ ${vcsrepo_to} ]] || die "%s not found in any of these repos: %s" "$pkgbase" "${STABLE_REPOS[*]}" done for pkgarch in "${ARCHES[@]}"; do -- 2.19.1