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

grunt-build-rpm

v1.1.0

Published

Create RPM package to install files/directories

Downloads

42

Readme

grunt-build-rpm

Build RPM package to install files/directories

Credits

This plugin was based entirely off of grunt-easy-rpm (https://github.com/panitw/easy-rpm). However, since it does not seem maintained I created this and plan to support it as best as possible.

Prerequisite

This plugin requires Grunt ~0.4.1 and can only run in RedHat varient linux distribution. The rpmdevtools and rpmlint package needed to be install beforehand.

[root@localhost ~]$ sudo yum install rpmdevtools rpmlint

Getting Started

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-build-rpm --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-build-rpm');

The "grunt_build_rpm" task

Overview

In your project's Gruntfile, add a section named grunt_build_rpm to the data object passed into grunt.initConfig().

grunt.initConfig({
  grunt_build_rpm: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
})

Options

options.name

Type: String Default value: 'noname'

A string value that is used to set at the name of your RPM package. It will also be used at the rpm file name

options.summary

Type: String Default value: 'No Summary'

A string value that is used to set as the summary text of your RPM package

options.description

Type: String Default value: 'No Description'

A string value that is used to set as the description of your RPM package

options.version

Type: String Default value: '0.1.0'

A string value that is used to set as the version of your RPM package. It will also be used at the rpm file name

options.release

Type: String Default value: '1'

A string value that is used to set as the release of your RPM package. It will also be used at the rpm file name

options.license

Type: String Default value: 'MIT'

A string value that is used to specify the license type of your RPM package

options.vendor

Type: String Default value: 'Vendor'

A string value that is used to set as the Vendor property of your RPM package

options.group

Type: String Default value: 'Development/Tools'

A string value that is used to specify the group of your RPM package

options.buildArch

Type: String Default value: 'noarch'

A string value that is used to set specify the target architecture of your RPM package. . It will also be used at the rpm file name

options.dependencies

Type: Array<String> Default value: []

An array of required packages, that should be installed before(e.g. ["nodejs >= 0.10.22"]). Is mapped to Requires property in spec file.

options.preInstallScript

Type: Array<String> Default value: []

An array of command to be excecuted before the installation. Each element of the array represent each command.

options.postInstallScript

Type: Array<string> Default value: []

An array of command to be excecuted after the installation. Each element of the array represent each command.

options.preUninstallScript

Type: Array<String> Default value: []

An array of command to be excecuted before the uninstallation. Each element of the array represent each command.

options.postUninstallScript

Type: Array<String> Default value: []

An array of command to be excecuted after the uninstallation. Each element of the array represent each command.

options.tempDir

Type: String Default value: 'tmp-'+<auto_gen_id>

A string value that will be use as the temporary path name to store the structure that is required by the rpmbuild command.

options.postPackageCreate

Type: String | function(rpmPath, rpmFilename, callback) Default value: null

A string value will tell the script where to copy the rpm after it has been created.

A function will be passed the rpmPath, the rpmFilename of the package that has been created, and a callback for completion of the task.

options.keepTemp

Type: Boolean Default value: false

A boolean value to tell the script to keep the temp folder after the package is built. Probably can be used for problem investigation.

Usage Examples

Basic Usage

In this example, the default options are used for most of the fields. Each file are copied indivitually. The directory structure will be preserved. It is important that 'files' group has to resides in a target. The example below is the target named 'release'

grunt.initConfig({
  grunt_build_rpm: {
    options: {
      name: "mypackage",
      version: "1.0.0",
      release: "1",
      buildArch: "x86_64"
    },
    release: {
      files: [
        {src: "output/file1.js", dest: "/target/dir"}, //Target = /target/dir/output/file1.js
        {src: "output/file2.js", dest: "/target/dir"}, //Target = /target/dir/output/file2.js
        {src: "output/file3.js", dest: "/target/dir"}, //Target = /target/dir/output/file3.js
      ]
    },
  },
})

Using CWD attribute (current working director)

In this example, Each file are copied indivitually. The "cwd" attribute is used to pick up the file in the "cwd", the directory structure under "cwd" is preserved

grunt.initConfig({
  grunt_build_rpm: {
    options: {
      name: "mypackage",
      version: "1.0.0",
      release: "1",
      buildArch: "x86_64"
    },
    release: {
      files: [
        {cwd: "output", src: "output/file1.js", dest: "/target/dir"}, //Target = /target/dir/file1.js
        {cwd: "output", src: "output/sub1/file2.js", dest: "/target/dir"}, //Target = /target/dir/sub1/file2.js
        {cwd: "output", src: "output/sub2/file3.js", dest: "/target/dir"}, //Target = /target/dir/sub2/file3.js
      ]
    },
  },
})

Dynamically generate the file list using wildcard

In this example, the file list will be generated automatically. Files that the path match the wildcard will be included. The file list is generated using node-glob so please find more info about the wildcard pattern at node-glob

grunt.initConfig({
  grunt_build_rpm: {
    options: {
      name: "mypackage",
      version: "1.0.0",
      release: "1",
      buildArch: "x86_64"
    },
    release: {
      files: [
        {src: "output/**", dest: "/target/dir"}, //Target = All files & directory structure under /output folders
      ]
    },
  },
})

Setting mode/owner/group of the target files

In this example, the mode/owner/group of each target file can be set using mode/owner/group attribute of each file element

grunt.initConfig({
  grunt_build_rpm: {
    options: {
      name: "mypackage",
      version: "1.0.0",
      release: "1",
      buildArch: "x86_64"
    },
    release: {
      files: [
        {src: "output/file1.js", dest: "/target/dir", mode: "755"},
        {src: "output/file2.js", dest: "/target/dir", mode: "o+x", owner: "mysql"},
        {src: "output/file3.js", dest: "/target/dir", owner: "admin", group: "admin"},
        {src: "output2/**", dest: "/target/dir", mode: "644"}, //Works with wildcard as well
      ]
    },
  },
})