Skip to content

Commit

Permalink
feat(linux): sh, rpm, freebsd, pacman, p5p, apk, 7z, zip, tar.xz, tar…
Browse files Browse the repository at this point in the history
….gz, tar.bz2, tar.lz

Closes #414
  • Loading branch information
develar committed May 23, 2016
1 parent f781217 commit 50d31f1
Show file tree
Hide file tree
Showing 26 changed files with 449 additions and 255 deletions.
4 changes: 4 additions & 0 deletions .idea/dictionaries/develar.xml

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

20 changes: 6 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,26 @@ osx_image: xcode7
dist: trusty
sudo: required

services:
- docker

env:
- NODE_VERSION=4
- NODE_VERSION=6

language: c

cache:
apt: true
bundler: true
directories:
- node_modules
- test/testApp/node_modules
- $HOME/.electron
- $HOME/.cache/fpm

addons:
apt:
sources:
- mono
packages:
- icnsutils
- graphicsmagick
- mono-devel

before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gnu-tar dpkg libicns graphicsmagick git-lfs; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gnu-tar dpkg libicns graphicsmagick git-lfs lzip; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then git lfs pull; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then test/install-linux-dependencies.sh; fi
- 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
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then git-lfs-1.2.0/git-lfs pull; fi

Expand All @@ -46,7 +37,8 @@ install:
- npm prune

script:
- npm run test
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then npm run test ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker run --rm -v ${PWD}:/project -v ~/.electron:/root/.electron electronuserland/electron-builder:wine /test.sh ; fi

after_success:
- node out/cleanup.js
Expand Down
76 changes: 74 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM buildpack-deps:xenial-curl
# rpm is required for FPM to build rpm package

RUN apt-get update -y && \
apt-get install --no-install-recommends -y build-essential icnsutils graphicsmagick gcc-multilib g++-multilib libgnome-keyring-dev zip rpm && \
apt-get install --no-install-recommends -y bsdtar build-essential autoconf libssl-dev icnsutils graphicsmagick gcc-multilib g++-multilib libgnome-keyring-dev zip lzip rpm && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

Expand Down Expand Up @@ -42,4 +42,76 @@ COPY test.sh /test.sh
WORKDIR /project

ENV DEBUG_COLORS true
ENV FORCE_COLOR true
ENV FORCE_COLOR true

# copied from https://github.com/docker-library/ruby/blob/0b94677b368947b64dcdcb312cd81ba946df3676/2.3/Dockerfile

# skip installing gem documentation
RUN mkdir -p /usr/local/etc \
&& { \
echo 'install: --no-document'; \
echo 'update: --no-document'; \
} >> /usr/local/etc/gemrc

ENV RUBY_MAJOR 2.3
ENV RUBY_VERSION 2.3.1
ENV RUBY_DOWNLOAD_SHA256 b87c738cb2032bf4920fef8e3864dc5cf8eae9d89d8d523ce0236945c5797dcd
ENV RUBYGEMS_VERSION 2.6.4

