Skip to content

Commit

Permalink
Merge pull request desktop#2993 from desktop/add-package-support-for-…
Browse files Browse the repository at this point in the history
…linux

first pass at packaging for Linux distros
  • Loading branch information
joshaber authored Oct 10, 2017
2 parents 7f882f1 + ba7d368 commit 5a638b7
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 6 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ addons:
# this package is essential for testing Electron in a headless fashion
# https://github.com/electron/electron/blob/master/docs/tutorial/testing-on-headless-ci.md
- xvfb
# packages required for electron-installer-debian
- fakeroot
- dpkg
# packages required for electron-installer-redhat
- rpm
# packages required for electron-installer-appimage
- xz-utils
- xorriso

branches:
only:
Expand Down
Binary file added app/static/logos/1024x1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/static/logos/256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/static/logos/512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions docs/contributing/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ Because we haven't yet upgraded to NPM 5, we need to downgrade to the latest `np
$ sudo npm install -g npm@4.6.1
```

If you want to package Desktop for distribution, you will need these additional dependencies:

```sh
$ sudo yum install fakeroot dpkg rpm rpm-build xz xorriso appstream bzip2-devel
#
# workarounds for linker issues when packaging for AppImage
# source: https://michaelheap.com/error-while-loading-shared-libraries-libbz2-so-1-0-cannot-open-shared-object-file-on-centos-7
$ sudo ln -s `find /usr/lib64/ -type f -name "libbz2.so.1*"` /usr/lib64/libbz2.so.1.0
# source: https://github.com/electron-userland/electron-builder/issues/993#issuecomment-291021974
$ sudo ln -s `find /usr/lib64/ -type f -name "libreadline.so.7.0"` /usr/lib64/libreadline.so.6
```

## Verification

With these things installed, open a shell and validate you have these commands
Expand Down
22 changes: 17 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@
"clean-webpack-plugin": "^0.1.16",
"cross-env": "^5.0.5",
"css-loader": "^0.28.5",
"electron": "1.7.8",
"electron-mocha": "^4.0.0",
"electron-packager": "^8.7.2",
"electron-winstaller": "2.5.2",
"express": "^4.15.0",
"extract-text-webpack-plugin": "^3.0.0",
"fs-extra": "^2.1.2",
Expand Down Expand Up @@ -112,6 +108,22 @@
"@types/ua-parser-js": "^0.7.30",
"@types/uuid": "^3.4.0",
"@types/winston": "^2.2.0",
"@types/xml2js": "^0.4.0"
"@types/xml2js": "^0.4.0",
"electron": "1.7.8",
"electron-builder": "19.33.0",
"electron-installer-appimage": "^1.0.1",
"electron-mocha": "^4.0.0",
"electron-packager": "^8.7.2",
"electron-winstaller": "2.5.2"
},
"optionalDependencies": {
"electron-installer-redhat": "^0.5.0",
"electron-installer-debian": "^0.6.0"
},
"build": {
"linux": {
"category": "public.app-category.developer-tools",
"icon": "app/static/logos"
}
}
}
85 changes: 84 additions & 1 deletion script/package
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ const distInfo = require('./dist-info')

const distPath = distInfo.getDistPath()
const productName = distInfo.getProductName()
const outputDir = path.join(distPath, '..', 'installer')

if (process.platform === 'darwin') {
packageOSX()
} else if (process.platform === 'win32') {
packageWindows()
} else if (process.platform === 'linux') {
packageLinux()
} else {
console.error(`I dunno how to package for ${process.platform} :(`)
process.exit(1)
Expand All @@ -31,7 +34,6 @@ function packageOSX() {

function packageWindows() {
const electronInstaller = require('electron-winstaller')
const outputDir = path.join(distPath, '..', 'installer')
const setupCertificatePath = path.join(
__dirname,
'setup-windows-certificate.ps1'
Expand Down Expand Up @@ -110,3 +112,84 @@ function packageWindows() {
process.exit(1)
})
}

function packageRedhat() {
const installer = require('electron-installer-redhat')

var options = {
src: distPath,
dest: outputDir,
arch: 'amd64',
}

return new Promise((resolve, reject) => {
console.log('Creating .rpm package...')
installer(options, function(err) {
if (err) {
reject(err)
} else {
resolve()
}
})
})
}

function packageDebian() {
const installer = require('electron-installer-debian')

var options = {
src: distPath,
dest: outputDir,
arch: 'amd64',
}

return new Promise((resolve, reject) => {
console.log('Creating .deb package...')
installer(options, function(err) {
if (err) {
reject(err)
} else {
resolve()
}
})
})
}

function packageAppImage() {
// Because electron-builder's CLI has some limits, we need to
// implement a couple of workarounds.
//
// First, it'll use `dist/make` for it's output directory, which
// results in this vague error when the directory doesn't exist:
//
// libburn : SORRY : Neither stdio-path nor its directory exist
//
// so let's just trash it (if already existing) and create the directory
const makeDir = path.join(distInfo.getDistRoot(), 'make')
fs.removeSync(makeDir)
fs.mkdirSync(makeDir)

const installer = require('electron-installer-appimage')

var options = {
dir: distPath,
targetArch: 'x64',
}

return installer.default(options).then(() => {
// Second, we need to move the relevant files from dist/make up to
// the installers directory so it's alongside the other packages
cp.execSync(`cp ${makeDir}/*.AppImage ${outputDir}`)
})
}

async function packageLinux() {
try {
await packageRedhat()
await packageDebian()
await packageAppImage()
console.log(`Successfully created packages at ${outputDir}`)
} catch (e) {
console.log(`error during packaging: ${e}`)
}
}

0 comments on commit 5a638b7

Please sign in to comment.