Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure tests/setup.sh is only ever run inside the test-image #3552

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/mktree.common
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ make_install()
mkdir -p $DESTDIR/$script_dir
cp rpmtests atlocal mktree.common setup.sh $DESTDIR/$script_dir/
cp @CMAKE_CURRENT_SOURCE_DIR@/rpmtests.sh $DESTDIR/$script_dir/

touch $DESTDIR/.rpmtestsuite
}
25 changes: 15 additions & 10 deletions tests/setup.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
#!/bin/bash

# Setup the environment inside the test-image
# DESTDIR is only for testing purposes, inside the image it's always /
export DESTDIR=${1:-/}
# Setup the environment in the test-image.
# Runs INSIDE the image, with our newly built rpm in the path.

mkdir -p $DESTDIR/build
ln -sf ../data/SOURCES $DESTDIR/build/
# Make sure nobody runs this accidentally outside the environment
if [ ! -f /.rpmtestsuite ]; then
echo "Not inside rpm test-suite image"
exit 99
fi

mkdir -p /build
ln -sf ../data/SOURCES /build/

# system-wide config to match our test environment
cp /data/macros.testenv $DESTDIR/@CMAKE_INSTALL_FULL_SYSCONFDIR@/rpm/
cp /data/macros.testenv @CMAKE_INSTALL_FULL_SYSCONFDIR@/rpm/

# setup an empty db that all tests are pointed to by default
rpmdb --dbpath $DESTDIR/$(rpm --eval "%{_dbpath}") --initdb
rpmdb --initdb

# gpg-connect-agent is very, very unhappy if this doesn't exist
mkdir -p $DESTDIR/root/.gnupg
chmod 700 $DESTDIR/root/.gnupg
mkdir -p /root/.gnupg
chmod 700 /root/.gnupg

# set up new-style XDG config directory
mkdir -p $DESTDIR/root/.config/rpm
mkdir -p /root/.config/rpm