puppet 2.7.25 → 2.7.26

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (77) hide show
  1. data/bin/puppet +4 -0
  2. data/ext/build_defaults.yaml +4 -4
  3. data/ext/debian/control +1 -1
  4. data/ext/packaging/Gemfile +8 -0
  5. data/ext/packaging/Gemfile.lock +28 -0
  6. data/ext/packaging/README.md +31 -4
  7. data/ext/packaging/lib/packaging.rb +21 -0
  8. data/ext/packaging/lib/packaging/config.rb +277 -0
  9. data/ext/packaging/lib/packaging/config/params.rb +175 -0
  10. data/ext/packaging/lib/packaging/tar.rb +186 -0
  11. data/ext/packaging/lib/packaging/util.rb +44 -0
  12. data/ext/packaging/lib/packaging/util/date.rb +15 -0
  13. data/ext/packaging/lib/packaging/util/file.rb +60 -0
  14. data/ext/packaging/lib/packaging/util/jira.rb +83 -0
  15. data/ext/packaging/lib/packaging/util/net.rb +16 -0
  16. data/ext/packaging/lib/packaging/util/rake_utils.rb +57 -0
  17. data/ext/packaging/lib/packaging/util/serialization.rb +19 -0
  18. data/ext/packaging/lib/packaging/util/tool.rb +30 -0
  19. data/ext/packaging/lib/packaging/util/version.rb +300 -0
  20. data/ext/packaging/packaging.rake +10 -5
  21. data/ext/packaging/spec/fixtures/config/ext/build_defaults.yaml +2 -0
  22. data/ext/packaging/spec/fixtures/config/ext/project_data.yaml +2 -0
  23. data/ext/packaging/spec/fixtures/config/params.yaml +2 -0
  24. data/ext/packaging/spec/fixtures/util/pre_tasks.yaml +4 -0
  25. data/ext/packaging/spec/lib/packaging/config_spec.rb +330 -0
  26. data/ext/packaging/spec/lib/packaging/tar_spec.rb +122 -0
  27. data/ext/packaging/spec/lib/packaging/util/file_spec.rb +48 -0
  28. data/ext/packaging/spec/lib/packaging/util/jira_spec.rb +50 -0
  29. data/ext/packaging/spec/lib/packaging/util/net_spec.rb +23 -0
  30. data/ext/packaging/spec/lib/packaging/util/rake_utils_spec.rb +70 -0
  31. data/ext/packaging/spec/lib/packaging/util/version_spec.rb +67 -0
  32. data/ext/packaging/spec/lib/packaging_spec.rb +19 -0
  33. data/ext/packaging/spec/spec_helper.rb +10 -0
  34. data/ext/packaging/spec/tasks/00_utils_spec.rb +218 -88
  35. data/ext/packaging/tasks/00_utils.rake +63 -320
  36. data/ext/packaging/tasks/30_metrics.rake +4 -4
  37. data/ext/packaging/tasks/apple.rake +28 -13
  38. data/ext/packaging/tasks/build.rake +2 -176
  39. data/ext/packaging/tasks/deb.rake +61 -20
  40. data/ext/packaging/tasks/deb_repos.rake +12 -12
  41. data/ext/packaging/tasks/doc.rake +5 -5
  42. data/ext/packaging/tasks/fetch.rake +9 -9
  43. data/ext/packaging/tasks/gem.rake +59 -33
  44. data/ext/packaging/tasks/ips.rake +22 -23
  45. data/ext/packaging/tasks/jenkins.rake +34 -34
  46. data/ext/packaging/tasks/jenkins_dynamic.rake +22 -19
  47. data/ext/packaging/tasks/load_extras.rake +21 -0
  48. data/ext/packaging/tasks/mock.rake +16 -16
  49. data/ext/packaging/tasks/pe_deb.rake +2 -2
  50. data/ext/packaging/tasks/pe_remote.rake +9 -9
  51. data/ext/packaging/tasks/pe_rpm.rake +1 -1
  52. data/ext/packaging/tasks/pe_ship.rake +48 -37
  53. data/ext/packaging/tasks/pe_sign.rake +5 -5
  54. data/ext/packaging/tasks/release.rake +5 -5
  55. data/ext/packaging/tasks/remote_build.rake +27 -27
  56. data/ext/packaging/tasks/retrieve.rake +5 -5
  57. data/ext/packaging/tasks/rpm.rake +27 -10
  58. data/ext/packaging/tasks/rpm_repos.rake +13 -12
  59. data/ext/packaging/tasks/ship.rake +67 -45
  60. data/ext/packaging/tasks/sign.rake +37 -30
  61. data/ext/packaging/tasks/tar.rake +14 -69
  62. data/ext/packaging/tasks/tickets.rake +449 -0
  63. data/ext/packaging/tasks/update.rake +2 -2
  64. data/ext/packaging/tasks/vendor_gems.rake +2 -2
  65. data/ext/packaging/tasks/version.rake +8 -38
  66. data/ext/packaging/tasks/z_data_dump.rake +35 -3
  67. data/ext/packaging/templates/downstream.xml.erb +2 -2
  68. data/ext/packaging/templates/packaging.xml.erb +13 -13
  69. data/ext/packaging/templates/repo.xml.erb +9 -7
  70. data/lib/puppet/indirector/facts/facter.rb +1 -1
  71. data/lib/puppet/version.rb +1 -1
  72. data/spec/unit/indirector/facts/facter_spec.rb +2 -2
  73. metadata +38 -13
  74. data/ext/packaging/spec/tasks/build_object_spec.rb +0 -178
  75. data/ext/packaging/tasks/10_setupvars.rake +0 -135
  76. data/ext/packaging/tasks/20_setupextravars.rake +0 -53
  77. data/ext/packaging/tasks/template.rake +0 -27
