RPM Builder

1.2.1 · abandoned · verified Tue Apr 21

RPM Builder is a Node.js library designed to create Red Hat Package Manager (RPM) packages programmatically. It wraps the underlying `rpmbuild` system utility, abstracting away the complexities of direct command-line execution and spec file generation. The package allows developers to define package metadata, specify files, handle glob patterns, and exclude files using a simple JavaScript API. The current stable version is 1.2.1, released over six years ago, and the package is effectively abandoned, meaning no further updates, feature enhancements, or security patches are expected. Its primary differentiator is providing a native Node.js interface for RPM creation, which can be integrated into CI/CD pipelines for projects requiring RPM distribution artifacts. It simplifies the packaging process compared to manually creating `.spec` files and executing `rpmbuild` commands.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `rpm-builder` to create a basic RPM package containing a Node.js application script and a configuration file, including necessary temporary file setup and cleanup.

const buildRpm = require('rpm-builder');
const path = require('path');
const fs = require('fs');

// Create some dummy files for the RPM
const tempDir = path.join(__dirname, 'temp_app_files');
fs.mkdirSync(tempDir, { recursive: true });
fs.writeFileSync(path.join(tempDir, 'app.js'), 'console.log("Hello RPM!");');
fs.writeFileSync(path.join(tempDir, 'config.json'), '{ "port": 3000 }');

const options = {
  name: 'my-node-application',
  version: '1.0.0',
  release: '1',
  summary: 'A simple Node.js application packaged as an RPM',
  description: 'This RPM contains a basic Node.js script and a configuration file.',
  group: 'Development/Tools',
  license: 'MIT',
  vendor: 'MyCompany',
  buildArch: 'noarch',
  files: [
    { src: path.join(tempDir, 'app.js'), dest: '/usr/local/bin/my-app/app.js' },
    { src: path.join(tempDir, 'config.json'), dest: '/etc/my-app/config.json' }
  ],
  // Optional: Set a temporary directory, will be cleaned up by default
  tempDir: path.join(__dirname, 'rpm_build_tmp'),
  // Optional: Keep the temporary directory for inspection after build
  keepTemp: false
};

buildRpm(options, function(err, rpmPath) {
  // Clean up dummy files after attempting RPM build
  fs.rmSync(tempDir, { recursive: true, force: true });
  if (options.tempDir && !options.keepTemp) {
    fs.rmSync(options.tempDir, { recursive: true, force: true });
  }

  if (err) {
    console.error('Failed to build RPM:', err);
    return;
  }
  console.log('Successfully built RPM:', rpmPath);
  // Example: mv ' + rpmPath + ' /path/to/my/rpms/new-package.rpm
});

view raw JSON →