Skip to content

Commit 7fb9c52

Browse files
committed
Updated gulp build (added rpm build and fixed linux build on macOS)
1 parent 9da966f commit 7fb9c52

File tree

3 files changed

+1258
-329
lines changed

3 files changed

+1258
-329
lines changed

gulpfile.js

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const del = require('del');
1111
const NwBuilder = require('nw-builder');
1212
const makensis = require('makensis');
1313
const deb = require('gulp-debian');
14+
const commandExistsSync = require('command-exists').sync;
1415

1516
const gulp = require('gulp');
1617
const concat = require('gulp-concat');
@@ -470,7 +471,12 @@ function compressFiles(srcPath, basePath, outputFile, zipFolder) {
470471
.pipe(gulp.dest(RELEASE_DIR));
471472
}
472473

473-
function release_deb(arch) {
474+
function release_deb(arch, done) {
475+
// Check if dpkg-deb exists
476+
if (!commandExistsSync('dpkg-deb')) {
477+
console.warn('dpkg-deb command not found, not generating deb package for ' + arch);
478+
return done();
479+
}
474480

475481
var debArch;
476482

@@ -507,6 +513,46 @@ function release_deb(arch) {
507513
}));
508514
}
509515

516+
function release_rpm(arch, done) {
517+
518+
// Check if dpkg-deb exists
519+
if (!commandExistsSync('rpmbuild')) {
520+
console.warn('rpmbuild command not found, not generating rpm package for ' + arch);
521+
return done();
522+
}
523+
524+
// The buildRpm does not generate the folder correctly, manually
525+
createDirIfNotExists(RELEASE_DIR);
526+
527+
var options = {
528+
name: pkg.name,
529+
version: pkg.version,
530+
buildArch: getLinuxPackageArch('rpm', arch),
531+
vendor: pkg.author,
532+
summary: pkg.description,
533+
license: 'GNU General Public License v3.0',
534+
requires: 'libgconf-2-4',
535+
prefix: '/opt',
536+
files:
537+
[ { cwd: path.join(APPS_DIR, pkg.name, arch),
538+
src: '*',
539+
dest: '/opt/betaflight/blackbox-log-viewer' } ],
540+
postInstallScript: ['xdg-desktop-menu install /opt/betaflight/blackbox-log-viewer/blackbox-log-viewer.desktop'],
541+
preUninstallScript: ['xdg-desktop-menu uninstall blackbox-log-viewer.desktop'],
542+
tempDir: path.join(RELEASE_DIR,'tmp-rpm-build-' + arch),
543+
keepTemp: false,
544+
verbose: false,
545+
rpmDest: RELEASE_DIR
546+
};
547+
548+
buildRpm(options, function(err, rpm) {
549+
if (err) {
550+
console.error("Error generating rpm package: " + err);
551+
}
552+
done();
553+
});
554+
}
555+
510556
// Create distribution package for macOS platform
511557
function release_osx64() {
512558
var appdmg = require('gulp-appdmg');
@@ -564,12 +610,14 @@ function listReleaseTasks(done) {
564610

565611
if (platforms.indexOf('linux64') !== -1) {
566612
releaseTasks.push(function release_linux64_zip(){ return release_zip('linux64') });
567-
releaseTasks.push(function release_linux64_deb(){ return release_deb('linux64') });
613+
releaseTasks.push(function release_linux64_deb(done){ return release_deb('linux64', done) });
614+
releaseTasks.push(function release_linux64_rpm(done){ return release_rpm('linux64', done) });
568615
}
569616

570617
if (platforms.indexOf('linux32') !== -1) {
571618
releaseTasks.push(function release_linux32_zip(){ return release_zip('linux32') });
572-
releaseTasks.push(function release_linux32_deb(){ return release_deb('linux32') });
619+
releaseTasks.push(function release_linux32_deb(done){ return release_deb('linux32', done) });
620+
releaseTasks.push(function release_linux32_rpm(done){ return release_rpm('linux32', done) });
573621
}
574622

575623
if (platforms.indexOf('osx64') !== -1) {

0 commit comments

Comments
 (0)