Skip to content

Commit

Permalink
feat(mac): upgrade osslsigncode, do not require wine
Browse files Browse the repository at this point in the history
Close #1713, Close #1707
  • Loading branch information
develar committed Jun 20, 2017
1 parent 239d16d commit ed662e8
Show file tree
Hide file tree
Showing 56 changed files with 415 additions and 374 deletions.
3 changes: 3 additions & 0 deletions .idea/dictionaries/develar.xml

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

37 changes: 12 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,34 @@
osx_image: xcode8.3
language: node_js

matrix:
include:
- os: osx
env: TEST_FILES=BuildTest,extraMetadataTest,globTest,filesTest,ignoreTest,linux.*,windows.* NODE_VERSION=6 PUBLISH_TO_NPM=true
env: TEST_FILES=BuildTest,extraMetadataTest,globTest,filesTest,ignoreTest,linux.*,windows.*
# env: TEST_FILES=oneClickInstallerTest.*
node_js: "8"

- os: osx
env: TEST_FILES=mac.* NODE_VERSION=8
env: TEST_FILES=mac.*
node_js: "8"

- os: osx
env: TEST_FILES=mac.* NODE_VERSION=6

language: c
env: TEST_FILES=mac.*
node_js: "6"

cache:
yarn: true
directories:
- node_modules
- $HOME/Library/Caches/electron
- $HOME/Library/Caches/electron-builder
- /tmp/jest-electron-builder-tests

before_install:
- curl -L https://dl.bintray.com/develar/bin/7za -o /tmp/7za
- chmod +x /tmp/7za
- curl -L https://dl.bintray.com/develar/bin/wine-2.0.7z -o /tmp/wine.7z
- /tmp/7za x -o/usr/local/Cellar -y /tmp/wine.7z
- brew link --overwrite gnutls libtasn1 libusb libusb-compat nettle openssl wine git-lfs gnu-tar dpkg xz
- git-lfs pull

# fontconfig jasper libgphoto2 libicns little-cms2 sane-backends webp gd

install:
- nvm install $NODE_VERSION
- nvm use --delete-prefix $NODE_VERSION
- ln -sf $PWD/test/vendor/yarn.js /usr/local/bin/yarn
- yarn --link-duplicates --pure-lockfile
- if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" && "$AUTO_PUBLISH" != "false" && "$TRAVIS_TAG" == "" && "$PUBLISH_TO_NPM" == "true" ]]; then yarn add @develar/semantic-release@next --dev ; fi
- mkdir -p /tmp/git-lfs && curl -L https://github.com/github/git-lfs/releases/download/v2.1.1/git-lfs-$([ "$TRAVIS_OS_NAME" == "linux" ] && echo "linux" || echo "darwin")-amd64-2.1.1.tar.gz | tar -xz -C /tmp/git-lfs --strip-components 1 && /tmp/git-lfs/git-lfs pull
- yarn

script:
- yarn test

after_success:
- if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" && "$AUTO_PUBLISH" != "false" && "$TRAVIS_TAG" == "" && "$PUBLISH_TO_NPM" == "true" ]]; then npm run semantic-release ; fi
- yarn test