# some of ruby's build scripts are written in ruby
# we purge this later to make sure our final image uses what we just built
RUN set -ex \
&& buildDeps=' \
bison \
libgdbm-dev \
ruby \
' \
&& apt-get update \
&& apt-get install -y --no-install-recommends $buildDeps \
&& rm -rf /var/lib/apt/lists/* \
&& curl -fSL -o ruby.tar.gz "http://cache.ruby-lang.org/pub/ruby/$RUBY_MAJOR/ruby-$RUBY_VERSION.tar.gz" \
&& echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.gz" | sha256sum -c - \
&& mkdir -p /usr/src/ruby \
&& tar -xzf ruby.tar.gz -C /usr/src/ruby --strip-components=1 \
&& rm ruby.tar.gz \
&& cd /usr/src/ruby \
&& { echo '#define ENABLE_PATH_CHECK 0'; echo; cat file.c; } > file.c.new && mv file.c.new file.c \
&& autoconf \
&& ./configure --disable-install-doc \
&& make -j"$(nproc)" \
&& make install \
&& apt-get purge -y --auto-remove $buildDeps \
&& gem update --system $RUBYGEMS_VERSION \
&& rm -r /usr/src/ruby

ENV BUNDLER_VERSION 1.12.4

RUN gem install bundler --version "$BUNDLER_VERSION"

# install things globally, for great justice
# and don't create ".bundle" in all our apps
ENV GEM_HOME /usr/local/bundle
ENV BUNDLE_PATH="$GEM_HOME" \
BUNDLE_BIN="$GEM_HOME/bin" \
BUNDLE_SILENCE_ROOT_WARNING=1 \
BUNDLE_APP_CONFIG="$GEM_HOME"
ENV PATH $BUNDLE_BIN:$PATH
RUN mkdir -p "$GEM_HOME" "$BUNDLE_BIN" \
&& chmod 777 "$GEM_HOME" "$BUNDLE_BIN" \
&& mkdir /fpm && curl -L https://github.com/jordansissel/fpm/archive/6e2514df27664912826b4fcd89affa19df0e713b.tar.gz | tar -xz -C /fpm --strip-components 1 && cd /fpm && bundle install && make install && cd ..

# use fpm commit https://github.com/jordansissel/fpm/commit/6e2514df27664912826b4fcd89affa19df0e713b because of some important unreleased fixes:
# https://github.com/jordansissel/fpm/commit/94be82c0a23c8cd641ab9e60f3eb4a8db445fff0
# https://github.com/jordansissel/fpm/commit/77b95747b9cc01ca420ee24084a449b3ac19e6d5

# we don't use our bundled fpm because it is better to build ruby & tools for specific platform - not generic. And easy to maintain (update ruby and so on).

ENV USE_SYSTEM_FPM true

# fix error /usr/local/bundle/gems/fpm-1.5.0/lib/fpm/package/freebsd.rb:72:in `encode': "\xE2" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
# http://jaredmarkell.com/docker-and-locales/
# http://askubuntu.com/a/601498
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
11 changes: 9 additions & 2 deletions docker/readme.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# Development machine

To build Linux:
```sh
docker run --rm -ti -v `pwd`:/project -v `pwd`/node_modules/.linux:/project/node_modules -v ~/.electron:/root/.electron electronuserland/electron-builder
```

Wine:
To build windows:
```sh
docker run --rm -ti -v ${PWD}:/project -v ${PWD##*/}-node-modules:/project/node_modules -v ~/.electron:/root/.electron electronuserland/electron-builder:wine
```

Consider using `/test.sh` to install npm dependencies and run tests.

# CI Server

```sh
docker run --rm -v ${PWD}:/project -v ~/.electron:/root/.electron -v ~/.cache:/root/.cache electronuserland/electron-builder:wine /test.sh
docker run --rm -v ${PWD}:/project -v ~/.electron:/root/.electron electronuserland/electron-builder:wine /test.sh
```

# Build
Expand All @@ -22,6 +25,10 @@ docker build -t electronuserland/electron-builder docker
docker build -t electronuserland/electron-builder:wine docker/wine
```

Or just `npm run docker-images`

# Notes

