Skip to content

Commit 6c9fdca

Browse files
authored
Merge pull request #105 from basdelfos/gulp-build
Updated gulp build (added rpm build and fixed linux build on macOS)
2 parents 7f884c9 + 137b832 commit 6c9fdca

File tree

3 files changed

+596
-318
lines changed

3 files changed

+596
-318
lines changed

gulpfile.js

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

1517
const gulp = require('gulp');
1618
const concat = require('gulp-concat');
@@ -470,7 +472,12 @@ function compressFiles(srcPath, basePath, outputFile, zipFolder) {
470472
.pipe(gulp.dest(RELEASE_DIR));
471473
}
472474

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

475482
var debArch;
476483

@@ -507,6 +514,46 @@ function release_deb(arch) {
507514
}));
508515
}
509516

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

588+
function getLinuxPackageArch(type, arch) {
589+
var packArch;
590+
591+
switch (arch) {
592+
case 'linux32':
593+
packArch = 'i386';
594+
break;
595+
case 'linux64':
596+
if (type == 'rpm') {
597+
packArch = 'x86_64';
598+
} else {
599+
packArch = 'amd64';
600+
}
601+
break;
602+
default:
603+
console.error("Package error, arch: " + arch);
604+
process.exit(1);
605+
break;
606+
}
607+
608+
return packArch;
609+
}
610+
541611
// Create the dir directory, with write permissions
542612
function createDirIfNotExists(dir) {
543613
fs.mkdir(dir, '0775', function(err) {
@@ -564,12 +634,14 @@ function listReleaseTasks(done) {
564634

565635
if (platforms.indexOf('linux64') !== -1) {
566636
releaseTasks.push(function release_linux64_zip(){ return release_zip('linux64') });
567-
releaseTasks.push(function release_linux64_deb(){ return release_deb('linux64') });
637+
releaseTasks.push(function release_linux64_deb(done){ return release_deb('linux64', done) });
638+
releaseTasks.push(function release_linux64_rpm(done){ return release_rpm('linux64', done) });
568639
}
569640

570641
if (platforms.indexOf('linux32') !== -1) {
571642
releaseTasks.push(function release_linux32_zip(){ return release_zip('linux32') });
572-
releaseTasks.push(function release_linux32_deb(){ return release_deb('linux32') });
643+
releaseTasks.push(function release_linux32_deb(done){ return release_deb('linux32', done) });
644+
releaseTasks.push(function release_linux32_rpm(done){ return release_rpm('linux32', done) });
573645
}
574646

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

0 commit comments

Comments
 (0)