From 2aff4239ccb0b6a50fa3aa84a011b293f0b85822 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Tue, 29 Oct 2024 14:10:05 +0100 Subject: [PATCH] [BOX32] Added an option to also add binfmt integration for box32 (for #1973) --- CMakeLists.txt | 19 ++++++++++++++----- system/box32.conf.cmake | 2 ++ 2 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 system/box32.conf.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e0fa7129..3d1bb3198 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ option(SW64 "Set ON if targeting an SW64 based device" ${SW64}) option(CI "Set to ON if running in CI" ${CI}) option(WITH_MOLD "Set to ON to use with mold" ${WITH_MOLD}) option(BOX32 "Set to ON to add Linux 32bits support (experimental, do not use)" ${BO64}) +option(BOX32_BINFMT "Also setup binfmt integration for box32" ${BO64_BINFMT}) if(TERMUX) set(TERMUX_PATH "/data/data/com.termux/files") @@ -1144,11 +1145,19 @@ if(NOT _x86 AND NOT _x86_64) if(NOT NO_CONF_INSTALL) configure_file(system/box64.conf.cmake system/box64.conf) if(NOT TERMUX) - install(FILES ${CMAKE_BINARY_DIR}/system/box64.conf DESTINATION /etc/binfmt.d/) - install(FILES ${CMAKE_SOURCE_DIR}/system/box64.box64rc DESTINATION /etc/) - else() - install(FILES ${CMAKE_BINARY_DIR}/system/box64.conf DESTINATION ${TERMUX_PATH}/usr/etc/binfmt.d/) - install(FILES ${CMAKE_SOURCE_DIR}/system/box64.box64rc DESTINATION ${TERMUX_PATH}/usr/etc/) + install(FILES ${CMAKE_BINARY_DIR}/system/box64.conf DESTINATION /etc/binfmt.d/) + install(FILES ${CMAKE_SOURCE_DIR}/system/box64.box64rc DESTINATION /etc/) + if(BOX32_BINFMT) + configure_file(system/box32.conf.cmake system/box32.conf) + install(FILES ${CMAKE_BINARY_DIR}/system/box32.conf DESTINATION /etc/binfmt.d/) + endif() + else() + install(FILES ${CMAKE_BINARY_DIR}/system/box64.conf DESTINATION ${TERMUX_PATH}/usr/etc/binfmt.d/) + install(FILES ${CMAKE_SOURCE_DIR}/system/box64.box64rc DESTINATION ${TERMUX_PATH}/usr/etc/) + if(BOX32_BINFMT) + configure_file(system/box32.conf.cmake system/box32.conf) + install(FILES ${CMAKE_BINARY_DIR}/system/box32.conf DESTINATION ${TERMUX_PATH}/usr/etc/binfmt.d/) + endif() endif() endif() diff --git a/system/box32.conf.cmake b/system/box32.conf.cmake new file mode 100644 index 000000000..0e872132e --- /dev/null +++ b/system/box32.conf.cmake @@ -0,0 +1,2 @@ +# /etc/binfmt.d/box32.conf +:box32:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:${CMAKE_INSTALL_PREFIX}/bin/${BOX64}: