"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MakerRpm = exports.rpmArch = void 0;
const path_1 = __importDefault(require("path"));
const maker_base_1 = require("@electron-forge/maker-base");
function renameRpm(dest, _src) {
    return path_1.default.join(dest, '<%= name %>-<%= version %>-<%= revision %>.<%= arch === "aarch64" ? "arm64" : arch %>.rpm');
}
function rpmArch(nodeArch) {
    switch (nodeArch) {
        case 'ia32':
            return 'i386';
        case 'x64':
            return 'x86_64';
        case 'arm64':
            return 'aarch64';
        case 'armv7l':
            return 'armv7hl';
        case 'arm':
            return 'armv6hl';
        default:
            return nodeArch;
    }
}
exports.rpmArch = rpmArch;
class MakerRpm extends maker_base_1.MakerBase {
    constructor() {
        super(...arguments);
        this.name = 'rpm';
        this.defaultPlatforms = ['linux'];
        this.requiredExternalBinaries = ['rpmbuild'];
    }
    isSupportedOnCurrentPlatform() {
        return this.isInstalled('electron-installer-redhat');
    }
    async make({ dir, makeDir, targetArch }) {
        // eslint-disable-next-line node/no-missing-require
        const installer = require('electron-installer-redhat');
        const outDir = path_1.default.resolve(makeDir, 'rpm', targetArch);
        await this.ensureDirectory(outDir);
        const { packagePaths } = await installer({
            ...this.config,
            arch: rpmArch(targetArch),
            src: dir,
            dest: outDir,
            rename: renameRpm,
        });
        return packagePaths;
    }
}
exports.default = MakerRpm;
exports.MakerRpm = MakerRpm;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFrZXJScG0uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvTWFrZXJScG0udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsZ0RBQXdCO0FBRXhCLDJEQUFxRTtBQUtyRSxTQUFTLFNBQVMsQ0FBQyxJQUFZLEVBQUUsSUFBWTtJQUMzQyxPQUFPLGNBQUksQ0FB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