From bda0cca8c2d62fb1c6753e99cd15c1c6742d804d Mon Sep 17 00:00:00 2001 From: hensm Date: Sun, 2 Dec 2018 09:56:01 +0000 Subject: [PATCH] Add .rpm package building --- app/bin/build.js | 41 +++++++++++++-------- app/package.json | 1 + app/packaging/linux/rpm/fx_cast_bridge.spec | 20 ++++++++++ 3 files changed, 46 insertions(+), 16 deletions(-) create mode 100644 app/packaging/linux/rpm/fx_cast_bridge.spec diff --git a/app/bin/build.js b/app/bin/build.js index ad21ceb..c2d454b 100644 --- a/app/bin/build.js +++ b/app/bin/build.js @@ -2,6 +2,7 @@ const fs = require("fs-extra"); const os = require("os"); const path = require("path"); const minimist = require("minimist"); +const glob = require("glob"); const { spawnSync } = require("child_process"); const { exec: pkgExec } = require("pkg"); @@ -82,10 +83,12 @@ async function build () { if (argv.package) { const installerName = await package(argv.platform); - // Move installer to dist - fs.moveSync(path.join(BUILD_PATH, installerName) - , path.join(DIST_PATH, installerName) - , { overwrite: true }); + if (installerName) { + // Move installer to dist + fs.moveSync(path.join(BUILD_PATH, installerName) + , path.join(DIST_PATH, path.basename(installerName)) + , { overwrite: true }); + } } else { // Move binary / app manifest fs.moveSync(path.join(BUILD_PATH, manifestName) @@ -130,10 +133,8 @@ function packageDarwin () { // Create pkgbuild root const rootPath = path.join(BUILD_PATH, "root"); - const rootExecutablePath = path.join(rootPath - , executablePath["darwin"]); - const rootManifestPath = path.join(rootPath - , manifestPath["darwin"]); + const rootExecutablePath = path.join(rootPath, executablePath["darwin"]); + const rootManifestPath = path.join(rootPath, manifestPath["darwin"]); // Create install locations fs.ensureDirSync(rootExecutablePath, { recursive: true }); @@ -171,14 +172,10 @@ function packageDarwin () { function packageLinuxDeb () { const installerName = "fx_cast_bridge.deb"; - const packagingDir = path.join(__dirname, "../packaging/linux/deb"); - // Create root const rootPath = path.join(BUILD_PATH, "root"); - const rootExecutablePath = path.join(rootPath - , executablePath["linux"]); - const rootManifestPath = path.join(rootPath - , manifestPath["linux"]); + const rootExecutablePath = path.join(rootPath, executablePath["linux"]); + const rootManifestPath = path.join(rootPath, manifestPath["linux"]); fs.ensureDirSync(rootExecutablePath, { recursive: true }); fs.ensureDirSync(rootManifestPath, { recursive: true }); @@ -190,7 +187,7 @@ function packageLinuxDeb () { , path.join(rootManifestPath, manifestName)); // Copy package info to root - fs.copySync(path.join(packagingDir, "DEBIAN") + fs.copySync(path.join(__dirname, "../packaging/linux/deb/DEBIAN/") , path.join(rootPath, "DEBIAN")); // Build .deb package @@ -202,7 +199,19 @@ function packageLinuxDeb () { return installerName; } -function packageLinuxRpm () {} +function packageLinuxRpm () { + const specPath = path.join(__dirname + , "../packaging/linux/rpm/fx_cast_bridge.spec"); + + spawnSync( + `rpmbuild -bb ${specPath} ` + + `--define "_distdir ${BUILD_PATH}" ` + + `--define "_rpmdir ${BUILD_PATH}" ` + , { shell: true }); + + return glob.sync("**/*.rpm", { cwd: BUILD_PATH })[0]; +} + function packageWin32 () {} diff --git a/app/package.json b/app/package.json index d1eb992..d65c5ab 100644 --- a/app/package.json +++ b/app/package.json @@ -23,6 +23,7 @@ "@babel/plugin-transform-runtime": "^7.0.0", "@babel/preset-env": "^7.0.0", "@babel/register": "^7.0.0", + "glob": "^7.1.3", "minimist": "^1.2.0", "pkg": "^4.3.4" }, diff --git a/app/packaging/linux/rpm/fx_cast_bridge.spec b/app/packaging/linux/rpm/fx_cast_bridge.spec new file mode 100644 index 0000000..d644e30 --- /dev/null +++ b/app/packaging/linux/rpm/fx_cast_bridge.spec @@ -0,0 +1,20 @@ +Name: fx_cast_bridge +Summary: fx_cast Bridge application +Version: 0.0.1 +Release: 1 +License: MIT + +%description +fx_cast Bridge application + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT/opt/fx_cast/ \ + $RPM_BUILD_ROOT/usr/lib/mozilla/native-messaging-hosts/ + +cp %{_distdir}/bridge $RPM_BUILD_ROOT/opt/fx_cast/ +cp %{_distdir}/fx_cast_bridge.json $RPM_BUILD_ROOT/usr/lib/mozilla/native-messaging-hosts/ + +%files +/opt/fx_cast/bridge +/usr/lib/mozilla/native-messaging-hosts/fx_cast_bridge.json