summaryrefslogtreecommitdiff
path: root/test/lib
diff options
context:
space:
mode:
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/common.inc168
1 files changed, 97 insertions, 71 deletions
diff --git a/test/lib/common.inc b/test/lib/common.inc
index a2dee10..954868b 100644
--- a/test/lib/common.inc
+++ b/test/lib/common.inc
@@ -1,7 +1,24 @@
+#!/hint/bash
set -E
-. "$(dirname ${BASH_SOURCE[0]})/../../config"
-. "$(dirname ${BASH_SOURCE[0]})/../../db-functions"
+. "$(dirname "${BASH_SOURCE[0]}")/../../config"
+. "$(dirname "${BASH_SOURCE[0]}")/../../config.testing"
+. "$(dirname "${BASH_SOURCE[0]}")/../../db-functions"
+
+signpkg() {
+ if [[ -r '/etc/makepkg.conf' ]]; then
+ source '/etc/makepkg.conf'
+ else
+ die '/etc/makepkg.conf not found!'
+ fi
+ if [[ -r ~/.makepkg.conf ]]; then
+ . ~/.makepkg.conf
+ fi
+ if [[ -n $GPGKEY ]]; then
+ SIGNWITHKEY=(-u "${GPGKEY}")
+ fi
+ gpg --detach-sign --use-agent "${SIGNWITHKEY[@]}" "${@}" || die
+}
oneTimeSetUp() {
local p
@@ -11,34 +28,38 @@ oneTimeSetUp() {
local pkgarch
local pkgversion
local build
- pkgdir="$(mktemp -d /tmp/$(basename $0).XXXXXXXXXX)"
- cp -Lr $(dirname ${BASH_SOURCE[0]})/../packages/* "${pkgdir}"
+ pkgdir="$(mktemp -dt "${0##*/}.XXXXXXXXXX")"
+ cp -Lr "$(dirname "${BASH_SOURCE[0]}")"/../packages/* "${pkgdir}"
msg 'Building packages...'
for d in "${pkgdir}"/*; do
- pushd $d >/dev/null
- pkgname=($(. PKGBUILD; echo ${pkgname[@]}))
- pkgarch=($(. PKGBUILD; echo ${arch[@]}))
- pkgversion=$(. PKGBUILD; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}))
+ pushd "$d" >/dev/null
+ pkgname=($(. PKGBUILD; echo "${pkgname[@]}"))
+ pkgarch=($(. PKGBUILD; echo "${arch[@]}"))
+ pkgversion=$(. PKGBUILD; get_full_version "${epoch:-0}" "${pkgver}" "${pkgrel}")
build=true
- for a in ${pkgarch[@]}; do
- for p in ${pkgname[@]}; do
- [ ! -f ${p}-${pkgversion}-${a}${PKGEXT} ] && build=false
+ for a in "${pkgarch[@]}"; do
+ for p in "${pkgname[@]}"; do
+ [ ! -f "${p}-${pkgversion}-${a}"${PKGEXT} ] && build=false
done
done
- if ! ${build}; then
+ if ! "${build}"; then
if [ "${pkgarch[0]}" == 'any' ]; then
sudo extra-x86_64-build || die 'extra-x86_64-build failed'
else
- for a in ${pkgarch[@]}; do
- sudo extra-${a}-build || die "extra-${a}-build failed"
+ for a in "${pkgarch[@]}"; do
+ if in_array "$a" "${ARCH_BUILD[@]}"; then
+ sudo "extra-${a}-build" || die "extra-${a}-build failed"
+ fi
done
fi
- for a in ${pkgarch[@]}; do
- for p in ${pkgname[@]}; do
- cp ${p}-${pkgversion}-${a}${PKGEXT} $(dirname ${BASH_SOURCE[0]})/../packages/$(basename ${d})
- done
+ for a in "${pkgarch[@]}"; do
+ if in_array "$a" "${ARCH_BUILD[@]}"; then
+ for p in "${pkgname[@]}"; do
+ cp "${p}-${pkgversion}-${a}"${PKGEXT} "$(dirname "${BASH_SOURCE[0]}")/../packages/${d##*/}"
+ done
+ fi
done
fi
popd >/dev/null
@@ -55,17 +76,17 @@ setUp() {
local r
local a
- [ -f "$(dirname ${BASH_SOURCE[0]})/../../config.local" ] && die "$(dirname ${BASH_SOURCE[0]})/../../config.local exists"
- TMP="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)"
+ [ -f "$(dirname "${BASH_SOURCE[0]}")/../../config.local" ] && die "$(dirname "${BASH_SOURCE[0]}")/../../config.local exists"
+ TMP="$(mktemp -dt "${0##*/}.XXXXXXXXXX")"
#msg "Using ${TMP}"
PKGREPOS=('core' 'extra' 'testing')
PKGPOOL='pool/packages'
mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-packages-{copy,repo}}
- for r in ${PKGREPOS[@]}; do
+ for r in "${PKGREPOS[@]}"; do
mkdir -p "${TMP}/staging/${r}"
- for a in ${ARCHES[@]} any; do
+ for a in "${ARCHES[@]}"; do
mkdir -p "${TMP}/ftp/${r}/os/${a}"
done
done
@@ -74,21 +95,23 @@ setUp() {
msg 'Creating svn repository...'
svnadmin create "${TMP}/svn-packages-repo"
- svn checkout -q "file://${TMP}/svn-packages-repo" "${TMP}/svn-packages-copy"
+ arch_svn checkout -q "file://${TMP}/svn-packages-repo" "${TMP}/svn-packages-copy"
for p in "${pkgdir}"/*; do
- pkg=$(basename $p)
+ pkg=${p##*/}
mkdir -p "${TMP}/svn-packages-copy/${pkg}"/{trunk,repos}
- cp "${p}"/* "${TMP}/svn-packages-copy"/${pkg}/trunk/
- svn add -q "${TMP}/svn-packages-copy"/${pkg}
- svn commit -q -m"initial commit of ${pkg}" "${TMP}/svn-packages-copy"
+ cp "${p}"/* "${TMP}/svn-packages-copy/${pkg}/trunk/"
+ arch_svn add -q "${TMP}/svn-packages-copy/${pkg}"
+ arch_svn commit -q -m"initial commit of ${pkg}" "${TMP}/svn-packages-copy"
done
- cat <<eot > "$(dirname ${BASH_SOURCE[0]})/../../config.local"
+ cat <<eot > "$(dirname "${BASH_SOURCE[0]}")/../../config.local"
FTP_BASE="${TMP}/ftp"
SVNREPO="file://${TMP}/svn-packages-repo"
- PKGREPOS=(${PKGREPOS[@]})
+ PKGREPOS=("${PKGREPOS[@]}")
PKGPOOL="${PKGPOOL}"
+ TESTING_REPO='testing'
+ STABLE_REPOS=('core' 'extra')
CLEANUP_DESTDIR="${TMP}/package-cleanup"
SOURCE_CLEANUP_DESTDIR="${TMP}/source-cleanup"
STAGING="${TMP}/staging"
@@ -97,12 +120,12 @@ setUp() {
SOURCE_CLEANUP_DRYRUN=false
REQUIRE_SIGNATURE=true
eot
- . "$(dirname ${BASH_SOURCE[0]})/../../config"
+ . "$(dirname "${BASH_SOURCE[0]}")/../../config"
}
tearDown() {
rm -rf "${TMP}"
- rm -f "$(dirname ${BASH_SOURCE[0]})/../../config.local"
+ rm -f "$(dirname "${BASH_SOURCE[0]}")/../../config.local"
echo
}
@@ -110,18 +133,24 @@ releasePackage() {
local repo=$1
local pkgbase=$2
local arch=$3
+ local a
+ local p
+ local pkgver
+ local pkgname
- pushd "${TMP}/svn-packages-copy"/${pkgbase}/trunk/ >/dev/null
- archrelease ${repo}-${arch} >/dev/null 2&>1
- pkgver=$(. PKGBUILD; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}))
+ pushd "${TMP}/svn-packages-copy/${pkgbase}/trunk/" >/dev/null
+ archrelease "${repo}-${arch}" >/dev/null 2>&1
+ pkgver=$(. PKGBUILD; get_full_version "${epoch:-0}" "${pkgver}" "${pkgrel}")
+ pkgname=($(. PKGBUILD; echo "${pkgname[@]}"))
popd >/dev/null
- cp "${pkgdir}/${pkgbase}"/*-${pkgver}-${arch}${PKGEXT} "${STAGING}"/${repo}/
+ cp "${pkgdir}/${pkgbase}"/*-"${pkgver}-${arch}"${PKGEXT} "${STAGING}/${repo}/"
- if ${REQUIRE_SIGNATURE}; then
- # TODO: really sign the packages with a valid key
- find "${STAGING}"/${repo}/ -type f \
- -name "*-${pkgver}-${arch}${PKGEXT}" \
- -exec touch {}.sig \;
+ if "${REQUIRE_SIGNATURE}"; then
+ for a in "${arch[@]}"; do
+ for p in "${pkgname[@]}"; do
+ signpkg "${STAGING}/${repo}/${p}-${pkgver}-${a}"${PKGEXT}
+ done
+ done
fi
}
@@ -132,42 +161,39 @@ checkAnyPackageDB() {
local db
[ -r "${FTP_BASE}/${PKGPOOL}/${pkg}" ] || fail "${PKGPOOL}/${pkg} not found"
- if ${REQUIRE_SIGNATURE}; then
+ if "${REQUIRE_SIGNATURE}"; then
[ -r "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] || fail "${PKGPOOL}/${pkg}.sig not found"
fi
- for arch in i686 x86_64; do
+ for arch in "${ARCH_BUILD[@]}"; do
[ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} is not a symlink"
[ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/${PKGPOOL}/${pkg}" ] \
|| fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}"
- if ${REQUIRE_SIGNATURE}; then
+ if "${REQUIRE_SIGNATURE}"; then
[ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig" ] || fail "${repo}/os/${arch}/${pkg}.sig is not a symlink"
[ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig")" == "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] \
|| fail "${repo}/os/${arch}/${pkg}.sig does not link to ${PKGPOOL}/${pkg}.sig"
fi
- done
- [ -r "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir"
- [ -r "${STAGING}"/${repo}/${pkg}.sig ] && fail "${repo}/${pkg}.sig found in staging dir"
- for db in ${DBEXT} ${FILESEXT}; do
- ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \
- && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkg}) \
- || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}"
+ for db in "${DBEXT}" "${FILESEXT}"; do
+ ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \
+ && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkg}" &>/dev/null) \
+ || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}"
+ done
done
-
- [ -r "${FTP_BASE}/${repo}/os/any/${pkg}" ] && fail "${repo}/os/any/${pkg} should not exist"
- [ -r "${FTP_BASE}/${repo}/os/any/${pkg}.sig" ] && fail "${repo}/os/any/${pkg}.sig should not exist"
+ [ -r "${STAGING}/${repo}/${pkg}" ] && fail "${repo}/${pkg} found in staging dir"
+ [ -r "${STAGING}/${repo}/${pkg}".sig ] && fail "${repo}/${pkg}.sig found in staging dir"
}
checkAnyPackage() {
local repo=$1
local pkg=$2
- checkAnyPackageDB $repo $pkg
+ checkAnyPackageDB "$repo" "$pkg"
local pkgbase=$(getpkgbase "${FTP_BASE}/${PKGPOOL}/${pkg}")
- svn up -q "${TMP}/svn-packages-copy/${pkgbase}"
+ arch_svn up -q "${TMP}/svn-packages-copy/${pkgbase}"
[ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-any" ] \
|| fail "svn-packages-copy/${pkgbase}/repos/${repo}-any does not exist"
}
@@ -180,23 +206,23 @@ checkPackageDB() {
[ -r "${FTP_BASE}/${PKGPOOL}/${pkg}" ] || fail "${PKGPOOL}/${pkg} not found"
[ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink"
- [ -r "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir"
+ [ -r "${STAGING}/${repo}/${pkg}" ] && fail "${repo}/${pkg} found in staging dir"
[ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/${PKGPOOL}/${pkg}" ] \
|| fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}"
- if ${REQUIRE_SIGNATURE}; then
+ if "${REQUIRE_SIGNATURE}"; then
[ -r "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] || fail "${PKGPOOL}/${pkg}.sig not found"
[ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig" ] || fail "${repo}/os/${arch}/${pkg}.sig is not a symlink"
- [ -r "${STAGING}"/${repo}/${pkg}.sig ] && fail "${repo}/${pkg}.sig found in staging dir"
+ [ -r "${STAGING}/${repo}/${pkg}.sig" ] && fail "${repo}/${pkg}.sig found in staging dir"
[ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig")" == "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] \
|| fail "${repo}/os/${arch}/${pkg}.sig does not link to ${PKGPOOL}/${pkg}.sig"
fi
- for db in ${DBEXT} ${FILESEXT}; do
+ for db in "${DBEXT}" "${FILESEXT}"; do
( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \
- && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkg}) \
+ && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkg}" &>/dev/null) \
|| fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}"
done
}
@@ -206,10 +232,10 @@ checkPackage() {
local pkg=$2
local arch=$3
- checkPackageDB $repo $pkg $arch
+ checkPackageDB "$repo" "$pkg" "$arch"
local pkgbase=$(getpkgbase "${FTP_BASE}/${PKGPOOL}/${pkg}")
- svn up -q "${TMP}/svn-packages-copy/${pkgbase}"
+ arch_svn up -q "${TMP}/svn-packages-copy/${pkgbase}"
[ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] \
|| fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} does not exist"
}
@@ -220,9 +246,9 @@ checkRemovedPackageDB() {
local arch=$3
local db
- for db in ${DBEXT} ${FILESEXT}; do
+ for db in "${DBEXT}" "${FILESEXT}"; do
( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \
- && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkgbase}) \
+ && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkgbase}" &>/dev/null) \
&& fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}"
done
}
@@ -232,9 +258,9 @@ checkRemovedPackage() {
local pkgbase=$2
local arch=$3
- checkRemovedPackageDB $repo $pkgbase $arch
+ checkRemovedPackageDB "$repo" "$pkgbase" "$arch"
- svn up -q "${TMP}/svn-packages-copy/${pkgbase}"
+ arch_svn up -q "${TMP}/svn-packages-copy/${pkgbase}"
[ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] \
&& fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} should not exist"
}
@@ -245,10 +271,10 @@ checkRemovedAnyPackageDB() {
local arch
local db
- for db in ${DBEXT} ${FILESEXT}; do
- for arch in i686 x86_64; do
+ for db in "${DBEXT}" "${FILESEXT}"; do
+ for arch in "${ARCH_BUILD[@]}"; do
( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \
- && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkgbase}) \
+ && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkgbase}" &>/dev/null) \
&& fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}"
done
done
@@ -258,9 +284,9 @@ checkRemovedAnyPackage() {
local repo=$1
local pkgbase=$2
- checkRemovedAnyPackageDB $repo $pkgbase
+ checkRemovedAnyPackageDB "$repo" "$pkgbase"
- svn up -q "${TMP}/svn-packages-copy/${pkgbase}"
+ arch_svn up -q "${TMP}/svn-packages-copy/${pkgbase}"
[ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-any" ] \
&& fail "svn-packages-copy/${pkgbase}/repos/${repo}-any should not exist"
}