Skip to content

Commit e7cee5e

Browse files
committed
feat: use self-containe fpm on OS X — don't need to install ruby anymore
1 parent d77c8da commit e7cee5e

16 files changed

+109
-27
lines changed

.idea/libraries/electron_builder_for_tests.xml

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

.idea/runConfigurations/linuxPackagerTest.xml

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

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ env:
1111
- NODE_VERSION=4
1212
- NODE_VERSION=6
1313

14-
language: ruby
14+
language: c
1515

1616
cache:
17+
apt: true
18+
bundler: true
1719
directories:
1820
- node_modules
1921
- test/testApp/node_modules
2022
- $HOME/.electron
21-
- $HOME/.npm
2223

2324
addons:
2425
apt:
@@ -33,16 +34,15 @@ before_install:
3334
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
3435
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gnu-tar dpkg libicns graphicsmagick git-lfs; fi
3536
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then git lfs pull; fi
36-
- gem install --no-rdoc --no-ri fpm
3737
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then test/install-linux-dependencies.sh; fi
3838
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then curl -L https://github.com/github/git-lfs/releases/download/v1.2.0/git-lfs-linux-amd64-1.2.0.tar.gz | tar -xz; fi
3939
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then git-lfs-1.2.0/git-lfs pull; fi
4040

4141
install:
4242
- nvm install $NODE_VERSION
4343
- npm install npm -g
44-
- npm prune
4544
- npm install
45+
- npm prune
4646

4747
script:
4848
- npm run test

docs/Multi Platform Build.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ brew install Caskroom/cask/xquartz wine mono
2222

2323
To build app in distributable format for Linux on OS X:
2424
```
25-
brew install ruby gnu-tar libicns graphicsmagick
26-
gem install fpm
25+
brew install gnu-tar libicns graphicsmagick
2726
```
2827

2928
## Linux

package.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"test": "node ./test/out/helpers/runTests.js",
2121
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
2222
"//": "Update wiki if docs changed. Update only if functionalily are generally available (latest release, not next)",
23-
"update-wiki": "git subtree split -b wiki --prefix docs/ && git push wiki wiki:master"
23+
"update-wiki": "git subtree split -b wiki --prefix docs/ && git push wiki wiki:master",
24+
"whitespace": "whitespace src/*.ts"
2425
},
2526
"repository": {
2627
"type": "git",
@@ -64,7 +65,7 @@
6465
"electron-osx-sign-tf": "~0.5.0-beta.0",
6566
"electron-packager-tf": "^7.0.2-beta.0",
6667
"electron-winstaller-fixed": "~2.4.0-beta.1",
67-
"fs-extra-p": "^1.0.0",
68+
"fs-extra-p": "^1.0.1",
6869
"globby": "^4.0.0",
6970
"hosted-git-info": "^2.1.4",
7071
"image-size": "^0.5.0",
@@ -76,15 +77,18 @@
7677
"signcode-tf": "^0.5.0",
7778
"source-map-support": "^0.4.0",
7879
"tmp": "0.0.28",
79-
"typescript": "^1.9.0-dev.20160502"
80+
"typescript": "^1.9.0-dev.20160503"
8081
},
8182
"optionalDependencies": {
8283
"appdmg-tf": "^0.3.11"
8384
},
8485
"config": {
8586
"pre-git": {
8687
"commit-msg": "conventional"
87-
}
88+
},
89+
"pre-commit": [
90+
"npm run whitespace"
91+
]
8892
},
8993
"devDependencies": {
9094
"ava-tf": "^0.12.4-beta.6",
@@ -102,7 +106,8 @@
102106
"ts-babel": "^0.8.6",
103107
"tsconfig-glob": "^0.4.3",
104108
"tslint": "next",
105-
"typescript": "^1.9.0-dev.20160414"
109+
"typescript": "^1.9.0-dev.20160414",
110+
"whitespace": "^2.0.0"
106111
},
107112
"babel": {
108113
"plugins": [
@@ -118,5 +123,8 @@
118123
"test/out/*"
119124
]
120125
},
121-
"typings": "./out/electron-builder.d.ts"
126+
"typings": "./out/electron-builder.d.ts",
127+
"publishConfig": {
128+
"tag": "next"
129+
}
122130
}

