Files
iptvnator/tools/packaging/linux-launcher-layout.cjs
4gray c266eaa680 fix(packaging): preserve Flatpak Electron ELF for Zypak (#1205)
Fixes the launcher/Zypak regression reported in #1203. The additional GPU/video.js behavior remains tracked separately in that issue.
2026-07-18 22:42:45 +02:00

57 lines
1.6 KiB
JavaScript

'use strict';
function normalizedTargetName(target) {
const value =
typeof target === 'string'
? target
: target && typeof target === 'object'
? target.name
: null;
if (typeof value !== 'string' || value.trim() === '') {
throw new Error('Linux launcher targets must expose a non-empty name.');
}
return value.trim().toLowerCase();
}
function resolveLinuxLauncherLayout(targets, executableName = 'iptvnator') {
if (!Array.isArray(targets)) {
throw new TypeError('Linux launcher targets must be an array.');
}
if (targets.length === 0) {
throw new Error(
'Linux launcher targets must contain at least one target.'
);
}
const targetNames = [];
for (const target of targets) {
const targetName = normalizedTargetName(target);
if (targetNames.includes(targetName)) {
throw new Error(
`Linux launcher target "${targetName}" is duplicated.`
);
}
targetNames.push(targetName);
}
const flatpakSelected = targetNames.includes('flatpak');
if (flatpakSelected && targetNames.length !== 1) {
throw new Error(
'Flatpak must be packaged in an isolated Electron Builder pass so Zypak receives the Electron ELF directly.'
);
}
const wrapperRequired = !flatpakSelected;
return {
targetNames,
electronBinaryName: wrapperRequired
? `${executableName}.bin`
: executableName,
wrapperRequired,
};
}
module.exports = {
resolveLinuxLauncherLayout,
};