Skip to content

Commit a043b67

Browse files
committed
Make AppRun files executable if necessary
The main use case for this feature is custom AppRun scripts.
1 parent f2e2308 commit a043b67

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

src/core/appdir_root_setup.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ namespace linuxdeploy {
105105
}
106106

107107
bool deployStandardAppRunFromDesktopFile(const DesktopFile& desktopFile, const bf::path& customAppRunPath) const {
108+
const bf::path appRunPath(appDir.path() / "AppRun");
109+
108110
// check if there is a custom AppRun already
109111
// in that case, skip deployment of symlink
110-
if (bf::exists(appDir.path() / "AppRun")) {
112+
if (bf::exists(appRunPath)) {
111113
ldLog() << LD_WARNING << "Existing AppRun detected, skipping deployment of symlink" << std::endl;
112114
} else {
113115
// look for suitable binary to create AppRun symlink
@@ -138,7 +140,7 @@ namespace linuxdeploy {
138140
ldLog() << "Deploying AppRun symlink for executable in AppDir root:" << executablePath
139141
<< std::endl;
140142

141-
if (!appDir.createRelativeSymlink(executablePath, appDir.path() / "AppRun")) {
143+
if (!appDir.createRelativeSymlink(executablePath, appRunPath)) {
142144
ldLog() << LD_ERROR
143145
<< "Failed to create AppRun symlink for executable in AppDir root:"
144146
<< executablePath << std::endl;
@@ -156,6 +158,21 @@ namespace linuxdeploy {
156158
}
157159
}
158160

161+
if (!bf::exists(appRunPath)) {
162+
ldLog() << LD_ERROR << "AppRun deployment failed unexpectedly" << std::endl;
163+
return false;
164+
}
165+
166+
// as a convenience feature, we just make the deployed AppRun file executable, so the user won't be
167+
// surprised during runtime when they forgot to do so
168+
// this is done for custom AppRun files, too
169+
if (bf::is_symlink(appRunPath)) {
170+
ldLog() << LD_DEBUG << "Deployed AppRun is a symlink, not making executable" << std::endl;
171+
} else {
172+
ldLog() << LD_DEBUG << "Deployed AppRun is not a symlink, making executable" << std::endl;
173+
makeFileExecutable(appRunPath);
174+
}
175+
159176
return true;
160177
}
161178

0 commit comments

Comments
 (0)