[arch-projects] [dbscripts] [PATCH 0/4] Refactoring svn calls
Having svn code intertwined with everything is complicated and results in it being harder to replace svn with something else. As a first step to hopefully migrating to git, I've refactored everything that directly touched svn to be contained in db-functions-svn, and renamed to be generic enough that any alternative backend should be able to implement some VCS-specific "vcs_*" functions. Also see https://github.com/archlinux/dbscripts/pull/12 Eli Schwartz (4): Preliminary work to break out svn-specific code. Factor out the exporting of files/folders from svn. More work on refactoring svn moving into VCS-agnostic routines. Finish the svn refactor by implementing helper functions to write to the VCS config | 7 ++- cron-jobs/sourceballs | 3 +- db-functions | 50 ++++++-------------- db-functions-svn | 106 ++++++++++++++++++++++++++++++++++++++++++ db-move | 56 ++++++++-------------- db-remove | 12 ++--- db-update | 4 +- testing2x | 37 +++++---------- 8 files changed, 165 insertions(+), 110 deletions(-) create mode 100644 db-functions-svn -- 2.19.1
Introduce "db-functions-$VCS" which will eventually contain all VCS-specific code, and make this configurable in config. Move private arch_svn function and svn acl handling here, and introduce a new source_pkgbuild function to handle discovering PKGBUILDs from the configured VCS and sourcing them to extract metadata. The PKGBUILD is the only file we ever check out from version control, and only ever to scrape information from it, except for when we actually want to db-move a whole directory (which is by necessity considerably dependent on the VCS in use). source_pkgbuild is inspired by commits from the dbscripts rewrite, authored by Florian Pritz <bluewind@xinu.at> Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- config | 7 +++++-- db-functions | 50 +++++++++++++++--------------------------------- db-functions-svn | 27 ++++++++++++++++++++++++++ db-move | 5 +++-- db-remove | 5 ++--- db-update | 4 ++-- 6 files changed, 54 insertions(+), 44 deletions(-) create mode 100644 db-functions-svn diff --git a/config b/config index fd79b6ee..1cfe11f4 100644 --- a/config +++ b/config @@ -1,14 +1,17 @@ #!/hint/bash FTP_BASE="/srv/ftp" -SVNREPO='' -SVNUSER='' PKGREPOS=() PKGPOOL='' SRCPOOL='' TESTING_REPO='' STABLE_REPOS=() +# VCS backend +VCS=svn +SVNREPO='' +SVNUSER='' + CLEANUP_DESTDIR="/var/tmp" CLEANUP_DRYRUN=false # Time in days to keep moved packages diff --git a/db-functions b/db-functions index 6d6084a9..7aeedced 100644 --- a/db-functions +++ b/db-functions @@ -39,11 +39,6 @@ mv_acl() { # set up general environment WORKDIR=$(mktemp -dt "${0##*/}.XXXXXXXXXX") -if [[ -n ${SVNUSER} ]]; then - setfacl -m u:"${SVNUSER}":rwx "${WORKDIR}" - setfacl -m d:u:"${USER}":rwx "${WORKDIR}" - setfacl -m d:u:"${SVNUSER}":rwx "${WORKDIR}" -fi LOCKS=() REPO_MODIFIED=0 @@ -306,27 +301,24 @@ check_pkgfile() { [[ ${pkgfile##*/} = "${pkgname}-${pkgver}-${pkgarch}"* ]] } -check_pkgsvn() { +# Check that the package file is consistent with the PKGBUILD in version control +check_pkgvcs() { local pkgfile="${1}" + local repo="${2}" local _pkgbase="$(getpkgbase "${pkgfile}")" || return 1 local _pkgname="$(getpkgname "${pkgfile}")" || return 1 local _pkgver="$(getpkgver "${pkgfile}")" || return 1 local _pkgarch="$(getpkgarch "${pkgfile}")" || return 1 - local repo="${2}" in_array "${repo}" "${PKGREPOS[@]}" || return 1 - if [[ ! -f ${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase} ]]; then - mkdir -p "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}" - arch_svn export -q "${SVNREPO}/${_pkgbase}/repos/${repo}-${_pkgarch}/PKGBUILD" \ - "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null || return 1 - fi + local vcsver vcsnames=() + read -rd'\n' vcsver vcsnames < <(source_pkgbuild "${_pkgbase}" "repos/${repo}-${_pkgarch}"; \ + get_full_version; echo "${pkgname[@]}") + read -ra vcsnames <<<"${vcsnames}" - local svnver="$(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; get_full_version)" - [[ "${svnver}" = "${_pkgver}" ]] || return 1 - - local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo "${pkgname[@]}")) - in_array "${_pkgname}" "${svnnames[@]}" || return 1 + [[ "${vcsver}" = "${_pkgver}" ]] || return 1 + in_array "${_pkgname}" "${vcsnames[@]}" || return 1 return 0 } @@ -337,7 +329,7 @@ check_splitpkgs() { local pkgfiles=("${@}") local pkgfile local pkgdir - local svnname + local vcsname mkdir -p "${WORKDIR}/check_splitpkgs/" pushd "${WORKDIR}/check_splitpkgs" >/dev/null @@ -350,22 +342,16 @@ check_splitpkgs() { mkdir -p "${repo}/${_pkgarch}/${_pkgbase}" echo "${_pkgname}" >> "${repo}/${_pkgarch}/${_pkgbase}/staging" - if [[ ! -f ${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase} ]]; then - mkdir -p "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}" - arch_svn export -q "${SVNREPO}/${_pkgbase}/repos/${repo}-${_pkgarch}/PKGBUILD" \ - "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null || return 1 - fi - - local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo "${pkgname[@]}")) - printf '%s\n' "${svnnames[@]}" >> "${repo}/${_pkgarch}/${_pkgbase}/svn" + local vcsnames=($(source_pkgbuild "${_pkgbase}" "repos/${repo}-${_pkgarch}"; echo "${pkgname[@]}")) + printf '%s\n' "${vcsnames[@]}" >> "${repo}/${_pkgarch}/${_pkgbase}/vcs" done popd >/dev/null for pkgdir in "${WORKDIR}/check_splitpkgs/${repo}"/*/*; do [[ ! -d ${pkgdir} ]] && continue sort -u "${pkgdir}/staging" -o "${pkgdir}/staging" - sort -u "${pkgdir}/svn" -o "${pkgdir}/svn" - if [[ ! -z "$(comm -13 "${pkgdir}/staging" "${pkgdir}/svn")" ]]; then + sort -u "${pkgdir}/vcs" -o "${pkgdir}/vcs" + if [[ ! -z "$(comm -13 "${pkgdir}/staging" "${pkgdir}/vcs")" ]]; then return 1 fi done @@ -458,10 +444,4 @@ arch_repo_modify() { REPO_MODIFIED=1 } -arch_svn() { - if [[ -z ${SVNUSER} ]]; then - /usr/bin/svn "${@}" - else - sudo -u "${SVNUSER}" -- /usr/bin/svn --username "${USER}" "${@}" - fi -} +. "$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")/db-functions-${VCS}" diff --git a/db-functions-svn b/db-functions-svn new file mode 100644 index 00000000..41a87cc0 --- /dev/null +++ b/db-functions-svn @@ -0,0 +1,27 @@ +#!/hint/bash + +if [[ -n ${SVNUSER} ]]; then + setfacl -m u:"${SVNUSER}":rwx "${WORKDIR}" + setfacl -m d:u:"${USER}":rwx "${WORKDIR}" + setfacl -m d:u:"${SVNUSER}":rwx "${WORKDIR}" +fi + +arch_svn() { + if [[ -z ${SVNUSER} ]]; then + /usr/bin/svn "${@}" + else + sudo -u "${SVNUSER}" -- /usr/bin/svn --username "${USER}" "${@}" + fi +} + +# source_pkgbuild pkgbase tag +# +# Source the PKGBUILD from the package's git/svn/whatever repo. +# Depending on how the VCS is used the tag might be "trunk" or "repos/$repo-$arch" +# or the full package version (epoch:pkgver-pkgrel) or any other recognized tag. +source_pkgbuild() { + local pkgbase=${1} + local tag=${2} + + . <(arch_svn cat "${SVNREPO}/${pkgbase}/${tag}/PKGBUILD" 2>/dev/null || echo "false") +} diff --git a/db-move b/db-move index b6448898..2a1da68d 100755 --- a/db-move +++ b/db-move @@ -77,8 +77,9 @@ for pkgbase in "${args[@]:2}"; do tarches=("${pkgarch}") fi msg2 "%s (%s)" "$pkgbase" "${tarches[*]}" - pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo "${pkgname[@]}")) - pkgver=$(. "${svnrepo_from}/PKGBUILD"; get_full_version) + read -rd'\n' pkgver pkgnames < <(source_pkgbuild "${pkgbase}" "repos/${repo_from}-${pkgarch}"; \ + get_full_version; echo "${pkgname[@]}") + read -ra pkgnames <<<"$pkgnames" if [[ -d ${svnrepo_to} ]]; then for file in $(arch_svn ls "${svnrepo_to}"); do diff --git a/db-remove b/db-remove index ac9a1688..3b09bfa1 100755 --- a/db-remove +++ b/db-remove @@ -32,10 +32,9 @@ done remove_pkgs=() for pkgbase in "${pkgbases[@]}"; do msg "Removing %s from [%s]..." "$pkgbase" "$repo" - arch_svn checkout -q "${SVNREPO}/${pkgbase}" "${WORKDIR}/svn/${pkgbase}" >/dev/null - if [[ -d ${WORKDIR}/svn/$pkgbase/repos/$svnrepo ]]; then - remove_pkgs+=($(. "${WORKDIR}/svn/$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgname[@]})) + if remove_pkgs+=($(source_pkgbuild "${pkgbase}" "repos/${svnrepo}" && 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 commit -q "${WORKDIR}/svn/$pkgbase" -m "${0##*/}: $pkgbase removed by $(id -un)" else diff --git a/db-update b/db-update index 8eb27dfe..313fb999 100755 --- a/db-update +++ b/db-update @@ -46,8 +46,8 @@ for repo in "${repos[@]}"; do if ! pacman-key -v "${pkg}.sig" >/dev/null 2>&1; then die "Package %s does not have a valid signature" "$repo/${pkg##*/}" fi - if ! check_pkgsvn "${pkg}" "${repo}"; then - die "Package %s is not consistent with svn repository" "$repo/${pkg##*/}" + if ! check_pkgvcs "${pkg}" "${repo}"; then + die "Package %s is not consistent with %s repository" "$repo/${pkg##*/}" "${VCS}" fi if ! check_pkgrepos "${pkg}"; then die "Package %s already exists in another repository" "$repo/${pkg##*/}" -- 2.19.1
As of the source_pkgbuild rewrite, this is only ever done once. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- cron-jobs/sourceballs | 3 +-- db-functions-svn | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs index 6be28abc..115c5bc0 100755 --- a/cron-jobs/sourceballs +++ b/cron-jobs/sourceballs @@ -79,8 +79,7 @@ for repo in "${PKGREPOS[@]}"; do # Get the sources from svn mkdir -p -m0770 "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}" - arch_svn export -q "${SVNREPO}/${pkgbase}/repos/${repo}-${pkgarch}" \ - "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}/${pkgbase}" >/dev/null 2>&1 + export_from_vcs "${pkgbase}" "repos/${repo}-${pkgarch}" "" "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}/${pkgbase}" if (( $? >= 1 )); then failedpkgs+=("${pkgbase}-${pkgver}${SRCEXT}") continue diff --git a/db-functions-svn b/db-functions-svn index 41a87cc0..deb4e389 100644 --- a/db-functions-svn +++ b/db-functions-svn @@ -25,3 +25,18 @@ source_pkgbuild() { . <(arch_svn cat "${SVNREPO}/${pkgbase}/${tag}/PKGBUILD" 2>/dev/null || echo "false") } + +# Export PKGBUILD resource(s) from the package's git/svn/whatever repo. +# Depending on how the VCS is used the tag might be "trunk" or "repos/$repo-$arch" +# or the full package version (epoch:pkgver-pkgrel) or any other recognized tag. +export_from_vcs() { + local pkgbase=${1} + local tag=${2} + local src=${3} + local dest=${4} + + if [[ ! -e ${dest} ]]; then + mkdir -p "${dest%/?*}" + arch_svn export -q "${SVNREPO}/${pkgbase}/${tag}/${src}" "${dest}" 2>/dev/null + fi +} -- 2.19.1
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
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- db-functions-svn | 46 ++++++++++++++++++++++++++++++++++++++++++++++ db-move | 23 ++++------------------- db-remove | 5 ++--- 3 files changed, 52 insertions(+), 22 deletions(-) diff --git a/db-functions-svn b/db-functions-svn index 9903f55e..f971cd2e 100644 --- a/db-functions-svn +++ b/db-functions-svn @@ -58,3 +58,49 @@ find_repo_for_package() { printf '%s\n' "${repos[@]%/}" } + +# Commit changes staged by (successive?) vcs_(re)?move_package runs. +vcs_commit() { + arch_svn commit -q "${WORKDIR}/svn/${pkgbase}" -m "${1}" +} + +# Write to the VCS in order to track a package moving between different pacman +# repositories. +vcs_move_package() { + local pkgbase=${1} + local vcsrepo_from=${WORKDIR}/svn/${pkgbase}/repos/${2} + local vcsrepo_to=${WORKDIR}/svn/${pkgbase}/repos/${3} + + if [[ ! -d ${WORKDIR}/svn ]]; then + arch_svn checkout -q -N "${SVNREPO}" "${WORKDIR}/svn" >/dev/null + fi + arch_svn up -q "${WORKDIR}/svn/${pkgbase}" >/dev/null + + if [[ -d ${vcsrepo_to} ]]; then + while read -r file; do + arch_svn rm -q "${vcsrepo_to}/${file}@" + done < <(arch_svn ls "${vcsrepo_to}") + else + mkdir "${vcsrepo_to}" + arch_svn add -q "${vcsrepo_to}" + fi + + while read -r file; do + arch_svn mv -q -r HEAD "${vcsrepo_from}/${file}@" "${vcsrepo_to}/" + done < <(arch_svn ls "${vcsrepo_from}") + arch_svn rm --force -q "${vcsrepo_from}" +} + +# Write to the VCS in order to track a package being deleted from a pacman +# repository. +vcs_remove_package() { + local pkgbase=${1} + local vcsrepo=${WORKDIR}/svn/${pkgbase}/repos/${2} + + if [[ ! -d ${WORKDIR}/svn ]]; then + arch_svn checkout -q -N "${SVNREPO}" "${WORKDIR}/svn" >/dev/null + fi + + arch_svn up -q "${WORKDIR}/svn/${pkgbase}" > /dev/null + arch_svn rm --force -q "${vcsrepo}" +} diff --git a/db-move b/db-move index 4867b41f..72aa0b35 100755 --- a/db-move +++ b/db-move @@ -58,15 +58,12 @@ 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}" - svnrepo_to="${WORKDIR}/svn/${pkgbase}/repos/${repo_to}-${pkgarch}" + vcsrepo_from=$(find_repo_for_package "${pkgbase}" "${pkgarch}" "${repo_from}") - if [[ -f ${svnrepo_from}/PKGBUILD ]]; then + if [[ ${vcsrepo_from} = ${repo_from}-${pkgarch} ]]; then if [[ ${pkgarch} = any ]]; then tarches=("${ARCHES[@]}") else @@ -77,19 +74,7 @@ for pkgbase in "${args[@]:2}"; do get_full_version; echo "${pkgname[@]}") read -ra pkgnames <<<"$pkgnames" - if [[ -d ${svnrepo_to} ]]; then - for file in $(arch_svn ls "${svnrepo_to}"); do - arch_svn rm -q "${svnrepo_to}/$file@" - done - else - mkdir "${svnrepo_to}" - arch_svn add -q "${svnrepo_to}" - fi - - for file in $(arch_svn ls "${svnrepo_from}"); do - arch_svn mv -q -r HEAD "${svnrepo_from}/$file@" "${svnrepo_to}/" - done - arch_svn rm --force -q "${svnrepo_from}" + vcs_move_package "${pkgbase}" "${repo_from}-${pkgarch}" "${repo_to}-${pkgarch}" tag_list+=", $pkgarch" for tarch in "${tarches[@]}"; do @@ -110,7 +95,7 @@ for pkgbase in "${args[@]:2}"; do fi done tag_list="${tag_list#, }" - arch_svn commit -q "${WORKDIR}/svn/${pkgbase}" -m "${0##*/}: moved ${pkgbase} from [${repo_from}] to [${repo_to}] (${tag_list})" + vcs_commit "${0##*/}: moved ${pkgbase} from [${repo_from}] to [${repo_to}] (${tag_list})" done for tarch in "${ARCHES[@]}"; do diff --git a/db-remove b/db-remove index b0a49cf8..a27a9f29 100755 --- a/db-remove +++ b/db-remove @@ -34,9 +34,8 @@ for pkgbase in "${pkgbases[@]}"; do msg "Removing %s from [%s]..." "$pkgbase" "$repo" 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/$vcsrepo" - arch_svn commit -q "${WORKDIR}/svn/$pkgbase" -m "${0##*/}: $pkgbase removed by $(id -un)" + vcs_remove_package "${pkgbase}" "${vcsrepo}" + vcs_commit "${0##*/}: $pkgbase removed by $(id -un)" else warning "%s not found in %s" "$pkgbase" "$vcsrepo" warning "Removing only %s from the repo" "$pkgbase" -- 2.19.1
participants (1)
-
Eli Schwartz