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
@@ -17,32 +17,35 @@ namespace :pl do
17
17
  task :uber_build => "pl:fetch" do
18
18
  # If we have a dirty source, bail, because changes won't get reflected in
19
19
  # the package builds
20
- fail_on_dirty_source
20
+ Pkg::Util::Version.fail_on_dirty_source
21
21
 
22
22
  # Use JSON to parse the json part of the submission, so we want to fail
23
23
  # here also if JSON isn't available
24
- require_library_or_fail 'json'
24
+ Pkg::Util.require_library_or_fail 'json'
25
25
 
26
26
  # The uber_build.xml.erb file is an XML erb template that will define a
27
27
  # job in Jenkins with all of the appropriate tasks
28
- work_dir = get_temp
28
+ work_dir = Pkg::Util::File.mktemp
29
29
  template_dir = File.join(File.dirname(__FILE__), '..', 'templates')
30
30
  templates = ['repo.xml.erb', 'packaging.xml.erb']
31
- templates.unshift('downstream.xml.erb') if ENV['DOWNSTREAM_JOB']
31
+ templates << ('downstream.xml.erb') if ENV['DOWNSTREAM_JOB']
32
32
 
33
33
  # Generate an XML file for every job configuration erb and attempt to
34
34
  # create a jenkins job from that XML config
35
35
  templates.each do |t|
36
- erb_file = File.join(template_dir, t)
36
+ erb_template = File.join(template_dir, t)
37
37
  xml_file = File.join(work_dir, t.gsub('.erb', ''))
38
- erb(erb_file, xml_file)
39
- job_name = "#{@build.project}-#{t.gsub('.xml.erb','')}-#{@build.build_date}-#{@build.ref}"
38
+ Pkg::Util::File.erb_file(erb_template, xml_file, nil, :binding => Pkg::Config.get_binding)
39
+ job_name = "#{Pkg::Config.project}-#{t.gsub('.xml.erb','')}-#{Pkg::Config.build_date}-#{Pkg::Config.ref}"
40
40
  puts "Checking for existence of #{job_name}..."
41
41
  if jenkins_job_exists?(job_name)
42
- raise "Job #{job_name} already exists on #{@build.jenkins_build_host}"
42
+ raise "Job #{job_name} already exists on #{Pkg::Config.jenkins_build_host}"
43
43
  else
44
44
  retry_on_fail(:times => 3) do
45
45
  url = create_jenkins_job(job_name, xml_file)
46
+ if t == "packaging.xml.erb"
47
+ ENV["PACKAGE_BUILD_URL"] = url
48
+ end
46
49
  puts "Verifying job created successfully..."
47
50
  unless jenkins_job_exists?(job_name)
48
51
  raise "Unable to verify Jenkins job, trying again..."
@@ -52,7 +55,7 @@ namespace :pl do
52
55
  end
53
56
  end
54
57
  rm_r work_dir
55
- packaging_name = "#{@build.project}-packaging-#{@build.build_date}-#{@build.ref}"
58
+ packaging_name = "#{Pkg::Config.project}-packaging-#{Pkg::Config.build_date}-#{Pkg::Config.ref}"
56
59
  invoke_task("pl:jenkins:trigger_dynamic_job", packaging_name)
57
60
  end
58
61
 
@@ -62,20 +65,20 @@ namespace :pl do
62
65
  task :trigger_dynamic_job, :name do |t, args|
63
66
  name = args.name
64
67
 
65
- properties = @build.params_to_yaml
68
+ properties = Pkg::Config.config_to_yaml
66
69
  bundle = git_bundle('HEAD')
67
70
 
68
71
  # Create a string of metrics to send to Jenkins for data analysis
69
- if @build.pe_version
70
- metrics = "#{ENV['USER']}~#{@build.version}~#{@build.pe_version}~#{@build.team}"
72
+ if Pkg::Config.pe_version
73
+ metrics = "#{ENV['USER']}~#{Pkg::Config.version}~#{Pkg::Config.pe_version}~#{Pkg::Config.team}"
71
74
  else
72
- metrics = "#{ENV['USER']}~#{@build.version}~N/A~#{@build.team}"
75
+ metrics = "#{ENV['USER']}~#{Pkg::Config.version}~N/A~#{Pkg::Config.team}"
73
76
  end
