puppet 2.7.20 → 2.7.21

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 (81) hide show
  1. data/CHANGELOG +226 -0
  2. data/conf/auth.conf +3 -3
  3. data/ext/packaging/README.md +191 -57
  4. data/ext/packaging/spec/spec_helper.rb +2 -2
  5. data/ext/packaging/spec/tasks/00_utils_spec.rb +63 -18
  6. data/ext/packaging/spec/tasks/build_object_spec.rb +171 -0
  7. data/ext/packaging/tasks/00_utils.rake +186 -33
  8. data/ext/packaging/tasks/10_setupvars.rake +94 -65
  9. data/ext/packaging/tasks/20_setupextravars.rake +45 -26
  10. data/ext/packaging/tasks/30_metrics.rake +41 -0
  11. data/ext/packaging/tasks/apple.rake +92 -36
  12. data/ext/packaging/tasks/build.rake +183 -0
  13. data/ext/packaging/tasks/deb.rake +45 -40
  14. data/ext/packaging/tasks/deb_repos.rake +103 -0
  15. data/ext/packaging/tasks/doc.rake +5 -5
  16. data/ext/packaging/tasks/fetch.rake +35 -10
  17. data/ext/packaging/tasks/gem.rake +38 -27
  18. data/ext/packaging/tasks/ips.rake +14 -14
  19. data/ext/packaging/tasks/jenkins.rake +337 -0
  20. data/ext/packaging/tasks/mock.rake +153 -72
  21. data/ext/packaging/tasks/pe_deb.rake +2 -2
  22. data/ext/packaging/tasks/pe_remote.rake +22 -19
  23. data/ext/packaging/tasks/pe_rpm.rake +5 -5
  24. data/ext/packaging/tasks/pe_ship.rake +31 -21
  25. data/ext/packaging/tasks/pe_sign.rake +20 -19
  26. data/ext/packaging/tasks/pe_sles.rake +40 -36
  27. data/ext/packaging/tasks/pe_tar.rake +5 -0
  28. data/ext/packaging/tasks/release.rake +32 -12
  29. data/ext/packaging/tasks/remote_build.rake +141 -83
  30. data/ext/packaging/tasks/retrieve.rake +23 -0
  31. data/ext/packaging/tasks/rpm.rake +11 -19
  32. data/ext/packaging/tasks/rpm_repos.rake +127 -0
  33. data/ext/packaging/tasks/ship.rake +68 -55
  34. data/ext/packaging/tasks/sign.rake +38 -10
  35. data/ext/packaging/tasks/tar.rake +25 -9
  36. data/ext/packaging/tasks/update.rake +2 -2
  37. data/ext/packaging/tasks/version.rake +34 -14
  38. data/ext/packaging/tasks/z_data_dump.rake +33 -0
  39. data/lib/puppet/indirector/catalog/compiler.rb +13 -2
  40. data/lib/puppet/indirector/certificate_status/file.rb +5 -0
  41. data/lib/puppet/indirector/errors.rb +5 -0
  42. data/lib/puppet/indirector/file_bucket_file/file.rb +4 -0
  43. data/lib/puppet/indirector/file_bucket_file/selector.rb +4 -0
  44. data/lib/puppet/indirector/indirection.rb +1 -0
  45. data/lib/puppet/indirector/resource/active_record.rb +3 -0
  46. data/lib/puppet/indirector/resource/ral.rb +4 -0
  47. data/lib/puppet/indirector/resource/store_configs.rb +3 -0
  48. data/lib/puppet/indirector/resource/validator.rb +8 -0
  49. data/lib/puppet/indirector/rest.rb +8 -0
  50. data/lib/puppet/indirector/run/local.rb +4 -0
  51. data/lib/puppet/indirector/terminus.rb +20 -0
  52. data/lib/puppet/network/formats.rb +3 -3
  53. data/lib/puppet/network/handler/master.rb +1 -1
  54. data/lib/puppet/network/handler/report.rb +1 -1
  55. data/lib/puppet/network/http/handler.rb +7 -1
  56. data/lib/puppet/network/http/rack/rest.rb +7 -2
  57. data/lib/puppet/network/http/webrick.rb +1 -0
  58. data/lib/puppet/network/rest_authconfig.rb +1 -1
  59. data/lib/puppet/parser/templatewrapper.rb +17 -17
  60. data/lib/puppet/util/monkey_patches.rb +58 -0
  61. data/lib/puppet/version.rb +1 -1
  62. data/spec/integration/indirector/catalog/compiler_spec.rb +1 -0
  63. data/spec/integration/indirector/catalog/queue_spec.rb +1 -1
  64. data/spec/integration/resource/catalog_spec.rb +1 -0
  65. data/spec/unit/indirector/catalog/compiler_spec.rb +29 -2
  66. data/spec/unit/indirector/indirection_spec.rb +18 -1
  67. data/spec/unit/indirector/terminus_spec.rb +191 -177
  68. data/spec/unit/network/formats_spec.rb +6 -6
  69. data/spec/unit/network/http/handler_spec.rb +25 -0
  70. data/spec/unit/network/http/rack/rest_spec.rb +17 -0
  71. data/spec/unit/network/http/webrick_spec.rb +4 -0
  72. data/spec/unit/network/http_pool_spec.rb +0 -1
  73. data/spec/unit/network/rest_authconfig_spec.rb +16 -1
  74. data/spec/unit/parser/functions/inline_template_spec.rb +13 -0
  75. data/spec/unit/parser/functions/template_spec.rb +15 -0
  76. data/spec/unit/parser/templatewrapper_spec.rb +19 -4
  77. data/spec/unit/ssl/certificate_request_spec.rb +2 -0
  78. data/spec/unit/ssl/host_spec.rb +1 -0
  79. data/spec/unit/util/monkey_patches_spec.rb +12 -0
  80. data/test/language/snippets.rb +1 -1
  81. metadata +13 -2
@@ -1,72 +1,101 @@
1
1
  require 'yaml'
2
2
  require 'erb'
3
+ require 'benchmark'
4
+ load File.expand_path('../build.rake', __FILE__)
3
5
 
4
- begin
5
- @project_specs ||= YAML.load_file('ext/project_data.yaml')
6
- @name = @project_specs['project']
7
- @author = @project_specs['author']
8
- @email = @project_specs['email']
9
- @homepage = @project_specs['homepage']
10
- @summary = @project_specs['summary']
11
- @description = @project_specs['description']
12
- @files = @project_specs['files']
13
- @tar_excludes = @project_specs['tar_excludes']
14
- @version_file = @project_specs['version_file']
15
- @gem_files = @project_specs['gem_files']
16
- @gem_require_path = @project_specs['gem_require_path']
17
- @gem_test_files = @project_specs['gem_test_files']
18
- @gem_executables = @project_specs['gem_executables']
19
- @gem_runtime_dependencies = @project_specs['gem_runtime_dependencies']
20
- @gem_devel_dependencies = @project_specs['gem_devel_dependencies']
21
- @gem_rdoc_options = @project_specs['gem_rdoc_options']
22
- @gem_forge_project = @project_specs['gem_forge_project']
23
- @gem_excludes = @project_specs['gem_excludes']
24
- rescue => e
25
- STDERR.puts "There was an error loading the project specifications from the 'ext/project_data.yaml' file.\n" + e
26
- exit 1
6
+ ##
7
+ # Where we get the data for our project depends on if a PARAMS_FILE environment
8
+ # variable is passed with the rake call. PARAMS_FILE should be a path to a yaml
9
+ # file containing all of the build parameters for a project, which are read
10
+ # into our BuildInstance object. If no build parameters file is specified, we
11
+ # assume input via the original methods of build_data.yaml and
12
+ # project_data.yaml. This also applies to the pl:fetch and pl:load_extras
13
+ # tasks, which are supplementary means of gathering data. These two are not
14
+ # used if a PARAMS_FILE is passed.
15
+
16
+ ##
17
+ # Create our BuildInstance object, which will contain all the data about our
18
+ # proposed build
19
+ #
20
+ @build = Build::BuildInstance.new
21
+
22
+ if ENV['PARAMS_FILE'] && ENV['PARAMS_FILE'] != ''
23
+ @build.set_params_from_file(ENV['PARAMS_FILE'])
24
+ else
25
+ # Load information about the project from the default params files
26
+ #
27
+ @build.set_params_from_file('ext/project_data.yaml') if File.readable?('ext/project_data.yaml')
28
+ @build.set_params_from_file('ext/build_defaults.yaml') if File.readable?('ext/build_defaults.yaml')
29
+
30
+ # Allow environment variables to override the settings we just read in. These
31
+ # variables are called out specifically because they are likely to require
32
+ # overriding in at least some cases.
33
+ #
34
+ @build.sign_tar = boolean_value(ENV['SIGN_TAR']) if ENV['SIGN_TAR']
35
+ @build.build_gem = boolean_value(ENV['GEM']) if ENV['GEM']
36
+ @build.build_dmg = boolean_value(ENV['DMG']) if ENV['DMG']
37
+ @build.build_ips = boolean_value(ENV['IPS']) if ENV['IPS']
38
+ @build.build_doc = boolean_value(ENV['DOC']) if ENV['DOC']
39
+ @build.build_pe = boolean_value(ENV['PE_BUILD']) if ENV['PE_BUILD']
40
+ @build.debug = boolean_value(ENV['DEBUG']) if ENV['DEBUG']
41
+ @build.default_cow = ENV['COW'] if ENV['COW']
42
+ @build.cows = ENV['COW'] if ENV['COW']
43
+ @build.pbuild_conf = ENV['PBUILDCONF'] if ENV['PBUILDCONF']
44
+ @build.packager = ENV['PACKAGER'] if ENV['PACKAGER']
45
+ @build.default_mock = ENV['MOCK'] if ENV['MOCK']
46
+ @build.final_mocks = ENV['MOCK'] if ENV['MOCK']
47
+ @build.rc_mocks = ENV['MOCK'] if ENV['MOCK']
48
+ @build.gpg_name = ENV['GPG_NAME'] if ENV['GPG_NAME']
49
+ @build.gpg_key = ENV['GPG_KEY'] if ENV['GPG_KEY']
50
+ @build.certificate_pem = ENV['CERT_PEM'] if ENV['CERT_PEM']
51
+ @build.privatekey_pem = ENV['PRIVATE_PEM'] if ENV['PRIVATE_PEM']
52
+ @build.yum_host = ENV['YUM_HOST'] if ENV['YUM_HOST']
53
+ @build.yum_repo_path = ENV['YUM_REPO'] if ENV['YUM_REPO']
54
+ @build.apt_host = ENV['APT_HOST'] if ENV['APT_HOST']
55
+ @build.apt_repo_path = ENV['APT_REPO'] if ENV['APT_REPO']
56
+ end
57
+
58
+ ##
59
+ # These parameters are either generated dynamically by the project, or aren't
60
+ # sufficiently generic/multi-purpose enough to justify being in
61
+ # build_defaults.yaml or project_data.yaml.
62
+ #
63
+ @build.release ||= get_release
64
+ @build.version ||= get_dash_version
65
+ @build.gemversion ||= get_dot_version
66
+ @build.ipsversion ||= get_ips_version
67
+ @build.debversion ||= get_debversion
68
+ @build.origversion ||= get_origversion
69
+ @build.rpmversion ||= get_rpmversion
70
+ @build.rpmrelease ||= get_rpmrelease
71
+ @build.builder_data_file ||= 'builder_data.yaml'
72
+ @build.team = ENV['TEAM'] || 'dev'
73
+ @build.random_mockroot = ENV['RANDOM_MOCKROOT'] ? boolean_value(ENV['RANDOM_MOCKROOT']) : true
74
+ @keychain_loaded ||= FALSE
75
+ @build_root ||= Dir.pwd
76
+ ##
77
+ # For backwards compatibilty, we set build:@name to build:@project. @name was
78
+ # renamed to @project in an effort to align the variable names with what has
79
+ # been supported for parameter names in the params files.
80
+ #
81
+ @build.name = @build.project
82
+
83
+ if @build.debug
84
+ @build.print_params
27
85
  end
28
86
 
29
- begin
30
- @pkg_defaults ||= YAML.load_file('ext/build_defaults.yaml')
31
- @sign_tar = boolean_value( ENV['SIGN_TAR'] || @pkg_defaults['sign_tar'] )
32
- @build_gem = boolean_value( ENV['GEM'] || @pkg_defaults['build_gem'] )
33
- @build_dmg = boolean_value( ENV['DMG'] || @pkg_defaults['build_dmg'] )
34
- @build_ips = boolean_value( ENV['IPS'] || @pkg_defaults['build_ips'] )
35
- @build_doc = boolean_value( ENV['DOC'] || @pkg_defaults['build_doc'] )
36
- @build_pe = boolean_value( ENV['PE'] || @pkg_defaults['build_pe'] )
37
- @default_cow = ENV['COW'] || @pkg_defaults['default_cow']
38
- @cows = ENV['COW'] || @pkg_defaults['cows']
39
- @pbuild_conf = ENV['PBUILDCONF'] || @pkg_defaults['pbuild_conf']
40
- @packager = ENV['PACKAGER'] || @pkg_defaults['packager']
41
- @default_mock = ENV['MOCK'] || @pkg_defaults['default_mock']
42
- @final_mocks = ENV['MOCK'] || @pkg_defaults['final_mocks']
43
- @rc_mocks = ENV['MOCK'] || @pkg_defaults['rc_mocks']
44
- @gpg_name = ENV['GPG_NAME'] || @pkg_defaults['gpg_name']
45
- @gpg_key = ENV['GPG_KEY'] || @pkg_defaults['gpg_key']
46
- @certificate_pem = ENV['CERT_PEM'] || @pkg_defaults['certificate_pem']
47
- @privatekey_pem = ENV['PRIVATE_PEM'] || @pkg_defaults['privatekey_pem']
48
- @yum_host = @pkg_defaults['yum_host']
49
- @yum_repo_path = @pkg_defaults['yum_repo_path']
50
- @apt_host = @pkg_defaults['apt_host']
51
- @apt_repo_url = @pkg_defaults['apt_repo_url']
52
- @apt_repo_path = @pkg_defaults['apt_repo_path']
53
- @ips_repo = @pkg_defaults['ips_repo']
54
- @ips_store = @pkg_defaults['ips_store']
55
- @ips_host = @pkg_defaults['ips_host']
56
- @ips_inter_cert = @pkg_defaults['ips_inter_cert']
57
- rescue => e
58
- STDERR.puts "There was an error loading the packaging defaults from the 'ext/build_defaults.yaml' file.\n" + e
59
- exit 1
87
+ ##
88
+ # MM 1-22-2013
89
+ # We have long made all of the variables available to erb templates in the
90
+ # various projects. The problem is now that we've switched to encapsulating all
91
+ # of this inside a build object, that information is no longer available. This
92
+ # section is for backwards compatibility only. It sets an instance variable
93
+ # for all of the parameters inside the build object. This is repeated in
94
+ # 20_setupextrasvars.rake. Note: The intention is to eventually abolish this
95
+ # behavior. We want to access information from the build object, not in what
96
+ # are essentially globally available rake variables.
97
+ #
98
+ @build.params.each do |param, value|
99
+ self.instance_variable_set("@#{param}", value)
60
100
  end
61
101
 
62
- @build_root ||= Dir.pwd
63
- @version ||= @build_pe ? get_dot_version : get_dash_version
64
- @gemversion ||= get_dot_version
65
- @ipsversion ||= get_ips_version
66
- @debversion ||= get_debversion
67
- @origversion ||= get_origversion
68
- @rpmversion ||= get_rpmversion
69
- @rpmrelease ||= get_rpmrelease
70
- @keychain_loaded ||= FALSE
71
- @builder_data_file ||= 'builder_data.yaml'
72
- @team ||= ENV['TEAM'] || 'pe'
@@ -6,33 +6,52 @@
6
6
  # generic tasks with data not generally useful outside the
7
7
  # PL Release team
8
8
  namespace :pl do
9
- task :load_extras do
10
- begin
11
- @build_data = YAML.load_file("#{ENV['HOME']}/.packaging/#{@builder_data_file}")
12
- @rpm_build_host = @build_data['rpm_build_host'] if @build_data['rpm_build_host']
13
- @deb_build_host = @build_data['deb_build_host'] if @build_data['deb_build_host']
14
- @osx_build_host = @build_data['osx_build_host'] if @build_data['osx_build_host']
15
- @ips_build_host = @build_data['ips_build_host'] if @build_data['ips_build_host']
16
- @tarball_path = @build_data['tarball_path'] if @build_data['tarball_path']
17
- @dmg_path = @build_data['dmg_path'] if @build_data['dmg_path']
18
- @pe_version = @build_data['pe_version'] if @build_data['pe_version']
19
- @team = @build_data['team'] if @build_data['team']
20
- @yum_repo_path = @build_data['yum_repo_path'] if @build_data['yum_repo_path']
21
- @apt_repo_path = @build_data['apt_repo_path'] if @build_data['apt_repo_path']
22
- @freight_conf = @build_data['freight_conf'] if @build_data['freight_conf']
23
- @sles_build_host = @build_data['sles_build_host'] if @build_data['sles_build_host']
24
- @sles_arch_repos = @build_data['sles_arch_repos'] if @build_data['sles_arch_repos']
25
- @sles_repo_path = @build_data['sles_repo_path'] if @build_data['sles_repo_path']
26
- @sles_repo_host = @build_data['sles_repo_host'] if @build_data['sles_repo_host']
27
- @ips_path = @build_data['ips_path'] if @build_data['ips_path']
28
- @ips_package_host = @build_data['ips_package_host'] if @build_data['ips_package_host']
29
- @certificate_pem = @build_data['certificate_pem'] if @build_data['certificate_pem']
30
- @privatekey_pem = @build_data['privatekey_pem'] if @build_data['privatekey_pem']
31
- @ips_inter_cert = @build_data['ips_inter_cert'] if @build_data['ips_inter_cert']
32
- rescue => e
33
- STDERR.puts "There was an error loading the builder data from #{ENV['HOME']}/.packaging/#{@builder_data_file}. Try rake pl:fetch to download the current extras builder data.\n" + e
34
- exit 1
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
+ @build.set_params_from_file("#{tempdir}/team/#{@build.builder_data_file}")
14
+ @build.set_params_from_file("#{tempdir}/project/#{@build.builder_data_file}")
15
+ # Overrideable
16
+ @build.build_pe = boolean_value(ENV['PE_BUILD']) if ENV['PE_BUILD']
17
+ # right now, puppetdb is the only one to override these, because it needs
18
+ # two sets of cows, one for PE and the other for FOSS
19
+ @build.cows = ENV['COW'] if ENV['COW']
20
+ @build.final_mocks = ENV['MOCK'] if ENV['MOCK']
21
+ @build.packager = ENV['PACKAGER'] if ENV['PACKAGER']
22
+ @build.pe_version = ENV['PE_VER'] if ENV['PE_VER']
23
+ @build.yum_repo_path = ENV['YUM_REPO'] if ENV['YUM_REPO']
24
+ @build.yum_host = ENV['YUM_HOST'] if ENV['YUM_HOST']
25
+ @build.apt_host = ENV['APT_HOST'] if ENV['APT_HOST']
26
+ @build.apt_repo_path = ENV['APT_REPO'] if ENV['APT_REPO']
35
27
  end
36
28
  end
37
29
  end
30
+ if @build.team == 'release'
31
+ @build.benchmark = TRUE
32
+ end
33
+
34
+ ##
35
+ # Starting with puppetdb, we'll maintain two separate build-data files, one for
36
+ # PE and the other for FOSS. This is the start to maintaining both PE and FOSS
37
+ # packaging in one source repo. As is done in 10_setupvars.rake, the @name
38
+ # variable is set to the value of @project, for backwards compatibility.
39
+ #
40
+ unless @build.pe_name.nil?
41
+ @build.project = @build.pe_name
42
+ @build.name = @build.project
43
+ end
38
44
 
45
+ ##
46
+ # MM 1-22-2013
47
+ # We have long made all of the variables available to erb templates in the
48
+ # various projects. The problem is now that we've switched to encapsulating all
49
+ # of this inside a build object, that information is no longer available. This
50
+ # section is for backwards compatibility only. It sets an instance variable
51
+ # for all of the parameters inside the build object. This is repeated in
52
+ # 10_setupvars.rake. Note that the intention is to eventually abolish this
53
+ # behavior, and access the parameters via the build object only.
54
+ #
55
+ @build.params.each do |param, value|
56
+ self.instance_variable_set("@#{param}", value)
57
+ end
@@ -0,0 +1,41 @@
1
+ if @build.benchmark
2
+ @metrics = []
3
+ @pg_major_version = nil
4
+ @db_table = 'metrics'
5
+
6
+ def add_metrics args
7
+ @metrics << {
8
+ :bench => args[:bench],
9
+ :dist => ( args[:dist] || ENV['DIST'] ),
10
+ :pkg => ( args[:pkg] || @build.project ),
11
+ :version => ( args[:version] || @build.version ),
12
+ :pe_version => ( args[:pe_version] || @build.pe_version ),
13
+ :date => ( args[:date] || timestamp ),
14
+ :who => ( args[:who] || ENV['USER'] ),
15
+ :where => ( args[:where] || hostname )
16
+ }
17
+ end
18
+
19
+ def post_metrics
20
+ if psql = find_tool('psql')
21
+ ENV["PGCONNECT_TIMEOUT"]="10"
22
+
23
+ @metrics.each do |metric|
24
+ date = metric[:date]
25
+ pkg = metric[:pkg]
26
+ dist = metric[:dist]
27
+ bench = metric[:bench]
28
+ who = metric[:who]
29
+ where = metric[:where]
30
+ version = metric[:version]
31
+ pe_version = metric[:pe_version]
32
+ @pg_major_version ||= %x{/usr/bin/psql --version}.match(/psql \(PostgreSQL\) (\d)\..*/)[1].to_i
33
+ no_pass_fail = "-w" if @pg_major_version > 8
34
+ %x{#{psql} #{no_pass_fail} -c "INSERT INTO #{@db_table} \
35
+ (date, package, dist, build_time, build_user, build_loc, version, pe_version) \
36
+ VALUES ('#{date}', '#{pkg}', '#{dist}', #{bench}, '#{who}', '#{where}', '#{version}', '#{pe_version}')"}
37
+ end
38
+ @metrics = []
39
+ end
40
+ end
41
+ end
@@ -1,4 +1,4 @@
1
- # Title: Rake task to build Apple packages for #{@name}.
1
+ # Title: Rake task to build Apple packages for #{@project}.
2
2
  # Author: Gary Larizza
3
3
  # Date: 05/18/2012
4
4
  # Description: This task will create a DMG-encapsulated package that will
@@ -20,17 +20,17 @@ SED = '/usr/bin/sed'
20
20
  task :setup do
21
21
  # Read the Apple file-mappings
22
22
  begin
23
- @source_files = YAML.load_file('ext/osx/file_mapping.yaml')
23
+ @source_files = data_from_yaml('ext/osx/file_mapping.yaml')
24
24
  rescue
25
25
  STDERR.puts "Could not load Apple file mappings from 'ext/osx/file_mapping.yaml'"
26
26
  exit 1
27
27
  end
28
- @package_name = @name
29
- @title = "#{@name}-#{@version}"
30
- @reverse_domain = "com.#{@packager}.#{@package_name}"
31
- @package_major_version = @version.split('.')[0]
32
- @package_minor_version = @version.split('.')[1] +
33
- @version.split('.')[2].split('-')[0].split('rc')[0]
28
+ @package_name = @build.project
29
+ @title = "#{@build.project}-#{@build.version}"
30
+ @reverse_domain = "com.#{@build.packager}.#{@package_name}"
31
+ @package_major_version = @build.version.split('.')[0]
32
+ @package_minor_version = @build.version.split('.')[1] +
33
+ @build.version.split('.')[2].split('-')[0].split('rc')[0]
34
34
  @pm_restart = 'None'
35
35
  @build_date = Time.new.strftime("%Y-%m-%dT%H:%M:%SZ")
36
36
  @apple_bindir = '/usr/bin'
@@ -59,17 +59,26 @@ def make_directory_tree
59
59
  mkdir_p(val)
60
60
  end
61
61
 
62
- erb 'ext/osx/preflight.erb', "#{@working_tree["scripts"]}/preflight"
63
- erb 'ext/osx/prototype.plist.erb', "#{@scratch}/prototype.plist"
62
+ if File.exists?('ext/osx/postflight.erb')
63
+ erb 'ext/osx/postflight.erb', "#{@working_tree["scripts"]}/postflight"
64
+ end
65
+
66
+ if File.exists?('ext/osx/preflight.erb')
67
+ erb 'ext/osx/preflight.erb', "#{@working_tree["scripts"]}/preflight"
68
+ end
69
+
70
+ if File.exists?('ext/osx/prototype.plist.erb')
71
+ erb 'ext/osx/prototype.plist.erb', "#{@scratch}/prototype.plist"
72
+ end
64
73
 
65
74
  end
66
75
 
67
76
  # method: build_dmg
68
77
  # description: This method builds a package from the directory structure in
69
- # /tmp/#{@name} and puts it in the
70
- # /tmp/#{@name}/#{@name}-#{version}/payload directory. A DMG is
78
+ # /tmp/#{@project} and puts it in the
79
+ # /tmp/#{@project}/#{@project}-#{version}/payload directory. A DMG is
71
80
  # created, using hdiutil, based on the contents of the
72
- # /tmp/#{@name}/#{@name}-#{version}/payload directory. The resultant
81
+ # /tmp/#{@project}/#{@project}-#{version}/payload directory. The resultant
73
82
  # DMG is placed in the pkg/apple directory.
74
83
  #
75
84
  def build_dmg
@@ -105,20 +114,20 @@ def build_dmg
105
114
  #{dmg_file}")
106
115
 
107
116
  if File.directory?("#{pwd}/pkg/apple")
108
- mv("#{pwd}/#{dmg_file}", "#{pwd}/pkg/apple/#{dmg_file}")
117
+ sh "sudo mv #{pwd}/#{dmg_file} #{pwd}/pkg/apple/#{dmg_file}"
109
118
  puts "moved: #{dmg_file} has been moved to #{pwd}/pkg/apple/#{dmg_file}"
110
119
  else
111
120
  mkdir_p("#{pwd}/pkg/apple")
112
- mv(dmg_file, "#{pwd}/pkg/apple/#{dmg_file}")
121
+ sh "sudo mv #{pwd}/#{dmg_file} #{pwd}/pkg/apple/#{dmg_file}"
113
122
  puts "moved: #{dmg_file} has been moved to #{pwd}/pkg/apple/#{dmg_file}"
114
123
  end
115
124
  end
116
125
 
117
126
  # method: pack_source
118
- # description: This method copies the #{@name} source into a directory
119
- # structure in /tmp/#{@name}/#{@name}-#{version}/root mirroring the
127
+ # description: This method copies the #{@project} source into a directory
128
+ # structure in /tmp/#{@project}/#{@project}-#{version}/root mirroring the
120
129
  # structure on the target system for which the package will be
121
- # installed. Anything installed into /tmp/#{@name}/root will be
130
+ # installed. Anything installed into /tmp/#{@project}/root will be
122
131
  # installed as the package's payload.
123
132
  #
124
133
  def pack_source
@@ -145,8 +154,16 @@ def pack_source
145
154
 
146
155
  # Setup a preflight script and replace variables in the files with
147
156
  # the correct paths.
148
- chown('root', 'wheel', "#{@working_tree['scripts']}/preflight")
149
- chmod(0644, "#{@working_tree['scripts']}/preflight")
157
+ if File.exists?("#{@working_tree['scripts']}/preflight")
158
+ chmod(0644, "#{@working_tree['scripts']}/preflight")
159
+ sh "sudo chown root:wheel #{@working_tree['scripts']}/preflight"
160
+ end
161
+
162
+ # Setup a postflight from from the erb created earlier
163
+ if File.exists?("#{@working_tree['scripts']}/postflight")
164
+ chmod(0755, "#{@working_tree['scripts']}/postflight")
165
+ sh "sudo chown root:wheel #{@working_tree['scripts']}/postflight"
166
+ end
150
167
 
151
168
  # Do a run through first setting the specified permissions then
152
169
  # making sure 755 is set for all directories
@@ -156,12 +173,42 @@ def pack_source
156
173
  group = params['group']
157
174
  perms = params['perms']
158
175
  path = params['path']
159
- chmod_R(Integer(perms), "#{work}/#{path}")
160
- chown_R(owner, group, "#{work}/#{path}")
161
- chmod(0755, "#{work}/#{path}")
176
+ ##
177
+ # Before setting our default permissions for all subdirectories/files of
178
+ # each directory listed in directories, we have to get a list of the
179
+ # directories. Otherwise, when we set the default perms (most likely
180
+ # 0644) we'll lose traversal on subdirectories, and later when we want to
181
+ # ensure they're 755 we won't be able to find them.
182
+ #
183
+ directories = []
162
184
  Dir["#{work}/#{path}/**/*"].each do |file|
163
- chmod(0755, file) if File.directory?(file)
185
+ directories << file if File.directory?(file)
164
186
  end
187
+
188
+ ##
189
+ # Here we're setting the default permissions for all files as described
190
+ # in file_mapping.yaml. Since we have a listing of directories, it
191
+ # doesn't matter if we remove executable permission on directories, we'll
192
+ # reset it later.
193
+ #
194
+ sh "sudo chmod -R #{perms} #{work}/#{path}"
195
+
196
+ ##
197
+ # We know at least one directory, the one listed in file_mapping.yaml, so
198
+ # we set it executable.
199
+ #
200
+ sh "sudo chmod 0755 #{work}/#{path}"
201
+
202
+ ##
203
+ # Now that default perms are set, we go in and reset executable perms on
204
+ # directories
205
+ #
206
+ directories.each { |d| sh "sudo chmod 0755 #{d}" }
207
+
208
+ ##
209
+ # Finally we set the owner/group as described in file_mapping.yaml
210
+ #
211
+ sh "sudo chown -R #{owner}:#{group} #{work}/#{path}"
165
212
  end
166
213
  end
167
214
 
@@ -173,8 +220,8 @@ def pack_source
173
220
  perms = params['perms']
174
221
  dest = params['path']
175
222
  # Allow for regexs like [A-Z]*
176
- FileList[file].each do |file|
177
- cmd = "#{INSTALL} -o #{owner} -g #{group} -m #{perms} #{source}/#{file} #{work}/#{dest}"
223
+ FileList[file].each do |f|
224
+ cmd = "sudo #{INSTALL} -o #{owner} -g #{group} -m #{perms} #{source}/#{f} #{work}/#{dest}"
178
225
  puts cmd
179
226
  system(cmd)
180
227
  end
@@ -182,20 +229,29 @@ def pack_source
182
229
  end
183
230
  end
184
231
 
185
- if @build_dmg
232
+ if @build.build_dmg
186
233
  namespace :package do
187
234
  desc "Task for building an Apple Package"
188
235
  task :apple => [:setup] do
189
- # Test for Root and Packagemaker binary
190
- raise "Please run rake as root to build Apple Packages" unless Process.uid == 0
191
- raise "Packagemaker must be installed. Please install XCode Tools" unless \
192
- File.exists?('/Developer/usr/bin/packagemaker')
193
-
194
- make_directory_tree
195
- pack_source
196
- build_dmg
197
- chmod_R(0775, "#{pwd}/pkg")
236
+ bench = Benchmark.realtime do
237
+ # Test for Packagemaker binary
238
+ raise "Packagemaker must be installed. Please install XCode Tools" unless \
239
+ File.exists?(PACKAGEMAKER)
240
+
241
+ make_directory_tree
242
+ pack_source
243
+ build_dmg
244
+ end
245
+ if @build.benchmark
246
+ add_metrics({ :dist => 'osx', :bench => bench })
247
+ post_metrics
248
+ end
198
249
  end
199
250
  end
251
+
252
+ # An alias task to simplify our remote logic in jenkins.rake
253
+ namespace :pl do
254
+ task :dmg => "package:apple"
255
+ end
200
256
  end
201
257