minecraft-pi-docker/dependencies/armhf-sysroot/CMakeLists.txt

114 lines
4.0 KiB
CMake
Raw Normal View History

2022-05-03 02:44:10 +00:00
project(armhf-sysroot)
2022-06-10 01:31:40 +00:00
# Check If Using Custom Sysroot
2022-05-04 01:04:22 +00:00
if(MCPI_CUSTOM_BUNDLED_ARMHF_SYSROOT)
# Custom Sysroot
set(SYSROOT_DIR "${MCPI_CUSTOM_BUNDLED_ARMHF_SYSROOT}")
else()
# Download From APT
set(APT_PACKAGES "libc6" "libstdc++6")
2022-05-03 02:44:10 +00:00
2022-05-04 01:04:22 +00:00
# Copy To Binary Directory
2022-05-11 22:24:03 +00:00
set(APT_DIR "${CMAKE_CURRENT_BINARY_DIR}/apt")
2022-05-04 01:04:22 +00:00
file(REMOVE_RECURSE "${APT_DIR}")
2022-05-11 22:24:03 +00:00
file(MAKE_DIRECTORY "${APT_DIR}")
2022-05-04 01:04:22 +00:00
# Make Directories
file(MAKE_DIRECTORY "${APT_DIR}/apt.conf.d")
file(MAKE_DIRECTORY "${APT_DIR}/preferences.d")
file(MAKE_DIRECTORY "${APT_DIR}/keys")
2022-05-04 01:04:22 +00:00
file(MAKE_DIRECTORY "${APT_DIR}/dpkg")
file(TOUCH "${APT_DIR}/dpkg/status")
2022-05-03 02:44:10 +00:00
2022-05-11 22:24:03 +00:00
# Create APT Sources
execute_process(
COMMAND "${CMAKE_SOURCE_DIR}/scripts/tools/get-apt-sources.sh"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE APT_SOURCES
RESULT_VARIABLE APT_SOURCES_RESULT
)
if(NOT APT_SOURCES_RESULT EQUAL 0)
message(FATAL_ERROR "Unable To Get APT Sources For ARMHF Sysroot")
endif()
file(WRITE "${APT_DIR}/sources.list" "${APT_SOURCES}")
2022-05-04 01:04:22 +00:00
# Create APT Config
string(CONCAT APT_CONFIG
"Dir \"${APT_DIR}\";\n"
"Dir::State \"${APT_DIR}\";\n"
"Dir::Cache \"${APT_DIR}\";\n"
"Dir::Etc::Main \"${APT_DIR}/apt.conf\";\n"
"Dir::Etc::Parts \"${APT_DIR}/apt.conf.d\";\n"
"Dir::Etc::SourceList \"${APT_DIR}/sources.list\";\n"
"Dir::Etc::SourceListParts \"${APT_DIR}/sources.list.d\";\n"
"Dir::Etc::PreferencesParts \"${APT_DIR}/preferences.d\";\n"
"Dir::Etc::TrustedParts \"${APT_DIR}/keys\";\n"
"Dir::State::status \"${APT_DIR}/dpkg/status\";\n"
"Dir::Ignore-Files-Silently \"False\";\n"
"APT::Install-Recommends \"False\";\n"
"APT::Install-Suggests \"False\";\n"
"APT::Immediate-Configure \"False\";\n"
"APT::Architecture \"armhf\";\n"
"APT::Architectures { \"armhf\"; }\n"
"Acquire::Languages \"none\";\n"
"APT::Get::AllowUnauthenticated \"True\";\n"
"Acquire::AllowInsecureRepositories \"True\";\n"
2022-05-04 01:04:22 +00:00
)
file(WRITE "${APT_DIR}/apt.conf" "${APT_CONFIG}")
2022-05-03 02:44:10 +00:00
2022-05-04 01:04:22 +00:00
# Environment
set(APT_ENV
"${CMAKE_COMMAND}"
-E env
"DEBIAN_FRONTEND=noninteractive"
"APT_CONFIG=${APT_DIR}/apt.conf"
)
2022-05-03 02:44:10 +00:00
2022-05-04 01:04:22 +00:00
# Create Sysroot Directory
set(SYSROOT_DIR "${CMAKE_CURRENT_BINARY_DIR}/sysroot")
file(REMOVE_RECURSE "${SYSROOT_DIR}")
file(MAKE_DIRECTORY "${SYSROOT_DIR}")
2022-05-03 02:44:10 +00:00
2022-05-04 01:04:22 +00:00
# Download
add_custom_command(
OUTPUT "${APT_DIR}/.update-stamp"
COMMAND ${APT_ENV} apt-get update
COMMAND "${CMAKE_COMMAND}" -E touch "${APT_DIR}/.update-stamp"
VERBATIM
)
add_custom_command(
OUTPUT "${APT_DIR}/.download-stamp"
DEPENDS "${APT_DIR}/.update-stamp"
COMMAND ${APT_ENV} apt-get install -y --no-install-recommends --download-only ${APT_PACKAGES}
COMMAND "${CMAKE_COMMAND}" -E touch "${APT_DIR}/.download-stamp"
VERBATIM
)
add_custom_command(
OUTPUT "${APT_DIR}/.extract-stamp"
DEPENDS "${APT_DIR}/.download-stamp"
COMMAND ${APT_ENV} find "${APT_DIR}/archives" -maxdepth 1 -type f -name "*.deb" -exec dpkg -x {} "${SYSROOT_DIR}" ";"
COMMAND "${CMAKE_COMMAND}" -E touch "${APT_DIR}/.extract-stamp"
VERBATIM
)
add_custom_target(armhf-sysroot ALL DEPENDS "${APT_DIR}/.extract-stamp")
endif()
2022-05-03 02:44:10 +00:00
# Install
install(
DIRECTORY "${SYSROOT_DIR}/"
DESTINATION "${MCPI_INSTALL_DIR}/sysroot"
USE_SOURCE_PERMISSIONS
REGEX "usr/lib/arm-linux-gnueabihf/gconv" EXCLUDE
REGEX "usr/lib/arm-linux-gnueabihf/audit" EXCLUDE
REGEX "usr/share/man" EXCLUDE
REGEX "usr/share/doc/.*/README\..*" EXCLUDE
REGEX "usr/share/doc/.*/changelog\..*" EXCLUDE
REGEX "usr/share/doc/.*/NEWS\..*" EXCLUDE
REGEX "usr/share/doc/.*/TODO\..*" EXCLUDE
REGEX "usr/share/lintian" EXCLUDE
REGEX "usr/share/gcc" EXCLUDE
REGEX "usr/share/gdb" EXCLUDE
REGEX "usr/share/locale" EXCLUDE
REGEX "usr/share/help" EXCLUDE
REGEX "etc" EXCLUDE
)