* We use [named data volume](https://madcoda.com/2016/03/docker-named-volume-explained/) instead of mounted host directory to store `node_modules` because NPM is unreliable and NPM team [doesn't want to fix it](https://github.com/npm/npm/issues/3565).

`${PWD##*/}-node-modules` is used as name of data volume — it is your current directory name (e. g. `foo`) and suffix `-node-modules`.
Expand Down
16 changes: 11 additions & 5 deletions docs/Multi Platform Build.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,25 @@ To build app in distributable format for Linux on OS X:
brew install gnu-tar libicns graphicsmagick
```

To build rpm: `brew install rpm`.

## Linux
To build app in distributable format for Linux:
```
sudo apt-get install icnsutils graphicsmagick xz-utils
sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils
```

To build rpm: `sudo apt-get install --no-install-recommends -y rpm`.

To build pacman: `sudo apt-get install --no-install-recommends -y bsdtar`.

To build app in distributable format for Windows on Linux:
* Install Wine (1.8+ is required):

```
sudo add-apt-repository ppa:ubuntu-wine/ppa -y
sudo apt-get update
sudo apt-get install wine1.8 -y
sudo apt-get install --no-install-recommends -y wine1.8
```

* Install [Mono](http://www.mono-project.com/docs/getting-started/install/linux/#usage) (4.2+ is required):
Expand All @@ -46,18 +52,18 @@ To build app in distributable format for Windows on Linux:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
sudo apt-get install mono-devel ca-certificates-mono -y
sudo apt-get install --no-install-recommends -y mono-devel ca-certificates-mono
```

* Install zip.
```
apt-get install zip
apt-get install --no-install-recommends -y zip
```

To build app in 32 bit from a machine with 64 bit:

```
sudo apt-get install -y gcc-multilib g++-multilib
sudo apt-get install --no-install-recommends -y gcc-multilib g++-multilib
```

### Travis Linux
Expand Down
3 changes: 2 additions & 1 deletion docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ See all [appdmg options](https://www.npmjs.com/package/appdmg#json-specification
| --- | ---
| icon | <a name="OsXBuildOptions-icon"></a>The path to icon, which will be shown when mounted (default: `build/icon.icns`).
| background | <a name="OsXBuildOptions-background"></a><p>The path to background (default: <code>build/background.png</code> if exists). The resolution of this file determines the resolution of the installer window. If background is not specified, use <code>window.size</code>, see [specification](https://github.com/LinusU/node-appdmg#json-specification).</p>
| target | <a name="OsXBuildOptions-target"></a>Target package type: list of `default`, `dmg`, `zip`, `mas`, `7z`. Defaults to `default` (dmg and zip for Squirrel.Mac).
| target | <a name="OsXBuildOptions-target"></a>Target package type: list of `default`, `dmg`, `zip`, `mas`, `7z`, `tar.xz`, `tar.gz`, `tar.bz2`, `tar.7z`. Defaults to `default` (dmg and zip for Squirrel.Mac).
| identity | <a name="OsXBuildOptions-identity"></a><p>The name of certificate to use when signing. Consider using environment variables [CSC_LINK or CSC_NAME](https://github.com/electron-userland/electron-builder/wiki/Code-Signing). MAS installer identity is specified in the [.build.mas](#MasBuildOptions-identity).</p>
| entitlements | <a name="OsXBuildOptions-entitlements"></a><p>The path to entitlements file for signing the app. <code>build/osx.entitlements</code> will be used if exists (it is a recommended way to set). MAS entitlements is specified in the [.build.mas](#MasBuildOptions-entitlements).</p>
| entitlementsInherit | <a name="OsXBuildOptions-entitlementsInherit"></a><p>The path to child entitlements which inherit the security settings for signing frameworks and bundles of a distribution. <code>build/osx.inherit.entitlements</code> will be used if exists (it is a recommended way to set). Otherwise [default](https://github.com/electron-userland/electron-osx-sign/blob/master/default.darwin.inherit.entitlements).</p> <p>This option only applies when signing with <code>entitlements</code> provided.</p>
Expand Down Expand Up @@ -107,6 +107,7 @@ MAS (Mac Application Store) specific options (in addition to `build.osx`).
| vendor | <a name="LinuxBuildOptions-vendor"></a>The vendor. Defaults to [author](#AppMetadata-author).
| compression | <a name="LinuxBuildOptions-compression"></a>*deb-only.* The compression type, one of `gz`, `bzip2`, `xz` (default: `xz`).
| depends | <a name="LinuxBuildOptions-depends"></a>Package dependencies. Defaults to `["libappindicator1", "libnotify-bin"]`.
| target | <a name="LinuxBuildOptions-target"></a><p>Target package type: list of <code>default</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>default</code> (<code>deb</code>).</p> <p>Only <code>deb</code> is tested. Feel free to file issues for <code>rpm</code> and other package formats.</p>

<a name="MetadataDirectories"></a>
## `.directories`
Expand Down
16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
"install-app-deps": "./out/install-app-deps.js"
},
"scripts": {
"compile": "npm run compile-production && npm run compile-test",
"compile": "npm run whitespace && npm run compile-production && npm run compile-test",
"compile-production": "tsconfig -i 2 && ts-babel",
"compile-test": "tsconfig -i 2 test && ts-babel test",
"lint": "tslint src/*.ts test/src/*.ts",
"pretest": "npm run compile && npm run lint",
"test": "node ./test/out/helpers/runTests.js",
"ci-test": "git-lfs pull && npm install && npm prune && npm run test",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"//": "Update wiki if docs changed. Update only if functionalily are generally available (latest release, not next)",
"update-wiki": "git subtree split -b wiki --prefix docs/ && git push wiki wiki:master",
Expand Down Expand Up @@ -70,7 +69,7 @@
"electron-packager-tf": "~7.1.0",
"electron-winstaller-fixed": "~2.8.3",
"fs-extra-p": "^1.0.1",
"globby": "^4.0.0",
"globby": "^4.1.0",
"hosted-git-info": "^2.1.5",
"image-size": "^0.5.0",
"lodash.template": "^4.2.5",
Expand All @@ -79,11 +78,10 @@
"progress-stream": "^1.2.0",
"read-package-json": "^2.0.4",
"signcode-tf": "^0.6.3",
"source-map-support": "^0.4.0",
"tmp": "0.0.28"
"source-map-support": "^0.4.0"
},
"optionalDependencies": {
"appdmg": "^0.4.3"
"appdmg": "^0.4.5"
},
"config": {
"pre-git": {
Expand All @@ -105,11 +103,11 @@
"plist": "^1.2.0",
"pre-git": "^3.8.4",
"semantic-release": "^6.2.2",
"should": "^8.3.1",
"should": "^8.4.0",
"ts-babel": "^0.8.6",
"tsconfig-glob": "^0.4.3",
"tslint": "3.10.2",
"typescript": "1.9.0-dev.20160515",
"tslint": "3.10.0-dev.2",
"typescript": "1.9.0-dev.20160520-1.0",
"whitespace": "^2.0.0"
},
"babel": {
Expand Down
18 changes: 2 additions & 16 deletions src/fpmDownload.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { statOrNull, spawn, debug, debug7z } from "./util"
import { statOrNull, spawn, debug, debug7zArgs, getTempName } from "./util"
import { writeFile, rename, remove, unlink, emptyDir } from "fs-extra-p"
import { download } from "./httpRequest"
import { path7za } from "7zip-bin"
Expand All @@ -9,12 +9,6 @@ import { Promise as BluebirdPromise } from "bluebird"
//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")

let tmpDirCounter = 0

function getTempName(prefix?: string | n): string {
return `${prefix == null ? "" : prefix + "-"}${process.pid}-${tmpDirCounter++}-${Date.now()}`
}

const versionToPromise = new Map<string, BluebirdPromise<string>>()

// can be called in parallel, all calls for the same version will get the same promise - will be downloaded only once
Expand Down Expand Up @@ -55,15 +49,7 @@ async function doDownloadFpm(version: string, osAndArch: string): Promise<string
await emptyDir(tempUnpackDir)
await download(url, archiveName, false)

const args = ["x", archiveName, "-o" + tempUnpackDir, "-bd"]
if (debug7z.enabled) {
args.push("-bb3")
}
else if (!debug.enabled) {
args.push("-bb0")
}

await spawn(path7za, args, {
await spawn(path7za, debug7zArgs("x").concat(archiveName, `-o${tempUnpackDir}`), {
cwd: cacheDir,
stdio: ["ignore", debug.enabled ? "inherit" : "ignore", "inherit"],
})
Expand Down
Loading

0 comments on commit 50d31f1

Please sign in to comment.