Skip to content

Commit

Permalink
PoC split test-root setup out of make_install()
Browse files Browse the repository at this point in the history
  • Loading branch information
pmatilai committed Jan 22, 2025
1 parent aec3d1d commit c4c29e4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 23 deletions.
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 3 additions & 20 deletions tests/mktree.common
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

# Build and install RPM and the test-suite data into a directory
make_install()
{
Expand All @@ -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
}
8 changes: 5 additions & 3 deletions tests/mktree.oci
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash -x
#
# OCI-based mktree backend

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/mktree.rootfs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ case $CMD in
build)
source ./mktree.common
make_install /
./setup.sh /
;;
check)
./rpmtests "$@"
Expand Down
25 changes: 25 additions & 0 deletions tests/setup.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c4c29e4

Please sign in to comment.