Skip to content

Commit

Permalink
Toolbox
Browse files Browse the repository at this point in the history
  • Loading branch information
dmnks committed Jan 5, 2024
1 parent 9802c76 commit 009cfdf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
7 changes: 6 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ if (MKTREE_BACKEND STREQUAL oci)
find_program(PODMAN podman)
mark_as_advanced(PODMAN)

if (PODMAN AND EXISTS ${DOCKERFILE})
if (EXISTS /run/.toolboxenv)
set(MKTREE_MODE toolbox)
find_program(FLATPAK_SPAWN flatpak-spawn REQUIRED)
mark_as_advanced(FLATPAK_SPAWN)
set(PODMAN "${FLATPAK_SPAWN} --host podman")
elseif (PODMAN AND EXISTS ${DOCKERFILE})
set(MKTREE_MODE native)
else()
set(MKTREE_MODE standalone)
Expand Down
17 changes: 17 additions & 0 deletions tests/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,20 @@ RUN cmake \
RUN make -j$(nproc) tree

RUN rm -rf /srv/{rpm,build}

FROM full AS toolbox
LABEL com.github.containers.toolbox="true"

# Disable optimizations for the best debugging experience
ENV CFLAGS="-O0 -g3"

# Some RPM plugins require extended privileges, remove all (for DNF to work)
RUN rm -f $(rpm --eval '%__plugindir')/*

# Install tools required by Toolbox and some extra ones
# More info: https://containertoolbx.org/distros/
RUN dnf -y install \
flatpak-spawn \
gdb \
passwd \
valgrind
2 changes: 1 addition & 1 deletion tests/mktree.common
Original file line number Diff line number Diff line change
Expand Up @@ -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 mktree.common $DESTDIR/$script_dir/
Expand Down
13 changes: 10 additions & 3 deletions tests/mktree.oci
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ if [ "$PROGRAM" == "mktree" ]; then
# Running from build directory
CMAKE=yes
MODE=@MKTREE_MODE@
PODMAN=@PODMAN@
CONTEXT=@CMAKE_SOURCE_DIR@
PODMAN="@PODMAN@"
CONTEXT="@CMAKE_SOURCE_DIR@"
else
# Running from source directory
CMAKE=no
Expand Down Expand Up @@ -70,12 +70,19 @@ case $CMD in
[ -n "$($PODMAN images -q $IMAGE)" ] && $PODMAN rmi $IMAGE
case $MODE in
native)
# Native build
# Native build on the host
id=$($PODMAN create $IMAGE/base)
trap "$PODMAN rm $id >/dev/null" EXIT
make_install $($PODMAN mount $id)
$PODMAN commit -q $id $IMAGE
;;
toolbox)
# Native build in this toolbox(1) container
id=$(sh -c 'source /run/.containerenv; echo $id')
$PODMAN exec --workdir "$PWD" $id \
@CMAKE_SOURCE_DIR@/tests/mktree.rootfs build
$PODMAN commit -q $id $IMAGE
;;
standalone)
# Standalone build
$PODMAN build --target full -t $IMAGE $ARGS
Expand Down

0 comments on commit 009cfdf

Please sign in to comment.