Skip to content

trevor-vaughan/rubygem-simp-rake-helpers

 
 

Repository files navigation

simp-rake-helpers

License Build Status Gem Gem_Downloads

Table of Contents

Overview

The simp-rake-helpers gem provides common Rake tasks to support the SIMP build process.

This gem is part of SIMP

This gem is part of (the build tooling for) the System Integrity Management Platform, a compliance-management framework built on Puppet.

Features

  • Customizable RPM packaging based on a Puppet module's metadata.json
  • RPM signing
  • Rubygem packaging

Setup

Gemfile

# Variables:
#
# SIMP_GEM_SERVERS | a space/comma delimited list of rubygem servers
# PUPPET_VERSION   | specifies the version of the puppet gem to load
puppetversion = ENV.key?('PUPPET_VERSION') ? "#{ENV['PUPPET_VERSION']}" : '~>3'
gem_sources   = ENV.key?('SIMP_GEM_SERVERS') ? ENV['SIMP_GEM_SERVERS'].split(/[, ]+/) : ['https://rubygems.org']

gem_sources.each { |gem_source| source gem_source }

group :test do
  gem 'puppet', puppetversion
  gem 'beaker-rspec'
  gem 'vagrant-wrapper'

  # Puppet 4+ has issues with Hiera 3.1+
   if puppetversion.to_s =~ />(\d+)/
     pversion = $1
     else
     pversion = puppetversion
   end

   if Gem::Dependency.new('puppet', '~> 4.0').match?('puppet', pversion)
     gem 'hiera', '~> 3.0.0'
   end

  # simp-rake-helpers does not suport puppet 2.7.X
  if "#{ENV['PUPPET_VERSION']}".scan(/\d+/).first != '2' &&
      # simp-rake-helpers and ruby 1.8.7 bomb Travis tests
      # TODO: fix upstream deps (parallel in simp-rake-helpers)
      RUBY_VERSION.sub(/\.\d+$/,'') != '1.8'
    gem 'simp-rake-helpers'
  end
end

Usage

In a Puppet module

Within the project's Rakefile:

require 'simp/rake/pupmod/helpers'

Simp::Rake::Pupmod::Helpers.new(File.dirname(__FILE__))

In a Ruby Gem

Within the project's Rakefile:

require 'simp/rake/rubygem'

# e.g., "simp-rake-helpers"
package = 'name-of-rubygem'
Simp::Rake::Rubygem.new(package, File.direname(__FILE__)

To see the extra rake tasks:

bunde exec rake -T

Generating RPMs

The task rake pkg:rpm) provides the ability to package an RPM from any Puppet module (regardless of whether it is a SIMP module or not). The only requirement is that the Puppet module MUST include a valid metadata.json file with entries for name, version, license, summary, and source.

The RPM package may be configured by other (optional) files under the project directory . The full list of files considered are:

./
├── metadata.json     # REQUIRED keys: name, version, license, summary, source
├── CHANGELOG         # OPTIONAL written in RPM's CHANGELOG format
└── build/            # OPTIONAL
    └── rpm_metadata/ # OPTIONAL
        ├── release   # OPTIONAL defines the RPM's "-0" release number
        ├── requires  # OPTIONAL supplementary 'Requires','Provides','Obsoletes'
        └── custom/   # OPTIONAL
          └── *       # OPTIONAL custom snippets in RPM .spec format

NOTE: The dependencies in metadata.json are not used to generate RPM dependencies!

RPM Changelog

The RPM Changelog will be derived from a CHANGELOG file at the top level of the project, if it exists.

  • The file is expected to conform to the RPM Changelog format described in the Fedora packaging guidelines
  • The file MUST start with a well-formatted RPM changelog string, or it will be ignored.
  • The format is not fully checked before attempting to build the RPM―the RPM build will fail if the Changelog entries are not valid.

RPM Dependencies

It is likely that you will want to declare your dependencies in your RPM. To do this, create a build/rpm_metadata directory at the root of the project. A requires file in the build/rpm_metadata directory will be used to declare the dependencies of the RPM. A file named release in the build/rpm_metadata directory will be used to declare the RPM release number.

The following directives may be declared in the requires file:

  • Provides:
  • Requires:
  • Obsoletes:

Reference

simp/rake/rpm

rake pkg:rpm

Packages the current SIMP project as an RPM

rake pkg:tar

Build the tar package for the current SIMP project

Limitations

Some versions of bundler fail on FIPS-enabled Systems

This is a limitation of Bundler, not the gem.

If you are running on a FIPS-enabled system, you will need to use bundler '~> 1.14.0' until the FIPS support can be corrected.

If you are using RVM, the appropriate steps are as follows:

rm Gemfile.lock ||:
rvm @global do gem uninstall bundler -a -x
rvm @global do gem install bundler -v '~> 1.14.0'

Development

Please see the SIMP Contribution Guidelines.

License

See LICENSE

History

See CHANGELOG.md

About

Rake Helpers for the SIMP Rake tasks

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 96.8%
  • Puppet 2.3%
  • Shell 0.9%