puppetlabs/puppetdb — pull request #831 by MosesMendoza (2014-02-04 19:50:50+00:00)
Title: Fixes to packaging and update for new packaging tools

This PR is primarily centered around making puppetdb compatible with the changes proposed to the packaging tools in https://github.com/puppetlabs/packaging/pull/237. https://github.com/puppetlabs/packaging/pull/237 changes the internal structure of the packaging tools to lay the groundwork for turning it into a library with rake task entry points as opposed to the hodgepodge mix it is now. However, this break puppetdb's packaging, because it accesses packaging internals (I blame myself) directly.

This PR updates the locations that we access the packaging repo data to conform to the new standard. The most interesting but opaque change is to the variable access in the many erb templates we evaluate during puppetdb packaging. A major change to the packaging tooling in PR 237 is that we stop exporting all data as Rake application-level instance variables (in essence global variables for the duration of a rake task run) and instead scope them within the class #Pkg::Config. Then when we do template evaluation, we pass in the binding of #Pkg::Config, making its instance variables in scope as "@" instance variables. In other projects this is fully backwards compatible, because we only use variables defined by the packaging repo (@version, @rpmversion etc), so strictly evaluating the templates with the binding of the Pkg::Config class requires no changes. However, in puppetdb, its templates mix "@" variables defined in puppetdb (e.g. top-level Rakefile) and "@" variables defined in the packaging repo. Since the packaging repo's "@" variables will no longer be available globally, and, AFAIK, we can't supply more than one binding to the erb template engine, we have to pick one. Since there are far more variables supplied by puppetdb in the templates than the packaging repo, we opt to use the puppetdb scope and fully qualify access to the variables supplied by the packaging repo, by referencing them as Pkg::Config wherever we use them.

Other changes include replacing non-portable shell-out calls in the templates with ruby, and durability improvements to the version determination. Before this PR, doing `rake version` without the packaging repo cloned would return an empty string. This commit updates the version determination to try the packaging repo's, which is the most robust, but then falling back to `git describe` if available, and if that is not, using the string '0.0-dev-build' which is what is 'project.clj' falls back to.

This PR should be merged in tandem with https://github.com/puppetlabs/packaging/pull/237 once they are both +1'd. It should *not* be merged before https://github.com/puppetlabs/packaging/pull/237, nor long afterward.