Class Pkg::Config
In: lib/packaging/config.rb
Parent: Object

This class is meant to encapsulate all of the data we know about a build invoked with `rake package:<build>` or `rake pl:<build>`. It can read in this data via a yaml file, have it set via accessors, and serialize it back to yaml for easy transport.

Methods

Public Class methods

By default return a hash of the names, values of current Pkg::Config instance variables. With :format => :yaml, write a yaml file containing the current names,values of Pkg::Config class instance variables

Take a hash of Config parameters, and iterate over them, setting the value for each Config param to the corresponding hash key,value.

Load a yaml file and use its contents to set the values for Pkg::Config class instance variables

Return a hash of all build parameters and their values, nil if unassigned.

Write all build parameters to a yaml file, either one specified or in a temporary location. Print the path to the file and return it as a string. Accept an argument for the write target file. If not specified, the name of the params file is the current git commit sha or tag.

Return the binding of class context. Used for erb templates.

Quite a few variables we also want to issue custom warnings about. These are they.

We also have renamed various variables as part of deprecations, and if any of these are still in use, we want to assign the values to the new variables. However, we skip this if they target variable is already populated, to avoid overwriting in the case that the user has started by populating the new variable name but left the old crufty one behind.

We supply several values by default, if they haven‘t been specified already by config or environment variable. This includes the project root as the default project root, which is relative to the packaging path

Since we‘re dealing with rake, much of the parameter override support is via environment variables passed on the command line to a rake task. These override any existing values of Pkg::Config class instance variables

Several workflows rely on being able to supply an optional yaml parameters file that overrides all set values with its data. This has always been supplied as an environment variable, "PARAMS_FILE." To honor this, we have a method in config to override values as expected. There is, however, a twist - it is absolutely essential that the overrides do not override the project_root setting, because this is environment-specific, and any value in a params file is going to be wrong. Thus, if we have a project root before we begin overriding, we save it and restore it after overrides.

Set all aspects of how the package will be versioned. Versioning relies exclusively on the git describe of the project, which will fail if either Pkg::Config.project_root is nil, isn‘t in a git repo, or is in a git repo, but there are no tags in the repo, in which case git-describe will fail.

It probably seems odd to load packaging-specific version determinations, such as rpmversion here, at the top-level, and it is. The reason for this that the creation of the most basic package composition, the tarball, includes the generation of many different packaging-specific files from templates in the source, and if faced with loading rpmversion in the Tar object vs rpmversion in the Config, I opt for the latter. It‘s basically a lose-lose, since it really belongs in the Rpm object.

Print the names and values of all the params known to the build object

[Validate]