2 Commits

Author SHA1 Message Date
TheAssassin 6a952b57f9 Make custom AppRun files executable
This eliminates the need for users to make the files executable
before running linuxdeploy.
2019-06-28 21:40:14 +02:00
TheAssassin 8fbe191d7a Fix APPIMAGE_EXTRACT_AND_RUN support for plugins, mk. 1 2019-06-28 20:18:51 +02:00
2 changed files with 27 additions and 3 deletions
+15 -3
View File
@@ -11,6 +11,7 @@
// local headers
#include "linuxdeploy/core/log.h"
#include "linuxdeploy/util/util.h"
#pragma once
@@ -48,10 +49,16 @@ namespace linuxdeploy {
auto output = subprocess::check_output({pluginPath.c_str(), "--plugin-api-version"});
std::string stdoutOutput = output.buf.data();
// only interpret last line (fixes issues with --appimage-extract-and-run, where the runtime
// prints all the paths it extracts out to stdout)
const auto& lines = util::splitLines(stdoutOutput);
const auto& lastLine = lines.back();
try {
auto apiLevel = std::stoi(stdoutOutput);
return apiLevel;
const auto pluginApiLevel = std::stoi(lastLine);
return pluginApiLevel;
} catch (const std::invalid_argument&) {
ldLog() << LD_DEBUG << "Failed to understand plugin response:" << lastLine << std::endl;
return -1;
}
}
@@ -87,7 +94,12 @@ namespace linuxdeploy {
if (d->apiLevel != API_LEVEL) {
std::stringstream msg;
msg << "This class only supports API level " << API_LEVEL << ", not " << d->apiLevel;
if (d->apiLevel < 0) {
msg << "Could not read plugin API level";
} else {
msg << "This class only supports API level " << API_LEVEL << ", not " << d->apiLevel;
}
throw WrongApiLevelError(msg.str());
}
}
+12
View File
@@ -580,6 +580,16 @@ namespace linuxdeploy {
return false;
}
bool makeExecutable(const bf::path& path) {
try {
ldLog() << LD_DEBUG << "Making" << path << "executable" << std::endl;
bf::permissions(path, bf::add_perms | bf::owner_exe | bf::group_exe | bf::others_exe);
return true;
} catch (const bf::filesystem_error& e) {
ldLog() << LD_ERROR << "Could not set permissions for path" << path << LD_NO_SPACE << ":" << e.what() << std::endl;
}
}
};
AppDir::AppDir(const bf::path& path) {
@@ -764,6 +774,8 @@ namespace linuxdeploy {
if (!d->copyFile(customAppRunPath, path() / "AppRun"))
return false;
if (!d->makeExecutable(path() / "AppRun"))
return false;
} else {
// check if there is a custom AppRun already
// in that case, skip deployment of symlink