Configure default resource and data directories from CMake

As anbox is expected to installed in two ways (`snap` or `make install`),
it should be enough to get `snap` ENV or configure by cmake.
This commit is contained in:
王振华 (WANG Zhenhua) 2017-08-28 10:06:57 +08:00
commit 202b556bea
4 changed files with 17 additions and 10 deletions

View file

@ -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;
}

View file

@ -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