UNPKG

1.55 kBPlain TextView Raw
1import path from 'path';
2
3import { MakerBase, MakerOptions } from '@electron-forge/maker-base';
4import { ForgeArch, ForgePlatform } from '@electron-forge/shared-types';
5
6import { MakerRpmConfig } from './Config';
7
8function renameRpm(dest: string, _src: string): string {
9 return path.join(dest, '<%= name %>-<%= version %>-<%= revision %>.<%= arch === "aarch64" ? "arm64" : arch %>.rpm');
10}
11
12export function rpmArch(nodeArch: ForgeArch): string {
13 switch (nodeArch) {
14 case 'ia32':
15 return 'i386';
16 case 'x64':
17 return 'x86_64';
18 case 'arm64':
19 return 'aarch64';
20 case 'armv7l':
21 return 'armv7hl';
22 case 'arm':
23 return 'armv6hl';
24 default:
25 return nodeArch;
26 }
27}
28
29export default class MakerRpm extends MakerBase<MakerRpmConfig> {
30 name = 'rpm';
31
32 defaultPlatforms: ForgePlatform[] = ['linux'];
33
34 requiredExternalBinaries: string[] = ['rpmbuild'];
35
36 isSupportedOnCurrentPlatform(): boolean {
37 return this.isInstalled('electron-installer-redhat');
38 }
39
40 async make({ dir, makeDir, targetArch }: MakerOptions): Promise<string[]> {
41 // eslint-disable-next-line node/no-missing-require
42 const installer = require('electron-installer-redhat');
43
44 const outDir = path.resolve(makeDir, 'rpm', targetArch);
45
46 await this.ensureDirectory(outDir);
47 const { packagePaths } = await installer({
48 ...this.config,
49 arch: rpmArch(targetArch),
50 src: dir,
51 dest: outDir,
52 rename: renameRpm,
53 });
54 return packagePaths;
55 }
56}
57
58export { MakerRpm, MakerRpmConfig };