Merge pull request #59 from morphis/f/launcher-fixes

Small fixes to get the app launchers working when running within a snap
This commit is contained in:
Simon Fels 2017-03-14 08:09:10 +01:00 • committed by GitHub
commit b8bfa79ce9
3 changed files with 13 additions and 3 deletions

View file

@ -33,6 +33,6 @@ export LD_LIBRARY_PATH="$SNAP_LIBRARY_PATH:$LD_LIBRARY_PATH"
# create all our application launchers in. The system application launcher will # create all our application launchers in. The system application launcher will
# be configured by our installer to look into this directory for available # be configured by our installer to look into this directory for available
# launchers. # launchers.
export XDG_DATA_HOME="$SNAP_USER_COMMON" export XDG_DATA_HOME="$SNAP_USER_COMMON/app-data"
exec $SNAP/usr/bin/anbox $@ exec $SNAP/usr/bin/anbox $@

View file

@ -25,6 +25,12 @@
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace {
// This will always point us to the right executable when we're running within
// a snap environment.
constexpr const char *snap_exe_path{"/snap/bin/anbox"};
}
namespace anbox { namespace anbox {
namespace application { namespace application {
LauncherStorage::LauncherStorage(const fs::path &path, LauncherStorage::LauncherStorage(const fs::path &path,
@ -62,7 +68,11 @@ void LauncherStorage::add_or_update(const Item &item) {
auto package_name = item.package; auto package_name = item.package;
std::replace(package_name.begin(), package_name.end(), '.', '-'); std::replace(package_name.begin(), package_name.end(), '.', '-');
std::string exec = utils::string_format("%s launch ", utils::process_get_exe_path(getpid())); auto exe_path = utils::process_get_exe_path(getpid());
if (utils::get_env_value("SNAP").length() > 0)
exe_path = snap_exe_path;
std::string exec = utils::string_format("%s launch ", exe_path);
if (!item.launch_intent.action.empty()) if (!item.launch_intent.action.empty())
exec += utils::string_format("--action=%s ", item.launch_intent.action); exec += utils::string_format("--action=%s ", item.launch_intent.action);

View file

@ -195,7 +195,7 @@ anbox::cmds::SystemInfo::SystemInfo()
: CommandWithFlagsAndAction{ : CommandWithFlagsAndAction{
cli::Name{"system-info"}, cli::Usage{"system-info"}, cli::Name{"system-info"}, cli::Usage{"system-info"},
cli::Description{"Print various information about the system we're running on"}} { cli::Description{"Print various information about the system we're running on"}} {
action([](const cli::Command::Context& ctxt) { action([](const cli::Command::Context&) {
SystemInformation si; SystemInformation si;
std::cout << si; std::cout << si;
return EXIT_SUCCESS; return EXIT_SUCCESS;