Skip to content

Commit 34a6358

Browse files
committed
fix(linux): run the staged executable of release builds
1 parent 41369c9 commit 34a6358

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

‎lib/common/mobile/linux/linux-application-manager.ts‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,19 @@ export class LinuxApplicationManager extends ApplicationManagerBase {
4444
});
4545
}
4646

47-
/** `packageFilePath` is the executable in the build output. */
47+
/** `packageFilePath` is the executable (debug) or the `.tar.gz` (release) in the build output. */
4848
public async installApplication(
4949
packageFilePath: string,
5050
appIdentifier?: string,
5151
_buildData?: IBuildData,
5252
): Promise<void> {
53-
fs.chmodSync(packageFilePath, 0o755);
54-
this._executables[path.basename(packageFilePath)] = packageFilePath;
53+
const executable = LinuxApplicationManager.executableIn(packageFilePath);
54+
fs.chmodSync(executable, 0o755);
55+
this._executables[path.basename(executable)] = executable;
5556
if (appIdentifier) {
56-
this._executables[appIdentifier] = packageFilePath;
57+
this._executables[appIdentifier] = executable;
5758
try {
58-
installDebugDesktopEntry(path.dirname(packageFilePath), appIdentifier);
59+
installDebugDesktopEntry(path.dirname(executable), appIdentifier);
5960
} catch (e) {
6061
this.$logger.warn(
6162
`Couldn't register ${appIdentifier} with the desktop: ${e?.message ?? e}`,
@@ -64,6 +65,14 @@ export class LinuxApplicationManager extends ApplicationManagerBase {
6465
}
6566
}
6667

68+
/** Release archives are packed from the staged `<name>/<name>`. */
69+
private static executableIn(packageFilePath: string): string {
70+
const archive = path.basename(packageFilePath).match(/^(.+)\.tar\.gz$/);
71+
return archive
72+
? path.join(path.dirname(packageFilePath), archive[1], archive[1])
73+
: packageFilePath;
74+
}
75+
6776
public async uninstallApplication(appIdentifier: string): Promise<void> {
6877
delete this._executables[appIdentifier];
6978
}

‎test/services/linux-application-manager.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ describe.runIf(isLinux)("LinuxApplicationManager", () => {
8989
await waitFor(() => lines.includes("synced"));
9090
});
9191

92+
it("runs the staged executable of a release archive", async () => {
93+
const staged = path.join(dir, "demo");
94+
fs.mkdirSync(staged);
95+
fs.writeFileSync(path.join(staged, "demo"), "#!/bin/sh\necho release\n");
96+
const archive = path.join(dir, "demo.tar.gz");
97+
fs.writeFileSync(archive, "not a script");
98+
await manager.installApplication(archive, "org.demo");
99+
assert.equal(fs.statSync(archive).mode & 0o111, 0);
100+
await manager.startApplication(<any>{
101+
appId: "org.demo",
102+
projectName: "demo",
103+
});
104+
await waitFor(() => lines.includes("release"));
105+
});
106+
92107
it("fails to start an app that wasn't built", async () => {
93108
let error: Error;
94109
try {

0 commit comments

Comments
 (0)