Skip to content

Commit 43e23c8

Browse files
committed
feat(snap): support electron 2
1 parent 2154934 commit 43e23c8

File tree

14 files changed

+105
-33
lines changed

14 files changed

+105
-33
lines changed

.idea/dictionaries/develar.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.

docker/base/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ RUN curl -L https://yarnpkg.com/latest.tar.gz | tar xvz && mv yarn-* /yarn && ln
1010
# python for node-gyp
1111
# rpm is required for FPM to build rpm package
1212
# libsecret-1-0 and libgnome-keyring-dev are required even for prebuild keytar
13-
# libgtk2.0-dev for snap desktop-gtk2 (see https://github.com/ubuntu/snapcraft-desktop-helpers/blob/master/snapcraft.yaml#L248)
13+
# libgtk2.0-dev for snap desktop-gtk2 sudo (see https://github.com/ubuntu/snapcraft-desktop-helpers/blob/master/snapcraft.yaml#L248)
14+
# sudo for snapcraft (install build packages)
1415
apt-get -qq install --no-install-recommends git qtbase5-dev bsdtar build-essential autoconf libssl-dev gcc-multilib g++-multilib lzip rpm python libcurl3 git git-lfs ssh unzip \
1516
libsecret-1-dev libgnome-keyring-dev \
1617
libopenjp2-tools \

docker/build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ docker build -t electronuserland/builder:9 -t electronuserland/builder:latest -t
77