data/bin/puppet CHANGED
@@ -1,4 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # For security reasons, ensure that '.' is not on the load path
4
+ # This is primarily for 1.8.7 since 1.9.2+ doesn't put '.' on the load path
5
+ $LOAD_PATH.delete '.'
6
+
3
7
  require 'puppet/util/command_line'
4
8
  Puppet::Util::CommandLine.new.execute
@@ -9,11 +9,11 @@ gpg_name: 'info@puppetlabs.com'
9
9
  gpg_key: '4BD6EC30'
10
10
  sign_tar: False
11
11
  # a space separated list of mock configs
12
- final_mocks: 'pl-el-5-i386 pl-el-6-i386 pl-fedora-17-i386'
13
- yum_host: 'burji.puppetlabs.com'
12
+ final_mocks: 'pl-el-5-i386 pl-el-6-i386'
13
+ yum_host: 'yum.puppetlabs.com'
14
14
  yum_repo_path: '/opt/repository/yum/'
15
15
  build_gem: FALSE
16
- build_dmg: TRUE
17
- apt_host: 'burji.puppetlabs.com'
16
+ build_dmg: FALSE
17
+ apt_host: 'apt.puppetlabs.com'
18
18
  apt_repo_url: 'http://apt.puppetlabs.com'
19
19
  apt_repo_path: '/opt/repository/incoming'
@@ -3,7 +3,7 @@ Section: admin
3
3
  Priority: optional
4
4
  Maintainer: Puppet Labs <info@puppetlabs.com>
5
5
  Uploaders: Micah Anderson <micah@debian.org>, Andrew Pollock <apollock@debian.org>, Nigel Kersten <nigel@explanatorygap.net>, Stig Sandbeck Mathisen <ssm@debian.org>
6
- Build-Depends-Indep: ruby1.8, libopenssl-ruby, facter (>= 1.5), facter (<< 2.0)
6
+ Build-Depends-Indep: ruby1.8, libopenssl-ruby, facter (>= 1.5)
7
7
  Build-Depends: debhelper (>= 7.0.0), openssl
8
8
  Standards-Version: 3.9.1
9
9
  Vcs-Git: git://git.debian.org/git/pkg-puppet/puppet.git
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :development, :test do
4
+ gem 'rake', "~> 0.9.6"
5
+ gem 'rspec', "~> 2.14.1"
6
+ gem 'pry'
7
+ end
8
+
@@ -0,0 +1,28 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ coderay (1.1.0)
5
+ diff-lcs (1.2.5)
6
+ method_source (0.8.2)
7
+ pry (0.9.12.6)
8
+ coderay (~> 1.0)
9
+ method_source (~> 0.8)
10
+ slop (~> 3.4)
11
+ rake (0.9.6)
12
+ rspec (2.14.1)
13
+ rspec-core (~> 2.14.0)
14
+ rspec-expectations (~> 2.14.0)
15
+ rspec-mocks (~> 2.14.0)
16
+ rspec-core (2.14.7)
17
+ rspec-expectations (2.14.5)
18
+ diff-lcs (>= 1.1.3, < 2.0)
19
+ rspec-mocks (2.14.6)
20
+ slop (3.4.7)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ pry
27
+ rake (~> 0.9.6)
28
+ rspec (~> 2.14.1)
@@ -1,5 +1,7 @@
1
1
  #Packaging
