Builds RPM packages using Node.js / io.js.
$ npm install rpm-builder
This module requires the rpmbuild
tool to be installed:
# fedora / cent os
$ yum install rpmdevtools
# ubuntu
$ apt-get install rpm
I recommend using Homebrew. Please check this quick guide.
var buildRpm = require('rpm-builder');
var options = {
name: 'my-project',
version: '0.0.0',
release: '1',
buildArch: 'noarch',
files: [
// will output files to
// /dist/dev/file1.txt
// /dist/dev/file2.txt
// /dist/dev/file3.txt
// /dist/dev/img1.png
// /dist/dev/img2.png
// /dist/dev/img3.png
{src: './dev/file1.txt', dest: '/dist/'},
{src: './dev/file2.txt', dest: '/dist/'}
{src: './dev/file3.txt', dest: '/dist/'}
{src: './dev/img1.png', dest: '/dist/'}
{src: './dev/img2.png', dest: '/dist/'}
{src: './dev/img3.png', dest: '/dist/'}
]
};
buildRpm(options, function(err, rpm) {
if (err) {
throw err;
}
console.log(rpm);
// /path/to/my-project-0.0.0-1.noarch.rpm
});
The cwd
attribute is used to define the working directory for an individual or set of files. When this attribute is set, src
entries are relative to the cwd
path.
var options = {
name: 'my-project',
version: '0.0.0',
release: '1',
buildArch: 'noarch',
files: [
// will output files to
// /dist/dev/file1.txt
// /dist/dev/file2.txt
// /dist/dev/file3.txt
// /dist/img1.png
// /dist/img2.png
// /dist/img3.png
{src: './dev/file1.txt', dest: '/dist/'},
{src: './dev/file2.txt', dest: '/dist/'}
{src: './dev/file3.txt', dest: '/dist/'}
{cwd: './dev/', src: 'img1.png', dest: '/dist/'}
{cwd: './dev/', src: 'img2.png', dest: '/dist/'}
{cwd: './dev/', src: 'img3.png', dest: '/dist/'}
]
};
Files can also be listed using the patterns that shell uses (we're relying on globby for this).
var options = {
name: 'my-project',
version: '0.0.0',
release: '1',
buildArch: 'noarch',
files: [
// will output files to
// /dist/dev/file1.txt
// /dist/dev/file2.txt
// /dist/dev/file3.txt
{src: './dev/*.txt', dest: '/dist/'},
]
};
var options = {
name: 'my-project',
version: '0.0.0',
release: '1',
buildArch: 'noarch',
files: [
// will output files to
// /dist/dev/img1.png
// /dist/dev/img2.png
// /dist/dev/img3.png
{src: './dev/img1.png', dest: '/dist/'},
{src: './dev/img2.png', dest: '/dist/'},
{src: './dev/img3.png', dest: '/dist/'},
{src: './dev/file1.txt', dest: '/dist/'},
{src: './dev/file2.txt', dest: '/dist/'}
{cwd: './dev/', src: 'file3.txt', dest: '/dist/'}
],
excludeFiles: [
'./dev/*.txt'
]
};
Type: Object
Type: Function
Args:
err
:null
||Error
.rpm
:String
||null
, path to the created RPM package.
String
(default: 'tmp-<auto_gen_id>'
)
Sets the temporary path name that stores the folder structure required by the rpmbuild
command. Note that this is used for setting up and building the package and does not affect the RPM itself.
Boolean
(default: false
)
If true will keep the temporary folder used to build the RPM. Useful for debugging.
String
(default: process.cwd()
)
After the RPM package is created, it'll be copied to the path specified here. If you don't want to copy the RPM package elsewhere just set it to false
, but be warned that if keepTemp === false
the whole folder will be removed, including the RPM package.
Boolean
(default: true
)
If true will log messages/progress to stdout
. Useful for debugging.
String
(default: 'no-name'
)
Sets the name tag in the RPM package. It's also used in the RPM file name.
String
(default: '0.0.0'
)
Sets the version tag in the RPM package. It's also used in the RPM file name.
String
| Number
(default: 1
)
Sets the release tag in the RPM package. It's also used in the RPM file name.
String
| Number
(default: ``)
The optional Epoch tag provides an ordering for the version numbers (replacing the deprecated Serial tag). Use this tag if RPM cannot figure out the ordering of which release comes after another.
String
(default: 'noarch'
)
Specifies the target architecture of the RPM package. It's also used in the RPM file name.
String
(default: 'No summary'
)
Sets the summary tag in the RPM package.
String
(default: 'No description'
)
Sets the description directive section in the RPM package.
String
(default: 'MIT'
)
Specifies the license tag in the RPM package.
String
(default: 'Vendor'
)
Sets the vendor tag in the RPM package.
String
Sets the packager tag in the RPM package.
String
(default: 'Development/Tools'
)
Specifies the group tag in the RPM package.
String
A URL to the project homepage or documentation of the project. Defined in the spec-file specification.
String
This will specify the relocatable root of the package so that it may be relocated by the user at install time. The manual entry for the prefix tag explains the use case quite well.
Array
Used to specify the locations the source code is provided by the developer(s). (Read more about this tag)[http://www.rpm.org/max-rpm-snapshot/s1-rpm-inside-tags.html].
Array
The patch tag is used to identify which patches are associated with the software being packaged. The patch files are kept in RPM's SOURCES directory, so only the name of the patch file should be specified.
Boolean
(default: true
)
These tags control automatic dependency processing while the package is being built. Their default state of true
is not a decision by this project but represents the default action taken by RPM. When both autoReq
and autoProv
are set to false
, the AutoReqProv
tag will instead be used with a value of
no
in the SPEC file.
Array
An array of packages that this package depends on (e.g. ["nodejs >= 0.10.22", "libpng"]
).
Array
An array of virtual packages that this package provides (e.g. ["nodejs", "libpng"]
).
Note that virtual packages may not have version numbers.
Array
An array of packages that this package conflicts with (e.g. ["cobol", "sparta > 300"]
).
Array
An array specifying which architectures to prevent the RPM from building on (e.g. ["sparc"]
).
Array
An array specifying only the architectures the RPM should build on (e.g. ["x86_64"]
).
Array
List of packages required for building (compiling) the program. You can specify a minimum version if necessary (e.g. ["ocaml >= 3.08"]
).
Array
An array of changelog entries in format:
{
date: Date,
author: String,
changes: Array<String>,
}
Example
const changelog = [
{
date: new Date('1995-12-17T03:24:00'),
author: 'John Foo <[email protected]>',
changes: [
'updated core library to 1.5.2',
'fixed API method `listUserContacts`'
]
},
{
date: new Date('1995-12-19T03:24:00'),
author: 'John Foo <[email protected]>',
changes: [
'established DB queries cache'
]
}
];
Array
The first script that RPM executes during a build. Each element in the array provided will be a line in the %prep
directive block of the SPEC file.
There are also some useful macros that can be used here.
Array
The build script is run after the prep script. Generally it is used for things like running make
.
Array
The install script is run after the build script and is used for running the commands that perform installation related tasks.
Array
The check script is run after the build script and is used for running the commands that perform installation checking tasks (test suites, etc.)
Array
The clean script is used to clean up the build directory tree. RPM usually does this automatically but this is especially useful for packages that specify a buildRoot
.
Array
An array of commands to be executed before the installation. Each element in the array represents a command.
Array
An array of commands to be executed after the installation. Each element in the array represents a command.
Array
An array of commands to be executed before uninstallation. Each element in the array represents a command.
Array
An array of commands to be executed after uninstallation. Each element in the array represents a command.
Array
This script is executed whenever the installed package is verified by RPMs verification command. Effectively, it should be used to verify the the correct installation of the package. Note that RPM already verifies the existence of the package's files along with their file attributes. Thus, the contents of this script should focus on other aspects of the installation.
$ npm test