Linux build: Fix incorrect log output (#381)
Now we use a function closure to capture the `destArch` variable so the for loop can't change it.
This commit is contained in:
@@ -291,51 +291,59 @@ function buildWin32 (cb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildLinux (packageType, cb) {
|
function buildLinux (packageType, cb) {
|
||||||
|
var distPath = path.join(config.ROOT_PATH, 'dist')
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
var distPath = path.join(config.ROOT_PATH, 'dist')
|
|
||||||
|
|
||||||
for (var i = 0; i < buildPath.length; i++) {
|
for (var i = 0; i < buildPath.length; i++) {
|
||||||
var filesPath = buildPath[i]
|
var filesPath = buildPath[i]
|
||||||
var destArch = filesPath.split('-').pop()
|
var destArch = filesPath.split('-').pop()
|
||||||
|
|
||||||
if (packageType === 'deb' || packageType === 'all') {
|
if (packageType === 'deb' || packageType === 'all') {
|
||||||
// Create .deb file for debian based platforms
|
packageDeb(filesPath, destArch)
|
||||||
var deb = require('nobin-debian-installer')()
|
|
||||||
var destPath = path.join('/opt', pkg.name)
|
|
||||||
|
|
||||||
deb.pack({
|
|
||||||
package: pkg,
|
|
||||||
info: {
|
|
||||||
arch: destArch === 'x64' ? 'amd64' : 'i386',
|
|
||||||
targetDir: distPath,
|
|
||||||
depends: 'libc6 (>= 2.4)',
|
|
||||||
scripts: {
|
|
||||||
postinst: path.join(config.STATIC_PATH, 'linux', 'postinst'),
|
|
||||||
prerm: path.join(config.STATIC_PATH, 'linux', 'prerm')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [{
|
|
||||||
src: ['./**'],
|
|
||||||
dest: destPath,
|
|
||||||
expand: true,
|
|
||||||
cwd: filesPath
|
|
||||||
}], function (err, done) {
|
|
||||||
if (err) return console.error(err.message || err)
|
|
||||||
console.log('Created Linux ' + destArch + ' .deb file.')
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packageType === 'zip' || packageType === 'all') {
|
if (packageType === 'zip' || packageType === 'all') {
|
||||||
// Create .zip file for Linux
|
packageZip(filesPath, destArch)
|
||||||
var zipPath = path.join(config.ROOT_PATH, 'dist', BUILD_NAME + '-linux-' + destArch + '.zip')
|
|
||||||
var appFolderName = path.basename(filesPath)
|
|
||||||
cp.execSync(`cd ${distPath} && zip -r -y ${zipPath} ${appFolderName}`)
|
|
||||||
console.log('Created Linux ' + destArch + ' .zip file.')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function packageDeb (filesPath, destArch) {
|
||||||
|
// 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: destArch === 'x64' ? 'amd64' : 'i386',
|
||||||
|
targetDir: distPath,
|
||||||
|
depends: 'libc6 (>= 2.4)',
|
||||||
|
scripts: {
|
||||||
|
postinst: path.join(config.STATIC_PATH, 'linux', 'postinst'),
|
||||||
|
prerm: path.join(config.STATIC_PATH, 'linux', 'prerm')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [{
|
||||||
|
src: ['./**'],
|
||||||
|
dest: destPath,
|
||||||
|
expand: true,
|
||||||
|
cwd: filesPath
|
||||||
|
}], function (err) {
|
||||||
|
if (err) return console.error(err.message || err)
|
||||||
|
console.log('Created Linux ' + destArch + ' .deb file.')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function packageZip (filesPath, destArch) {
|
||||||
|
// Create .zip file for Linux
|
||||||
|
var zipPath = path.join(config.ROOT_PATH, 'dist', BUILD_NAME + '-linux-' + destArch + '.zip')
|
||||||
|
var appFolderName = path.basename(filesPath)
|
||||||
|
cp.execSync(`cd ${distPath} && zip -r -y ${zipPath} ${appFolderName}`)
|
||||||
|
console.log('Created Linux ' + destArch + ' .zip file.')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function printDone (err, buildPath) {
|
function printDone (err, buildPath) {
|
||||||
|
|||||||
Reference in New Issue
Block a user