diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index adc09aea98..bce3ffad7e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -106,6 +106,7 @@ message(STATUS "Using mktree backend: ${MKTREE_BACKEND} " "(native: ${MKTREE_NATIVE})") configure_file(mktree.common mktree.common @ONLY) configure_file(mktree.${MKTREE_BACKEND} mktree @ONLY) +configure_file(setup.sh setup.sh @ONLY) if (MKTREE_NATIVE) find_program(AUTOM4TE autom4te REQUIRED) diff --git a/tests/mktree.common b/tests/mktree.common index f1441dcef1..70ef5e2dfc 100644 --- a/tests/mktree.common +++ b/tests/mktree.common @@ -1,3 +1,5 @@ +#!/bin/sh + # Build and install RPM and the test-suite data into a directory make_install() { @@ -18,25 +20,6 @@ make_install() ln -s $script_dir/rpmtests.sh $DESTDIR/usr/bin/rpmtests mkdir -p $DESTDIR/$script_dir - cp rpmtests atlocal mktree.common $DESTDIR/$script_dir/ + cp rpmtests atlocal mktree.common setup.sh $DESTDIR/$script_dir/ cp @CMAKE_CURRENT_SOURCE_DIR@/rpmtests.sh $DESTDIR/$script_dir/ - - mkdir -p $DESTDIR/build - ln -sf ../data/SOURCES $DESTDIR/build/ - - # setup an empty db that all tests are pointed to by default - dbpath="/var/lib/rpm-testsuite" - mkdir -p $DESTDIR/$dbpath - echo "%_dbpath $dbpath" > $DESTDIR/@CMAKE_INSTALL_FULL_SYSCONFDIR@/rpm/macros.db - rpmdb --dbpath $DESTDIR/$dbpath --initdb - - # system-wide config to match our test environment - cp @CMAKE_CURRENT_SOURCE_DIR@/data/macros.testenv $DESTDIR/@CMAKE_INSTALL_FULL_SYSCONFDIR@/rpm/ - - # gpg-connect-agent is very, very unhappy if this doesn't exist - mkdir -p $DESTDIR/root/.gnupg - chmod 700 $DESTDIR/root/.gnupg - - # set up new-style XDG config directory - mkdir -p $DESTDIR/root/.config/rpm } diff --git a/tests/mktree.oci b/tests/mktree.oci index b7d79570be..72a0214673 100755 --- a/tests/mktree.oci +++ b/tests/mktree.oci @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -x # # OCI-based mktree backend @@ -70,9 +70,11 @@ case $CMD in [ -n "$($PODMAN images -q $IMAGE)" ] && $PODMAN rmi $IMAGE if [ $NATIVE == yes ]; then # Native build - id=$($PODMAN create $IMAGE/base) - trap "$PODMAN rm $id >/dev/null" EXIT + id=$($PODMAN create -t $IMAGE/base) + trap "$PODMAN kill $id >/dev/null; $PODMAN rm $id > /dev/null" EXIT + $PODMAN start $id make_install $($PODMAN mount $id) + $PODMAN exec $id /usr/share/mktree/setup.sh $PODMAN commit -q $id $IMAGE else # Standalone build diff --git a/tests/mktree.rootfs b/tests/mktree.rootfs index 409aa90eda..4357c2800c 100755 --- a/tests/mktree.rootfs +++ b/tests/mktree.rootfs @@ -14,6 +14,7 @@ case $CMD in build) source ./mktree.common make_install / + ./setup.sh / ;; check) ./rpmtests "$@" diff --git a/tests/setup.sh b/tests/setup.sh new file mode 100755 index 0000000000..bffaa45926 --- /dev/null +++ b/tests/setup.sh @@ -0,0 +1,25 @@ +#!/bin/bash -x + +# Setup the environment inside the test-image +# DESTDIR is only for testing purposes, inside the image it's always / +export DESTDIR=${1:-/} + +mkdir -p $DESTDIR/build +ln -sf ../data/SOURCES $DESTDIR/build/ + +# setup an empty db that all tests are pointed to by default +dbpath="/var/lib/rpm-testsuite" +mkdir -p $DESTDIR/$dbpath +echo "%_dbpath $dbpath" > $DESTDIR/@CMAKE_INSTALL_FULL_SYSCONFDIR@/rpm/macros.db +rpmdb --dbpath $DESTDIR/$dbpath --initdb + +# system-wide config to match our test environment +cp /data/macros.testenv $DESTDIR/@CMAKE_INSTALL_FULL_SYSCONFDIR@/rpm/ + +# gpg-connect-agent is very, very unhappy if this doesn't exist +mkdir -p $DESTDIR/root/.gnupg +chmod 700 $DESTDIR/root/.gnupg + +# set up new-style XDG config directory +mkdir -p $DESTDIR/root/.config/rpm +