summaryrefslogtreecommitdiff
path: root/test/lib/common.inc
diff options
context:
space:
mode:
Diffstat (limited to 'test/lib/common.inc')
-rw-r--r--test/lib/common.inc143
1 files changed, 99 insertions, 44 deletions
diff --git a/test/lib/common.inc b/test/lib/common.inc
index a2dee10..2f308dd 100644
--- a/test/lib/common.inc
+++ b/test/lib/common.inc
@@ -1,24 +1,60 @@
set -E
+# override the default TMPDIR
+init_tmpdir() {
+ [[ -n $MASTER_TMPDIR ]] || export MASTER_TMPDIR="$(mktemp -dqt ${0##*/}.XXXXXXXXXX)"
+ export TMPDIR=$MASTER_TMPDIR
+}
+
+_TMPDIR=$TMPDIR
. "$(dirname ${BASH_SOURCE[0]})/../../config"
+TMPDIR=$_TMPDIR
+init_tmpdir
+
. "$(dirname ${BASH_SOURCE[0]})/../../db-functions"
+arches() (
+ . $(librelib conf.sh)
+ load_files libretools
+ printf '%s\n' "${ARCHES[*]}"
+)
+
+arch_svn() {
+ /usr/bin/svn "$@"
+}
+
+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
local d
local a
+ local arches=($(arches))
local pkgname
local pkgarch
local pkgversion
local build
- pkgdir="$(mktemp -d /tmp/$(basename $0).XXXXXXXXXX)"
+ pkgdir="$(mktemp -dqt ${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}))
+ pkgversion=$(. PKGBUILD; get_full_version)
build=true
for a in ${pkgarch[@]}; do
@@ -29,17 +65,19 @@ oneTimeSetUp() {
if ! ${build}; then
if [ "${pkgarch[0]}" == 'any' ]; then
- sudo extra-x86_64-build || die 'extra-x86_64-build failed'
+ sudo libremakepkg || die 'libremakepkg failed'
else
for a in ${pkgarch[@]}; do
- sudo extra-${a}-build || die "extra-${a}-build failed"
+ if in_array $a ${arches[@]}; then
+ sudo setarch $a libremakepkg -n $a || die "setarch ${a} libremakepkg -n ${a} failed"
+ for p in ${pkgname[@]}; do
+ cp ${p}-${pkgversion}-${a}${PKGEXT} $(dirname ${BASH_SOURCE[0]})/../packages/${d##*/}
+ done
+ else
+ warning "skipping arch %s" "$a"
+ 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
- done
fi
popd >/dev/null
done
@@ -56,16 +94,18 @@ setUp() {
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)"
+ init_tmpdir
+ TMP="$(mktemp -dqt ${0##*/}.XXXXXXXXXX)"
#msg "Using ${TMP}"
PKGREPOS=('core' 'extra' 'testing')
PKGPOOL='pool/packages'
+ SRCPOOL='pool/sources'
mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-packages-{copy,repo}}
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 +114,33 @@ 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"
+ arch_svn add -q "${TMP}/svn-packages-copy"/${pkg}
+ arch_svn commit -q -m"initial commit of ${pkg}" "${TMP}/svn-packages-copy"
done
+ mkdir -p "${TMP}/home/.config/libretools"
+ export XDG_CONFIG_HOME="${TMP}/home/.config"
+ printf '%s\n' \
+ 'SVNURL=foo' \
+ "SVNREPO=\"${TMP}/svn-packages-copy\"" \
+ "ARCHES=($(arches))" \
+ > $XDG_CONFIG_HOME/libretools/xbs-abs.conf
+ printf '%s\n' 'BUILDSYSTEM=abs' > $XDG_CONFIG_HOME/xbs.conf
+
cat <<eot > "$(dirname ${BASH_SOURCE[0]})/../../config.local"
FTP_BASE="${TMP}/ftp"
- SVNREPO="file://${TMP}/svn-packages-repo"
+ SVNREPO="${TMP}/svn-packages-copy"
PKGREPOS=(${PKGREPOS[@]})
PKGPOOL="${PKGPOOL}"
+ SRCPOOL="${SRCPOOL}"
+ TESTING_REPO='testing'
+ STABLE_REPOS=('core' 'extra')
CLEANUP_DESTDIR="${TMP}/package-cleanup"
SOURCE_CLEANUP_DESTDIR="${TMP}/source-cleanup"
STAGING="${TMP}/staging"
@@ -110,18 +162,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}))
+ xbs release ${repo} ${arch} >/dev/null 2>&1
+ pkgver=$(. PKGBUILD; get_full_version)
+ pkgname=($(. PKGBUILD; echo ${pkgname[@]}))
popd >/dev/null
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 \;
+ for a in ${arch[@]}; do
+ for p in ${pkgname[@]}; do
+ signpkg "${STAGING}"/${repo}/${p}-${pkgver}-${a}${PKGEXT}
+ done
+ done
fi
}
@@ -136,28 +194,25 @@ checkAnyPackageDB() {
[ -r "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] || fail "${PKGPOOL}/${pkg}.sig not found"
fi
- for arch in i686 x86_64; do
+ for arch in $(arches); 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}" ] \
+ [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "$(readlink -e "${FTP_BASE}/${PKGPOOL}/${pkg}")" ] \
|| fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}"
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" ] \
+ [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig")" == "$(readlink -e "${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
+ ( [ -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 "${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.*}"
- 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"
}
checkAnyPackage() {
@@ -167,7 +222,7 @@ checkAnyPackage() {
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"
}
@@ -182,7 +237,7 @@ checkPackageDB() {
[ -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"
- [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/${PKGPOOL}/${pkg}" ] \
+ [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "$(readlink -e "${FTP_BASE}/${PKGPOOL}/${pkg}")" ] \
|| fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}"
if ${REQUIRE_SIGNATURE}; then
@@ -190,13 +245,13 @@ checkPackageDB() {
[ -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"
- [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig")" == "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] \
+ [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig")" == "$(readlink -e "${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
( [ -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
}
@@ -209,7 +264,7 @@ checkPackage() {
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"
}
@@ -222,7 +277,7 @@ checkRemovedPackageDB() {
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
}
@@ -234,7 +289,7 @@ checkRemovedPackage() {
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"
}
@@ -246,9 +301,9 @@ checkRemovedAnyPackageDB() {
local db
for db in ${DBEXT} ${FILESEXT}; do
- for arch in i686 x86_64; do
+ for arch in $(arches); 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
@@ -260,7 +315,7 @@ checkRemovedAnyPackage() {
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"
}