summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2010-12-02 18:06:45 +0100
committerPierre Schmitz <pierre@archlinux.de>2010-12-02 18:06:45 +0100
commit6037b3e9aa414d94cd14b8c51b9b04be054c5e04 (patch)
treed13b294ee5cb4f2f755825d6af6e8e3b918c69cd
parent69721f4e42fa296de2d5a568d07758888c354328 (diff)
db-update: Fail if a set of split packages is incomplete
-rw-r--r--db-functions58
-rwxr-xr-xdb-update3
-rwxr-xr-xtest/test.d/db-update.sh23
3 files changed, 83 insertions, 1 deletions
diff --git a/db-functions b/db-functions
index 67a52aa..cb76e7a 100644
--- a/db-functions
+++ b/db-functions
@@ -198,9 +198,20 @@ getpkgbase() {
_base="$(_grep_pkginfo "$1" "pkgbase")"
if [ -z "$_base" ]; then
getpkgname "$1"
+ else
+ echo "$_base"
fi
+}
- echo "$_base"
+issplitpkg() {
+ local _base
+
+ _base="$(_grep_pkginfo "$1" "pkgbase")"
+ if [ -z "$_base" ]; then
+ return 1
+ else
+ return 0
+ fi
}
# Get the package name
@@ -319,6 +330,51 @@ check_pkgsvn() {
return 0
}
+check_splitpkgs() {
+ local repo="${1}"
+ shift
+ local pkgfiles=(${@})
+ local pkgfile
+ local pkgdir
+ local svnname
+
+ mkdir -p "${WORKDIR}/check_splitpkgs/"
+ pushd "${WORKDIR}/check_splitpkgs" >/dev/null
+
+ for pkgfile in ${pkgfiles[@]}; do
+ issplitpkg "${pkgfile}" || continue
+ local _pkgbase="$(getpkgbase ${pkgfile})"
+ local _pkgname="$(getpkgname ${pkgfile})"
+ local _pkgarch="$(getpkgarch ${pkgfile})"
+ 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}"
+ svn export -q "${SVNREPO}/${_pkgbase}/repos/${repo}-${_pkgarch}/PKGBUILD" \
+ "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null
+ [ $? -ge 1 ] && return 1
+ fi
+
+ local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo ${pkgname[@]}))
+ for svnname in ${svnnames[@]}; do
+ echo "${svnname}" >> "${repo}/${_pkgarch}/${_pkgbase}/svn"
+ done
+ 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
+ return 1
+ fi
+ done
+
+ return 0
+}
+
check_pkgrepos() {
local pkgfile=$1
diff --git a/db-update b/db-update
index 49ecbde..3a49f0a 100755
--- a/db-update
+++ b/db-update
@@ -42,6 +42,9 @@ for repo in ${repos[@]}; do
die "Package ${repo}/$(basename ${pkg}) already exists in another repository"
fi
done
+ if ! check_splitpkgs ${repo} ${pkgs[@]}; then
+ die "Missing split packages for ${repo}"
+ fi
else
die "Could not read ${STAGING}"
fi
diff --git a/test/test.d/db-update.sh b/test/test.d/db-update.sh
index 3c41b39..ad0be32 100755
--- a/test/test.d/db-update.sh
+++ b/test/test.d/db-update.sh
@@ -124,4 +124,27 @@ testUpdateSameAnyPackageToDifferentRepositories() {
done
}
+
+testAddIncompleteSplitPackage() {
+ local arches=('i686' 'x86_64')
+ local repo='extra'
+ local pkgbase='pkg-split-a'
+ local arch
+
+ for arch in ${arches[@]}; do
+ releasePackage ${repo} ${pkgbase} ${arch}
+ done
+
+ # remove a split package to make db-update fail
+ rm "${STAGING}"/extra/${pkgbase}1-*
+
+ ../db-update >/dev/null 2>&1 && fail "db-update should fail when a split package is missing!"
+
+ for arch in ${arches[@]}; 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
+}
+
. "${curdir}/../lib/shunit2"