Skip to content

Commit e7d4f76

Browse files
committed
fix(AppImage): AppImage should have arch in filename
Closes #594
1 parent fd1e7da commit e7d4f76

File tree

7 files changed

+23
-24
lines changed

7 files changed

+23
-24
lines changed

.idea/typescript-compiler.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Complete solution to package and build ready for distribution and "auto update"
1414
* [Windows](https://github.com/electron-userland/electron-builder/wiki/Options#WinBuildOptions-target): NSIS, Squirrel.Windows.
1515
* [Publishing artifacts to GitHub Releases](https://github.com/electron-userland/electron-builder/wiki/Publishing-Artifacts).
1616

17-
[electron-packager](https://github.com/electron-userland/electron-packager) and
1817
[appdmg](https://github.com/LinusU/node-appdmg) are used under the hood.
1918

2019
_Note: `appdmg` (and the platform specific `7zip-bin-*` packages) are `optionalDependencies`, which may require manual install if you have npm configured to [not install optional deps by default](https://docs.npmjs.com/misc/config#optional)._

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
"diff": "^2.2.3",
119119
"json8": "^0.9.0",
120120
"pre-git": "^3.10.0",
121-
"should": "^9.0.2",
121+
"should": "^10.0.0",
122122
"ts-babel": "^1.0.3",
123123
"tslint": "3.13.0",
124124
"typescript": "^2.1.0-dev.20160712",

src/platformPackager.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AppMetadata, DevMetadata, Platform, PlatformSpecificBuildOptions, Arch, archToString } from "./metadata"
1+
import { AppMetadata, DevMetadata, Platform, PlatformSpecificBuildOptions, Arch } from "./metadata"
22
import EventEmitter = NodeJS.EventEmitter
33
import { Promise as BluebirdPromise } from "bluebird"
44
import * as path from "path"
@@ -212,8 +212,8 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
212212

213213
await BluebirdPromise.all(promises)
214214
}
215-
await task(`Packaging for platform ${this.platform.name} ${archToString(arch)} using electron ${this.info.electronVersion} to ${path.relative(this.projectDir, appOutDir)}`,
216-
pack(options, appOutDir, platformName, archToString(arch), this.info.electronVersion))
215+
await task(`Packaging for platform ${this.platform.name} ${Arch[arch]} using electron ${this.info.electronVersion} to ${path.relative(this.projectDir, appOutDir)}`,
216+
pack(options, appOutDir, platformName, Arch[arch], this.info.electronVersion))
217217

218218
await this.doCopyExtraFiles(true, appOutDir, arch, platformSpecificBuildOptions)
219219
await this.doCopyExtraFiles(false, appOutDir, arch, platformSpecificBuildOptions)
@@ -375,16 +375,12 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
375375
return archiveApp(this.devMetadata.build.compression, format, outFile, this.platform === Platform.MAC ? path.join(appOutDir, `${this.appInfo.productFilename}.app`) : appOutDir)
376376
}
377377

378-
generateName(ext: string | null, arch: Arch, deployment: boolean): string {
379-
return this.generateName2(ext, arch === Arch.x64 ? null : Arch[arch], deployment)
380-
}
381-
382-
generateName1(ext: string | null, arch: Arch, classifier: string, deployment: boolean): string {
383-
let c = arch === Arch.x64 ? null : Arch[arch]
378+
generateName(ext: string | null, arch: Arch, deployment: boolean, classifier: string | null = null): string {
379+
let c = arch === Arch.x64 ? (ext === "AppImage" ? "x86_64" : null) : Arch[arch]
384380
if (c == null) {
385381
c = classifier
386382
}
387-
else {
383+
else if (classifier != null) {
388384
c += `-${classifier}`
389385
}
390386
return this.generateName2(ext, c, deployment)

src/targets/nsis.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { WinPackager } from "../winPackager"
2-
import { Arch, NsisOptions, archToString } from "../metadata"
2+
import { Arch, NsisOptions } from "../metadata"
33
import { debug, doSpawn, handleProcess } from "../util/util"
44
import * as path from "path"
55
import { Promise as BluebirdPromise } from "bluebird"
@@ -36,7 +36,7 @@ export default class NsisTarget extends Target {
3636

3737
async build(arch: Arch, appOutDir: string) {
3838
const packager = this.packager
39-
const archSuffix = archToString(arch)
39+
const archSuffix = Arch[arch]
4040
const archiveFile = path.join(this.outDir, `${packager.appInfo.name}-${packager.appInfo.version}-${archSuffix}.nsis.7z`)
4141
this.archs.set(arch, task(`Creating NSIS ${archSuffix} package`, archiveApp(packager.devMetadata.build.compression, "7z", archiveFile, appOutDir, true)))
4242
}

src/winPackager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ export class WinPackager extends PlatformPackager<WinBuildOptions> {
143143
const format = target.name
144144
log(`Creating Windows ${format}`)
145145
// we use app name here - see https://github.com/electron-userland/electron-builder/pull/204
146-
const outFile = path.join(outDir, this.generateName1(format, arch, "win", false))
146+
const outFile = path.join(outDir, this.generateName(format, arch, false, "win"))
147147
promises.push(this.archiveApp(format, appOutDir, outFile)
148-
.then(() => this.dispatchArtifactCreated(outFile, this.generateName1(format, arch, "win", true))))
148+
.then(() => this.dispatchArtifactCreated(outFile, this.generateName(format, arch, true, "win"))))
149149
}
150150
}
151151
}

test/src/helpers/packTester.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,25 +129,28 @@ async function packAndCheck(projectDir: string, packagerOptions: PackagerOptions
129129
}
130130

131131
async function checkLinuxResult(projectDir: string, packager: Packager, checkOptions: AssertPackOptions, artifacts: Array<ArtifactCreated>, arch: Arch, nameToTarget: Map<String, Target>) {
132+
const appInfo = packager.appInfo
133+
132134
function getExpected(): Array<string> {
133135
const result: Array<string> = []
134136
for (let target of nameToTarget.keys()) {
135-
result.push(`TestApp-${packager.appInfo.version}${target === "appimage" ? "" : `.${target}`}`)
137+
if (target === "appimage") {
138+
result.push(`${appInfo.productFilename}-${appInfo.version}-${arch === Arch.x64 ? "x86_64" : Arch[arch]}.AppImage`)
139+
}
140+
else {
141+
result.push(`TestApp-${appInfo.version}.${target}`)
142+
}
136143
}
137144
return result
138145
}
139146

140-
if (nameToTarget.has("appimage")) {
141-
return
142-
}
143-
144147
assertThat(getFileNames(artifacts)).containsAll(getExpected())
145148

146149
if (!nameToTarget.has("deb")) {
147150
return
148151
}
149152

150-
const productFilename = packager.appInfo.productFilename
153+
const productFilename = appInfo.productFilename
151154
const expectedContents = pathSorter(expectedLinuxContents.map(it => {
152155
if (it === "/opt/TestApp/TestApp") {
153156
return "/opt/" + productFilename + "/" + productFilename
@@ -163,10 +166,10 @@ async function checkLinuxResult(projectDir: string, packager: Packager, checkOpt
163166
// console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-amd64.deb", productName), null, 2))
164167
// console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb", productName), null, 2))
165168

166-
const packageFile = `${projectDir}/${outDirName}/TestApp-${packager.appInfo.version}.deb`
169+
const packageFile = `${projectDir}/${outDirName}/TestApp-${appInfo.version}.deb`
167170
assertThat(await getContents(packageFile)).isEqualTo(expectedContents)
168171
if (arch === Arch.ia32) {
169-
assertThat(await getContents(`${projectDir}/${outDirName}/TestApp-${packager.appInfo.version}-i386.deb`)).isEqualTo(expectedContents)
172+
assertThat(await getContents(`${projectDir}/${outDirName}/TestApp-${appInfo.version}-i386.deb`)).isEqualTo(expectedContents)
170173
}
171174

172175
assertThat2(parseDebControl(await exec("dpkg", ["--info", packageFile]))).has.properties({

0 commit comments

Comments
 (0)