RPM maker for Electron Forge that builds .rpm package files for RedHat-based Linux distributions
npx @tessl/cli install tessl/npm-electron-forge--maker-rpm@7.8.0The @electron-forge/maker-rpm package provides an RPM maker for Electron Forge that builds .rpm package files for RedHat-based Linux distributions such as Fedora. It integrates with the Electron Forge build system to automatically package Electron applications as RPM packages with configurable metadata including package name, version, description, dependencies, desktop integration settings, and application categories.
npm install @electron-forge/maker-rpmThe package exports the following components:
MakerRpm - Main RPM maker class (named export)MakerRpmConfig - Configuration interface (named export)import { MakerRpm, MakerRpmConfig } from "@electron-forge/maker-rpm";For CommonJS:
const { MakerRpm, MakerRpmConfig } = require("@electron-forge/maker-rpm");The RPM maker is typically configured in an Electron Forge configuration file and used through the Forge build system:
// forge.config.js
module.exports = {
makers: [
{
name: '@electron-forge/maker-rpm',
config: {
options: {
name: 'my-electron-app',
productName: 'My Electron App',
description: 'An awesome Electron application',
homepage: 'https://example.com',
categories: ['Utility', 'Development'],
icon: './assets/icon.png'
}
}
}
]
};The RPM maker extends the base MakerBase class from @electron-forge/maker-base and provides:
electron-installer-redhat internally to generate RPM files@electron-forge/maker-base - Provides the base maker functionality@electron-forge/shared-types - Shared type definitions across Forge packageselectron-installer-redhat - Does the actual RPM package creationMain maker class that extends MakerBase to provide RPM package generation functionality.
export class MakerRpm extends MakerBase<MakerRpmConfig> {
/** Maker name identifier */
name: string; // Always "rpm"
/** Supported platforms for this maker */
defaultPlatforms: ForgePlatform[]; // ["linux"]
/** Required external binaries */
requiredExternalBinaries: string[]; // ["rpmbuild"]
/** Gets the actual platforms to build for */
get platforms(): ForgePlatform[];
/** Prepare configuration for the specified architecture */
prepareConfig(targetArch: ForgeArch): Promise<void>;
/** Check if maker is supported on current platform */
isSupportedOnCurrentPlatform(): boolean;
/** Create a copy of this maker instance */
clone(): MakerRpm;
/** Create RPM package files */
make(options: MakerOptions): Promise<string[]>;
/** Ensure a directory exists, creating it if necessary */
protected ensureDirectory(dir: string): Promise<void>;
/** Ensure a file exists, creating it if necessary */
protected ensureFile(file: string): Promise<void>;
/** Check if all required external binaries exist */
externalBinariesExist(): boolean;
/** Ensure all required external binaries exist, throwing if not */
ensureExternalBinariesExist(): void;
/** Check if a Node.js module is installed */
protected isInstalled(module: string): boolean;
/** Normalize Windows version strings for compatibility */
protected normalizeWindowsVersion(version: string): string;
}
interface MakerOptions {
/** Directory containing the packaged Electron application */
dir: string;
/** Directory to put all artifacts (potentially in sub folders) */
makeDir: string;
/** Human friendly name of the project */
appName: string;
/** Target platform to build for */
targetPlatform: ForgePlatform;
/** Target architecture to build for */
targetArch: ForgeArch;
/** Fully resolved forge configuration */
forgeConfig: ResolvedForgeConfig;
/** Application's package.json file */
packageJSON: any;
}
type ForgePlatform = "linux" | "win32" | "darwin" | "mas";
type ForgeArch = "ia32" | "x64" | "arm64" | "armv7l" | "arm";
interface ResolvedForgeConfig {
/** Build identifier for uniquely identifying artifacts */
buildIdentifier?: string | (() => string);
/** Output directory (default: './out') */
outDir?: string;
/** Forge hooks configuration */
hooks?: ForgeHookMap;
/** Plugin interface for internal use */
pluginInterface: IForgePluginInterface;
/** Array of Forge plugins */
plugins: ForgeConfigPlugin[];
/** Rebuild configuration options */
rebuildConfig: ForgeRebuildOptions;
/** Packager configuration options */
packagerConfig: ForgePackagerOptions;
/** Array of configured makers */
makers: ForgeConfigMaker[];
/** Array of configured publishers */
publishers: ForgeConfigPublisher[];
}
// Note: Complete type definitions for complex Forge types like ForgeHookMap,
// IForgePluginInterface, etc. are available in @electron-forge/shared-typesUsage Example:
import { MakerRpm } from "@electron-forge/maker-rpm";
// Note: RPM makers are typically configured in forge.config.js
// and instantiated automatically by the Forge build system.
// Direct instantiation is primarily for testing or advanced use cases.
const maker = new MakerRpm({
options: {
name: 'my-app',
productName: 'My Application'
}
});
// Check platform support
if (maker.isSupportedOnCurrentPlatform()) {
// Make method is called by Forge build system
const packagePaths = await maker.make({
dir: '/path/to/packaged/app',
makeDir: '/path/to/output',
appName: 'My App',
targetPlatform: 'linux',
targetArch: 'x64',
forgeConfig: config,
packageJSON: pkg
});
console.log('Created RPM packages:', packagePaths);
}The RPM maker internally converts Node.js/Electron architecture names to RPM architecture names using an internal rpmArch function. This function is not exported but is used internally during package creation.
Internal Architecture Mappings:
'ia32' → 'i386''x64' → 'x86_64''arm64' → 'aarch64''armv7l' → 'armv7hl''arm' → 'armv6hl'This mapping is applied automatically when you specify a targetArch in the MakerOptions.
Configuration interfaces that define RPM package metadata and options. The configuration is passed through the Electron Forge build system and extends the base MakerBase configuration pattern.
export interface MakerRpmConfig {
/** Configuration options for the RPM package */
options?: MakerRpmConfigOptions;
}
export interface MakerRpmConfigOptions {
/** Package name used in the Package field of the spec file */
name?: string;
/** Application display name used in the Name field of desktop specification */
productName?: string;
/** Generic application name for GenericName field of desktop specification */
genericName?: string;
/** Short description used in the Summary field of spec file */
description?: string;
/** Long description used in the %description tag of spec file */
productDescription?: string;
/** Version number used in the Version field of spec file */
version?: string;
/** Revision number used in the Release field of spec file */
revision?: string;
/** License used in the License field of spec file */
license?: string;
/** Group used in the Group field of spec file */
group?: string;
/** Runtime package dependencies for the Requires field */
requires?: string[];
/** Homepage URL for the package */
homepage?: string;
/** Package compression level from 0 to 9 */
compressionLevel?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
/** Relative path to executable for the Exec field of desktop specification */
bin?: string;
/** Command-line arguments for the executable */
execArguments?: string[];
/** Path to application icon */
icon?: string;
/** Desktop menu categories for the Categories field */
categories?: DesktopCategory[];
/** MIME types the application can open */
mimeType?: string[];
}
type DesktopCategory =
| "AudioVideo" | "Audio" | "Video"
| "Development" | "Education" | "Game"
| "Graphics" | "Network" | "Office"
| "Science" | "Settings" | "System"
| "Utility";Configuration Example:
const rpmConfig: MakerRpmConfig = {
options: {
name: 'electron-quick-edit',
productName: 'Quick Edit',
genericName: 'Text Editor',
description: 'A fast text editor built with Electron',
productDescription: 'Quick Edit is a lightweight, fast text editor designed for developers and writers who need a clean, distraction-free writing environment.',
homepage: 'https://quickedit.example.com',
license: 'MIT',
categories: ['Utility', 'Development'],
icon: './assets/icon.png',
requires: ['glibc >= 2.17'],
compressionLevel: 9,
mimeType: ['text/plain', 'text/markdown']
}
};rpmbuild binary must be installedelectron-installer-redhat package must be availableThe make() method returns a Promise<string[]> containing absolute paths to the generated .rpm files. File names follow the pattern: <name>-<version>-<revision>.<arch>.rpm
The maker will throw errors in the following cases:
rpmbuild binary is not installed on the systemelectron-installer-redhat package is not available