From c77f4f4abe91c55ecf6e89288f3b546068c6e899 Mon Sep 17 00:00:00 2001 From: Michal Domonkos Date: Mon, 18 Nov 2024 15:18:56 +0100 Subject: [PATCH] PoC --- tests/mktree.common | 2 +- tests/mktree.oci | 30 +++++++++++++++++++----------- tests/snapshot | 3 ++- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/tests/mktree.common b/tests/mktree.common index 4cebd853e8..f91225d83e 100644 --- a/tests/mktree.common +++ b/tests/mktree.common @@ -15,7 +15,7 @@ make_install() mkdir -p $DESTDIR/usr/bin cp @TESTPROG_NAMES@ $DESTDIR/usr/bin/ - ln -s $script_dir/rpmtests.sh $DESTDIR/usr/bin/rpmtests + ln -sf $script_dir/rpmtests.sh $DESTDIR/usr/bin/rpmtests mkdir -p $DESTDIR/$script_dir cp rpmtests atlocal snapshot mktree.common $DESTDIR/$script_dir/ diff --git a/tests/mktree.oci b/tests/mktree.oci index b7d79570be..0327ef10bc 100755 --- a/tests/mktree.oci +++ b/tests/mktree.oci @@ -27,16 +27,14 @@ fi IMAGE=rpm ARGS="-f Dockerfile $FROM $CONTEXT" -ROOTLESS=$([ $(id -u) == 0 ] && echo 0 || echo 1) CMD=$1; shift -export ROOTLESS source mktree.common rpmtests() { local opts - local vol="$PWD:/srv:z" + local vol="$PWD:/srv" # Pass select options to $PODMAN case "$1" in @@ -50,8 +48,18 @@ rpmtests() vol=/srv fi - $PODMAN run --privileged -it --rm --read-only --tmpfs /tmp -v $vol \ - --workdir /srv -e ROOTLESS=$ROOTLESS $opts $IMAGE rpmtests "$@" + source ./snapshot + rm -rf $PWD/blah-img + mkdir -p $PWD/blah-img + chcon -Rt container_file_t $PWD + ( cd $PWD/blah-img; podman create --name foo rpm; podman export foo | tar x; podman rm foo ) + chmod -Rf u+rwX $PWD/blah-img + RPMTREE=$PWD/blah-rpm:$PWD/blah-img + RPMTEST=$PWD/blah-mnt + snapshot mount + $PODMAN run --privileged -it --read-only --tmpfs /tmp -v $vol \ + --workdir /srv $opts --rootfs $RPMTEST rpmtests "$@" + snapshot umount } unshared() @@ -67,28 +75,28 @@ case $CMD in $PODMAN build --target base -t $IMAGE/base $ARGS # Add RPM install on top - [ -n "$($PODMAN images -q $IMAGE)" ] && $PODMAN rmi $IMAGE + # [ -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 - make_install $($PODMAN mount $id) + make_install $PWD/blah-rpm $PODMAN commit -q $id $IMAGE else # Standalone build $PODMAN build --target full -t $IMAGE $ARGS fi ;; - check) + check) unshared "$@" rpmtests "$@" ;; - atshell) + atshell) unshared "$@" rpmtests --shell "$@" ;; - shell) + shell) unshared "$@" rpmtests --shell snapshot shell ;; - reset) + reset) unshared rpmtests --reset ;; esac diff --git a/tests/snapshot b/tests/snapshot index eb561d991e..80f49c7318 100644 --- a/tests/snapshot +++ b/tests/snapshot @@ -13,7 +13,8 @@ snapshot() mkdir -p $1/diff $1/work opts="-o upperdir=$1/diff,workdir=$1/work" fi - [ ${ROOTLESS:-1} == 1 ] && opts+=" -o userxattr" + # [ ${ROOTLESS:-1} == 1 ] && opts+=" -o userxattr" + opts+=" -o userxattr" mkdir -p ${RPMTEST} mount -t overlay sandbox \ -o lowerdir="${RPMTREE}" \