mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-12 10:39:57 +00:00
Add .deb package building
This commit is contained in:
151
app/bin/build.js
151
app/bin/build.js
@@ -16,10 +16,12 @@ const { executableName
|
|||||||
|
|
||||||
const argv = minimist(process.argv.slice(2), {
|
const argv = minimist(process.argv.slice(2), {
|
||||||
boolean: [ "package" ]
|
boolean: [ "package" ]
|
||||||
, string: [ "platform" ]
|
, string: [ "platform", "packageType" ]
|
||||||
, default: {
|
, default: {
|
||||||
platform: os.platform()
|
platform: os.platform()
|
||||||
, package: false
|
, package: false
|
||||||
|
// Linux package type (deb/rpm)
|
||||||
|
, packageType: "deb"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -27,6 +29,7 @@ const BUILD_PATH = path.join(__dirname, "../build");
|
|||||||
|
|
||||||
|
|
||||||
// Clean
|
// Clean
|
||||||
|
fs.removeSync(BUILD_PATH);
|
||||||
fs.removeSync(DIST_PATH);
|
fs.removeSync(DIST_PATH);
|
||||||
|
|
||||||
// Make directories
|
// Make directories
|
||||||
@@ -77,7 +80,7 @@ async function build () {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if (argv.package) {
|
if (argv.package) {
|
||||||
const installerName = await buildInstaller(argv.platform);
|
const installerName = await package(argv.platform);
|
||||||
|
|
||||||
// Move installer to dist
|
// Move installer to dist
|
||||||
fs.moveSync(path.join(BUILD_PATH, installerName)
|
fs.moveSync(path.join(BUILD_PATH, installerName)
|
||||||
@@ -97,64 +100,112 @@ async function build () {
|
|||||||
fs.removeSync(BUILD_PATH);
|
fs.removeSync(BUILD_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildInstaller (platform) {
|
|
||||||
|
function package (platform) {
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case "darwin": {
|
case "darwin":
|
||||||
const installerName = "fx_cast_bridge.pkg";
|
return packageDarwin();
|
||||||
const componentName = "fx_cast_bridge_default.pkg";
|
|
||||||
const installerPath = path.join(BUILD_PATH, installerName);
|
|
||||||
const componentPath = path.join(BUILD_PATH, componentName);
|
|
||||||
|
|
||||||
const packagingDir = path.join(__dirname, "../packaging/macos/");
|
case "linux":
|
||||||
|
switch (argv.packageType) {
|
||||||
// Create pkgbuild root
|
case "deb":
|
||||||
const rootPath = path.join(BUILD_PATH, "root");
|
return packageLinuxDeb();
|
||||||
const rootExecutablePath = path.join(rootPath
|
case "rpm":
|
||||||
, executablePath[platform]);
|
return packageLinuxRpm();
|
||||||
const rootManifestPath = path.join(rootPath
|
}
|
||||||
, manifestPath[platform]);
|
|
||||||
|
|
||||||
// Create install locations
|
|
||||||
fs.ensureDirSync(rootExecutablePath, { recursive: true });
|
|
||||||
fs.ensureDirSync(rootManifestPath, { recursive: true });
|
|
||||||
|
|
||||||
// Move files to root
|
|
||||||
fs.moveSync(path.join(BUILD_PATH, executableName[platform])
|
|
||||||
, path.join(rootExecutablePath, executableName[platform]));
|
|
||||||
fs.moveSync(path.join(BUILD_PATH, manifestName)
|
|
||||||
, path.join(rootManifestPath, manifestName));
|
|
||||||
|
|
||||||
// Build component package
|
|
||||||
spawnSync(
|
|
||||||
`pkgbuild --root ${rootPath} `
|
|
||||||
+ `--identifier "tf.matt.fx_cast_bridge" `
|
|
||||||
+ `--version "0.0.1" `
|
|
||||||
+ `--scripts ${path.join(packagingDir, "scripts")} `
|
|
||||||
+ `${componentPath}`
|
|
||||||
, { shell: true });
|
|
||||||
|
|
||||||
// Distribution XML file
|
|
||||||
const distFilePath = path.join(packagingDir, "distribution.xml");
|
|
||||||
|
|
||||||
// Build installer package
|
|
||||||
spawnSync(
|
|
||||||
`productbuild --distribution ${distFilePath} `
|
|
||||||
+ `--package-path ${BUILD_PATH} `
|
|
||||||
+ `${installerPath}`
|
|
||||||
, { shell: true });
|
|
||||||
|
|
||||||
return installerName;
|
|
||||||
};
|
|
||||||
|
|
||||||
case "win32":
|
case "win32":
|
||||||
case "linux":
|
return packageWin32();
|
||||||
// TODO: installers
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
console.log("Cannot build installer package for this platform");
|
console.log("Cannot build installer package for this platform");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function packageDarwin () {
|
||||||
|
const installerName = "fx_cast_bridge.pkg";
|
||||||
|
const componentName = "fx_cast_bridge_component.pkg";
|
||||||
|
|
||||||
|
const packagingDir = path.join(__dirname, "../packaging/mac/");
|
||||||
|
|
||||||
|
// Create pkgbuild root
|
||||||
|
const rootPath = path.join(BUILD_PATH, "root");
|
||||||
|
const rootExecutablePath = path.join(rootPath
|
||||||
|
, executablePath["darwin"]);
|
||||||
|
const rootManifestPath = path.join(rootPath
|
||||||
|
, manifestPath["darwin"]);
|
||||||
|
|
||||||
|
// Create install locations
|
||||||
|
fs.ensureDirSync(rootExecutablePath, { recursive: true });
|
||||||
|
fs.ensureDirSync(rootManifestPath, { recursive: true });
|
||||||
|
|
||||||
|
// Move files to root
|
||||||
|
fs.moveSync(path.join(BUILD_PATH, executableName["darwin"])
|
||||||
|
, path.join(rootExecutablePath, executableName["darwin"]));
|
||||||
|
fs.moveSync(path.join(BUILD_PATH, manifestName)
|
||||||
|
, path.join(rootManifestPath, manifestName));
|
||||||
|
|
||||||
|
// Build component package
|
||||||
|
spawnSync(
|
||||||
|
`pkgbuild --root ${rootPath} `
|
||||||
|
+ `--identifier "tf.matt.fx_cast_bridge" `
|
||||||
|
+ `--version "0.0.1" `
|
||||||
|
+ `--scripts ${path.join(packagingDir, "scripts")} `
|
||||||
|
+ `${path.join(BUILD_PATH, componentName)}`
|
||||||
|
, { shell: true });
|
||||||
|
|
||||||
|
// Distribution XML file
|
||||||
|
const distFilePath = path.join(packagingDir, "distribution.xml");
|
||||||
|
|
||||||
|
// Build installer package
|
||||||
|
spawnSync(
|
||||||
|
`productbuild --distribution ${distFilePath} `
|
||||||
|
+ `--package-path ${BUILD_PATH} `
|
||||||
|
+ `${path.join(BUILD_PATH, installerName)}`
|
||||||
|
, { shell: true });
|
||||||
|
|
||||||
|
return installerName;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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"]);
|
||||||
|
|
||||||
|
fs.ensureDirSync(rootExecutablePath, { recursive: true });
|
||||||
|
fs.ensureDirSync(rootManifestPath, { recursive: true });
|
||||||
|
|
||||||
|
// Move files to root
|
||||||
|
fs.moveSync(path.join(BUILD_PATH, executableName["linux"])
|
||||||
|
, path.join(rootExecutablePath, executableName["linux"]));
|
||||||
|
fs.moveSync(path.join(BUILD_PATH, manifestName)
|
||||||
|
, path.join(rootManifestPath, manifestName));
|
||||||
|
|
||||||
|
// Copy package info to root
|
||||||
|
fs.copySync(path.join(packagingDir, "DEBIAN")
|
||||||
|
, path.join(rootPath, "DEBIAN"));
|
||||||
|
|
||||||
|
// Build .deb package
|
||||||
|
spawnSync(
|
||||||
|
`dpkg-deb --build ${rootPath} `
|
||||||
|
+ `${path.join(BUILD_PATH, installerName)}`
|
||||||
|
, { shell: true});
|
||||||
|
|
||||||
|
return installerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
function packageLinuxRpm () {}
|
||||||
|
function packageWin32 () {}
|
||||||
|
|
||||||
|
|
||||||
build().catch(e => {
|
build().catch(e => {
|
||||||
console.log("Build failed", e);
|
console.log("Build failed", e);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ exports.executablePath = {
|
|||||||
exports.manifestName = "fx_cast_bridge.json";
|
exports.manifestName = "fx_cast_bridge.json";
|
||||||
|
|
||||||
exports.manifestPath = {
|
exports.manifestPath = {
|
||||||
darwin: "/Library/Application Support/Mozilla/NativeMessagingHosts/"
|
win32: "C:\\Program Files\\fx_cast\\"
|
||||||
, linux: ".mozilla/native-messaging-hosts/"
|
, darwin: "/Library/Application Support/Mozilla/NativeMessagingHosts/"
|
||||||
, win32: "C:\\Program Files\\fx_cast\\"
|
, linux: "/usr/lib/mozilla/native-messaging-hosts/"
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.pkgPlatform = {
|
exports.pkgPlatform = {
|
||||||
|
|||||||
5
app/packaging/linux/deb/DEBIAN/control
Normal file
5
app/packaging/linux/deb/DEBIAN/control
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Package: fx-cast-bridge
|
||||||
|
Version: 0.0.1
|
||||||
|
Priority: optional
|
||||||
|
Architecture: amd64
|
||||||
|
Description: fx_cast Bridge application
|
||||||
Reference in New Issue
Block a user