2
2
 
3
+ [![Build Status](https://travis-ci.org/puppetlabs/packaging.png?branch=master)](https://travis-ci.org/puppetlabs/packaging)
4
+
3
5
  This is a repository for packaging automation for Puppet Labs software.
4
6
  The goal is to abstract and automate packaging processes beyond individual
5
7
  software projects to a level where this repo can be cloned inside any project
@@ -275,23 +277,32 @@ value, presumably a url to a jenkins job to trigger programmatically.
275
277
 
276
278
  An important note about `DOWNSTREAM_JOB`: `DOWNSTREAM_JOB` in the dynamic jenkins
277
279
  workflow is _always_ invoked if it is passed in as an environment variable.
278
- However, it is also appended with an additional parameter, `PACKAGE_BUILD_STATUS`,
280
+ However, it is appended with an additional parameter, `PACKAGE_BUILD_STATUS`,
279
281
  which will be the string "success" if package and repo builds succeeded, or
280
282
  "failure" if package or repo builds failed. By modifying the actual downstream
281
283
  jenkins job to accept a string parameter of `PACKAGE_BUILD_STATUS`, one can
282
284
  switch on the success or failure of the packaging job, responding
283
- appropriately.
285
+ appropriately. A second parameter, `PACKAGE_BUILD_URL` is also appended to
286
+ `DOWNSTREAM_JOB`, the value of which is the url of the packaging job itself.
287
+ This is to assist with tracing failures in a multi-jenkins environment. By
288
+ modifying the downstream jenkins job to accept a string parameter of
289
+ `PACKAGE_BUILD_URL`, one can use the value to display the url prominently in
290
+ case of failure, for example.
284
291
 
285
292
  E.g., a job url:
286
293
  http://jenkins.example.net/job/downstream/buildWithParameters?FOO=bar
287
294
 
288
295
  in the success case will be transformed into
289
296
 
290
- http://jenkins.example.net/job/downstream/buildWithParameters?FOO=bar&PACKAGE_BUILD_STATUS=success
297
+ http://jenkins.example.net/job/downstream/buildWithParameters?FOO=bar&PACKAGE_BUILD_STATUS=success&PACKAGE_BUILD_URL=http://jenkins.example.net/job/packaging_job
291
298
 
292
299
  and in the failure case transformed into
293
300
 
294
- http://jenkins.example.net/job/downstream/buildWithParameters?FOO=bar&PACKAGE_BUILD_STATUS=failure
301
+ http://jenkins.example.net/job/downstream/buildWithParameters?FOO=bar&PACKAGE_BUILD_STATUS=failure&PACKAGE_BUILD_URL=http://jenkins.example.net/job/packaging_job
302
+
303
+ Since jenkins will just drop parameters that are not configured in the job,
304
+ accepting PACKAGE_BUILD_STATUS and PACKAGE_BUILD_URL in the downstream job
305
+ isn't mandatory.
295
306
 
296
307
  All 3 jobs are configured by default for removal by jenkins after 3 days, to
297
308
  avoid clutter.
@@ -390,6 +401,14 @@ default_cow: 'base-squeeze-i386.cow'
390
401
  cows: 'base-lucid-amd64.cow base-lucid-i386.cow base-natty-amd64.cow base-natty-i386.cow base-oneiric-amd64.cow base-oneiric-i386.cow base-precise-amd64.cow base-precise-i386.cow base-sid-amd64.cow base-sid-i386.cow base-squeeze-amd64.cow base-squeeze-i386.cow base-testing-amd64.cow base-testing-i386.cow base-wheezy-i386.cow'
391
402
  # The pbuilder configuration file to use
392
403
  pbuild_conf: '/etc/pbuilderrc'
404
+ # Alternate debian mirrors to build against (must be an array)
405
+ # The __DIST__ string is automatically replaced with codename of the cow being built, so when the squeeze cow is being built the deb_build_mirrors will be:
406
+ # deb http://apt.puppetlabs.com squeeze main dependencies
407
+ # deb http://somethingelse.com/debian squeeze
408
+ # This will happen for each cow during the build.
409
+ deb_build_mirrors:
410
+ - deb http://apt.puppetlabs.com __DIST__ main dependencies
411
+ - deb http://somethingelse.com/debian __DIST__
393
412
  # Who is packaging. Turns up in various packaging artifacts
394
413
  packager: 'puppetlabs'
395
414
  # Who is signing packages
@@ -854,6 +873,14 @@ files:
854
873
  `ext/project_data.yaml`, as well as whatever is overridden with environment
855
874
  variables. Useful for debugging problems with parameter values.
856
875
 
876
+ * **pl:print_build_param[param]**
877
+
878
+ Print a specific build parameter to STDOUT as it would be used in a package
879
+ build. This prints data that is loaded from `ext/build_defaults.yaml` and
880
+ `ext/project_data.yaml`, as well as whatever is overridden with environment
881
+ variables. Useful for debugging problems with parameter values. param
882
+ should be the name of the parameter as a symbol, e.g. :ref or :version
883
+
857
884
  * **pl:release_deb**
858
885
 
859
886
  A composite task of `package:tar`, `pl:deb_all`, `pl:sign_deb_changes`, and
@@ -0,0 +1,21 @@
1
+ module Pkg
2
+
3
+ LIBDIR = File.expand_path(File.dirname(__FILE__))
4
+
5
+ $:.unshift(LIBDIR) unless
6
+ $:.include?(File.dirname(__FILE__)) || $:.include?(LIBDIR)
7
+
8
+ require 'packaging/util'
9
+ require 'packaging/config'
10
+ require 'packaging/tar'
11
+
12
+ # Load configuration defaults
13
+ Pkg::Config.load_defaults
14
+ Pkg::Config.load_default_configs
15
+ Pkg::Config.load_versioning
16
+ Pkg::Config.load_overrides
17
+ Pkg::Config.load_envvars
18
+ Pkg::Config.issue_reassignments
19
+ Pkg::Config.issue_deprecations
20
+ end
21
+
@@ -0,0 +1,277 @@
1
+ module Pkg
2
+ ##
3
+ # This class is meant to encapsulate all of the data we know about a build invoked with
4
+ # `rake package:<build>` or `rake pl:<build>`. It can read in this data via a yaml file,
5
+ # have it set via accessors, and serialize it back to yaml for easy transport.
6
+ #
7
+ class Config
8
+ require 'packaging/config/params.rb'
9
+ require 'yaml'
10
+
11
+ class << self
12
+
13
+ # Every element in Pkg::Params::BUILD_PARAMS is a configurable setting
14
+ # for the build. We use Pkg::Params::BUILD_PARAMS as the source of
15
+ # truth for defining the the class instance variables and their
16
+ # accessors of the Pkg::Config class
17
+ Pkg::Params::BUILD_PARAMS.each do |v|
18
+ attr_accessor v
19
+ end
20
+
21
+ # Return the binding of class context. Used for erb templates.
22
+ #
23
+ def get_binding
24
+ return binding
25
+ end
26
+
27
+ ##
28
+ # Take a hash of Config parameters, and iterate over them, setting the
29
+ # value for each Config param to the corresponding hash key,value.
30
+ #
31
+ def config_from_hash(data = {})
32
+ data.each do |param, value|
33
+ if Pkg::Params::BUILD_PARAMS.include?(param.to_sym)
34
+ self.instance_variable_set("@#{param}", value)
35
+ else
36
+ warn "Warning - No build data parameter found for '#{param}'. Perhaps you have an erroneous entry in your yaml file?"
37
+ end
38
+ end
39
+ end
40
+
41
+ ##
42
+ # Load a yaml file and use its contents to set the values for Pkg::Config
43
+ # class instance variables
44
+ #
45
+ def config_from_yaml(file)
46
+ build_data = Pkg::Util::Serialization.load_yaml(file)
47
+ config_from_hash(build_data)
48
+ end
49
+
50
+ ##
51
+ # By default return a hash of the names, values of current Pkg::Config
52
+ # instance variables. With :format => :yaml, write a yaml file containing
53
+ # the current names,values of Pkg::Config class instance variables
54
+ #
55
+ def config(args={:target => nil, :format => :hash})
56
+ case args[:format]
57
+ when :hash
58
+ self.config_to_hash
59
+ when :yaml
60
+ self.config_to_yaml(args[:target])
61
+ end
62
+ end
63
+
64
+ ##
65
+ # Return a hash of all build parameters and their values, nil if unassigned.
66
+ #
67
+ def config_to_hash
68
+ data = {}
69
+ Pkg::Params::BUILD_PARAMS.each do |param|
70
+ data.store(param, self.instance_variable_get("@#{param}"))
71
+ end
72
+ data
73
+ end
74
+
75
+ ##
76
+ # Write all build parameters to a yaml file, either one specified or in a
77
+ # temporary location. Print the path to the file and return it as a
78
+ # string. Accept an argument for the write target file. If not specified,
79
+ # the name of the params file is the current git commit sha or tag.
80
+ #
81
+ def config_to_yaml(target=nil)
82
+ file = "#{self.ref}.yaml"
83
+ target = target.nil? ? File.join(Pkg::Util::File.mktemp, "#{self.ref}.yaml") : File.join(target, file)
84
+ Pkg::Util::File.file_writable?(File.dirname(target), :required => true)
85
+ File.open(target, 'w') do |f|
86
+ f.puts self.config_to_hash.to_yaml
87
+ end
88
+ puts target
89
+ target
90
+ end
91
+
92
+ ##
93
+ # Print the names and values of all the params known to the build object
94
+ #
95
+ def print_config
96
+ self.config_to_hash.each { |k,v| puts "#{k}: #{v}" }
97
+ end
98
+
99
+ ##
100
+ # Return the names of all of the cows for the project, taking off the
101
+ # base prefix, the architecture, and the .cow suffix. This is helpful in
102
+ # the debian changelog.
103
+ #
104
+ def cow_list
105
+ self.cows.split(' ').map do
106
+ |cow| cow.split('-')[1]
107
+ end.uniq.join(' ')
108
+ end
109
+
110
+ def default_project_root
111
+ # It is really quite unsafe to assume github.com/puppetlabs/packaging has been
112
+ # cloned into $project_root/ext/packaging even if it has _always_ been the
113
+ # default location. We really don't have much choice as of this moment but to
114
+ # assume this directory, or assume the user has passed in the correct one via
115
+ # ENV['PROJECT_ROOT']. It is critical we have the correct $project_root, because
116
+ # we get all of the package versioning from the `git-describe` of $project. If we
117
+ # assume $project/ext/packaging, it means packaging/lib/packaging.rb is
118
+ # three subdirectories below $project_root, e.g.,
119
+ # $project_root/ext/packaging/lib/packaging.rb.
120
+ #
121
+ ENV['PROJECT_ROOT'] || File.expand_path(File.join(LIBDIR, "..","..",".."))
122
+ end
123
+
124
+ def default_packaging_root
125
+ # It is really quite unsafe to assume github.com/puppetlabs/packaging has been
126
+ # cloned into $project_root/ext/packaging even if it has _always_ been the
127
+ # default location. Here we use the PACKAGING_ROOT constant defined in
128
+ # packaging.rake if it is available, or use the parent directory of the
129
+ # current file as the packaging_root.
130
+ #
131
+ defined?(PACKAGING_ROOT) ? File.expand_path(PACKAGING_ROOT) : File.expand_path(File.join(LIBDIR, ".."))
132
+ end
133
+
134
+ def load_default_configs
135
+ default_project_data = File.join(@project_root, "ext", "project_data.yaml")
136
+ default_build_defaults = File.join(@project_root, "ext", "build_defaults.yaml")
137
+
138
+ [default_project_data, default_build_defaults].each do |config|
139
+ if File.readable? config
140
+ self.config_from_yaml(config)
141
+ else
142
+ puts "Skipping load of expected default config #{config}, cannot read file."
143
+ # Since the default configuration files are not readable, most
144
+ # likely not present, at this point we assume the project_root
145
+ # isn't what we hoped it would be, and unset it.
146
+ @project_root = nil
147
+ end
148
+ end
149
+
150
+ if @project_root
151
+ self.config
152
+ end
153
+ end
154
+
155
+ # Set all aspects of how the package will be versioned. Versioning
156
+ # relies exclusively on the git describe of the project, which will
157
+ # fail if either Pkg::Config.project_root is nil, isn't in a git repo,
158
+ # or is in a git repo, but there are no tags in the repo, in which case
159
+ # git-describe will fail.
160
+ #
161
+ # It probably seems odd to load packaging-specific version
162
+ # determinations, such as rpmversion here, at the top-level, and it is.
163
+ # The reason for this that the creation of the most basic package
164
+ # composition, the tarball, includes the generation of many different
165
+ # packaging-specific files from templates in the source, and if faced
166
+ # with loading rpmversion in the Tar object vs rpmversion in the
167
+ # Config, I opt for the latter. It's basically a lose-lose, since it
168
+ # really belongs in the Rpm object.
169
+
170
+ def load_versioning
171
+ if @project_root and Pkg::Util::Version.git_tagged?
172
+ @ref = Pkg::Util::Version.git_sha_or_tag
173
+ @version = Pkg::Util::Version.get_dash_version
174
+ @gemversion = Pkg::Util::Version.get_dot_version
175
+ @ipsversion = Pkg::Util::Version.get_ips_version
176
+ @debversion = Pkg::Util::Version.get_debversion
177
+ @origversion = Pkg::Util::Version.get_origversion
178
+ @rpmversion = Pkg::Util::Version.get_rpmversion
179
+ @rpmrelease = Pkg::Util::Version.get_rpmrelease
180
+ else
181
+ puts "Skipping determination of version via git describe, Pkg::Config.project_root is not set to the path of a tagged git repo."
182
+ end
183
+ end
184
+
185
+ ##
186
+ # Since we're dealing with rake, much of the parameter override support
187
+ # is via environment variables passed on the command line to a rake task.
188
+ # These override any existing values of Pkg::Config class instance
189
+ # variables
190
+ #
191
+ def load_envvars
192
+ Pkg::Params::ENV_VARS.each do |v|
193
+ if var = ENV[v[:envvar].to_s]
194
+ if v[:type] == :bool
195
+ self.instance_variable_set("@#{v[:var]}", Pkg::Util.boolean_value(var))
196
+ else
197
+ self.instance_variable_set("@#{v[:var]}", var)
198
+ end
199
+ end
200
+ end
201
+ end
202
+
203
+ ##
204
+ # We supply several values by default, if they haven't been specified
205
+ # already by config or environment variable. This includes the project
206
+ # root as the default project root, which is relative to the
207
+ # packaging path
208
+ #
209
+ def load_defaults
210
+ @project_root ||= default_project_root
211
+ @packaging_root ||= default_packaging_root
212
+
213
+ Pkg::Params::DEFAULTS.each do |v|
214
+ unless self.instance_variable_get("@#{v[:var]}")
215
+ self.instance_variable_set("@#{v[:var]}", v[:val])
216
+ end
217
+ end
218
+ end
219
+
220
+ ##
221
+ #
222
+ # Several workflows rely on being able to supply an optional yaml
223
+ # parameters file that overrides all set values with its data. This has
224
+ # always been supplied as an environment variable, "PARAMS_FILE." To
225
+ # honor this, we have a method in config to override values as
226
+ # expected. There is, however, a twist - it is absolutely essential
227
+ # that the overrides do not override the project_root or packaging_root
228
+ # settings, because this is environment-specific, and any value in a
229
+ # params file is going to be wrong. Thus, if we have a project root or
230
+ # packaging root before we begin overriding, we save it and restore it
231
+ # after overrides.
232
+ #
233
+ def load_overrides
234
+ if ENV['PARAMS_FILE'] && ENV['PARAMS_FILE'] != ''
235
+ if File.readable?(ENV['PARAMS_FILE'])
236
+ project_root = self.instance_variable_get("@project_root")
237
+ packaging_root = self.instance_variable_get("@packaging_root")
238
+ self.config_from_yaml(ENV['PARAMS_FILE'])
239
+ self.instance_variable_set("@project_root", project_root) if project_root
240
+ self.instance_variable_set("@packaging_root", packaging_root) if packaging_root
241
+ else
242
+ fail "PARAMS_FILE was set, but not to the path to a readable file."
243
+ end
244
+ end
245
+ end
246
+
247
+ ##
248
+ # We also have renamed various variables as part of deprecations, and
249
+ # if any of these are still in use, we want to assign the values to the
250
+ # new variables. However, we skip this if they target variable is already
251
+ # populated, to avoid overwriting in the case that the user has started
252
+ # by populating the new variable name but left the old crufty one behind.
253
+ #
254
+ def issue_reassignments
255
+ Pkg::Params::REASSIGNMENTS.each do |v|
256
+ oldval = self.instance_variable_get("@#{v[:oldvar]}")
257
+ newval = self.instance_variable_get("@#{v[:newvar]}")
258
+ if newval.nil? and not oldval.nil?
259
+ self.instance_variable_set("@#{v[:newvar]}", oldval)
260
+ end
261
+ end
262
+ end
263
+
264
+ ##
265
+ # Quite a few variables we also want to issue custom warnings about.
266
+ # These are they.
267
+ #
268
+ def issue_deprecations
269
+ Pkg::Params::DEPRECATIONS.each do |v|
270
+ if self.instance_variable_get("@#{v[:var]}")
271
+ warn v[:message]
272
+ end
273
+ end
274
+ end
275
+ end
276
+ end
277
+ end
@@ -0,0 +1,175 @@
1
+ # These are all of the parameters known to our packaging system.
2
+ # They are ingested by the config class as class instance variables
3
+ module Pkg::Params
4
+ BUILD_PARAMS = [:apt_host,
5
+ :apt_repo_path,
6
+ :apt_repo_url,
7
+ :author,
8
+ :benchmark,
9
+ :build_date,
10
+ :build_defaults,
11
+ :build_dmg,
12
+ :build_doc,
13
+ :build_gem,
14
+ :build_ips,
15
+ :build_pe,
16
+ :builder_data_file,
17
+ :builds_server,
18
+ :bundle_platforms,
19
+ :certificate_pem,
20
+ :cows,
21
+ :db_table,
22
+ :deb_build_host,
23
+ :deb_build_mirrors,
24
+ :debversion,
25
+ :debug,
26
+ :default_cow,
27
+ :default_mock,
28
+ :description,
29
+ :distribution_server,
30
+ :dmg_path,
31
+ :email,
32
+ :files,
33
+ :final_mocks,
34
+ :freight_conf,
35
+ :gem_default_executables,
36
+ :gem_dependencies,
37
+ :gem_description,
38
+ :gem_devel_dependencies,
39
+ :gem_development_dependencies,
40
+ :gem_excludes,
41
+ :gem_executables,
42
+ :gem_files,
43
+ :gem_forge_project,
44
+ :gem_name,
45
+ :gem_platform_dependencies,
46
+ :gem_rdoc_options,
47
+ :gem_require_path,
48
+ :gem_runtime_dependencies,
49
+ :gem_summary,
50
+ :gem_test_files,
51
+ :gemversion,
52
+ :gpg_key,
53
+ :gpg_name,
54
+ :homepage,
55
+ :ips_build_host,
56
+ :ips_host,
57
+ :ips_inter_cert,
58
+ :ips_package_host,
59
+ :ips_path,
60
+ :ips_repo,
61
+ :ips_store,
62
+ :ipsversion,
63
+ :jenkins_build_host,
64
+ :jenkins_packaging_job,
65
+ :jenkins_repo_path,
66
+ :metrics,
67
+ :metrics_url,
68
+ :name,
69
+ :notify,
70
+ :project,
71
+ :origversion,
72
+ :osx_build_host,
73
+ :packager,
74
+ :packaging_repo,
75
+ :packaging_root,
76
+ :packaging_url,
77
+ :pbuild_conf,
78
+ :pe_name,
79
+ :pe_version,
80
+ :pg_major_version,
81
+ :pre_tar_task,
82
+ :pre_tasks,
83
+ :privatekey_pem,
84
+ :project_root,
85
+ :random_mockroot,
86
+ :rc_mocks,
87
+ :redis_hostname,
88
+ :release,
89
+ :rpm_build_host,
90
+ :rpmrelease,
91
+ :rpmversion,
92
+ :ref,
93
+ :sign_tar,
94
+ :summary,
95
+ :tar_excludes,
96
+ :tar_host,
97
+ :tarball_path,
98
+ :task,
99
+ :team,
100
+ :templates,
101
+ :update_version_file,
102
+ :version,
103
+ :version_file,
104
+ :version_strategy,
105
+ :yum_host,
106
+ :yum_repo_path]
107
+
108
+ # Environment variable overrides for Pkg::Config parameters
109
+ #
110
+ # :var => :config_param, :envvar => :environment var :type => :variable type
111
+ #
112
+ # Note: :type is assumed :string if not present
113
+ #
114
+ ENV_VARS = [{:var => :apt_host, :envvar => :APT_HOST},
115
+ {:var => :apt_repo_path, :envvar => :APT_REPO},
116
+ {:var => :build_dmg, :envvar => :DMG, :type => :bool},
117
+ {:var => :build_doc, :envvar => :DOC, :type => :bool},
118
+ {:var => :build_gem, :envvar => :GEM, :type => :bool},
119
+ {:var => :build_ips, :envvar => :IPS, :type => :bool},
120
+ {:var => :build_pe, :envvar => :PE_BUILD, :type => :bool},
121
+ {:var => :certificate_pem, :envvar => :CERT_PEM},
122
+ {:var => :cows, :envvar => :COW},
123
+ {:var => :debug, :envvar => :DEBUG, :type => :bool},
124
+ {:var => :default_cow, :envvar => :COW},
125
+ {:var => :default_mock, :envvar => :MOCK},
126
+ {:var => :final_mocks, :envvar => :MOCK},
127
+ {:var => :gpg_name, :envvar => :GPG_NAME},
128
+ {:var => :gpg_key, :envvar => :GPG_KEY},
129
+ {:var => :notify, :envvar => :NOTIFY},
130
+ {:var => :packager, :envvar => :PACKAGER},
131
+ {:var => :pbuild_conf, :envvar => :PBUILDCONF},
132
+ {:var => :pe_version, :envvar => :PE_VER},
133
+ {:var => :privatekey_pem, :envvar => :PRIVATE_PEM},
134
+ {:var => :project_root, :envvar => :PROJECT_ROOT},
135
+ {:var => :random_mockroot, :envvar => :RANDOM_MOCKROOT, :type => :bool},
136
+ {:var => :rc_mocks, :envvar => :MOCK},
137
+ {:var => :release, :envvar => :RELEASE},
138
+ {:var => :sign_tar, :envvar => :SIGN_TAR, :type => :bool},
139
+ {:var => :team, :envvar => :TEAM},
140
+ {:var => :update_version_file, :envvar => :NEW_STYLE_PACKAGE},
141
+ {:var => :yum_repo_path, :envvar => :YUM_REPO},
142
+ {:var => :yum_host, :envvar => :YUM_HOST}]
143
+ # Default values that are supplied if the user does not supply them
144
+ #
145
+ # usage is the same as above
146
+ #
147
+ DEFAULTS = [{:var => :builder_data_file, :val => 'builder_data.yaml'},
148
+ {:var => :team, :val => 'dev'},
149
+ {:var => :random_mockroot, :val => true},
150
+ {:var => :keychain_loaded, :val => false},
151
+ {:var => :build_date, :val => Pkg::Util::Date.timestamp('-')},
152
+ {:var => :release, :val => '1'}]
153
+
154
+ # These are variables which, over time, we decided to rename or replace. For
155
+ # backwards compatibility, we assign the value of the old/deprecated
156
+ # variables, if set, to the new ones. We also use this method for accessor
157
+ # "redirects" - e.g. defaulting the populated value of one parameter for another
158
+ # in case it is not set.
159
+ #
160
+ REASSIGNMENTS = [{:oldvar => :name, :newvar => :project},
161
+ {:oldvar => :yum_host, :newvar => :tar_host},
162
+ {:oldvar => :gem_devel_dependencies, :newvar => :gem_development_dependencies},
163
+ {:oldvar => :pe_name, :newvar => :project},
164
+ {:oldvar => :project, :newvar => :gem_name}]
165
+
166
+ # These are variables that we have deprecated. If they are encountered in a
167
+ # project's config, we issue deprecations for them.
168
+ #
169
+ DEPRECATIONS = [{:var => :gem_devel_dependencies, :message => "
170
+ DEPRECATED, 9-Nov-2013: 'gem_devel_dependencies' has been replaced with
171
+ 'gem_development_dependencies.' Please update this field in your
172
+ project_data.yaml"}]
173
+
174
+ end
175
+