74
77
 
75
78
  # Construct the parameters, which is an array of hashes we turn into JSON
76
79
  parameters = [{ "name" => "BUILD_PROPERTIES", "file" => "file0" },
77
80
  { "name" => "PROJECT_BUNDLE", "file" => "file1" },
78
- { "name" => "PROJECT", "value" => "#{@build.project}" },
81
+ { "name" => "PROJECT", "value" => "#{Pkg::Config.project}" },
79
82
  { "name" => "METRICS", "value" => "#{metrics}"}]
80
83
 
81
84
  # Contruct the json string
@@ -86,18 +89,18 @@ namespace :pl do
86
89
  curl_args = [
87
90
  "-Fname=BUILD_PROPERTIES", "-Ffile0=@#{properties}",
88
91
  "-Fname=PROJECT_BUNDLE" , "-Ffile1=@#{bundle}",
89
- "-Fname=PROJECT" , "-Fvalue=#{@build.project}",
92
+ "-Fname=PROJECT" , "-Fvalue=#{Pkg::Config.project}",
90
93
  "-Fname=METRICS" , "-Fvalue=#{metrics}",
91
94
  "-FSubmit=Build",
92
95
  "-Fjson=#{json.to_json}",
93
96
  ]
94
97
 
95
98
  # Contstruct the job url
96
- trigger_url = "#{@build.jenkins_build_host}/job/#{name}/build"
99
+ trigger_url = "#{Pkg::Config.jenkins_build_host}/job/#{name}/build"
97
100
 
98
101
  if curl_form_data(trigger_url, curl_args)
99
- print_url_info("#{@build.jenkins_build_host}/job/#{name}")
100
- puts "Your packages will be available at #{@build.distribution_server}:#{@build.jenkins_repo_path}/#{@build.project}/#{@build.ref}"
102
+ print_url_info("http://#{Pkg::Config.jenkins_build_host}/job/#{name}")
103
+ puts "Your packages will be available at #{Pkg::Config.distribution_server}:#{Pkg::Config.jenkins_repo_path}/#{Pkg::Config.project}/#{Pkg::Config.ref}"
101
104
  else
102
105
  fail "An error occurred submitting the job to jenkins. Take a look at the preceding http response for more info."
103
106
  end
@@ -113,7 +116,7 @@ namespace :pe do
113
116
  namespace :jenkins do
114
117
  desc "Dynamic Jenkins UBER build: Build all the things with ONE job"
115
118
  task :uber_build do
116
- check_var("PE_VER", @build.pe_version)
119
+ check_var("PE_VER", Pkg::Config.pe_version)
117
120
  invoke_task("pl:jenkins:uber_build")
118
121
  end
119
122
  end
@@ -0,0 +1,21 @@
1
+ # The pl:load_extras tasks is intended to load variables
2
+ # from the extra yaml file downloaded by the pl:fetch task.
3
+ # The goal is to be able to augment/override settings in the
4
+ # source project's build_data.yaml and project_data.yaml with
5
+ # Puppet Labs-specific data, rather than having to clutter the
6
+ # generic tasks with data not generally useful outside the
7
+ # PL Release team
8
+ namespace :pl do
9
+ task :load_extras, :tempdir do |t, args|
10
+ unless ENV['PARAMS_FILE'] && ENV['PARAMS_FILE'] != ''
11
+ tempdir = args.tempdir
12
+ raise "pl:load_extras requires a directory containing extras data" if tempdir.nil?
13
+ Pkg::Config.config_from_yaml("#{tempdir}/#{Pkg::Config.builder_data_file}")
14
+
15
+ # Environment variables take precedence over those loaded from configs,
16
+ # so we make sure that any we clobbered are reset.
17
+ Pkg::Config.load_envvars
18
+ end
19
+ end
20
+ end
21
+
@@ -18,10 +18,10 @@
18
18
  # e.g.,
19
19
  # pkg/el-5-i386/*.rpm
20
20
  def mock_artifact(mock_config, cmd_args)
21
- unless mock = find_tool('mock')
21
+ unless mock = Pkg::Util::Tool.find_tool('mock')
22
22
  raise "mock is required for building srpms with mock. Please install mock and try again."
23
23
  end
24
- randomize = @build.random_mockroot
24
+ randomize = Pkg::Config.random_mockroot
25
25
  configdir = nil
26
26
  basedir = File.join('var', 'lib', 'mock')
27
27
 
@@ -91,7 +91,7 @@ end
91
91
  # and pl-fedora-17-i386 = "fedora"
92
92
  #
93
93
  def mock_el_family(mock_config)
94
- if @build.build_pe
94
+ if Pkg::Config.build_pe
95
95
  family = mock_config.split('-')[2][/[a-z]+/]
96
96
  else
97
97
  first, second = mock_config.split('-')
@@ -113,7 +113,7 @@ end
113
113
  # and "pl-fedora-17-i386" = "17"
114
114
  #
115
115
  def mock_el_ver(mock_config)
116
- if @build.build_pe
116
+ if Pkg::Config.build_pe
117
117
  version = mock_config.split('-')[2][/[0-9]+/]
118
118
  else
119
119
  first, second, third = mock_config.split('-')
@@ -151,7 +151,7 @@ def build_rpm_with_mock(mocks)
151
151
  mocks.split(' ').each do |mock_config|
152
152
  family = mock_el_family(mock_config)
153
153
  version = mock_el_ver(mock_config)
154
- subdir = is_final? ? 'products' : 'devel'
154
+ subdir = Pkg::Util::Version.is_final? ? 'products' : 'devel'
155
155
  bench = Benchmark.realtime do
156
156
  # Set up the rpmbuild dir in a temp space, with our tarball and spec
157
157
  workdir = prep_rpm_build_dir
@@ -168,7 +168,7 @@ def build_rpm_with_mock(mocks)
168
168
  rpms.each do |rpm|
169
169
  rpm.strip!
170
170
 
171
- if @build.build_pe
171
+ if Pkg::Config.build_pe
172
172
  %x{mkdir -p pkg/pe/rpm/#{family}-#{version}-{srpms,i386,x86_64}}
173
173
  case File.basename(rpm)
174
174
  when /debuginfo/
@@ -181,7 +181,7 @@ def build_rpm_with_mock(mocks)
181
181
  cp_pr(rpm, "pkg/pe/rpm/#{family}-#{version}-x86_64")
182
182
  when /noarch/
183
183
  cp_pr(rpm, "pkg/pe/rpm/#{family}-#{version}-i386")
184
- ln("pkg/pe/rpm/#{family}-#{version}-i386/#{File.basename(rpm)}", "pkg/pe/rpm/#{family}-#{version}-x86_64/")
184
+ FileUtils.ln("pkg/pe/rpm/#{family}-#{version}-i386/#{File.basename(rpm)}", "pkg/pe/rpm/#{family}-#{version}-x86_64/", :force => true, :verbose => true)
185
185
  end
186
186
  else
187
187
  %x{mkdir -p pkg/#{family}/#{version}/#{subdir}/{SRPMS,i386,x86_64}}
@@ -196,14 +196,14 @@ def build_rpm_with_mock(mocks)
196
196
  cp_pr(rpm, "pkg/#{family}/#{version}/#{subdir}/x86_64")
197
197
  when /noarch/
198
198
  cp_pr(rpm, "pkg/#{family}/#{version}/#{subdir}/i386")
199
- ln("pkg/#{family}/#{version}/#{subdir}/i386/#{File.basename(rpm)}", "pkg/#{family}/#{version}/#{subdir}/x86_64/")
199
+ FileUtils.ln("pkg/#{family}/#{version}/#{subdir}/i386/#{File.basename(rpm)}", "pkg/#{family}/#{version}/#{subdir}/x86_64/", :force => true, :verbose => true)
200
200
  end
201
201
  end
202
202
  end
203
203
  # To avoid filling up the system with our random mockroots, we should
204
204
  # clean up. However, this requires sudo. If we don't have sudo, we'll
205
205
  # just fail and not clean up, but warn the user about it.
206
- if @build.random_mockroot
206
+ if Pkg::Config.random_mockroot
207
207
  %x{sudo -n echo 'Cleaning build root.'}
208
208
  if $?.success?
209
209
  sh "sudo -n rm -r #{File.dirname(srpm)}" unless File.dirname(srpm).nil?
@@ -231,7 +231,7 @@ def mock_with_basedir(mock, basedir)
231
231
  config = IO.readlines(mock)
232
232
  basedir = "config_opts['basedir'] = '#{basedir}'"
233
233
  config.unshift(basedir)
234
- tempdir = get_temp
234
+ tempdir = Pkg::Util::File.mktemp
235
235
  newmock = File.join(tempdir, File.basename(mock))
236
236
  File.open(newmock, 'w') { |f| f.puts config }
237
237
  newmock
@@ -245,7 +245,7 @@ end
245
245
  # configuration file and returns the path to the new configuration dir.
246
246
  #
247
247
  def setup_mock_config_dir(mock)
248
- tempdir = get_temp
248
+ tempdir = Pkg::Util::File.mktemp
249
249
  cp File.join('/', 'etc', 'mock', 'site-defaults.cfg'), tempdir
250
250
  cp File.join('/', 'etc', 'mock', 'logging.ini'), tempdir
251
251
  cp mock, tempdir
@@ -259,7 +259,7 @@ end
259
259
  #
260
260
  def randomize_mock_config_dir(mock_config)
261
261
  # basedir will be the location of our temporary mock root
262
- basedir = get_temp
262
+ basedir = Pkg::Util::File.mktemp
263
263
  chown("#{ENV['USER']}", "mock", basedir)
264
264
  # Mock requires the sticky bit be set on the basedir
265
265
  chmod(02775, basedir)
@@ -278,13 +278,13 @@ end
278
278
  namespace :pl do
279
279
  desc "Use default mock to make a final rpm, keyed to PL infrastructure, pass MOCK to specify config"
280
280
  task :mock => "package:tar" do
281
- # If default mock isn't specified, just take the first one in the @build.final_mocks list
282
- @build.default_mock ||= @build.final_mocks.split(' ')[0]
283
- build_rpm_with_mock(@build.default_mock)
281
+ # If default mock isn't specified, just take the first one in the Pkg::Config.final_mocks list
282
+ Pkg::Config.default_mock ||= Pkg::Config.final_mocks.split(' ')[0]
283
+ build_rpm_with_mock(Pkg::Config.default_mock)
284
284
  end
285
285
 
286
286
  desc "Use specified mocks to make rpms, keyed to PL infrastructure, pass MOCK to specifiy config"
287
287
  task :mock_all => "package:tar" do
288
- build_rpm_with_mock(@build.final_mocks)
288
+ build_rpm_with_mock(Pkg::Config.final_mocks)
289
289
  end
290
290
  end
@@ -1,9 +1,9 @@
1
1
  # "Alias" tasks for PE - these just point at the standard pl: tasks. They exist
2
2
  # for ease of aggregation with PE-specific tasks that _are_ actually different
3
3
  # from their "pl" counterparts
4
- if @build.build_pe
4
+ if Pkg::Config.build_pe
5
5
  namespace :pe do
6
- desc "Create a PE deb from this repo using the default cow #{@build.default_cow}."
6
+ desc "Create a PE deb from this repo using the default cow #{Pkg::Config.default_cow}."
7
7
  task :deb => "pl:deb"
8
8
 
9
9
  desc "Create PE debs from this git repository using all cows specified in build_defaults yaml"
@@ -1,33 +1,33 @@
1
1
  # PE remote tasks
2
2
  # We keep these around for backwards compatibility and as a backup in case the
3
3
  # jenkins infrastructure fails. We hide them to reduce task clutter
4
- if @build.build_pe
4
+ if Pkg::Config.build_pe
5
5
  namespace :pe do
6
6
  namespace :remote do
7
7
  task :deb => 'pl:fetch' do
8
- ENV['PE_VER'] ||= @build.pe_version
8
+ ENV['PE_VER'] ||= Pkg::Config.pe_version
9
9
  check_var('PE_VER', ENV['PE_VER'])
10
10
  Rake::Task["pl:remote:build"].reenable
11
- Rake::Task["pl:remote:build"].invoke(@build.deb_build_host, 'HEAD', "pe:deb PE_BUILD=#{@build.build_pe} TEAM=#{@build.team} PE_VER=#{ENV['PE_VER']}")
11
+ Rake::Task["pl:remote:build"].invoke(Pkg::Config.deb_build_host, 'HEAD', "pe:deb PE_BUILD=#{Pkg::Config.build_pe} TEAM=#{Pkg::Config.team} PE_VER=#{ENV['PE_VER']}")
12
12
  end
13
13
 
14
14
  task :deb_all => 'pl:fetch' do
15
- ENV['PE_VER'] ||= @build.pe_version
15
+ ENV['PE_VER'] ||= Pkg::Config.pe_version
16
16
  check_var('PE_VER', ENV['PE_VER'])
17
17
  Rake::Task["pl:remote:build"].reenable
18
- Rake::Task["pl:remote:build"].invoke(@build.deb_build_host, 'HEAD', "pe:deb_all PE_BUILD=#{@build.build_pe} COW='#{@build.cows}' TEAM=#{@build.team} PE_VER=#{ENV['PE_VER']}")
18
+ Rake::Task["pl:remote:build"].invoke(Pkg::Config.deb_build_host, 'HEAD', "pe:deb_all PE_BUILD=#{Pkg::Config.build_pe} COW='#{Pkg::Config.cows}' TEAM=#{Pkg::Config.team} PE_VER=#{ENV['PE_VER']}")
19
19
  end
20
20
 
21
21
  task :mock => 'pl:fetch' do
22
- ENV['PE_VER'] ||= @build.pe_version
22
+ ENV['PE_VER'] ||= Pkg::Config.pe_version
23
23
  Rake::Task["pl:remote:build"].reenable
24
- Rake::Task["pl:remote:build"].invoke(@build.rpm_build_host, 'HEAD', "pe:mock PE_BUILD=#{@build.build_pe} TEAM=#{@build.team} PE_VER=#{ENV['PE_VER']}")
24
+ Rake::Task["pl:remote:build"].invoke(Pkg::Config.rpm_build_host, 'HEAD', "pe:mock PE_BUILD=#{Pkg::Config.build_pe} TEAM=#{Pkg::Config.team} PE_VER=#{ENV['PE_VER']}")
25
25
  end
26
26
 
27
27
  task :mock_all => 'pl:fetch' do
28
- ENV['PE_VER'] ||= @build.pe_version
28
+ ENV['PE_VER'] ||= Pkg::Config.pe_version
29
29
  Rake::Task["pl:remote:build"].reenable
30
- Rake::Task["pl:remote:build"].invoke(@build.rpm_build_host, 'HEAD', "pe:mock_all PE_BUILD=#{@build.build_pe} MOCK='#{@build.final_mocks}' TEAM=#{@build.team} PE_VER=#{ENV['PE_VER']}")
30
+ Rake::Task["pl:remote:build"].invoke(Pkg::Config.rpm_build_host, 'HEAD', "pe:mock_all PE_BUILD=#{Pkg::Config.build_pe} MOCK='#{Pkg::Config.final_mocks}' TEAM=#{Pkg::Config.team} PE_VER=#{ENV['PE_VER']}")
31
31
  end
32
32
 
33
33
  task :all => ['clean', 'pl:fetch'] do
@@ -1,4 +1,4 @@
1
- if @build.build_pe
1
+ if Pkg::Config.build_pe
2
2
  namespace :pe do
3
3
  desc "Build a PE rpm using rpmbuild (requires all BuildRequires, rpmbuild, etc)"
4
4
  task :rpm => "package:rpm"
@@ -1,20 +1,20 @@
1
- if @build.build_pe
1
+ if Pkg::Config.build_pe
2
2
  namespace :pe do
3
- desc "ship PE rpms to #{@build.yum_host}"
3
+ desc "ship PE rpms to #{Pkg::Config.yum_host}"
4
4
  task :ship_rpms => "pl:fetch" do
5
- empty_dir?("pkg/pe/rpm") and fail "The 'pkg/pe/rpm' directory has no packages. Did you run rake pe:deb?"
6
- target_path = ENV['YUM_REPO'] ? ENV['YUM_REPO'] : "#{@build.yum_repo_path}/#{@build.pe_version}/repos/"
5
+ Pkg::Util::File.empty_dir?("pkg/pe/rpm") and fail "The 'pkg/pe/rpm' directory has no packages. Did you run rake pe:deb?"
6
+ target_path = ENV['YUM_REPO'] ? ENV['YUM_REPO'] : "#{Pkg::Config.yum_repo_path}/#{Pkg::Config.pe_version}/repos/"
7
7
  retry_on_fail(:times => 3) do
8
- rsync_to('pkg/pe/rpm/', @build.yum_host, target_path)
8
+ rsync_to('pkg/pe/rpm/', Pkg::Config.yum_host, target_path)
9
9
  end
10
- if @build.team == 'release'
10
+ if Pkg::Config.team == 'release'
11
11
  Rake::Task["pe:remote:update_yum_repo"].invoke
12
12
  end
13
13
  end
14
14
 
15
- desc "Ship PE debs to #{@build.apt_host}"
15
+ desc "Ship PE debs to #{Pkg::Config.apt_host}"
16
16
  task :ship_debs => "pl:fetch" do
17
- empty_dir?("pkg/pe/deb") and fail "The 'pkg/pe/deb' directory has no packages!"
17
+ Pkg::Util::File.empty_dir?("pkg/pe/deb") and fail "The 'pkg/pe/deb' directory has no packages!"
18
18
  target_path = ENV['APT_REPO']
19
19
 
20
20
  # If APT_REPO isn't specified as an environment variable, we use a temporary one
@@ -30,8 +30,8 @@ if @build.build_pe
30
30
  Dir["pkg/pe/deb/*"].each do |dist|
31
31
  dist = File.basename(dist)
32
32
  unless target_path
33
- puts "Creating temporary incoming dir on #{@build.apt_host}"
34
- target_path = %x{ssh -t #{@build.apt_host} 'mktemp -d -t incoming-XXXXXX'}.chomp
33
+ puts "Creating temporary incoming dir on #{Pkg::Config.apt_host}"
34
+ target_path = %x{ssh -t #{Pkg::Config.apt_host} 'mktemp -d -t incoming-XXXXXX'}.chomp
35
35
  end
36
36
 
37
37
  # For reprepro, we ship just the debs into an incoming dir. On the remote end,
@@ -49,15 +49,16 @@ if @build.build_pe
49
49
  # |_precise/*.deb
50
50
  # |_wheezy/*.deb
51
51
  #
52
- puts "Shipping PE debs to apt repo 'incoming' dir on #{@build.apt_host}"
52
+ puts "Shipping PE debs to apt repo 'incoming' dir on #{Pkg::Config.apt_host}"
53
53
  retry_on_fail(:times => 3) do
54
54
  Dir["pkg/pe/deb/#{dist}/*.deb"].each do |deb|
55
- remote_ssh_cmd(@build.apt_host, "mkdir -p '#{target_path}/#{dist}'")
56
- rsync_to(deb, @build.apt_host, "#{target_path}/#{dist}/#{File.basename(deb)}")
55
+ remote_ssh_cmd(Pkg::Config.apt_host, "mkdir -p '#{target_path}/#{dist}'")
56
+ rsync_to(deb, Pkg::Config.apt_host, "#{target_path}/#{dist}/#{File.basename(deb)}")
57
57
  end
58
58
  end
59
59
 
60
- if @build.team == 'release'
60
+ if Pkg::Config.team == 'release'
61
+ Rake::Task["pe:remote:apt"].reenable
61
62
  Rake::Task["pe:remote:apt"].invoke(target_path, dist)
62
63
  end
63
64
 
@@ -80,18 +81,18 @@ if @build.build_pe
80
81
  # by newer ones. To handle this, we make everything we ship to the archive
81
82
  # directories immutable, after rsyncing out.
82
83
  #
83
- base_path = "#{@build.apt_repo_path}/#{@build.pe_version}/repos"
84
+ base_path = "#{Pkg::Config.apt_repo_path}/#{Pkg::Config.pe_version}/repos"
84
85
 
85
- puts "Shipping all built artifacts to to archive directories on #{@build.apt_host}"
86
+ puts "Shipping all built artifacts to to archive directories on #{Pkg::Config.apt_host}"
86
87
 
87
- @build.cows.split(' ').map { |i| i.sub('.cow','') }.each do |cow|
88
+ Pkg::Config.cows.split(' ').map { |i| i.sub('.cow','') }.each do |cow|
88
89
  _base, dist, arch = cow.split('-')
89
- unless empty_dir? "pkg/pe/deb/#{dist}"
90
+ unless Pkg::Util::File.empty_dir? "pkg/pe/deb/#{dist}"
90
91
  archive_path = "#{base_path}/#{dist}-#{arch}"
91
92
 
92
93
  # Ship arch-specific debs to correct dir, e.g. 'squeeze-i386'
93
94
  unless Dir["pkg/pe/deb/#{dist}/pe-*_#{arch}.deb"].empty?
94
- rsync_to("pkg/pe/deb/#{dist}/pe-*_#{arch}.deb --ignore-existing", @build.apt_host, "#{archive_path}/" )
95
+ rsync_to("pkg/pe/deb/#{dist}/pe-*_#{arch}.deb --ignore-existing", Pkg::Config.apt_host, "#{archive_path}/" )
95
96
  end
96
97
 
97
98
  # Ship all-arch debs to same dist-location, but to all known
@@ -101,16 +102,16 @@ if @build.build_pe
101
102
 
102
103
  unless Dir["pkg/pe/deb/#{dist}/pe-*_all.deb"].empty?
103
104
  if dist =~ /cumulus/
104
- rsync_to("pkg/pe/deb/#{dist}/pe-*_all.deb --ignore-existing", @build.apt_host, "#{base_path}/#{dist}-powerpc/")
105
+ rsync_to("pkg/pe/deb/#{dist}/pe-*_all.deb --ignore-existing", Pkg::Config.apt_host, "#{base_path}/#{dist}-powerpc/")
105
106
  else
106
- rsync_to("pkg/pe/deb/#{dist}/pe-*_all.deb --ignore-existing", @build.apt_host, "#{base_path}/#{dist}-i386/")
107
- rsync_to("pkg/pe/deb/#{dist}/pe-*_all.deb --ignore-existing", @build.apt_host, "#{base_path}/#{dist}-amd64/")
107
+ rsync_to("pkg/pe/deb/#{dist}/pe-*_all.deb --ignore-existing", Pkg::Config.apt_host, "#{base_path}/#{dist}-i386/")
108
+ rsync_to("pkg/pe/deb/#{dist}/pe-*_all.deb --ignore-existing", Pkg::Config.apt_host, "#{base_path}/#{dist}-amd64/")
108
109
  end
109
110
  end
110
111
 
111
112
  unless Dir["pkg/pe/deb/#{dist}/pe-*"].select { |i| i !~ /^.*\.deb$/ }.empty?
112
113
  # Ship source files to source dir, e.g. 'squeeze-source'
113
- rsync_to("pkg/pe/deb/#{dist}/pe-* --exclude *.deb --ignore-existing", @build.apt_host, "#{base_path}/#{dist}-source")
114
+ rsync_to("pkg/pe/deb/#{dist}/pe-* --exclude *.deb --ignore-existing", Pkg::Config.apt_host, "#{base_path}/#{dist}-source")
114
115
  end
115
116
 
116
117
  files = Dir["pkg/pe/deb/#{dist}/pe-*{_#{arch},all}.deb"].map { |f| "#{archive_path}/#{File.basename(f)}" }
@@ -118,17 +119,27 @@ if @build.build_pe
118
119
  files += Dir["pkg/pe/deb/#{dist}/pe-*"].select { |f| f !~ /^.*\.deb$/ }.map { |f| "#{base_path}/#{dist}-source/#{File.basename(f)}" }
119
120
 
120
121
  unless files.empty?
121
- remote_set_immutable(@build.apt_host, files)
122
+ remote_set_immutable(Pkg::Config.apt_host, files)
122
123
  end
123
124
  end
124
125
  end
125
-
126
126
  end
127
127
 
128
128
  namespace :remote do
129
- desc "Update remote rpm repodata for PE on #{@build.yum_host}"
129
+ desc "Update remote rpm repodata for PE on #{Pkg::Config.yum_host}"
130
130
  task :update_yum_repo => "pl:fetch" do
131
- remote_ssh_cmd(@build.yum_host, "for dir in $(find #{@build.apt_repo_path}/#{@build.pe_version}/repos/{sles,el}* -type d | grep -v repodata | grep -v cache | xargs) ; do pushd $dir; sudo createrepo -q -d --update .; popd &> /dev/null ; done; sync")
131
+ repo_base_path = File.join(Pkg::Config.yum_repo_path, Pkg::Config.pe_version, "repos")
132
+ mock_paths = Pkg::Config.final_mocks.split.map {|mock| "#{mock_el_family(mock)}-#{mock_el_ver(mock)}"}
133
+
134
+ # This entire command is going to be passed across SSH, but it's unwieldy on a
135
+ # single line. By breaking it into a series of concatenated strings, we can maintain
136
+ # a semblance of formatting and structure (nevermind readability).
137
+ command = %{for dir in #{repo_base_path}/{#{mock_paths.join(",")}}-*; do}
138
+ command += %{ sudo createrepo --checksum=sha --quiet --database --update $dir; }
139
+ command += %{done; }
140
+ command += %{sync}
141
+
142
+ remote_ssh_cmd(Pkg::Config.yum_host, command)
132
143
  end
133
144
 
134
145
  # the repsimple application is a small wrapper around reprepro, the purpose of
@@ -137,30 +148,30 @@ if @build.build_pe
137
148
  # command expects an incoming directory option containing .deb files.
138
149
  # Per previous comments, the incoming directory must contain subdirectories named
139
150
  # for debian distributions.
140
- desc "Remotely add shipped packages to apt repo on #{@build.apt_host}"
151
+ desc "Remotely add shipped packages to apt repo on #{Pkg::Config.apt_host}"
141
152
  task :apt, :incoming, :dist do |t, args|
142
153
  dist = args.dist
143
154
  if dist =~ /cumulus/
144
- reprepro_confdir = "/etc/reprepro/networking/#{@build.pe_version}/cumulus"
145
- reprepro_basedir = "/opt/enterprise/networking/#{@build.pe_version}/cumulus"
146
- reprepro_dbdir = "/var/lib/reprepro/networking/#{@build.pe_version}/cumulus"
155
+ reprepro_confdir = "/etc/reprepro/networking/#{Pkg::Config.pe_version}/cumulus"
156
+ reprepro_basedir = "/opt/enterprise/networking/#{Pkg::Config.pe_version}/cumulus"
157
+ reprepro_dbdir = "/var/lib/reprepro/networking/#{Pkg::Config.pe_version}/cumulus"
147
158
  else
148
- reprepro_confdir = "/etc/reprepro/#{@build.pe_version}"
149
- reprepro_basedir = "#{@build.apt_repo_path}/#{@build.pe_version}/repos/debian"
150
- reprepro_dbdir = "/var/lib/reprepro/#{@build.pe_version}"
159
+ reprepro_confdir = "/etc/reprepro/#{Pkg::Config.pe_version}"
160
+ reprepro_basedir = "#{Pkg::Config.apt_repo_path}/#{Pkg::Config.pe_version}/repos/debian"
161
+ reprepro_dbdir = "/var/lib/reprepro/#{Pkg::Config.pe_version}"
151
162
  end
152
163
 
153
164
  incoming_dir = args.incoming
154
165
  incoming_dir or fail "Adding packages to apt repo requires an incoming directory"
155
166
  invoke_task("pl:fetch")
156
- remote_ssh_cmd(@build.apt_host, "/usr/bin/repsimple add_all \
167
+ remote_ssh_cmd(Pkg::Config.apt_host, "/usr/bin/repsimple add_all \
157
168
  --confdir #{reprepro_confdir} \
158
169
  --basedir #{reprepro_basedir} \
159
170
  --databasedir #{reprepro_dbdir} \
160
171
  --incomingdir #{incoming_dir}")
161
172
 
162
- puts "Cleaning up apt repo 'incoming' dir on #{@build.apt_host}"
163
- remote_ssh_cmd(@build.apt_host, "rm -r #{incoming_dir}")
173
+ puts "Cleaning up apt repo 'incoming' dir on #{Pkg::Config.apt_host}"
174
+ remote_ssh_cmd(Pkg::Config.apt_host, "rm -r #{incoming_dir}")
164
175
 
165
176
  end
166
177
  end