Skip to content

Commit

Permalink
fix(AppImage): AppImage should have arch in filename
Browse files Browse the repository at this point in the history
Closes #594
  • Loading branch information
develar committed Jul 19, 2016
1 parent fd1e7da commit e7d4f76
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 24 deletions.
1 change: 1 addition & 0 deletions .idea/typescript-compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

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

_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)._
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"diff": "^2.2.3",
"json8": "^0.9.0",
"pre-git": "^3.10.0",
"should": "^9.0.2",
"should": "^10.0.0",
"ts-babel": "^1.0.3",
"tslint": "3.13.0",
"typescript": "^2.1.0-dev.20160712",
Expand Down
16 changes: 6 additions & 10 deletions src/platformPackager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppMetadata, DevMetadata, Platform, PlatformSpecificBuildOptions, Arch, archToString } from "./metadata"
import { AppMetadata, DevMetadata, Platform, PlatformSpecificBuildOptions, Arch } from "./metadata"
import EventEmitter = NodeJS.EventEmitter
import { Promise as BluebirdPromise } from "bluebird"
import * as path from "path"
Expand Down Expand Up @@ -212,8 +212,8 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>

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

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

generateName(ext: string | null, arch: Arch, deployment: boolean): string {
return this.generateName2(ext, arch === Arch.x64 ? null : Arch[arch], deployment)
}

generateName1(ext: string | null, arch: Arch, classifier: string, deployment: boolean): string {
let c = arch === Arch.x64 ? null : Arch[arch]
generateName(ext: string | null, arch: Arch, deployment: boolean, classifier: string | null = null): string {
let c = arch === Arch.x64 ? (ext === "AppImage" ? "x86_64" : null) : Arch[arch]
if (c == null) {
c = classifier
}
else {
else if (classifier != null) {
c += `-${classifier}`
}
return this.generateName2(ext, c, deployment)
Expand Down
4 changes: 2 additions & 2 deletions src/targets/nsis.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { WinPackager } from "../winPackager"
import { Arch, NsisOptions, archToString } from "../metadata"
import { Arch, NsisOptions } from "../metadata"
import { debug, doSpawn, handleProcess } from "../util/util"
import * as path from "path"
import { Promise as BluebirdPromise } from "bluebird"
Expand Down Expand Up @@ -36,7 +36,7 @@ export default class NsisTarget extends Target {

async build(arch: Arch, appOutDir: string) {
const packager = this.packager
const archSuffix = archToString(arch)
const archSuffix = Arch[arch]
const archiveFile = path.join(this.outDir, `${packager.appInfo.name}-${packager.appInfo.version}-${archSuffix}.nsis.7z`)
this.archs.set(arch, task(`Creating NSIS ${archSuffix} package`, archiveApp(packager.devMetadata.build.compression, "7z", archiveFile, appOutDir, true)))
}
Expand Down
4 changes: 2 additions & 2 deletions src/winPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ export class WinPackager extends PlatformPackager<WinBuildOptions> {
const format = target.name
log(`Creating Windows ${format}`)
// we use app name here - see https://github.com/electron-userland/electron-builder/pull/204
const outFile = path.join(outDir, this.generateName1(format, arch, "win", false))
const outFile = path.join(outDir, this.generateName(format, arch, false, "win"))
promises.push(this.archiveApp(format, appOutDir, outFile)
.then(() => this.dispatchArtifactCreated(outFile, this.generateName1(format, arch, "win", true))))
.then(() => this.dispatchArtifactCreated(outFile, this.generateName(format, arch, true, "win"))))
}
}
}
Expand Down
19 changes: 11 additions & 8 deletions test/src/helpers/packTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,25 +129,28 @@ async function packAndCheck(projectDir: string, packagerOptions: PackagerOptions
}

async function checkLinuxResult(projectDir: string, packager: Packager, checkOptions: AssertPackOptions, artifacts: Array<ArtifactCreated>, arch: Arch, nameToTarget: Map<String, Target>) {
const appInfo = packager.appInfo

function getExpected(): Array<string> {
const result: Array<string> = []
for (let target of nameToTarget.keys()) {
result.push(`TestApp-${packager.appInfo.version}${target === "appimage" ? "" : `.${target}`}`)
if (target === "appimage") {
result.push(`${appInfo.productFilename}-${appInfo.version}-${arch === Arch.x64 ? "x86_64" : Arch[arch]}.AppImage`)
}
else {
result.push(`TestApp-${appInfo.version}.${target}`)
}
}
return result
}

if (nameToTarget.has("appimage")) {
return
}

assertThat(getFileNames(artifacts)).containsAll(getExpected())

if (!nameToTarget.has("deb")) {
return
}

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

const packageFile = `${projectDir}/${outDirName}/TestApp-${packager.appInfo.version}.deb`
const packageFile = `${projectDir}/${outDirName}/TestApp-${appInfo.version}.deb`
assertThat(await getContents(packageFile)).isEqualTo(expectedContents)
if (arch === Arch.ia32) {
assertThat(await getContents(`${projectDir}/${outDirName}/TestApp-${packager.appInfo.version}-i386.deb`)).isEqualTo(expectedContents)
assertThat(await getContents(`${projectDir}/${outDirName}/TestApp-${appInfo.version}-i386.deb`)).isEqualTo(expectedContents)
}

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

0 comments on commit e7d4f76

Please sign in to comment.