Merge pull request #264 from grunjol/feature-debian-package
Linux: Create .deb package
This commit is contained in:
@@ -50,10 +50,12 @@ $ npm run package
|
|||||||
To build for one platform:
|
To build for one platform:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ npm run package -- [platform]
|
$ npm run package -- [platform] [package-type]
|
||||||
```
|
```
|
||||||
|
|
||||||
Where `[platform]` is `darwin`, `linux`, or `win32`.
|
Where `[platform]` is `darwin`, `linux`, or `win32`
|
||||||
|
|
||||||
|
and `[package-type]` is `all` (default), `deb` or `zip` (`linux` platform only)
|
||||||
|
|
||||||
#### Windows build notes
|
#### Windows build notes
|
||||||
|
|
||||||
@@ -75,4 +77,3 @@ brew install wine
|
|||||||
## License
|
## License
|
||||||
|
|
||||||
MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).
|
MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).
|
||||||
|
|
||||||
|
|||||||
@@ -16,18 +16,19 @@ var BUILD_NAME = config.APP_NAME + '-v' + config.APP_VERSION
|
|||||||
|
|
||||||
function build () {
|
function build () {
|
||||||
var platform = process.argv[2]
|
var platform = process.argv[2]
|
||||||
|
var packageType = process.argv.length > 3 ? process.argv[3] : 'all'
|
||||||
if (platform === 'darwin') {
|
if (platform === 'darwin') {
|
||||||
buildDarwin(printDone)
|
buildDarwin(printDone)
|
||||||
} else if (platform === 'win32') {
|
} else if (platform === 'win32') {
|
||||||
buildWin32(printDone)
|
buildWin32(printDone)
|
||||||
} else if (platform === 'linux') {
|
} else if (platform === 'linux') {
|
||||||
buildLinux(printDone)
|
buildLinux(packageType, printDone)
|
||||||
} else {
|
} else {
|
||||||
buildDarwin(function (err, buildPath) {
|
buildDarwin(function (err, buildPath) {
|
||||||
printDone(err, buildPath)
|
printDone(err, buildPath)
|
||||||
buildWin32(function (err, buildPath) {
|
buildWin32(function (err, buildPath) {
|
||||||
printDone(err, buildPath)
|
printDone(err, buildPath)
|
||||||
buildLinux(printDone)
|
buildLinux(packageType, printDone)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -285,16 +286,45 @@ function buildWin32 (cb) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildLinux (cb) {
|
function buildLinux (packageType, cb) {
|
||||||
electronPackager(Object.assign({}, all, linux), function (err, buildPath) {
|
electronPackager(Object.assign({}, all, linux), function (err, buildPath) {
|
||||||
if (err) return cb(err)
|
if (err) return cb(err)
|
||||||
|
|
||||||
// Create .zip file for Linux
|
|
||||||
var distPath = path.join(config.ROOT_PATH, 'dist')
|
var distPath = path.join(config.ROOT_PATH, 'dist')
|
||||||
var zipPath = path.join(config.ROOT_PATH, 'dist', BUILD_NAME + '-linux.zip')
|
var filesPath = buildPath[0]
|
||||||
var appFolderName = path.basename(buildPath[0])
|
|
||||||
cp.execSync(`cd ${distPath} && zip -r -y ${zipPath} ${appFolderName}`)
|
if (packageType === 'deb' || packageType === 'all') {
|
||||||
console.log('Created Linux .zip file.')
|
// Create .deb file for debian based platforms
|
||||||
|
var deb = require('nobin-debian-installer')()
|
||||||
|
var destPath = path.join('/opt', pkg.name)
|
||||||
|
|
||||||
|
deb.pack({
|
||||||
|
package: pkg,
|
||||||
|
info: {
|
||||||
|
arch: 'amd64',
|
||||||
|
targetDir: distPath,
|
||||||
|
scripts: {
|
||||||
|
postinst: path.join(config.STATIC_PATH, 'linux', 'postinst'),
|
||||||
|
postrm: path.join(config.STATIC_PATH, 'linux', 'postrm')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [{
|
||||||
|
src: ['./**'],
|
||||||
|
dest: destPath,
|
||||||
|
expand: true,
|
||||||
|
cwd: filesPath
|
||||||
|
}], function (err, done) {
|
||||||
|
console.log(err || 'Created Linux .deb file.')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (packageType === 'zip' || packageType === 'all') {
|
||||||
|
// Create .zip file for Linux
|
||||||
|
var zipPath = path.join(config.ROOT_PATH, 'dist', BUILD_NAME + '-linux.zip')
|
||||||
|
var appFolderName = path.basename(filesPath)
|
||||||
|
cp.execSync(`cd ${distPath} && zip -r -y ${zipPath} ${appFolderName}`)
|
||||||
|
console.log('Created Linux .zip file.')
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ function initLinux () {
|
|||||||
installIconFile()
|
installIconFile()
|
||||||
|
|
||||||
function installDesktopFile () {
|
function installDesktopFile () {
|
||||||
var templatePath = path.join(config.STATIC_PATH, 'webtorrent.desktop')
|
var templatePath = path.join(config.STATIC_PATH, 'linux', 'webtorrent-desktop.desktop')
|
||||||
fs.readFile(templatePath, 'utf8', writeDesktopFile)
|
fs.readFile(templatePath, 'utf8', writeDesktopFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ function initLinux () {
|
|||||||
'.local',
|
'.local',
|
||||||
'share',
|
'share',
|
||||||
'applications',
|
'applications',
|
||||||
'webtorrent.desktop'
|
'webtorrent-desktop.desktop'
|
||||||
)
|
)
|
||||||
mkdirp(path.dirname(desktopFilePath))
|
mkdirp(path.dirname(desktopFilePath))
|
||||||
fs.writeFile(desktopFilePath, desktopFile, function (err) {
|
fs.writeFile(desktopFilePath, desktopFile, function (err) {
|
||||||
@@ -216,7 +216,7 @@ function initLinux () {
|
|||||||
'.local',
|
'.local',
|
||||||
'share',
|
'share',
|
||||||
'icons',
|
'icons',
|
||||||
'webtorrent.png'
|
'webtorrent-desktop.png'
|
||||||
)
|
)
|
||||||
mkdirp(path.dirname(iconFilePath))
|
mkdirp(path.dirname(iconFilePath))
|
||||||
fs.writeFile(iconFilePath, iconFile, function (err) {
|
fs.writeFile(iconFilePath, iconFile, function (err) {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
"electron-packager": "^6.0.0",
|
"electron-packager": "^6.0.0",
|
||||||
"electron-winstaller": "^2.0.5",
|
"electron-winstaller": "^2.0.5",
|
||||||
"gh-release": "^2.0.3",
|
"gh-release": "^2.0.3",
|
||||||
|
"nobin-debian-installer": "^0.0.5",
|
||||||
"plist": "^1.2.0",
|
"plist": "^1.2.0",
|
||||||
"rimraf": "^2.5.2",
|
"rimraf": "^2.5.2",
|
||||||
"standard": "^6.0.5"
|
"standard": "^6.0.5"
|
||||||
|
|||||||
4
static/linux/postinst
Normal file
4
static/linux/postinst
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
chmod +x /opt/webtorrent-desktop/WebTorrent
|
||||||
|
ln -s /opt/webtorrent-desktop/WebTorrent /usr/bin/webtorrent-desktop
|
||||||
3
static/linux/postrm
Normal file
3
static/linux/postrm
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
rm /usr/bin/webtorrent-desktop
|
||||||
@@ -6,7 +6,7 @@ X-GNOME-FullName=$APP_NAME
|
|||||||
Comment=Download and share files over BitTorrent
|
Comment=Download and share files over BitTorrent
|
||||||
Encoding=UTF-8
|
Encoding=UTF-8
|
||||||
Type=Application
|
Type=Application
|
||||||
Icon=webtorrent
|
Icon=webtorrent-desktop
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Path=$APP_PATH
|
Path=$APP_PATH
|
||||||
Exec=$EXEC_PATH %U
|
Exec=$EXEC_PATH %U
|
||||||
Reference in New Issue
Block a user