branches:
except:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ _Note: Platform specific `7zip-bin-*` packages are `optionalDependencies`, which
```
Then you can run `npm run dist` (to package in a distributable format (e.g. dmg, windows installer, deb package)) or `npm run pack` (only generates the package directory without really packaging it. This is useful for testing purposes).

To ensure your native dependencies are always matched electron version, simply add `"postinstall": "install-app-deps"` to your `package.json`.
To ensure your native dependencies are always matched electron version, simply add script `"postinstall": "electron-builder install-app-deps"` to your `package.json`.

5. If you have native addons of your own that are part of the application (not as a dependency), add `"nodeGypRebuild": true` to the `build` section of your development `package.json`.
:bulb: Don't [use](https://github.com/electron-userland/electron-builder/issues/683#issuecomment-241214075) [npm](http://electron.atom.io/docs/tutorial/using-native-node-modules/#using-npm) (neither `.npmrc`) for configuring electron headers. Use [node-gyp-rebuild](https://github.com/electron-userland/electron-builder/issues/683#issuecomment-241488783) bin instead.
Expand Down
1 change: 0 additions & 1 deletion docker/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ FROM buildpack-deps:zesty-curl

# rpm is required for FPM to build rpm package
# yasm is required to build p7zip
# osslsigncode to sign windows on Linux

# install modern multi-thread xz
# ldconfig - see 4.6. liblzma.so (or similar) not found when running xz
Expand Down
1 change: 0 additions & 1 deletion docs/Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@
**Programmatic API**

* [[electron-builder]]
* [[electron-builder-util]]
* [[electron-publish]]
15 changes: 2 additions & 13 deletions docs/Multi Platform Build.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,9 @@ You don't need to clean dist output before build — output directory is cleaned

## macOS

Use [brew](http://brew.sh) to install required packages.
All required system dependencies (except rpm) will be downloaded automatically on demand on macOS 10.12+ (macOS Sierra). On Travis, please add `osx_image: xcode8.3`

### To build app for Windows on macOS:
```
brew install wine --without-x11
brew install mono
```

### To build app for Linux on macOS:
```
brew install gnu-tar xz
```

To build rpm: `brew install rpm`.
To build rpm: `brew install rpm` ([brew](https://brew.sh)).

## Linux

Expand Down
1 change: 0 additions & 1 deletion docs/_Sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@
**Programmatic API**

* [[electron-builder]]
* [[electron-builder-util]]
* [[electron-publish]]
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"compile": "ts-babel packages/asar-integrity packages/electron-builder-http packages/electron-builder-util packages/electron-publish packages/electron-builder packages/electron-builder-squirrel-windows packages/electron-updater packages/electron-publisher-s3 test && node ./test/vendor/yarn.js schema",
"lint": "node test/out/helpers/lint.js",
"lint-deps": "node ./test/out/helpers/checkDeps.js",
"pretest": "node ./test/vendor/yarn.js compile && concurrently \"node test/out/helpers/lint.js\" \"node ./test/out/helpers/checkDeps.js\"",
"pretest": "node ./test/vendor/yarn.js compile && node test/out/helpers/lint.js && node ./test/out/helpers/checkDeps.js",
"///": "Please see https://github.com/electron-userland/electron-builder/blob/master/CONTRIBUTING.md#run-test-using-cli how to run particular test instead full (and very slow) run",
"test": "node ./test/out/helpers/runTests.js skipArtifactPublisher ALL_TESTS=isCi",
"test-all": "node ./test/vendor/yarn.js pretest && node ./test/out/helpers/runTests.js",
"test-linux": "docker run --rm -ti -v ${PWD}: /project -v ${PWD##*/}-node-modules:/project/node_modules -v ~/.electron:/root/.electron electronuserland/electron-builder:wine /bin/bash -c \"node ./test/vendor/yarn.js && node ./test/vendor/yarn.js test\"",
"test-linux": "docker run --rm -ti -v ${PWD}:/project -v ${PWD##*/}-node-modules:/project/node_modules -v ~/.electron:/root/.electron electronuserland/electron-builder:wine /bin/bash -c \"node ./test/vendor/yarn.js && node ./test/vendor/yarn.js test\"",
"//": "Update wiki if docs changed. Update only if functionalily are generally available (latest release, not next)",
"update-wiki": "(git branch -D wiki || true) && git subtree split -b wiki --prefix docs/ && git push -f wiki wiki:master",
"whitespace": "whitespace 'src/**/*.ts'",
Expand All @@ -30,7 +30,7 @@
"ajv": "^5.2.0",
"ajv-keywords": "^2.1.0",
"archiver": "^1.3.0",
"aws-sdk": "^2.72.0",
"aws-sdk": "^2.73.0",
"bluebird-lst": "^1.0.2",
"chalk": "^1.1.3",
"chromium-pickle-js": "^0.2.0",
Expand Down Expand Up @@ -66,7 +66,7 @@
},
"devDependencies": {
"@types/ini": "^1.3.29",
"@types/jest": "^20.0.0",
"@types/jest": "^20.0.1",
"@types/js-yaml": "^3.5.31",
"@types/node-forge": "^0.6.9",
"@types/source-map-support": "^0.4.0",
Expand All @@ -77,7 +77,6 @@
"babel-plugin-transform-es2015-parameters": "^6.24.1",
"babel-plugin-transform-es2015-spread": "^6.22.0",
"babel-plugin-transform-inline-imports-commonjs": "^1.2.0",
"concurrently": "^3.4.0",
"convert-source-map": "^1.5.0",
"decompress-zip": "^0.3.0",
"depcheck": "^0.6.7",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import BluebirdPromise from "bluebird-lst"
import { debug, exec, execWine, prepareArgs, spawn } from "electron-builder-util"
import { debug, exec, log, spawn } from "electron-builder-util"
import { copyFile, walk } from "electron-builder-util/out/fs"
import { log } from "electron-builder-util/out/log"
import { execWine, prepareArgs } from "electron-builder/out/util/wine"
import { WinPackager } from "electron-builder/out/winPackager"
import { createWriteStream, ensureDir, remove, stat, unlink } from "fs-extra-p"
import * as path from "path"
Expand Down Expand Up @@ -231,7 +231,8 @@ async function encodedZip(archive: any, dir: string, prefix: string, vendorPath:
})

// createExecutableStubForExe
if (file.endsWith(".exe") && !file.includes("squirrel.exe")) {
// https://github.com/Squirrel/Squirrel.Windows/pull/1051 Only generate execution stubs for the top-level executables
if (file.endsWith(".exe") && !file.includes("squirrel.exe") && !relativeSafeFilePath.includes("/")) {
const tempFile = await packager.getTempFile("stub.exe")
await copyFile(path.join(vendorPath, "StubExecutable.exe"), tempFile)
await execWine(path.join(vendorPath, "WriteZipToSetup.exe"), ["--copy-stub-resources", file, tempFile])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Arch, getArchSuffix, Target } from "electron-builder"
import { log, warn } from "electron-builder-util"
import { getBinFromGithub } from "electron-builder-util/out/binDownload"
import { log, warn } from "electron-builder-util/out/log"
import { SquirrelWindowsOptions } from "electron-builder/out/options/winOptions"
import { WinPackager } from "electron-builder/out/winPackager"
import * as path from "path"
Expand Down
19 changes: 18 additions & 1 deletion packages/electron-builder-util/src/binDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { CancellationToken, DownloadOptions } from "electron-builder-http"
import { emptyDir, rename, unlink } from "fs-extra-p"
import * as path from "path"
import { statOrNull } from "./fs"
import { log, warn } from "./log"
import { httpExecutor } from "./nodeHttpExecutor"
import { debug, debug7zArgs, getCacheDirectory, getTempName, spawn } from "./util"

Expand Down Expand Up @@ -46,6 +47,8 @@ async function doGetBin(name: string, dirName: string, url: string, checksum: st
return dirPath
}

log(`Downloading ${dirName}, please wait`)

// 7z cannot be extracted from the input stream, temp file is required
const tempUnpackDir = path.join(cachePath, getTempName())
const archiveName = `${tempUnpackDir}.7z`
Expand All @@ -64,7 +67,21 @@ async function doGetBin(name: string, dirName: string, url: string, checksum: st
(<any>options).sha512 = checksum
}

await httpExecutor.download(url, archiveName, options)
for (let attemptNumber = 1; attemptNumber < 4; attemptNumber++) {
try {
await httpExecutor.download(url, archiveName, options)
}
catch (e) {
if (attemptNumber >= 3) {
throw e
}

warn(`Cannot download ${name}, attempt #${attemptNumber}: ${e}`)
await new BluebirdPromise((resolve, reject) => {
setTimeout(() => httpExecutor.download(url, archiveName, options).then(resolve).catch(reject), 1000 * attemptNumber)
})
}
}

