Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dmnks committed Feb 11, 2025
1 parent e426de9 commit 391b5f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
14 changes: 8 additions & 6 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,18 @@ endif()

# Set up mktree
set(MKTREE_BACKEND oci CACHE STRING "Mktree backend to use")
option(MKTREE_NATIVE "Enable native mktree build integration" ON)
if (MKTREE_BACKEND STREQUAL oci)
find_program(PODMAN podman)
find_program(DOCKER docker)
mark_as_advanced(PODMAN DOCKER)
os_release(OS_NAME ID)
os_release(OS_VERSION VERSION_ID)
set(DOCKERFILE ${CMAKE_CURRENT_SOURCE_DIR}/Dockerfile.${OS_NAME})
if (PODMAN AND EXISTS ${DOCKERFILE})
set(MKTREE_NATIVE yes)
if (NOT PODMAN OR NOT EXISTS ${DOCKERFILE})
set(MKTREE_NATIVE OFF)
endif()
if (MKTREE_NATIVE)
configure_file(${DOCKERFILE} Dockerfile COPYONLY)
add_custom_target(ci
COMMAND ./mktree.oci build
Expand All @@ -94,17 +97,16 @@ if (MKTREE_BACKEND STREQUAL oci)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
else()
set(MKTREE_NATIVE no)
configure_file(Dockerfile Dockerfile COPYONLY)
endif()
find_program(PODMAN NAMES podman docker REQUIRED)
elseif (MKTREE_BACKEND STREQUAL rootfs)
set(MKTREE_NATIVE yes)
set(MKTREE_NATIVE ON)
find_program(BWRAP bwrap REQUIRED)
mark_as_advanced(BWRAP)
endif()
message(STATUS "Using mktree backend: ${MKTREE_BACKEND} "
"(native: ${MKTREE_NATIVE})")
message(STATUS "Using mktree backend: ${MKTREE_BACKEND}")
message(STATUS "Native mktree build integration: ${MKTREE_NATIVE}")
configure_file(mktree.common mktree.common @ONLY)
configure_file(mktree.${MKTREE_BACKEND} mktree @ONLY)
configure_file(setup.sh setup.sh @ONLY)
Expand Down
8 changes: 4 additions & 4 deletions tests/mktree.oci
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ if [ "$PROGRAM" == "mktree" ]; then
else
# Running from source directory
CMAKE=no
NATIVE=no
NATIVE=OFF
PODMAN=${MKTREE_ENGINE:-podman}
CONTEXT=..
fi

if [ $NATIVE == yes ]; then
if [ $NATIVE == ON ]; then
FROM="--from @OS_NAME@:@OS_VERSION@"
else
FROM=
Expand Down Expand Up @@ -70,7 +70,7 @@ clean()

unshared()
{
[ $(id -u) != 0 ] && [ $NATIVE == yes ] || return 0
[ $(id -u) != 0 ] && [ $NATIVE == ON ] || return 0
$PODMAN unshare $0 $CMD "$@"
exit
}
Expand All @@ -82,7 +82,7 @@ case $CMD in

# Add RPM install on top
clean
if [ $NATIVE == yes ]; then
if [ $NATIVE == ON ]; then
# Native build
id=$($PODMAN create -t $BASE_TAG)
trap "$PODMAN kill $id >/dev/null; $PODMAN rm $id > /dev/null" EXIT
Expand Down

0 comments on commit 391b5f2

Please sign in to comment.