npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-brass

v0.1.11

Published

Build RPM package

Downloads

168

Readme

gulp-brass

Build Status NPM Version

Build RPM package.

Introduction

This is a wrapper around rpmbuild command and SPEC file generator done in gulp way. It covers subset of RPM features required to package, deploy, and run application on (usually) server. That is, it's possible but not encouraged to to use gulp-brass as a tool to package software for publishing to end users. On the contrary, you should see gulp-brass as deployment tool for, but not limited to, your own applications.

gulp-brass follows gulp pattern gulp.src(...) -> transform -> gulp.dest(...). From this pattern emerges core gulp-brass API design principle: sane defaults and extensibility over configuration. Following this, provided SPEC file and service file templates are and will be kept at bare minimum. If you want to extend them, you should copy and modify provided files or write your own from scratch and pass them to gulp.src(...). Not so rare example cases would be adding pre/post install/uninstall hooks to SPEC file or using advanced systemd features.

How to use

Below is API documentation but it's highly recommended look at examples to see how gulpfile might look as a whole.

FAQ

Q: How to create user during RPM installation?

A: See example.

Q: How to customize systemd unit file?

A: See example.

Q: I need feature X to be added to spec/unit file

A: These files are meant to be extended by user. See examples above.

RPM

var brass = require('gulp-brass');

brass.create(options)

var rpm = brass.create(options);

Options that represent SPEC file tags (see more information on SPEC tags):

  • type (default: rpm) - for now only RPM is supported.
  • name - name of the software being packaged.
  • version - version of the software being packaged.
  • license - license of software being packaged.
  • summary - one-line description of the packaged software.
  • description - in-depth description of the packaged software.
  • release (default: 1) - package's version.
  • url (optional) - URL that can be used to obtain additional information about the packaged software.

Other options:

  • prefix (default: /usr, optional) - prefix where to install binaries. It's not used by gulp-brass but intended to be used by plugins. For example, it's used by gulp-brass-npm.

Service options (see more information on services):

  • service.type - service type, eg: systemd, sysv, upstart.
  • service.name - name of the service to be installed.
  • service.summary - one-line description of service. Used only by sysv.
  • service.description - description of service.
  • service.exec - command with arguments that are executed when the service is started.
  • service.user - user that the service process is executed as.
  • service.group - group that the service process is executed as.

This is recommended service object structure and it's expected by default service file templates and plugins, eg. gulp-brass-npm.

rpm.options

An object that contains merged default option and options passed to brass.create(). It can be modified to adjust settings after brass.create() was called.

rpm.globOptions

Returns an options object to be passed to gulp.src(globs[, options]) when the sources of software being packaged are unpacked to BUILD directory. It's value always is:

{
  mark: true,
  cwd: rpm.buildDir_BUILD,
  base: rpm.buildDir_BUILD
}

rpm.buildDir_*

rpmbuild uses five special purpose directories in which performs build: SOURCES, SPECS, BUILD, RPMS, SRPMS. See more information on build directory structure.

  • SOURCES is not used by gulp-brass.
  • SPECS contains SPEC file. rpm.specTask() places SPEC file to this directory and rpm.buildTask() runs rpmbuild against that file. Customized SPEC file also should be placed to this directory.
  • BUILD is the directory for unpacked sources and software building. Although it's not necessary to use this directory at all, but it's the place to build or put built software when using one build system for building software, and gulp only for packaging it to RPM.
  • RPMS contains built RPM file.
  • RPMS is not used by gulp-brass.

rpm.buildRoot

This directory represents root directory on the machine the RPM will be installed to. Hence, all packaged files should be placed to subdirectories of rpm.buildRoot.

Example:

File thefile upon RPM install will be placed to /usr/bin/thefile.

gulp.src('thefile')
gulp.pipe(gulp.dest(path.join(rpm.buildRoot, 'usr/bin')))
gulp.pipe(rpm.files())

rpm.setupTask()

Returns gulp task for rpm.setup().

This task is recommended way to run setup since rpm.setup() doesn't return stream, hence there's nothing to customize.

rpm.setup(callback)

Creates build directory (./brass_build) and directory structure required by rpmbuild in it.

rpm.files()

Returns transform stream which registers piped files to be listed in SPEC file. All packaged files must be piped to this stream. Always pipe after gulp.dest().

rpm.specTask()

Returns gulp task which renders default SPEC file template.

Use this task if you're not going to customize SPEC file.

rpm.spec()

Returns transform stream which renders piped SPEC file template. Before rendering template it populates rpm.options.specFileList with rpm.renderFileList() output.

rpm.buildTask()

Returns gulp task which runs rpmbuild against SPEC file.

This task is recommended way to run build since rpm.build() doesn't accept any customizations.

rpm.build()

Returns transform stream which runs rpmbuild against piped SPEC files.

rpm.renderFileList()

Returns registered files list with inlined attributes as string to be used in %files section in SPEC file. See section vinyl extension.

Utils

var util = brass.util;

util.assets(filename)

Returns path to internal asset. Intended to use with gulp.src().

util.stream(callback, flush)

Returns transform stream in object mode.

Callback arguments are callback(file, callback).

Flush arguments are flush(callback).

util.template(data)

Returns stream that renders piped vinyl objects as templates with provided data. Uses handlebars template engine and handlebars-helper-equal helper.

util.symlink(name, [options])

Returns stream that makes symlinks to name path like $ ln -s target name. If name is an array, it iterates to next name with each file.

Options:

  • deep - if true, makes symlink for each name to each piped file. This is convenient when you need to have few symlinks to same file.

Services

gulp-brass comes with service file templates since often packaged software installations run as system services. Service file should be placed to corresponding service file directory and registered as packaged file. gulp task that does these steps may look like this:

gulp.task('service', [ 'setup' ], function () {
    return gulp.src(brass.util.assets('service/systemd'))
    .pipe(brass.util.template(options.service))
    .pipe(brass.util.rename(options.service.name +'.service'))
    .pipe(gulp.dest(path.join(rpm.buildRoot, '/lib/systemd/system')))
    .pipe(rpm.files());
});

Vinyl extensions

rpm.renderFileList() uses some vinyl file object extensions:

  • file.attr ([ mode, user, group ]) - sets file mode, user, and group, eg. [ '0777', 'apache', 'apache' ].
  • file.config (default: false) - sets if file is config file.
  • file.noreplace (default: false) - sets config file upgrade policy.

More info on config and noreplace prefixes.

License

ISC