await spawn(path7za, debug7zArgs("x").concat(archiveName, `-o${tempUnpackDir}`), {
cwd: cachePath,
Expand Down
12 changes: 1 addition & 11 deletions packages/electron-builder-util/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { statOrNull } from "./fs"
import { log, warn } from "./log"

export { TmpDir } from "./tmp"
export { log, warn, task, subTask } from "./log"

export const debug = _debug("electron-builder")
export const debug7z = _debug("electron-builder:7z")
Expand All @@ -36,17 +37,6 @@ export function removePassword(input: string) {
})
}

export function execWine(file: string, args: Array<string>, options?: ExecOptions): Promise<string> {
return exec(process.platform === "win32" ? file : "wine", prepareArgs(args, file), options)
}

export function prepareArgs(args: Array<string>, exePath: string) {
if (process.platform !== "win32") {
args.unshift(exePath)
}
return args
}

export function exec(file: string, args?: Array<string> | null, options?: ExecOptions): Promise<string> {
if (debug.enabled) {
debug(`Executing ${file} ${args == null ? "" : removePassword(args.join(" "))}`)
Expand Down
3 changes: 1 addition & 2 deletions packages/electron-builder/src/appInfo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { isEmptyOrSpaces, smarten } from "electron-builder-util"
import { warn } from "electron-builder-util/out/log"
import { isEmptyOrSpaces, smarten, warn } from "electron-builder-util"
import sanitizeFileName from "sanitize-filename"
import { SemVer } from "semver"
import { Config, Metadata } from "./metadata"
Expand Down
3 changes: 1 addition & 2 deletions packages/electron-builder/src/builder.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import BluebirdPromise from "bluebird-lst"
import { underline } from "chalk"
import { CancellationToken } from "electron-builder-http"
import { addValue, isEmptyOrSpaces } from "electron-builder-util"
import { warn } from "electron-builder-util/out/log"
import { addValue, isEmptyOrSpaces, warn } from "electron-builder-util"
import { executeFinally } from "electron-builder-util/out/promise"
import { PublishOptions } from "electron-publish"
import { Arch, archFromString, DIR_TARGET, Platform } from "./core"
Expand Down
7 changes: 3 additions & 4 deletions packages/electron-builder/src/cli/cli.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#! /usr/bin/env node

import { cyan, dim, green, reset, underline } from "chalk"
import { exec } from "electron-builder-util"
import { log, warn } from "electron-builder-util/out/log"
import { exec, log, warn } from "electron-builder-util"
import { printErrorAndExit } from "electron-builder-util/out/promise"
import { readJson } from "fs-extra-p"
import isCi from "is-ci"
import * as path from "path"
import updateNotifier from "update-notifier"
import yargs from "yargs"
import { build, configureBuildCommand } from "../builder"
import { getElectronVersion, loadConfig } from "../util/config"
import { getConfig, getElectronVersion } from "../util/config"
import { getGypEnv } from "../util/yarn"
import { createSelfSignedCert } from "./create-self-signed-cert"
import { configureInstallAppDepsCommand, installAppDeps } from "./install-app-deps"
Expand Down Expand Up @@ -65,7 +64,7 @@ function checkIsOutdated() {

async function rebuildAppNativeCode(args: any) {
const projectDir = process.cwd()
const config = await loadConfig(projectDir)
const config = await getConfig(projectDir, null, null, null)
log(`Execute node-gyp rebuild for ${args.platform}:${args.arch}`)
// this script must be used only for electron
await exec(process.platform === "win32" ? "node-gyp.cmd" : "node-gyp", ["rebuild"], {
Expand Down
3 changes: 1 addition & 2 deletions packages/electron-builder/src/cli/create-self-signed-cert.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { bold } from "chalk"
import { exec, spawn, TmpDir } from "electron-builder-util"
import { exec, log, spawn, TmpDir } from "electron-builder-util"
import { unlinkIfExists } from "electron-builder-util/out/fs"
import { log } from "electron-builder-util/out/log"
import { ensureDir } from "fs-extra-p"
import * as path from "path"
import sanitizeFileName from "sanitize-filename"
Expand Down
7 changes: 3 additions & 4 deletions packages/electron-builder/src/cli/install-app-deps.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#! /usr/bin/env node

import BluebirdPromise from "bluebird-lst"
import { computeDefaultAppDirectory, use } from "electron-builder-util"
import { log, warn } from "electron-builder-util/out/log"
import { computeDefaultAppDirectory, log, use, warn } from "electron-builder-util"
import { printErrorAndExit } from "electron-builder-util/out/promise"
import yargs from "yargs"
import { getElectronVersion, loadConfig } from "../util/config"
import { getConfig, getElectronVersion } from "../util/config"
import { installOrRebuild } from "../util/yarn"

declare const PACKAGE_VERSION: string
Expand Down Expand Up @@ -40,7 +39,7 @@ export async function installAppDeps(args: any) {
}

const projectDir = process.cwd()
const config = (await loadConfig(projectDir)) || {}
const config = (await getConfig(projectDir, null, null, null)) || {}
const muonVersion = config.muonVersion
const results = await BluebirdPromise.all<string>([
computeDefaultAppDirectory(projectDir, use(config.directories, it => it!.app)),
Expand Down
3 changes: 1 addition & 2 deletions packages/electron-builder/src/fileMatcher.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import BluebirdPromise from "bluebird-lst"
import { asArray, debug } from "electron-builder-util"
import { asArray, debug, warn } from "electron-builder-util"
import { copyDir, copyOrLinkFile, Filter, statOrNull } from "electron-builder-util/out/fs"
import { warn } from "electron-builder-util/out/log"
import { mkdirs } from "fs-extra-p"
import { Minimatch } from "minimatch"
import * as path from "path"
Expand Down
3 changes: 1 addition & 2 deletions packages/electron-builder/src/fileTransformer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { debug } from "electron-builder-util"
import { debug, warn } from "electron-builder-util"
import { deepAssign } from "electron-builder-util/out/deepAssign"
import { FileTransformer } from "electron-builder-util/out/fs"
import { warn } from "electron-builder-util/out/log"
import { readJson } from "fs-extra-p"
import * as path from "path"
import { BuildInfo } from "./packagerApi"
Expand Down
3 changes: 1 addition & 2 deletions packages/electron-builder/src/macPackager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import BluebirdPromise from "bluebird-lst"
import { exec, isPullRequest } from "electron-builder-util"
import { exec, isPullRequest, log, task, warn } from "electron-builder-util"
import { deepAssign } from "electron-builder-util/out/deepAssign"
import { log, task, warn } from "electron-builder-util/out/log"
import { signAsync, SignOptions } from "electron-osx-sign"
import { ensureDir } from "fs-extra-p"
import * as path from "path"
Expand Down
5 changes: 3 additions & 2 deletions packages/electron-builder/src/options/winOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,10 @@ export interface NsisWebOptions extends NsisOptions {
}

/**
* Squirrel.Windows options.
* Squirrel.Windows options. Squirrel.Windows target is maintained, but deprecated. Please use `nsis` instead.
*
* To use Squirrel.Windows please install `electron-builder-squirrel-windows` dependency. Squirrel.Windows target is maintained, but deprecated. Please use `nsis` instead.
* To use Squirrel.Windows please install `electron-builder-squirrel-windows` dependency.
* To build for Squirrel.Windows on macOS, please install `mono`: `brew install mono`.
*/
export interface SquirrelWindowsOptions extends WinBuildOptions {
/**
Expand Down
Loading

0 comments on commit ed662e8

Please sign in to comment.