Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions config
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions cron-jobs/sourceballs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 15 additions & 35 deletions db-functions
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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}"
106 changes: 106 additions & 0 deletions db-functions-svn
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/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")
}

# 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
}

# 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[@]%/}"
}

# 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}"
}
56 changes: 19 additions & 37 deletions db-move
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -67,32 +61,20 @@ done
for pkgbase in "${args[@]:2}"; do
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
tarches=("${pkgarch}")
fi
msg2 "%s (%s)" "$pkgbase" "${tarches[*]}"
pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo "${pkgname[@]}"))
pkgver=$(. "${svnrepo_from}/PKGBUILD"; get_full_version)

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
read -rd'\n' pkgver pkgnames < <(source_pkgbuild "${pkgbase}" "repos/${repo_from}-${pkgarch}"; \
get_full_version; echo "${pkgname[@]}")
read -ra pkgnames <<<"$pkgnames"

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
Expand All @@ -113,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
Expand Down
12 changes: 5 additions & 7 deletions db-remove
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -32,14 +32,12 @@ 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[@]}))
arch_svn rm --force -q "${WORKDIR}/svn/$pkgbase/repos/$svnrepo"
arch_svn commit -q "${WORKDIR}/svn/$pkgbase" -m "${0##*/}: $pkgbase removed by $(id -un)"
if remove_pkgs+=($(source_pkgbuild "${pkgbase}" "repos/${vcsrepo}" && echo ${pkgname[@]})); then
vcs_remove_package "${pkgbase}" "${vcsrepo}"
vcs_commit "${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")
Expand Down
4 changes: 2 additions & 2 deletions db-update
Original file line number Diff line number Diff line change
Expand Up @@ -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##*/}"
Expand Down
Loading