Skip to content

Commit

Permalink
Add rpm package creation support (#1694)
Browse files Browse the repository at this point in the history
Add rpm package creation support
  • Loading branch information
feross committed Sep 19, 2019
2 parents 9c4ca25 + 6e69e5d commit 88e7167
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 16 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ The following optional arguments are available:
- `--sign` - Sign the application (Mac, Windows)
- `--package=[type]` - Package single output type.
- `deb` - Debian package
- `rpm` - RedHat package
- `zip` - Linux zip file
- `dmg` - Mac disk image
- `exe` - Windows installer
Expand Down
49 changes: 43 additions & 6 deletions bin/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,16 +485,14 @@ function buildLinux (cb) {

const tasks = []
buildPath.forEach(function (filesPath) {
let destArch = filesPath.split('-').pop()

// Linux convention for 'x64' is 'amd64'
if (destArch === 'x64') {
destArch = 'amd64'
}
const destArch = filesPath.split('-').pop()

if (argv.package === 'deb' || argv.package === 'all') {
tasks.push((cb) => packageDeb(filesPath, destArch, cb))
}
if (argv.package === 'rpm' || argv.package === 'all') {
tasks.push((cb) => packageRpm(filesPath, destArch, cb))
}
if (argv.package === 'zip' || argv.package === 'all') {
tasks.push((cb) => packageZip(filesPath, destArch, cb))
}
Expand All @@ -505,6 +503,11 @@ function buildLinux (cb) {
})

function packageDeb (filesPath, destArch, cb) {
// Linux convention for Debian based 'x64' is 'amd64'
if (destArch === 'x64') {
destArch = 'amd64'
}

// Create .deb file for Debian-based platforms
console.log(`Linux: Creating ${destArch} deb...`)

Expand Down Expand Up @@ -533,6 +536,40 @@ function buildLinux (cb) {
)
}

function packageRpm (filesPath, destArch, cb) {
// Linux convention for RedHat based 'x64' is 'x86_64'
if (destArch === 'x64') {
destArch = 'x86_64'
}

// Create .rpm file for RedHat-based platforms
console.log(`Linux: Creating ${destArch} rpm...`)

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

const options = {
src: filesPath + '/',
dest: DIST_PATH,
arch: destArch,
bin: 'WebTorrent',
icon: {
'48x48': path.join(config.STATIC_PATH, 'linux/share/icons/hicolor/48x48/apps/webtorrent-desktop.png'),
'256x256': path.join(config.STATIC_PATH, 'linux/share/icons/hicolor/256x256/apps/webtorrent-desktop.png')
},
categories: ['Network', 'FileTransfer', 'P2P'],
mimeType: ['application/x-bittorrent', 'x-scheme-handler/magnet', 'x-scheme-handler/stream-magnet'],
desktopTemplate: path.join(config.STATIC_PATH, 'linux/webtorrent-desktop.ejs')
}

installer(options).then(
() => {
console.log(`Linux: Created ${destArch} rpm.`)
cb(null)
},
(err) => cb(err)
)
}

function packageZip (filesPath, destArch, cb) {
// Create .zip file for Linux
console.log(`Linux: Creating ${destArch} zip...`)
Expand Down
45 changes: 37 additions & 8 deletions package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@
"main": "index.js",
"optionalDependencies": {
"appdmg": "^0.6.0",
"electron-installer-debian": "^2.0.0"
"electron-installer-debian": "^2.0.0",
"electron-installer-redhat": "^2.0.0"
},
"private": true,
"productName": "WebTorrent",
Expand All @@ -99,7 +100,7 @@
"build": "buble src --target chrome:71 --output build",
"clean": "node ./bin/clean.js",
"gh-release": "gh-release",
"install-system-deps": "brew install fakeroot dpkg",
"install-system-deps": "brew install fakeroot dpkg rpm",
"open-config": "node ./bin/open-config.js",
"package": "node ./bin/package.js",
"start": "npm run build && electron .",
Expand Down

0 comments on commit 88e7167

Please sign in to comment.