(#108) Update Modulefile to work when built outside the module root

Other tools, like `puppet-librarian`, try to build the module while running
outside the root of the checkout.  This caused some problems with version
number extraction and changelog generation, since the Modulefile assumed it
ran at the top of the checkout.

This updates that to use the full path to the various scripts, ensuring that
we build correctly when invoked from the outside.  Mostly, that means using a
path relative to the Modulefile itself.

This closes #108.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Remove duplicate headers from generated changelog

When the HEAD of the module checkout was a final release, such as 0.6.0, the
changelog generator would emit a duplicate header.  It was treating "0.6.0" as
the development version, and then as the head of the previous release.

This was technically correct, but useless, since there was no distinction
between the two, and so the second "in development" changelog contained
no content.

This simply skips a header when the top and bottom are the same tag, since
that will always be an empty set.  That eliminates the duplicate header, but
keeps building a correct changelog when an in-flight version exists.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Merge pull request #110 from daniel-pittman/feature/master/108-build-outside-moduledir-should-work

(#108) build outside moduledir should work
Quote $@ in razor.erb to avoid issue with tag matchers containing whitespace.

Problem:
Tag matchers containing whitespace would have everything after the whitespace removed when added using the /usr/bin/razor wrapper.  For example:

razor tag 1Og6DsvezhrTfz3Jm91TdE matcher add --key productname --compare equal --value 'PowerEdge R410'
Tag Matcher created:
 Key =>  productname
 Compare =>  equal
 Value =>  PowerEdge
 Inverse =>  false
 UUID =>  5nHnjhCLxaj0tOYCtZrVE

Note that " R410" is missing from the Value.

Solution:
Quote $@ in razor.erb, which is used to create /usr/bin/razor.  Per the bash man page:

@

Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, each parameter expands to a separate word. That is, "$@" is equivalent to "$1" "$2" ...

I chose to quote $@ to resolve this issue with the minimum change to existing code.  Another solution would be to make /usr/bin/razor a symlink to /opt/razor/bin/razor.
Merge pull request #111 from jparsonssaffron/master

Quote $@ in templates/razor.erb to avoid whitespace issues
(#112) Added rubygems_update param to razor class.

This change adds the rubygems_update parameter to the razor class so
that it can be propagated to the ::ruby class.

The first motivation is that the current version of rubygems is 2.0.1
which doesn't seem to be compatible with earlier versions. This results
in lots of errors about the --include-dependencies option which is
apparently now implied by default:

  Notice: /Stage[main]/Ruby::Dev/Package[ruby-devel]/ensure: created
    Error: Execution of '/usr/bin/gem install --include-dependencies
      --no-rdoc --no-ri require_all' returned 1:
      ERROR: While executing gem ... (OptionParser::InvalidOption)
        invalid option: --include-dependencies

The second motivation is that it makes it possible to override the default
behavior on CentOS to update rubygems. This override would be desirable
for people who don't necessarily want to pull external dependencies. It
might also be desirable for people who actually want to update rubygems
on other OS families.
Merge pull request #113 from cr3/112

(#112) Added rubygems_update param to razor class.
(#114) Handle 0.6.1-rc1 style RC tags in git

My previous code for automatically generating version numbers, and the
changelog, worked fine for regular releases, and for the nightly builds, which
were all that we had ever made of this project.

Now that we have tagged our first RC, a shortfall is exposed: my code
incorrectly identified an RC version as being a nightly build, and then failed
during generation of the build number.

This fixes that, by treating anything that isn't in the form "a.b.c-N", where
N is a number, as an RC version.  Given `git describe` will generate a number
in the second slot for the "number of commits since the tag", in a nightly
build repository, this seems the safest choice.

Specifically, we now map:

 * 0.6.1-1-foo     => 0.6.2-1-foo       # 0.6.1 to 0.6.2
 * 0.6.2-rc1       => 0.6.2-rc1         # stays the same
 * 0.6.2-rc1-1-foo => 0.6.2-rc2-1-foo   # rc1 to rc2
 * 0.6.2           => 0.6.2             # stays the same

This modifies both the Modulefile and changelog generator, since both
calculate the next version of the module.

It also extracts the logic for generating the version number into a separate
Ruby script, since the complexity had grown to the point it was worth the cost
of factoring that out.

This closes #114, and fixes the currently broken RC build.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Git should ignore the CHANGELOG file

The changelog is machine generated, so should be ignored.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Merge pull request #115 from daniel-pittman/bug/master/114-fix-automatic-changelog-generation-for-rc-builds

Fix automatic changelog generation for rc builds
Cache downloaded images.
Handle SemVer sorting correctly in the changelog generator

The shell changelog generator worked fine, but didn't sort correctly: RC
versions were sorted after, not before, their parent.  (In part because SemVer
is a human focused version sort, and it is actually hard to find a portable
shell implementation of that sorting.)

This replaces it with a small Ruby script that does the same work, but allows
me to implement a SemVer-correct sorting routine.  It is kind of ugly, because
the logic is ugly, but it works correctly now.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Add notice to inform that we're going to use a cached image.
Log image's md5 mismatches.
Define the new cache and md5 properties.
Merge pull request #117 from calavera/cache_rz_image

Cache downloaded images.
Install the `net-scp` gem in addition to `net-ssh`

The external script broker, recently added to Razor, adds a new dependency on
the `net-scp` gem in addition to the `net-ssh` library; this extends the later
with an integration of scp file transfer.

This updates the Ruby manifests to install both gems, which ensures that
current Razor continues to run correctly.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Merge pull request #118 from daniel-pittman/bug/master/handle-semver-sorting-in-changelog-tool

Handle SemVer sorting correctly in the changelog generator
Merge pull request #119 from daniel-pittman/bug/master/add-net-scp-gem-for-external-script-broker

Install the `net-scp` gem in addition to `net-ssh`
Fix dangling `tmpdir` reference from cache feature

The added cache feature tried to reference a temporary directory that no
longer existed; this corrects that bug by excising the additional code.

Since this was unused, no ill effects flow from this.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>