Skip to content

Commit

Permalink
Remount root fs as read-only in mktree.rootfs
Browse files Browse the repository at this point in the history
This is better and more explicit than just assuming/documenting that.
  • Loading branch information
dmnks committed Oct 5, 2023
1 parent 67dcad3 commit 98dc587
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions tests/mktree.rootfs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/bin/bash
#
# Rootfs mktree backend for use in throwaway build containers.
# Installs RPM into / and runs the test-suite against the same.
#
# Installs RPM into the root filesystem and runs the test-suite against it.
# PWD must be host-mounted for OverlayFS mounts to work.
# The / filesystem should be read-only to prevent parallel tests from altering
# it (online changes to an underlying filesystem are disallowed in OverlayFS).
#
# The root filesystem must be read-only and will be remounted as such otherwise
# before rpmtests is executed. This is needed because lowerdir is not allowed
# to change when part of an OverlayFS (which rpmtests creates).

source ./mktree.common

Expand All @@ -15,7 +17,22 @@ case $CMD in
make_install /
;;
check)
rpmtests "$@"
# Get root's current rw/ro mode
MODE=$(findmnt -n -o OPTIONS / | cut -d, -f1)

# Remount root as read-only if not already, exit if that fails
if [ "$MODE" == "rw" ]; then
mount -o remount,ro / || exit
fi

rpmtests "$@"; RC=$?

# Revert root back to read/write if that was the original mode
if [ "$MODE" == "rw" ]; then
mount -o remount,rw / || exit
fi

exit $RC
;;
*)
echo "Unsupported command." >&2
Expand Down

0 comments on commit 98dc587

Please sign in to comment.