Using 'sudo' in a test? Not on my machine, I don't care how secure it should be, it is totally unnecessary, not to mention the annoyance of password prompts, needing the chroot setups, etc. Instead, use makepkg directly along with some very vanilla makepkg.conf config files to do the work. This makes for a more reproducable environment as far as makepkg settings goes. Also adjust the package building code in common.inc to be a bit more straightforward. Remove the need for three seperate loops, and only ever copy packages in one direction (from the local test directory to the /dev/shm/ staging area). With these changes, I didn't have too many problems running the test suite locally on my box after cloning the repository. Signed-off-by: Dan McGee <dan@archlinux.org> --- test/lib/common.inc | 54 ++++++++++++++++++++------------------- test/lib/makepkg.i686.conf | 10 +++++++ test/lib/makepkg.x86_64.conf | 10 +++++++ test/test.d/db-update.sh | 6 +++- test/test.d/pool-transition.sh | 3 +- test/test.d/testing2x.sh | 3 +- 6 files changed, 56 insertions(+), 30 deletions(-) create mode 100644 test/lib/makepkg.i686.conf create mode 100644 test/lib/makepkg.x86_64.conf diff --git a/test/lib/common.inc b/test/lib/common.inc index eb46508..a2ba1e0 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -10,39 +10,39 @@ oneTimeSetUp() { local pkgname local pkgarch local pkgversion - local build + origindir="$(dirname ${BASH_SOURCE[0]})/../packages" pkgdir="$(mktemp -d /dev/shm/$(basename $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})) - - build=true - for a in ${pkgarch[@]}; do - for p in ${pkgname[@]}; do - [ ! -f ${p}-${pkgversion}-${a}${PKGEXT} ] && build=false - done - done - if ! ${build}; then + if [ -f ${origindir}/packages-built ]; then + msg 'Using existing packages.' + else + msg 'Building packages...' + for d in "${origindir}"/*; do + pushd $d >/dev/null + pkgname=($(. PKGBUILD; echo ${pkgname[@]})) + pkgarch=($(. PKGBUILD; echo ${arch[@]})) + pkgversion=$(. PKGBUILD; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})) + + PKGDEST=$(pwd) + export PKGDEST + echo $PKGDEST if [ "${pkgarch[0]}" == 'any' ]; then - sudo extra-x86_64-build || die 'extra-x86_64-build failed' + MAKEPKG_CONF="$(dirname ${BASH_SOURCE[0]})/makepkg.i686.conf" + makepkg --force --config "$MAKEPKG_CONF" else for a in ${pkgarch[@]}; do - sudo extra-${a}-build || die "extra-${a}-build failed" + MAKEPKG_CONF="$(dirname ${BASH_SOURCE[0]})/makepkg.$a.conf" + makepkg --force --config "$MAKEPKG_CONF" 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 + popd >/dev/null + done + + touch ${origindir}/packages-built + fi + + cp -Lr "${origindir}"/* "${pkgdir}" + rm "${pkgdir}"/packages-built } oneTimeTearDown() { @@ -229,3 +229,5 @@ checkRemovedAnyPackage() { [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-any" ] \ && fail "svn-packages-copy/${pkgbase}/repos/${repo}-any should not exist" } + +# vim: syntax=sh: diff --git a/test/lib/makepkg.i686.conf b/test/lib/makepkg.i686.conf new file mode 100644 index 0000000..6fae31e --- /dev/null +++ b/test/lib/makepkg.i686.conf @@ -0,0 +1,10 @@ +# /etc/makepkg.conf + +CARCH="i686" + +BUILDENV=(fakeroot !distcc color !ccache check !sign) +OPTIONS=(strip docs libtool emptydirs zipman purge) + +INTEGRITY_CHECK=(md5) +PKGEXT='.pkg.tar.xz' +SRCEXT='.src.tar.gz' diff --git a/test/lib/makepkg.x86_64.conf b/test/lib/makepkg.x86_64.conf new file mode 100644 index 0000000..cdee1d7 --- /dev/null +++ b/test/lib/makepkg.x86_64.conf @@ -0,0 +1,10 @@ +# /etc/makepkg.conf + +CARCH="x86_64" + +BUILDENV=(fakeroot !distcc color !ccache check !sign) +OPTIONS=(strip docs libtool emptydirs zipman purge) + +INTEGRITY_CHECK=(md5) +PKGEXT='.pkg.tar.xz' +SRCEXT='.src.tar.gz' diff --git a/test/test.d/db-update.sh b/test/test.d/db-update.sh index e38c328..5db276b 100755 --- a/test/test.d/db-update.sh +++ b/test/test.d/db-update.sh @@ -82,7 +82,8 @@ testUpdateAnyPackage() { pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD svn commit -q -m"update pkg to pkgrel=2" >/dev/null - sudo extra-i686-build >/dev/null 2>&1 + MAKEPKG_CONF="${curdir}/../lib/makepkg.i686.conf" + makepkg --force --config "$MAKEPKG_CONF" mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" popd >/dev/null @@ -100,7 +101,8 @@ testUpdateAnyPackageToDifferentRepositoriesAtOnce() { pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD svn commit -q -m"update pkg to pkgrel=2" >/dev/null - sudo extra-i686-build >/dev/null 2>&1 + MAKEPKG_CONF="${curdir}/../lib/makepkg.i686.conf" + makepkg --force --config "$MAKEPKG_CONF" mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" popd >/dev/null diff --git a/test/test.d/pool-transition.sh b/test/test.d/pool-transition.sh index 5873f00..545c2a5 100755 --- a/test/test.d/pool-transition.sh +++ b/test/test.d/pool-transition.sh @@ -63,7 +63,8 @@ testUpdateAnyPackageWithoutPool() { pushd "${TMP}/svn-packages-copy/${pkgname}/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD svn commit -q -m"update pkg to pkgrel=2" >/dev/null - sudo extra-i686-build >/dev/null 2>&1 + MAKEPKG_CONF="${curdir}/../lib/makepkg.i686.conf" + makepkg --force --config "$MAKEPKG_CONF" mv "${pkg2}" "${pkgdir}/${pkgname}/" popd >/dev/null diff --git a/test/test.d/testing2x.sh b/test/test.d/testing2x.sh index eda6cd6..bcc1b9d 100755 --- a/test/test.d/testing2x.sh +++ b/test/test.d/testing2x.sh @@ -10,7 +10,8 @@ testTesting2xAnyPackage() { pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD svn commit -q -m"update pkg to pkgrel=2" >/dev/null - sudo extra-i686-build >/dev/null 2>&1 + MAKEPKG_CONF="${curdir}/../lib/makepkg.i686.conf" + makepkg --force --config "$MAKEPKG_CONF" mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" popd >/dev/null -- 1.7.6