diff --git a/.gitignore b/.gitignore index f3b4966..bc7082a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ build*/ parts/ stage/ prime/ +snap/ +android-images/ *.snap CMakeLists.txt.user *.o.cmd @@ -14,6 +16,8 @@ CMakeLists.txt.user modules.order .tmp_versions .idea +src/anbox/config.h + debian/anbox-modules-dkms.debhelper.log debian/anbox-modules-dkms.substvars diff --git a/CMakeLists.txt b/CMakeLists.txt index 71aa61d..e613b1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,6 +108,12 @@ endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/anbox/build/version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/anbox/build/version.h) +set(ANBOX_RESOURCE_DIR "${CMAKE_INSTALL_DATADIR}/anbox") +set(ANBOX_RESOURCE_DIR_FULL "${CMAKE_INSTALL_FULL_DATADIR}/anbox") +set(ANBOX_STATEDIR_FULL "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/anbox") +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/anbox/config.h.in + ${CMAKE_CURRENT_SOURCE_DIR}/src/anbox/config.h) + add_subdirectory(external) add_subdirectory(src) add_subdirectory(tests) @@ -118,7 +124,7 @@ if (NOT "${HOST_CMAKE_C_COMPILER}" STREQUAL "") message(STATUS "Host C compiler: ${HOST_CMAKE_CXX_COMPILER}") endif() -install(FILES data/ui/loading-screen.png DESTINATION share/anbox/ui) +install(FILES data/ui/loading-screen.png DESTINATION ${ANBOX_RESOURCE_DIR}/ui) # uninstall target configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" diff --git a/src/anbox/config.cpp b/src/anbox/config.cpp index eb3d185..a1725e2 100644 --- a/src/anbox/config.cpp +++ b/src/anbox/config.cpp @@ -90,18 +90,11 @@ anbox::SystemConfiguration::SystemConfiguration() { const auto snap_path = utils::get_env_value("SNAP"); if (!snap_path.empty()) { return fs::path(snap_path) / "usr/share/anbox"; - } - - const std::string exe = utils::process_get_exe_path(::getpid()); - const std::size_t pos = exe.rfind("/bin/anbox"); - if (pos != std::string::npos) { - const std::string leading_path = exe.substr(0, pos); - return fs::path(leading_path) / "share/anbox"; } else { - return "/usr/local/share/anbox"; + return default_resource_path; } }; resource_path = gen_resource_path(); - data_path = "/var/local/lib/anbox"; + data_path = default_path_path; } diff --git a/src/anbox/config.h b/src/anbox/config.h.in similarity index 89% rename from src/anbox/config.h rename to src/anbox/config.h.in index c6b88da..26f07de 100644 --- a/src/anbox/config.h +++ b/src/anbox/config.h.in @@ -48,6 +48,10 @@ class SystemConfiguration { boost::filesystem::path data_path; boost::filesystem::path resource_path; + private: + static constexpr const char *default_resource_path{"@ANBOX_RESOURCE_DIR_FULL@"}; + static constexpr const char *default_path_path{"@ANBOX_STATEDIR_FULL@"}; + }; } // namespace anbox