88
docker build -t electronuserland/builder:wine docker/wine
99
docker build -t electronuserland/builder:wine-mono docker/wine-mono
10-
docker build -t electronuserland/builder:wine-chrome docker/wine-chrome
10+
docker build -t electronuserland/builder:wine-chrome docker/wine-chrome
11+
12+
docker build -t electronuserland/snapcraft-electron:2 docker/snapcraft-electron2
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM snapcore/snapcraft:latest
2+
3+
# list from snapcraft message "Installing build dependencies"
4+
RUN apt-get -qq update && apt-get -qq install --no-install-recommends acl adwaita-icon-theme at-spi2-core colord colord-data dbus dconf-gsettings-backend dconf-service gir1.2-atspi-2.0 gir1.2-gtk-3.0 glib-networking glib-networking-common glib-networking-services gsettings-desktop-schemas hicolor-icon-theme humanity-icon-theme libatk-bridge2.0-0 libatk-bridge2.0-dev libatspi2.0-0 libatspi2.0-dev libcap-ng0 libcolord2 libcolorhug2 libcroco3 libdbus-1-dev libdconf1 libepoxy-dev libepoxy0 libexif12 libgd3 libgmp-dev libgmpxx4ldbl libgphoto2-6 libgphoto2-l10n libgphoto2-port12 libgtk-3-0 libgtk-3-bin libgtk-3-common libgtk-3-dev libgusb2 libieee1284-3 libjson-glib-1.0-0 libjson-glib-1.0-common libltdl7 libpam-systemd libpolkit-agent-1-0 libpolkit-backend-1-0 libpolkit-gobject-1-0 librest-0.7-0 librsvg2-2 librsvg2-common libsane libsane-common libsoup-gnome2.4-1 libsoup2.4-1 libusb-1.0-0 libvpx3 libxpm4 libxtst-dev libxtst6 nettle-dev policykit-1 ubuntu-mono x11proto-record-dev
5+

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
"////": "All typings are added into root `package.json` to avoid duplication errors in the IDE compiler (several `node.d.ts` files).",
3030
"dependencies": {
3131
"7zip-bin": "~3.1.0",
32-
"app-builder-bin": "1.4.1",
32+
"app-builder-bin": "1.5.0",
3333
"archiver": "^2.1.1",
3434
"async-exit-hook": "^2.0.1",
35-
"aws-sdk": "^2.201.0",
35+
"aws-sdk": "^2.202.0",
3636
"bluebird-lst": "^1.0.5",
3737
"chalk": "^2.3.0",
3838
"chromium-pickle-js": "^0.2.0",

packages/builder-util/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"out"
1212
],
1313
"dependencies": {
14-
"app-builder-bin": "1.4.1",
14+
"app-builder-bin": "1.5.0",
1515
"temp-file": "^3.1.1",
1616
"fs-extra-p": "^4.5.2",
1717
"is-ci": "^1.1.0",

packages/electron-builder-lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"homepage": "https://github.com/electron-userland/electron-builder",
4343
"dependencies": {
4444
"7zip-bin": "~3.1.0",
45-
"app-builder-bin": "1.4.1",
45+
"app-builder-bin": "1.5.0",
4646
"async-exit-hook": "^2.0.1",
4747
"bluebird-lst": "^1.0.5",
4848
"chromium-pickle-js": "^0.2.0",

packages/electron-builder-lib/src/linuxPackager.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Arch, AsyncTaskManager, log, executeAppBuilder } from "builder-util"
22
import { rename } from "fs-extra-p"
33
import * as path from "path"
44
import sanitizeFileName from "sanitize-filename"
5+
import * as semver from "semver"
56
import { AfterPackContext } from "./configuration"
67
import { DIR_TARGET, Platform, Target, TargetSpecificOptions } from "./core"
78
import { LinuxConfiguration } from "./options/linuxOptions"
@@ -24,6 +25,10 @@ export class LinuxPackager extends PlatformPackager<LinuxConfiguration> {
2425
this.executableName = executableName == null ? this.appInfo.sanitizedName.toLowerCase() : sanitizeFileName(executableName)
2526
}
2627

28+
get isElectron2(): boolean {
29+
return semver.gte(this.config.electronVersion || "1.8.3", "2.0.0-beta.1")
30+
}
31+
2732
get defaultTarget(): Array<string> {
2833
return ["snap", "appimage"]
2934
}
@@ -84,11 +89,14 @@ export class LinuxPackager extends PlatformPackager<LinuxConfiguration> {
8489
protected async postInitApp(packContext: AfterPackContext): Promise<void> {
8590
const executable = path.join(packContext.appOutDir, this.executableName)
8691
await rename(path.join(packContext.appOutDir, this.electronDistExecutableName), executable)
87-
try {
88-
await executeAppBuilder(["clear-exec-stack", "--input", executable])
89-
}
90-
catch (e) {
91-
log.debug({error: e}, "cannot clear exec stack")
92+
93+
if (!this.isElectron2) {
94+
try {
95+
await executeAppBuilder(["clear-exec-stack", "--input", executable])
96+
}
97+
catch (e) {
98+
log.debug({error: e}, "cannot clear exec stack")
99+
}
92100
}
93101
}
94102
}

packages/electron-builder-lib/src/targets/snap.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default class SnapTarget extends Target {
7373
app: {
7474
plugin: "nil",
7575
"stage-packages": this.replaceDefault(options.stagePackages, defaultStagePackages),
76-
after: this.replaceDefault(options.after, ["desktop-gtk2"]),
76+
after: this.replaceDefault(options.after, [this.packager.isElectron2 ? "desktop-gtk3" : "desktop-gtk2"]),
7777
}
7878
},
7979
}
@@ -129,7 +129,7 @@ export default class SnapTarget extends Target {
129129
"--stage", stageDir,
130130
"--arch", toLinuxArchString(arch),
131131
"--output", artifactPath,
132-
"--docker-image", "electronuserland/builder:latest",
132+
"--docker-image", this.packager.isElectron2 ? "electronuserland/snapcraft-electron:2" : "electronuserland/builder:latest",
133133
]
134134

135135
await this.helper.icons
@@ -163,7 +163,7 @@ export default class SnapTarget extends Target {
163163
}
164164

165165
if (this.isUseTemplateApp) {
166-
args.push("--template-url", "electron1")
166+
args.push("--template-url", this.packager.isElectron2 ? "electron2" : "electron1")
167167
}
168168
await executeAppBuilder(args)
169169
packager.dispatchArtifactCreated(artifactPath, this, arch)

packages/electron-publisher-s3/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"dependencies": {
1414
"fs-extra-p": "^4.5.2",
15-
"aws-sdk": "^2.201.0",
15+
"aws-sdk": "^2.202.0",
1616
"mime": "^2.2.0",
1717
"electron-publish": "~0.0.0-semantic-release",
1818
"builder-util": "^0.0.0-semantic-release",

0 commit comments

Comments
 (0)