Skip to content

Commit

Permalink
fix(AppImage): Binary not found in new AppImage support
Browse files Browse the repository at this point in the history
Close #2151
  • Loading branch information
develar committed Oct 4, 2017
1 parent 2fd6bf9 commit efe0793
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/electron-builder/src/targets/appImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { UUID } from "builder-util-runtime"
import { getBinFromGithub } from "builder-util/out/binDownload"
import { unlinkIfExists, copyOrLinkFile } from "builder-util/out/fs"
import * as ejs from "ejs"
import { emptyDir, readFile, remove, writeFile } from "fs-extra-p"
import { emptyDir, ensureDir, readFile, remove, writeFile } from "fs-extra-p"
import { Lazy } from "lazy-val"
import * as path from "path"
import { Target } from "../core"
Expand Down Expand Up @@ -45,7 +45,7 @@ export default class AppImageTarget extends Target {
const stageDir = path.join(this.outDir, `__appimage-${Arch[arch]}`)
const appInStageDir = path.join(stageDir, "app")
await emptyDir(stageDir)
await copyDirUsingHardLinks(appOutDir, appInStageDir)
await copyDirUsingHardLinks(appOutDir, appInStageDir, true)

const iconNames = await BluebirdPromise.map(this.helper.icons, it => {
let filename = `icon-${it.size}.png`
Expand Down Expand Up @@ -88,7 +88,7 @@ export default class AppImageTarget extends Target {
const vendorDir = await getBinFromGithub("appimage", "9.0.1", "mcme+7/krXSYb5C+6BpSt9qgajFYpn9dI1rjxzSW3YB5R/KrGYYrpZbVflEMG6pM7k9CL52poiOpGLBDG/jW3Q==")

if (arch === Arch.x64 || arch === Arch.ia32) {
await copyDirUsingHardLinks(path.join(vendorDir, "lib", arch === Arch.x64 ? "x86_64-linux-gnu" : "i386-linux-gnu"), path.join(stageDir, "usr/lib"))
await copyDirUsingHardLinks(path.join(vendorDir, "lib", arch === Arch.x64 ? "x86_64-linux-gnu" : "i386-linux-gnu"), path.join(stageDir, "usr/lib"), false)
}

if (this.packager.packagerOptions.effectiveOptionComputed != null && await this.packager.packagerOptions.effectiveOptionComputed({desktop: await this.desktopEntry.value})) {
Expand Down Expand Up @@ -119,13 +119,18 @@ export default class AppImageTarget extends Target {
}

// https://unix.stackexchange.com/questions/202430/how-to-copy-a-directory-recursively-using-hardlinks-for-each-file
function copyDirUsingHardLinks(source: string, destination: string) {
// pax and cp requires created dir
const promise = emptyDir(destination)
function copyDirUsingHardLinks(source: string, destination: string, useLink: boolean) {
if (process.platform !== "darwin") {
return promise.then(() => exec("cp", ["-d", "--recursive", "--preserve=mode", source, destination]))
const args = ["-d", "--recursive", "--preserve=mode"]
if (useLink) {
args.push("--link")
}
args.push(source + "/", destination + "/")
return ensureDir(path.dirname(destination)).then(() => exec("cp", args))
}

// pax requires created dir
const promise = ensureDir(destination)
return promise
.then(() => exec("pax", ["-rwl", "-p", "amp" /* Do not preserve file access times, Do not preserve file modification times, Preserve the file mode bits */, ".", destination], {
cwd: source,
Expand Down
1 change: 1 addition & 0 deletions test/src/helpers/runTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ async function runTests() {
args.push("PublishManagerTest", "ArtifactPublisherTest", "httpRequestTest", "RepoSlugTest")
args.push("macPackagerTest")
args.push("portableTest")
args.push("linuxPackagerTest")
}
else {
args.push("BuildTest")
Expand Down

0 comments on commit efe0793

Please sign in to comment.