From f24c167722b5a19237804788415565845ab48b28 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sun, 3 May 2020 18:32:55 +0200 Subject: [PATCH] Add $LINUXDEPLOY for input plugins The input plugins can use this environment variable to call linuxdeploy themselves. This can be very handy to have it deploy additional dependencies on libraries they copy themselves. An alternative approach is to simply use liblinuxdeploy inside the plugin, like the Qt plugin does. --- include/linuxdeploy/plugin/base_impl.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/include/linuxdeploy/plugin/base_impl.h b/include/linuxdeploy/plugin/base_impl.h index 15a10d0..0efc3b5 100644 --- a/include/linuxdeploy/plugin/base_impl.h +++ b/include/linuxdeploy/plugin/base_impl.h @@ -11,6 +11,7 @@ // local headers #include "linuxdeploy/core/log.h" +#include "linuxdeploy/util/util.h" #pragma once @@ -136,8 +137,21 @@ namespace linuxdeploy { } log << std::endl; - auto process = subprocess::Popen(args, subprocess::output{subprocess::PIPE}, subprocess::error{subprocess::PIPE}); + std::map environmentVariables{}; + if (this->pluginType() == PLUGIN_TYPE::INPUT_TYPE) { + // add $LINUXDEPLOY, which points to the current binary + // we do not need to pass $APPIMAGE or alike, since while linuxdeploy is running, the path in the + // temporary mountpoint of its AppImage will be valid anyway + environmentVariables["LINUXDEPLOY"] = linuxdeploy::util::getOwnExecutablePath(); + } + + auto process = subprocess::Popen( + args, + subprocess::output{subprocess::PIPE}, + subprocess::error{subprocess::PIPE}, + subprocess::environment{environmentVariables} + ); std::vector pfds(2); auto* opfd = &pfds[0];