summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2010-09-05 13:32:27 +0200
committerPierre Schmitz <pierre@archlinux.de>2010-09-05 13:32:27 +0200
commit6f29ee2f02c2a8e2991599ce1d76a59b58a7ee67 (patch)
treed5bea9dd1cc7109f616f56507ceb80626fd606a0
parentcca13c2b41ba1389ce4187a728e05a376ad3ad0d (diff)
Check if package exists in any other repository on update
This also checks if the sam package exists within the old package layout (without package pool)
-rw-r--r--db-functions25
-rwxr-xr-xdb-update4
-rwxr-xr-xtest/runTest45
3 files changed, 71 insertions, 3 deletions
diff --git a/db-functions b/db-functions
index 4ac282a..4081d54 100644
--- a/db-functions
+++ b/db-functions
@@ -312,6 +312,31 @@ check_pkgsvn() {
fi
}
+check_pkgrepos() {
+ local pkgfile=$1
+
+ local pkgname="$(getpkgname ${pkgfile})"
+ [ $? -ge 1 ] && return 1
+ local pkgver="$(getpkgver ${pkgfile})"
+ [ $? -ge 1 ] && return 1
+
+ if [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkgname}-${pkgver}-"*${PKGEXT} ]; then
+ return 1
+ fi
+
+ local repo
+ local arch
+ for repo in $(get_repos_for_host); do
+ for arch in ${ARCHES[@]}; do
+ if [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkgname}-${pkgver}"*${PKGEXT} ]; then
+ return 1
+ fi
+ done
+ done
+
+ return 0
+}
+
get_repos_for_host() {
if [ -n "${PKGREPO[$(hostname -s)]}" ]; then
echo "${PKGREPO[$(hostname -s)]}"
diff --git a/db-update b/db-update
index 61d1636..70f0525 100755
--- a/db-update
+++ b/db-update
@@ -38,8 +38,8 @@ for repo in ${repos[@]}; do
if ! check_pkgsvn "${pkg}" "${repo}"; then
die "Package ${repo}/$(basename ${pkg}) is not consistent with svn repository"
fi
- if [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/$(basename ${pkg})" ]; then
- die "Package ${repo}/$(basename ${pkg}) already exists in ${FTP_BASE}/$(get_pkgpool_for_host)"
+ if ! check_pkgrepos "${pkg}"; then
+ die "Package ${repo}/$(basename ${pkg}) already exists in another repository"
fi
done
else
diff --git a/test/runTest b/test/runTest
index e254de0..b07b099 100755
--- a/test/runTest
+++ b/test/runTest
@@ -106,7 +106,7 @@ testUpdateAnyPackage() {
rm "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz"
}
-testUpdateAnyPackageInDifferentRepositoriesAtOnce() {
+testUpdateAnyPackageToDifferentRepositoriesAtOnce() {
releasePackage extra pkg-any-a any
pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null
@@ -126,6 +126,22 @@ testUpdateAnyPackageInDifferentRepositoriesAtOnce() {
rm "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz"
}
+testUpdateSameAnyPackageToDifferentRepositories() {
+ releasePackage extra pkg-any-a any
+ ../db-update
+ checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz any
+
+ releasePackage testing pkg-any-a any
+ ../db-update >/dev/null 2>&1 && (fail 'Adding an existing package to another repository should fail'; return 1)
+
+ local arch
+ for arch in i686 x86_64; do
+ ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \
+ && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \
+ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}"
+ done
+}
+
#
# db-remove
#
@@ -493,4 +509,31 @@ testMoveAnyPackagesWithoutPool() {
done
}
+testUpdateSameAnyPackageToDifferentRepositoriesWithoutPool() {
+ local pkg
+ local arch
+
+ releasePackage extra pkg-any-a any
+ ../db-update
+
+ # transform a package to old style layout
+ for pkg in "${pkgdir}/pkg-any-a"/*-any.pkg.tar.*; do
+ pkg=$(basename $pkg)
+ mv -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" "${FTP_BASE}/extra/os/any/${pkg}"
+ for arch in i686 x86_64; do
+ ln -sf "../any/${pkg}" "${FTP_BASE}/extra/os/${arch}/${pkg}"
+ done
+ done
+
+ releasePackage testing pkg-any-a any
+ ../db-update >/dev/null 2>&1 && (fail 'Adding an existing package to another repository should fail'; return 1)
+
+ for arch in i686 x86_64; do
+ ( [ -r "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" ] \
+ && bsdtar -xf "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" -O | grep -q pkg-any-a) \
+ && fail "pkg-any-a should not be in testing/os/${arch}/testing${DBEXT%.tar.*}"
+ done
+}
+
+
. "${curdir}/lib/shunit2"