Skip to content

Commit 66b1225

Browse files
committed
feat(snap): electron 5 support
Close #3872, Close #3923
1 parent 1d9d5ed commit 66b1225

File tree

33 files changed

+1441
-401
lines changed

33 files changed

+1441
-401
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.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# electron-builder [![npm version](https://img.shields.io/npm/v/electron-builder.svg?label=latest)](https://yarn.pm/electron-builder) [![downloads per month](https://img.shields.io/npm/dm/electron-builder.svg)](https://yarn.pm/electron-builder) [![donate](https://img.shields.io/badge/Donate-Donorbox-green.svg)](https://www.electron.build/donate)
2-
A complete solution to package and build a ready for distribution [Electron](https://electronjs.org), [Proton Native](https://proton-native.js.org/) or [Muon](https://github.com/brave/muon) app for macOS, Windows and Linux with “auto update” support out of the box.
2+
A complete solution to package and build a ready for distribution [Electron](https://electronjs.org), [Proton Native](https://proton-native.js.org/) app for macOS, Windows and Linux with “auto update” support out of the box.
33

44
See documentation on [electron.build](https://www.electron.build).
55

@@ -21,7 +21,7 @@ See documentation on [electron.build](https://www.electron.build).
2121
* Build and publish in parallel, using hard links on CI server to reduce IO and disk space usage.
2222
* [electron-compile](https://github.com/electron/electron-compile) support (compile for release-time on the fly on build).
2323
* [Docker](https://www.electron.build/multi-platform-build#docker) images to build Electron app for Linux or Windows on any platform.
24-
* [Proton Native](https://www.electron.build/configuration/configuration/#proton-native) and [Muon](https://github.com/brave/muon) support.
24+
* [Proton Native](https://www.electron.build/configuration/configuration/#proton-native) support.
2525
* Downloads all required tools files on demand automatically (e.g. to code sign windows application, to make AppX), no need to setup.
2626

2727
| Question | Answer |

docker/base/Dockerfile

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,12 @@ RUN apt-get -qq update && apt-get -qq dist-upgrade && \
1010
# python for node-gyp
1111
# rpm is required for FPM to build rpm package
1212
# libsecret-1-dev and libgnome-keyring-dev are required even for prebuild keytar
13-
# sudo for snapcraft (install build packages)
14-
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 \
13+
apt-get -qq install --no-install-recommends qtbase5-dev bsdtar build-essential autoconf libssl-dev gcc-multilib g++-multilib lzip rpm python libcurl3 git git-lfs ssh unzip \
1514
libsecret-1-dev libgnome-keyring-dev \
16-
libopenjp2-tools \
17-
# for snap desktop-gtk3 sudo (see https://github.com/ubuntu/snapcraft-desktop-helpers/blob/master/snapcraft.yaml#L189)
18-
libxkbcommon0 ttf-ubuntu-font-family dmz-cursor-theme light-themes adwaita-icon-theme gnome-themes-standard shared-mime-info libgtk-3-0 libgdk-pixbuf2.0-0 libglib2.0-bin libgtk-3-bin unity-gtk3-module libappindicator3-1 locales-all xdg-user-dirs ibus-gtk3 libibus-1.0-5 \
19-
# snap build packages
20-
apt-transport-https autotools-dev bsdmainutils debhelper dh-strip-nondeterminism file gettext gettext-base gir1.2-atk-1.0 gir1.2-atspi-2.0 gir1.2-freedesktop gir1.2-gdkpixbuf-2.0 gir1.2-gtk-3.0 gir1.2-pango-1.0 groff-base intltool-debian libarchive-zip-perl libasprintf-dev libasprintf0v5 libatk-bridge2.0-dev libatk1.0-dev libatspi2.0-dev libcairo-script-interpreter2 libcairo2-dev libdbus-1-dev libepoxy-dev libexpat1-dev libfile-stripnondeterminism-perl libfontconfig1-dev libfreetype6-dev libgdk-pixbuf2.0-dev libgettextpo-dev libgettextpo0 libgmp-dev libgmpxx4ldbl libgtk-3-dev libharfbuzz-dev libharfbuzz-gobject0 libharfbuzz-icu0 libice-dev libmail-sendmail-perl libpango1.0-dev libpangoxft-1.0-0 libpipeline1 libpixman-1-dev libpng12-dev libsm-dev libsys-hostname-long-perl libtimedate-perl libunistring0 libxcb-shm0-dev libxcomposite-dev libxcursor-dev libxft-dev libxft2 libxi-dev libxinerama-dev libxrandr-dev libxrender-dev libxtst-dev libxtst6 man-db nettle-dev po-debconf x11proto-composite-dev x11proto-randr-dev x11proto-record-dev x11proto-render-dev x11proto-xinerama-dev && \
15+
libopenjp2-tools && \
2116
# git-lfs
2217
git lfs install && \
23-
# snap
24-
apt-get -qq install --no-install-recommends jq squashfs-tools && \
25-
curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/core' | jq '.download_url' -r) --output core.snap && \
26-
mkdir -p /snap/core && unsquashfs -d /snap/core/current core.snap && rm core.snap && \
27-
curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/snapcraft?channel=edge' | jq '.download_url' -r) --output snapcraft.snap && \
28-
mkdir -p /snap/snapcraft && unsquashfs -d /snap/snapcraft/current snapcraft.snap && rm snapcraft.snap && \
29-
mkdir -p /snap/bin && \
30-
echo "#!/bin/sh" > /usr/bin/snapcraft && \
31-
echo 'exec $SNAP/usr/bin/python3 $SNAP/bin/snapcraft "$@"' >> /usr/bin/snapcraft && \
32-
chmod a+x /usr/bin/snapcraft && \
33-
apt-get -qq purge jq squashfs-tools && \
34-
rm -rf /var/lib/apt/lists/*
18+
apt-get purge -y --auto-remove && rm -rf /var/lib/apt/lists/*
3519

3620
COPY test.sh /test.sh
3721

@@ -47,9 +31,4 @@ ENV LC_ALL C.UTF-8
4731
ENV USE_UNZIP true
4832

4933
ENV DEBUG_COLORS true
50-
ENV FORCE_COLOR true
51-
52-
ENV SNAP=/snap/snapcraft/current
53-
ENV SNAP_ARCH=amd64
54-
ENV SNAP_NAME=snapcraft
55-
ENV SNAP_VERSION=edge
34+
ENV FORCE_COLOR true

docker/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -e
33

44
docker build -t electronuserland/builder:base -t electronuserland/builder:base-06.19 docker/base
55

6-
docker build -t electronuserland/builder:12 -t electronuserland/builder:latest -t electronuserland/builder:12-06.19 docker/12
6+
docker build -t electronuserland/builder:12 -t electronuserland/builder:latest -t electronuserland/builder:12-06.19 docker/node
77

88
docker build -t electronuserland/builder:wine docker/wine
99
docker build -t electronuserland/builder:wine-mono docker/wine-mono
File renamed without changes.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"@types/debug": "^4.1.4",
3535
"@types/is-ci": "^2.0.0",
3636
"@types/semver": "^6.0.0",
37-
"app-builder-bin": "2.6.7",
37+
"app-builder-bin": "2.6.11",
3838
"archiver": "^3.0.0",
3939
"async-exit-hook": "^2.0.1",
4040
"bluebird-lst": "^1.0.9",
@@ -92,7 +92,7 @@
9292
"@babel/preset-react": "^7.0.0",
9393
"@types/ejs": "^2.6.3",
9494
"@types/ini": "^1.3.30",
95-
"@types/jest": "^24.0.13",
95+
"@types/jest": "^24.0.14",
9696
"@types/js-yaml": "^3.12.1",
9797
"@types/lodash.isequal": "^4.5.5",
9898
"@types/node-emoji": "^1.8.1",
@@ -117,7 +117,7 @@
117117
"ts-babel": "6.1.4",
118118
"ts-jsdoc": "^3.0.1",
119119
"tslint": "^5.17.0",
120-
"typescript": "~3.5.1",
120+
"typescript": "~3.5.2",
121121
"whitespace": "^2.1.0",
122122
"worker-farm": "^1.7.0"
123123
},

packages/app-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": "~4.1.0",
45-
"app-builder-bin": "2.6.7",
45+
"app-builder-bin": "2.6.11",
4646
"async-exit-hook": "^2.0.1",
4747
"bluebird-lst": "^1.0.9",
4848
"chromium-pickle-js": "^0.2.0",

packages/app-builder-lib/src/Framework.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ export interface PrepareApplicationStageDirectoryOptions {
5050
}
5151

5252
export function isElectronBased(framework: Framework) {
53-
return framework.name === "electron" || framework.name === "muon"
53+
return framework.name === "electron"
5454
}

packages/app-builder-lib/src/configuration.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,6 @@ export interface Configuration extends PlatformSpecificBuildOptions {
162162
*/
163163
readonly ?: boolean
164164

165-
/**
166-
* The version of muon you are packaging for.
167-
*/
168-
readonly muonVersion?: string | null
169-
170165
/**
171166
* *libui-based frameworks only* The version of NodeJS you are packaging for.
172167
* You can set it to `current` to set the Node.js version that you use to run.

packages/app-builder-lib/src/electron/ElectronFramework.ts

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { CONCURRENCY, copyDir, DO_NOT_USE_HARD_LINKS, statOrNull, unlinkIfExists
44
import { emptyDir, readdir, remove, rename } from "fs-extra-p"
55
import { Lazy } from "lazy-val"
66
import * as path from "path"
7-
import * as semver from "semver"
87
import { Configuration } from "../configuration"
98
import { BeforeCopyExtraFilesOptions, Framework, PrepareApplicationStageDirectoryOptions } from "../Framework"
109
import { ElectronPlatformName, Packager, Platform } from "../index"
@@ -52,22 +51,13 @@ function createDownloadOpts(opts: Configuration, platform: ElectronPlatformName,
5251
}
5352
}
5453

55-
async function beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions, isClearExecStack: boolean) {
54+
async function beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {
5655
const packager = options.packager
5756
const appOutDir = options.appOutDir
5857
if (packager.platform === Platform.LINUX) {
5958
const linuxPackager = (packager as LinuxPackager)
6059
const executable = path.join(appOutDir, linuxPackager.executableName)
6160
await rename(path.join(appOutDir, packager.electronDistExecutableName), executable)
62-
63-
if (isClearExecStack) {
64-
try {
65-
await executeAppBuilder(["clear-exec-stack", "--input", executable])
66-
}
67-
catch (e) {
68-
log.debug({error: e}, "cannot clear exec stack")
69-
}
70-
}
7161
}
7262
else if (packager.platform === Platform.WINDOWS) {
7363
const executable = path.join(appOutDir, `${packager.appInfo.productFilename}.exe`)
@@ -126,30 +116,11 @@ class ElectronFramework implements Framework {
126116
}
127117

128118
beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {
129-
return beforeCopyExtraFiles(options, this.name === "electron" && semver.lte(this.version || "1.8.3", "1.8.3"))
130-
}
131-
}
132-
133-
class MuonFramework extends ElectronFramework {
134-
constructor(version: string) {
135-
super("muon", version, "Brave.app")
136-
}
137-
138-
prepareApplicationStageDirectory(options: PrepareApplicationStageDirectoryOptions) {
139-
return unpack(options, {
140-
mirror: "https://github.com/brave/muon/releases/download/v",
141-
customFilename: `brave-v${options.version}-${options.platformName}-${options.arch}.zip`,
142-
isVerifyChecksum: false,
143-
...createDownloadOpts(options.packager.config, options.platformName, options.arch, options.version),
144-
}, this.distMacOsAppName)
119+
return beforeCopyExtraFiles(options)
145120
}
146121
}
147122

148123
export async function createElectronFrameworkSupport(configuration: Configuration, packager: Packager): Promise<Framework> {
149-
if (configuration.muonVersion != null) {
150-
return new MuonFramework(configuration.muonVersion!!)
151-
}
152-
153124
let version = configuration.electronVersion
154125
if (version == null) {
155126
// for prepacked app asar no dev deps in the app.asar

0 commit comments

Comments
 (0)