Compatible resource directory determination
Previously, the resource directory is generated from `SNAP` if set, `/usr/share/anbox` is used otherwise. This cannot work with binaries installed via `make install` since the loading screen is mostly at `/usr/local/share/anbox/ui/loading-screen.png`. With this patch, anbox can get correct resource directory when it's installed without snap.
This commit is contained in:
parent
17f6c8cd8b
commit
7a8f1efab9
3 changed files with 24 additions and 14 deletions
|
|
@ -119,12 +119,6 @@ anbox::cmds::Launch::Launch()
|
|||
auto bus = std::make_shared<core::dbus::Bus>(bus_type);
|
||||
bus->install_executor(core::dbus::asio::make_executor(bus, rt->service()));
|
||||
|
||||
const auto snap_path = utils::get_env_value("SNAP");
|
||||
if (!snap_path.empty()) {
|
||||
const auto resource_path = fs::path(snap_path) / "usr" / "share" / "anbox";
|
||||
SystemConfiguration::instance().set_resource_path(resource_path);
|
||||
}
|
||||
|
||||
std::shared_ptr<ui::SplashScreen> ss;
|
||||
|
||||
// Instead of relying on the user session init system to start our
|
||||
|
|
|
|||
|
|
@ -41,10 +41,6 @@ void anbox::SystemConfiguration::set_data_path(const std::string &path) {
|
|||
data_path = path;
|
||||
}
|
||||
|
||||
void anbox::SystemConfiguration::set_resource_path(const fs::path &path) {
|
||||
resource_path = path;
|
||||
}
|
||||
|
||||
fs::path anbox::SystemConfiguration::data_dir() const {
|
||||
return data_path;
|
||||
}
|
||||
|
|
@ -88,3 +84,24 @@ anbox::SystemConfiguration& anbox::SystemConfiguration::instance() {
|
|||
static SystemConfiguration config;
|
||||
return config;
|
||||
}
|
||||
|
||||
anbox::SystemConfiguration::SystemConfiguration() {
|
||||
auto gen_resource_path = [] () -> fs::path {
|
||||
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";
|
||||
}
|
||||
};
|
||||
|
||||
resource_path = gen_resource_path();
|
||||
data_path = "/var/local/lib/anbox";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ class SystemConfiguration {
|
|||
virtual ~SystemConfiguration() = default;
|
||||
|
||||
void set_data_path(const std::string &path);
|
||||
void set_resource_path(const boost::filesystem::path &path);
|
||||
|
||||
boost::filesystem::path data_dir() const;
|
||||
std::string rootfs_dir() const;
|
||||
|
|
@ -44,10 +43,10 @@ class SystemConfiguration {
|
|||
std::string resource_dir() const;
|
||||
|
||||
protected:
|
||||
SystemConfiguration() = default;
|
||||
SystemConfiguration();
|
||||
|
||||
boost::filesystem::path data_path = "/var/lib/anbox";
|
||||
boost::filesystem::path resource_path = "/usr/share/anbox";
|
||||
boost::filesystem::path data_path;
|
||||
boost::filesystem::path resource_path;
|
||||
|
||||
};
|
||||
} // namespace anbox
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue