Skip to content

Commit 9a69286

Browse files
committed
fix: AppImage desktop icons
1 parent a9afdd4 commit 9a69286

File tree

16 files changed

+120
-281
lines changed

16 files changed

+120
-281
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ dist/
1111
/typings/browser.d.ts
1212
/typings/main.d.ts
1313
.DS_Store
14-
.idea/shelf/
14+
.idea/shelf/
15+
test/typings/electron-builder.d.ts

.idea/bashsupport_project.xml

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

.idea/codeStyleSettings.xml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Complete solution to package and build ready for distribution and "auto update"
1010
* Numerous target formats:
1111
* All platforms: `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`.
1212
* [MacOS](https://github.com/electron-userland/electron-builder/wiki/Options#MacOptions-target): `dmg`, `mas`.
13-
* [Linux](https://github.com/electron-userland/electron-builder/wiki/Options#LinuxBuildOptions-target): `deb`, `rpm`, `freebsd`, `pacman`, `p5p`, `apk`.
13+
* [Linux](https://github.com/electron-userland/electron-builder/wiki/Options#LinuxBuildOptions-target): `AppImage`, `deb`, `rpm`, `freebsd`, `pacman`, `p5p`, `apk`.
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

docs/Options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ Linux specific build options.
140140
| Name | Description
141141
| --- | ---
142142
| description | <a name="LinuxBuildOptions-description"></a>As [description](#AppMetadata-description) from application package.json, but allows you to specify different for Linux.
143+
| target | <a name="LinuxBuildOptions-target"></a><p>Target package type: list of <code>AppImage</code>, <code>deb</code>, <code>rpm</code>, <code>freebsd</code>, <code>pacman</code>, <code>p5p</code>, <code>apk</code>, <code>7z</code>, <code>zip</code>, <code>tar.xz</code>, <code>tar.lz</code>, <code>tar.gz</code>, <code>tar.bz2</code>. Defaults to <code>deb</code>.</p> <p>The most effective [xz](https://en.wikipedia.org/wiki/Xz) compression format used by default.</p> <p>Only <code>deb</code> and <code>AppImage</code> is tested. Feel free to file issues for <code>rpm</code> and other package formats.</p>
143144
| synopsis | <a name="LinuxBuildOptions-synopsis"></a>*deb-only.* The [short description](https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description).
144145
| maintainer | <a name="LinuxBuildOptions-maintainer"></a>The maintainer. Defaults to [author](#AppMetadata-author).
145146
| vendor | <a name="LinuxBuildOptions-vendor"></a>The vendor. Defaults to [author](#AppMetadata-author).
146147
| compression | <a name="LinuxBuildOptions-compression"></a>*deb-only.* The compression type, one of `gz`, `bzip2`, `xz`. Defaults to `xz`.
147148
| depends | <a name="LinuxBuildOptions-depends"></a>Package dependencies. Defaults to `["libappindicator1", "libnotify-bin"]`.
148-
| target | <a name="LinuxBuildOptions-target"></a><p>Target package type: list of <code>deb</code>, <code>rpm</code>, <code>freebsd</code>, <code>pacman</code>, <code>p5p</code>, <code>apk</code>, <code>7z</code>, <code>zip</code>, <code>tar.xz</code>, <code>tar.lz</code>, <code>tar.gz</code>, <code>tar.bz2</code>. Defaults to <code>deb</code>.</p> <p>The most effective [xz](https://en.wikipedia.org/wiki/Xz) compression format used by default.</p> <p>Only <code>deb</code> is tested. Feel free to file issues for <code>rpm</code> and other package formats.</p>
149149

150150
<a name="MetadataDirectories"></a>
151151
## `.directories`

package.json

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
},
1616
"scripts": {
1717
"compile": "npm run compile-production && npm run compile-test",
18-
"compile-production": "tsconfig -i 2 && ts-babel",
19-
"compile-test": "tsconfig -i 2 test && ts-babel test",
18+
"compile-production": "ts-babel",
19+
"compile-test": "ts-babel test",
2020
"lint": "tslint src/*.ts test/src/*.ts",
2121
"pretest": "npm run compile && npm run lint",
2222
"test": "node ./test/out/helpers/runTests.js",
@@ -83,7 +83,7 @@
8383
"semver": "^5.2.0",
8484
"signcode-tf": "~0.7.3",
8585
"source-map-support": "^0.4.1",
86-
"typescript": "^2.0.0-dev.20160630",
86+
"typescript": "2.0.0-dev.20160705",
8787
"update-notifier": "^1.0.2",
8888
"uuid-1345": "^0.99.6",
8989
"yargs": "^4.7.1"
@@ -100,11 +100,11 @@
100100
]
101101
},
102102
"devDependencies": {
103-
"@types/debug": "0.0.22-alpha",
104-
"@types/mime": "0.0.25-alpha",
105-
"@types/progress": "^1.1.24-alpha",
106-
"@types/semver": "^4.3.23-alpha",
107-
"@types/source-map-support": "^0.2.24-alpha",
103+
"@types/debug": "0.0.26-alpha",
104+
"@types/mime": "0.0.26-alpha",
105+
"@types/progress": "^1.1.25-alpha",
106+
"@types/semver": "^4.3.24-alpha",
107+
"@types/source-map-support": "^0.2.25-alpha",
108108
"ava-tf": "^0.15.3",
109109
"babel-plugin-array-includes": "^2.0.3",
110110
"babel-plugin-transform-es2015-destructuring": "^6.9.0",
@@ -119,8 +119,7 @@
119119
"semantic-release": "^6.3.0",
120120
"should": "^9.0.2",
121121
"ts-babel": "^1.0.3",
122-
"tsconfig-glob": "^0.4.3",
123-
"tslint": "3.12.0-dev.1",
122+
"tslint": "3.13.0",
124123
"typescript": "2.0.0-dev.20160620-1.0",
125124
"whitespace": "^2.0.0"
126125
},
@@ -139,8 +138,5 @@
139138
"test/out/*.js"
140139
]
141140
},
142-
"typings": "./out/electron-builder.d.ts",
143-
"publishConfig": {
144-
"tag": "next"
145-
}
141+
"typings": "./out/electron-builder.d.ts"
146142
}

src/builder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ export function normalizeOptions(args: CliOptions): BuildOptions {
164164
delete r.w
165165
delete r.windows
166166
delete r.osx
167+
delete r.macos
167168
delete r["$0"]
168169
delete r._
169170
delete r.version

src/metadata.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ export interface BuildMetadata {
178178
*/
179179
readonly linux?: LinuxBuildOptions | null
180180

181+
readonly deb?: LinuxBuildOptions | null
182+
181183
/*
182184
The compression level, one of `store`, `normal`, `maximum` (default: `normal`). If you want to rapidly test build, `store` can reduce build time significantly.
183185
*/
@@ -391,6 +393,15 @@ export interface LinuxBuildOptions extends PlatformSpecificBuildOptions {
391393
*/
392394
readonly description?: string | null
393395

396+
/*
397+
Target package type: list of `AppImage`, `deb`, `rpm`, `freebsd`, `pacman`, `p5p`, `apk`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`. Defaults to `deb`.
398+
399+
The most effective [xz](https://en.wikipedia.org/wiki/Xz) compression format used by default.
400+
401+
Only `deb` and `AppImage` is tested. Feel free to file issues for `rpm` and other package formats.
402+
*/
403+
readonly target?: Array<string> | null
404+
394405
/*
395406
*deb-only.* The [short description](https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description).
396407
*/
@@ -424,15 +435,6 @@ export interface LinuxBuildOptions extends PlatformSpecificBuildOptions {
424435
Package dependencies. Defaults to `["libappindicator1", "libnotify-bin"]`.
425436
*/
426437
readonly depends?: string[] | null
427-
428-
/*
429-
Target package type: list of `deb`, `rpm`, `freebsd`, `pacman`, `p5p`, `apk`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`. Defaults to `deb`.
430-
431-
The most effective [xz](https://en.wikipedia.org/wiki/Xz) compression format used by default.
432-
433-
Only `deb` is tested. Feel free to file issues for `rpm` and other package formats.
434-
*/
435-
readonly target?: Array<string> | null
436438
}
437439

438440
/*

src/targets/LinuxTargetHelper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class LinuxTargetHelper {
6464
}
6565
}
6666

67-
async computeDesktopEntry(exec?: string): Promise<string> {
67+
async computeDesktopEntry(exec?: string, extra?: string): Promise<string> {
6868
const appInfo = this.packager.appInfo
6969

7070
const custom = this.packager.platformSpecificBuildOptions.desktop
@@ -81,7 +81,7 @@ Exec=${(exec == null ? `"${installPrefix}/${productFilename}/${productFilename}"
8181
Terminal=false
8282
Type=Application
8383
Icon=${appInfo.name}
84-
`)
84+
${extra == null ? "" : `${extra}\n`}`)
8585
return tempFile
8686
}
8787

src/targets/appImage.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@ import { Promise as BluebirdPromise } from "bluebird"
1111
const __awaiter = require("../util/awaiter")
1212

1313
const appImageVersion = "AppImage-5"
14+
//noinspection SpellCheckingInspection
1415
const appImagePathPromise = getBin("AppImage", appImageVersion, `https://dl.bintray.com/electron-userland/bin/${appImageVersion}.7z`, "19833e5db3cbc546432de8ddc8a54181489e6faad4944bd1f3138adf4b771259")
1516

1617
export default class AppImageTarget extends TargetEx {
18+
private readonly desktopEntry: Promise<string>
19+
1720
constructor(private packager: PlatformPackager<LinuxBuildOptions>, private helper: LinuxTargetHelper, private outDir: string) {
1821
super("appImage")
22+
23+
this.desktopEntry = helper.computeDesktopEntry("AppRun", `X-AppImage-Version=${packager.appInfo.buildVersion}`)
1924
}
2025

2126
async build(appOutDir: string, arch: Arch): Promise<any> {
@@ -33,6 +38,7 @@ export default class AppImageTarget extends TargetEx {
3338
"-padding", "0",
3439
"-map", appOutDir, "/usr/bin",
3540
"-map", path.join(__dirname, "..", "..", "templates", "linux", "AppRun.sh"), `/AppRun`,
41+
"-map", await this.desktopEntry, `/${appInfo.name}.desktop`,
3642
"-move", `/usr/bin/${appInfo.productFilename}`, "/usr/bin/app",
3743
]
3844
for (let [from, to] of (await this.helper.icons)) {
@@ -50,17 +56,17 @@ export default class AppImageTarget extends TargetEx {
5056

5157
await exec(process.platform === "darwin" ? path.join(appImagePath, "xorriso") : "xorriso", args)
5258

59+
await new BluebirdPromise((resolve, reject) => {
60+
const rd = createReadStream(path.join(appImagePath, arch === Arch.ia32 ? "32" : "64", "runtime"))
61+
rd.on("error", reject)
62+
const wr = createWriteStream(image)
63+
wr.on("error", reject)
64+
wr.on("finish", resolve)
65+
rd.pipe(wr)
66+
})
67+
5368
const fd = await open(image, "r+")
5469
try {
55-
await new BluebirdPromise((resolve, reject) => {
56-
const rd = createReadStream(path.join(appImagePath, arch === Arch.ia32 ? "32" : "64", "runtime"))
57-
rd.on("error", reject)
58-
const wr = createWriteStream(image, <any>{fd: fd, autoClose: false})
59-
wr.on("error", reject)
60-
wr.on("finish", resolve)
61-
rd.pipe(wr)
62-
})
63-
6470
const magicData = new Buffer([0x41, 0x49, 0x01])
6571
await write(fd, magicData, 0, magicData.length, 8)
6672
}
@@ -72,7 +78,7 @@ export default class AppImageTarget extends TargetEx {
7278
// we archive because you cannot distribute exe as is - e.g. Ubuntu clear exec flag and user cannot just click on AppImage to run
7379
// also, LZMA compression - 29MB vs zip 42MB
7480
// we use slow xz instead of 7za because 7za doesn't preserve exec file permissions for xz
75-
await spawn("xz", ["--compress", "--force", image], {
81+
await spawn("xz", ["--x86", "--lzma2", "--compress", "--force", packager.devMetadata.build.compression === "store" ? "-0" : "-9e", image], {
7682
cwd: path.dirname(image),
7783
stdio: ["ignore", debug.enabled ? "inherit" : "ignore", "inherit"],
7884
})

0 commit comments

Comments
 (0)