src/build-cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if (args.help) {
3838
}
3939
else {
4040
if (args.appDir) {
41-
warn(`-appDir CLI parameter is deprecated, please configure build.directories.app instead
41+
warn(`-appDir CLI parameter is deprecated, please configure build.directories.app instead
4242
See https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-app`)
4343
}
4444

src/errorMessages.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const buildIsMissed = `Please specify 'build' configuration in the development package.json ('%s'), at least
2-
2+
33
build: {
44
"app-bundle-id": "your.id",
55
"app-category-type": "your.app.category.type",
@@ -14,11 +14,11 @@ export const authorEmailIsMissed = `Please specify author 'email' in the applica
1414
1515
See https://docs.npmjs.com/files/package.json#people-fields-author-contributors
1616
17-
It is required to set Linux .deb package maintainer. Or you can set maintainer in the custom linux options.
17+
It is required to set Linux .deb package maintainer. Or you can set maintainer in the custom linux options.
1818
(see https://github.com/electron-userland/electron-builder#distributable-format-configuration).
1919
`
2020

21-
export const buildInAppSpecified = `'build' in the application package.json ('%s') is not supported since 3.0 anymore
21+
export const buildInAppSpecified = `'build' in the application package.json ('%s') is not supported since 3.0 anymore
2222
2323
Please move 'build' into the development package.json ('%s')
2424
`

src/fpmDownload.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { statOrNull, spawn, debug } from "./util"
2+
import { emptyDir, move, remove } from "fs-extra-p"
3+
import { download } from "./httpRequest"
4+
import { path7za } from "7zip-bin"
5+
import * as path from "path"
6+
import { tmpdir } from "os"
7+
import { Promise as BluebirdPromise } from "bluebird"
8+
9+
//noinspection JSUnusedLocalSymbols
10+
const __awaiter = require("./awaiter")
11+
12+
let tmpDirCounter = 0
13+
14+
function getTempName(prefix?: string | n): string {
15+
return `${prefix == null ? "" : prefix + "-"}${process.pid}-${tmpDirCounter++}-${Date.now()}`
16+
}
17+
18+
const versionToPromise = new Map<string, BluebirdPromise<string>>()
19+
20+
// can be called in parallel, all calls for the same version will get the same promise - will be downloaded only once
21+
export function downloadFpm(version: string): Promise<string> {
22+
let promise = versionToPromise.get(version)
23+
// if rejected, we will try to download again
24+
if (<any>promise != null && !promise!.isRejected()) {
25+
return promise!
26+
}
27+
28+
promise = <BluebirdPromise<string>>doDownloadFpm(version)
29+
versionToPromise.set(version, promise)
30+
return promise
31+
}
32+
33+
async function doDownloadFpm(version: string): Promise<string> {
34+
const dirName = `fpm-${version}-osx`
35+
const url = `https://github.com/develar/fpm-self-contained/releases/download/v${version}/${dirName}.7z`
36+
const cache = path.join(__dirname, "..", "node_modules", ".fpm")
37+
const fpmDir = path.join(cache, dirName)
38+
39+
const stat = await statOrNull(fpmDir)
40+
if (stat != null && stat.isDirectory()) {
41+
return path.join(fpmDir, "fpm")
42+
}
43+
44+
// the only version currently supported (i.e. all clients are consumed the same version
45+
await emptyDir(cache)
46+
47+
const archiveName = path.join(tmpdir(), getTempName("fpm-download") + ".7z")
48+
await download(url, archiveName)
49+
const tempUnpackDir = path.join(cache, getTempName())
50+
await spawn(path7za, ["x", archiveName, "-o" + tempUnpackDir, "-bb" + (debug.enabled ? "3" : "0"), "-bd"], {
51+
cwd: cache,
52+
stdio: ["ignore", "inherit", "inherit"],
53+
})
54+
55+
await move(path.join(tempUnpackDir, dirName), fpmDir, {clobber: true})
56+
await BluebirdPromise.all([remove(tempUnpackDir), remove(archiveName)])
57+
58+
return path.join(fpmDir, "fpm")
59+
}

src/gitHubRequest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function doGitHubRequest<T>(options: RequestOptions, token: string | null
3838
if (response.statusCode === 404) {
3939
// error is clear, we don't need to read detailed error description
4040
reject(new HttpError(response, `method: ${options.method} url: https://${options.hostname}${options.path}
41-
41+
4242
Please double check that your GitHub Token is correct. Due to security reasons GitHub doesn't report actual status, but 404.
4343
`))
4444
}

src/httpRequest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function doDownload(url: string, destination: string, redirectCount: number, cal
2929
hostname: parsedUrl.hostname,
3030
path: parsedUrl.path,
3131
headers: {
32-
"User-Agent": "electron-complete-builder"
32+
"User-Agent": "electron-builder"
3333
}
3434
}, (response: IncomingMessage) => {
3535
if (response.statusCode >= 400) {

0 commit comments

Comments
 (0)