Giter VIP home page Giter VIP logo

easy-rpm's Introduction

grunt-easy-rpm

A Grunt task to easily create RPM packages.

Prerequisites

This plugin requires Grunt ~0.4.5 and, at minimum, the rpmdevtools. The RPM tools can be installed on most unix-like systems, including Mac OSX.

Linux

sudo yum install rpmdevtools rpmlint

Mac OSX

Installation can be done from source either manually or with Homebrew. See these notes regarding installation with Homebrew.

Getting Started

If you haven't used Grunt before, be sure to check out the Getting Started guide. The guide covers creating a Gruntfile, installing and using plugins. Once you're familiar with thr process, install easy-rpm:

npm install grunt-easy-rpm --save-dev

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

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

The "easy_rpm" task

Overview

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

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

Usage Examples

Basic Usage

In this example, the default options are used for most of the fields. Each file is copied indivitually with the directory structure being preserved.

Note that the files group(s) must reside in targets, not the options definition. In the example below, the target name is 'release'.

grunt.initConfig({
  easy_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 (current working directory)

The cwd attribute is used to define the working directory for an individual or set of files. When this attribute is set, the cwd is removed from the resulting target path. Any directory structure below the cwd is preserved.

grunt.initConfig({
  easy_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
      ]
    },
  },
})

Using Wildcards

File lists can also be generated using wildcards whose syntax is defined by node-glob. Note that this can also be paired with the above-mentioned cwd attribute.

grunt.initConfig({
  easy_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
      ]
    },
  },
})

Excludng Files

Files can be excluded from packaging by adding them to the excludeFiles list. The node-glob wildcard syntax can be used to specify exclusions as well. Note that the paths to exclude apply to the source file paths.

grunt.initConfig({
  easy_rpm: {
    options: {
      name: "mypackage",
      version: "1.0.0",
      release: "1",
      buildArch: "x86_64"
    },
    release: {
      files: [
        {src: "routes/**/*", dest: "/target/dir"},
        {src: "views/**/*", dest: "/target/dir"}
      ],
      excludeFiles: [
        "**/index.html",
        "routes/fileA.js"
      ]
    },
  },
})

Setting Target Mode, Owner, and Group

Each target file can have it's mode, owner, and group set by specifying these values in the file elements.

grunt.initConfig({
  easy_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
      ]
    },
  },
})

Setting %doc and %config

Target files can be marked as documentation or configuration files by setting doc and config to 'true' as needed.

grunt.initConfig({
  easy_rpm: {
    options: {
      name: "mypackage",
      version: "1.0.0",
      release: "1",
      buildArch: "x86_64"
    },
    release: {
      files: [
        {src: "output/file1.js", dest: "/target/dir", mode: "755"},
        {doc:'true', cwd:'output', src: "README", dest: "/target/dir", mode: "o+x", owner: "mysql"},
        {config:'true', cwd:'output', src: "mypackage.conf", dest: "/etc/mypackage", owner: "admin", group: "admin"}
      ]
    },
  },
})

Options

Note that some options inherit their values from your package.json. These options are marked by 'Inherits from package.json'.

options.name

Type: String Default value: 'noname'

A string value that is used to set at the name of your RPM package. This value is also used in the construction of the RPM file name.

'Inherits from package.json'.

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.

'Inherits from package.json'.

options.version

Type: String Default value: '0.1.0'

A string value that is used to set as the version of your RPM package. This value is also used in the construction of the RPM file name.

'Inherits from package.json'.

options.release

Type: String Default value: '1'

A string value that is used to set as the release of your RPM package. This value is also used in the construction of 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. This value is also used in the constructon of the RPM file name.

options.prefix

Type: String Default value: undefined

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.

options.dependencies

Type: Array<String> Default value: []

An array of packages that this package depends on (e.g. ["nodejs >= 0.10.22"]). This is mapped to the Requires property in spec file.

options.preInstallScript

Type: Array<String> Default value: []

An array of commands to be excecuted before the installation. Each element in the array represents a command.

options.postInstallScript

Type: Array<String> Default value: []

An array of commands to be excecuted after the installation. Each element in the array represents a command.

options.preUninstallScript

Type: Array<String> Default value: []

An array of commands to be excecuted before uninstallation. Each element in the array represents a command.

options.postUninstallScript

Type: Array<String> Default value: []

An array of commands to be excecuted after uninstallation. Each element in the array represents a command.

options.tempDir

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

Sets the temporary path name that stores the structure that required by the rpmbuild command.

options.postPackageCreate

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

When a string, sets where to copy the rpm after it has been created.

When given a function, the function is executed when the package has been created and provided with two arguments: the path and filename of the newly created package.

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.

options.rpmDestination

Type: String Default value: .

Location where the resulting RPM should be placed, . by default.

options.quoteFilePaths

Type: Boolean Default value: true

Toggles quoting the target file paths in the RPM spec. It is generally best to keep this setting to true.

easy-rpm's People

Contributors

blyork avatar idralyuk avatar jan-molak avatar panitw avatar paulcoyle avatar tmuehl avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.