packaging 0.88.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +17 -0
  3. data/README-Solaris.md +117 -0
  4. data/README.md +977 -0
  5. data/lib/packaging.rb +32 -0
  6. data/lib/packaging/archive.rb +126 -0
  7. data/lib/packaging/artifactory.rb +651 -0
  8. data/lib/packaging/artifactory/extensions.rb +94 -0
  9. data/lib/packaging/config.rb +492 -0
  10. data/lib/packaging/config/params.rb +387 -0
  11. data/lib/packaging/config/validations.rb +13 -0
  12. data/lib/packaging/deb.rb +28 -0
  13. data/lib/packaging/deb/repo.rb +264 -0
  14. data/lib/packaging/gem.rb +70 -0
  15. data/lib/packaging/metrics.rb +15 -0
  16. data/lib/packaging/nuget.rb +39 -0
  17. data/lib/packaging/paths.rb +376 -0
  18. data/lib/packaging/platforms.rb +507 -0
  19. data/lib/packaging/repo.rb +155 -0
  20. data/lib/packaging/retrieve.rb +75 -0
  21. data/lib/packaging/rpm.rb +5 -0
  22. data/lib/packaging/rpm/repo.rb +254 -0
  23. data/lib/packaging/sign.rb +8 -0
  24. data/lib/packaging/sign/deb.rb +9 -0
  25. data/lib/packaging/sign/dmg.rb +41 -0
  26. data/lib/packaging/sign/ips.rb +57 -0
  27. data/lib/packaging/sign/msi.rb +124 -0
  28. data/lib/packaging/sign/rpm.rb +115 -0
  29. data/lib/packaging/tar.rb +163 -0
  30. data/lib/packaging/util.rb +146 -0
  31. data/lib/packaging/util/date.rb +20 -0
  32. data/lib/packaging/util/execution.rb +85 -0
  33. data/lib/packaging/util/file.rb +125 -0
  34. data/lib/packaging/util/git.rb +174 -0
  35. data/lib/packaging/util/git_tags.rb +73 -0
  36. data/lib/packaging/util/gpg.rb +66 -0
  37. data/lib/packaging/util/jenkins.rb +95 -0
  38. data/lib/packaging/util/misc.rb +69 -0
  39. data/lib/packaging/util/net.rb +410 -0
  40. data/lib/packaging/util/os.rb +17 -0
  41. data/lib/packaging/util/platform.rb +40 -0
  42. data/lib/packaging/util/rake_utils.rb +112 -0
  43. data/lib/packaging/util/serialization.rb +19 -0
  44. data/lib/packaging/util/ship.rb +300 -0
  45. data/lib/packaging/util/tool.rb +41 -0
  46. data/lib/packaging/util/version.rb +334 -0
  47. data/spec/fixtures/config/ext/build_defaults.yaml +2 -0
  48. data/spec/fixtures/config/ext/project_data.yaml +2 -0
  49. data/spec/fixtures/configs/components/test_file.json +1 -0
  50. data/spec/fixtures/configs/components/test_file_2.json +0 -0
  51. data/spec/fixtures/configs/components/test_file_not_tagged.json +1 -0
  52. data/spec/fixtures/configs/components/test_file_wrong_ext.txt +0 -0
  53. data/spec/fixtures/configs/components/test_file_wrong_ext.wrong +0 -0
  54. data/spec/fixtures/util/pre_tasks.yaml +4 -0
  55. data/spec/lib/packaging/artifactory_spec.rb +221 -0
  56. data/spec/lib/packaging/config_spec.rb +576 -0
  57. data/spec/lib/packaging/deb/repo_spec.rb +157 -0
  58. data/spec/lib/packaging/deb_spec.rb +52 -0
  59. data/spec/lib/packaging/gem_spec.rb +86 -0
  60. data/spec/lib/packaging/paths_spec.rb +418 -0
  61. data/spec/lib/packaging/platforms_spec.rb +178 -0
  62. data/spec/lib/packaging/repo_spec.rb +135 -0
  63. data/spec/lib/packaging/retrieve_spec.rb +100 -0
  64. data/spec/lib/packaging/rpm/repo_spec.rb +133 -0
  65. data/spec/lib/packaging/sign_spec.rb +133 -0
  66. data/spec/lib/packaging/tar_spec.rb +116 -0
  67. data/spec/lib/packaging/util/execution_spec.rb +56 -0
  68. data/spec/lib/packaging/util/file_spec.rb +139 -0
  69. data/spec/lib/packaging/util/git_spec.rb +160 -0
  70. data/spec/lib/packaging/util/git_tag_spec.rb +36 -0
  71. data/spec/lib/packaging/util/gpg_spec.rb +64 -0
  72. data/spec/lib/packaging/util/jenkins_spec.rb +112 -0
  73. data/spec/lib/packaging/util/misc_spec.rb +31 -0
  74. data/spec/lib/packaging/util/net_spec.rb +259 -0
  75. data/spec/lib/packaging/util/os_spec.rb +31 -0
  76. data/spec/lib/packaging/util/rake_utils_spec.rb +70 -0
  77. data/spec/lib/packaging/util/ship_spec.rb +199 -0
  78. data/spec/lib/packaging/util/version_spec.rb +123 -0
  79. data/spec/lib/packaging_spec.rb +19 -0
  80. data/spec/spec_helper.rb +22 -0
  81. data/static_artifacts/PackageInfo.plist +3 -0
  82. data/tasks/00_utils.rake +214 -0
  83. data/tasks/30_metrics.rake +33 -0
  84. data/tasks/apple.rake +268 -0
  85. data/tasks/archive.rake +69 -0
  86. data/tasks/build.rake +12 -0
  87. data/tasks/clean.rake +5 -0
  88. data/tasks/config.rake +35 -0
  89. data/tasks/deb.rake +129 -0
  90. data/tasks/deb_repos.rake +28 -0
  91. data/tasks/deprecated.rake +130 -0
  92. data/tasks/doc.rake +20 -0
  93. data/tasks/education.rake +57 -0
  94. data/tasks/fetch.rake +60 -0
  95. data/tasks/gem.rake +159 -0
  96. data/tasks/jenkins.rake +538 -0
  97. data/tasks/jenkins_dynamic.rake +202 -0
  98. data/tasks/load_extras.rake +21 -0
  99. data/tasks/mock.rake +348 -0
  100. data/tasks/nightly_repos.rake +286 -0
  101. data/tasks/pe_deb.rake +12 -0
  102. data/tasks/pe_rpm.rake +13 -0
  103. data/tasks/pe_ship.rake +226 -0
  104. data/tasks/pe_sign.rake +13 -0
  105. data/tasks/pe_tar.rake +5 -0
  106. data/tasks/retrieve.rake +52 -0
  107. data/tasks/rpm.rake +66 -0
  108. data/tasks/rpm_repos.rake +29 -0
  109. data/tasks/ship.rake +692 -0
  110. data/tasks/sign.rake +154 -0
  111. data/tasks/tag.rake +8 -0
  112. data/tasks/tar.rake +28 -0
  113. data/tasks/update.rake +16 -0
  114. data/tasks/vanagon.rake +35 -0
  115. data/tasks/vendor_gems.rake +117 -0
  116. data/tasks/version.rake +33 -0
  117. data/tasks/z_data_dump.rake +65 -0
  118. data/templates/README +1 -0
  119. data/templates/downstream.xml.erb +47 -0
  120. data/templates/msi.xml.erb +197 -0
  121. data/templates/packaging.xml.erb +346 -0
  122. data/templates/repo.xml.erb +117 -0
  123. metadata +287 -0
@@ -0,0 +1,17 @@
1
+ # Utility methods for handling system os information
2
+
3
+ require 'rbconfig'
4
+
5
+ module Pkg::Util::OS
6
+ def windows?
7
+ case RbConfig::CONFIG['host_os']
8
+ when /mswin|mingw/i
9
+ true
10
+ else
11
+ false
12
+ end
13
+ end
14
+ module_function :windows?
15
+
16
+ DEVNULL = windows? ? 'NUL' : '/dev/null'
17
+ end
@@ -0,0 +1,40 @@
1
+ module Pkg::Util::Platform
2
+ module_function
3
+ ##########################################################################
4
+ # DEPRECATED METHODS
5
+ #
6
+ def platform_tags
7
+ Pkg::Util.deprecate('Pkg::Util::Platform.platform_tags', 'Pkg::Platforms.platform_tags')
8
+ Pkg::Platforms.platform_tags
9
+ end
10
+
11
+ def platform_lookup(platform_tag)
12
+ Pkg::Util.deprecate('Pkg::Util::Platform.platform_lookup', 'Pkg::Platforms.platform_lookup')
13
+ Pkg::Platforms.platform_lookup(platform_tag)
14
+ end
15
+
16
+ def parse_platform_tag(platform_tag)
17
+ Pkg::Util.deprecate('Pkg::Util::Platform.parse_platform_tag', 'Pkg::Platforms.parse_platform_tag')
18
+ Pkg::Platforms.parse_platform_tag(platform_tag)
19
+ end
20
+
21
+ def get_attribute(platform_tag, attribute_name)
22
+ Pkg::Util.deprecate('Pkg::Util::Platform.get_attribute', 'Pkg::Platforms.get_attribute')
23
+ Pkg::Platforms.get_attribute(platform_tag, attribute_name)
24
+ end
25
+
26
+ def artifacts_path(platform_tag, package_url = nil)
27
+ Pkg::Util.deprecate('Pkg::Util::Platform.artifacts_path', 'Pkg::Paths.artifacts_path')
28
+ Pkg::Paths.artifacts_path(platform_tag)
29
+ end
30
+
31
+ def repo_path(platform_tag)
32
+ Pkg::Util.deprecate('Pkg::Util::Platform.repo_path', 'Pkg::Paths.repo_path')
33
+ Pkg::Paths.repo_path(platform_tag)
34
+ end
35
+
36
+ def repo_config_path(platform_tag)
37
+ Pkg::Util.deprecate('Pkg::Util::Platform.repo_config_path', 'Pkg::Paths.repo_config_path')
38
+ Pkg::Paths.repo_config_path(platform_tag)
39
+ end
40
+ end
@@ -0,0 +1,112 @@
1
+ require 'rake'
2
+
3
+ # Utility methods for working with rake tasks. These utilities will not work
4
+ # if the packaging repo was loaded as a library unless rake has been required
5
+ # explicitly.
6
+
7
+ module Pkg::Util::RakeUtils
8
+ class << self
9
+ def using_rake?
10
+ defined?(Rake::Task)
11
+ end
12
+
13
+ def task_defined?(task_name)
14
+ if using_rake?
15
+ Rake::Task.task_defined?(task_name)
16
+ end
17
+ end
18
+
19
+ # Return the Rake::Task object associated with a task name
20
+ #
21
+ def get_task(task_name)
22
+ if using_rake? and task_defined?(task_name)
23
+ Rake::Task[task_name]
24
+ end
25
+ end
26
+
27
+ def invoke_task(task, *args)
28
+ Rake::Task[task].reenable
29
+ Rake::Task[task].invoke(*args)
30
+ end
31
+
32
+ # Add a dependency to a rake task. "depender" must be an instance of
33
+ # Rake::Task, but dependency can be either a Rake::Task instance, or a String
34
+ # referring to the name of a Rake::Task instance.
35
+ #
36
+ def add_dependency(depender, dependency)
37
+ if using_rake?
38
+ if !task_defined?(depender)
39
+ fail "Could not locate a Rake task named '#{depender.to_s}' to add a dependency of '#{dependency.to_s}' to"
40
+ elsif !task_defined?(dependency)
41
+ fail "Could not locate a Rake task named '#{dependency.to_s}' to add as a dependency of '#{depender.to_s}'"
42
+ else
43
+ depender_task = Rake::Task[depender]
44
+ depender_task.enhance([dependency])
45
+ end
46
+ end
47
+ end
48
+
49
+ # Evaluate any pre-tasks known by the configuration of this invocation.
50
+ # Again, this is quite pointless if the user has not invoked the packaging
51
+ # repo via rake, so we're just not going to do anything.
52
+ #
53
+ def evaluate_pre_tasks
54
+ if using_rake? and Pkg::Config.pre_tasks
55
+ unless Pkg::Config.pre_tasks.is_a?(Hash)
56
+ fail "The 'pre_tasks' key must be a Hash of depender => dependency pairs"
57
+ end
58
+ Pkg::Config.pre_tasks.each do |depender, dependency|
59
+ add_dependency(depender, dependency)
60
+ end
61
+ end
62
+ end
63
+
64
+ def load_packaging_tasks(packaging_root = Pkg::Config.packaging_root)
65
+ packaging_task_dir = File.join(packaging_root, 'tasks')
66
+ tasks = [
67
+ '00_utils.rake',
68
+ '30_metrics.rake',
69
+ 'apple.rake',
70
+ 'archive.rake',
71
+ 'build.rake',
72
+ 'clean.rake',
73
+ 'deb.rake',
74
+ 'deb_repos.rake',
75
+ 'doc.rake',
76
+ 'education.rake',
77
+ 'fetch.rake',
78
+ 'gem.rake',
79
+ 'jenkins.rake',
80
+ 'jenkins_dynamic.rake',
81
+ 'load_extras.rake',
82
+ 'mock.rake',
83
+ 'nightly_repos.rake',
84
+ 'pe_deb.rake',
85
+ 'pe_rpm.rake',
86
+ 'pe_ship.rake',
87
+ 'pe_sign.rake',
88
+ 'pe_tar.rake',
89
+ 'retrieve.rake',
90
+ 'rpm.rake',
91
+ 'rpm_repos.rake',
92
+ 'ship.rake',
93
+ 'sign.rake',
94
+ 'tag.rake',
95
+ 'tar.rake',
96
+ 'update.rake',
97
+ 'vendor_gems.rake',
98
+ 'version.rake',
99
+ 'z_data_dump.rake',
100
+ 'config.rake',
101
+ 'vanagon.rake',
102
+ 'deprecated.rake'
103
+ ]
104
+
105
+ tasks.each do |task|
106
+ load File.join(packaging_task_dir, task)
107
+ end
108
+
109
+ Pkg::Util::RakeUtils.evaluate_pre_tasks
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,19 @@
1
+ # Utility methods for dealing with serialization of Config params
2
+
3
+ module Pkg::Util::Serialization
4
+ class << self
5
+
6
+ # Given the path to a yaml file, load the yaml file into an object and return the object.
7
+ def load_yaml(file)
8
+ require 'yaml'
9
+ file = File.expand_path(file)
10
+ begin
11
+ input_data = YAML.load_file(file) || {}
12
+ rescue => e
13
+ fail "There was an error loading data from #{file}.\n#{e}"
14
+ end
15
+ input_data
16
+ end
17
+ end
18
+ end
19
+
@@ -0,0 +1,300 @@
1
+ # Module for shipping all packages to places
2
+ require 'tmpdir'
3
+ module Pkg::Util::Ship
4
+ module_function
5
+
6
+ def collect_packages(pkg_exts, excludes = []) # rubocop:disable Metrics/MethodLength
7
+ pkgs = pkg_exts.map { |ext| Dir.glob(ext) }.flatten
8
+ return [] if pkgs.empty?
9
+ excludes.each do |exclude|
10
+ pkgs.delete_if { |p| p.match(exclude) }
11
+ end if excludes
12
+ if pkgs.empty?
13
+ $stdout.puts "No packages with (#{pkg_exts.join(', ')}) extensions found staged in 'pkg'"
14
+ $stdout.puts "Maybe your excludes argument (#{excludes}) is too restrictive?"
15
+ end
16
+ pkgs
17
+ end
18
+
19
+ # Takes a set of packages and reorganizes them into the final repo
20
+ # structure before they are shipping out to their final destination.
21
+ #
22
+ # This assumes the working directory is a temporary directory that will
23
+ # later be cleaned up
24
+ #
25
+ # If this is platform_independent the packages will not get reorganized,
26
+ # just copied under the tmp directory for more consistent workflows
27
+ def reorganize_packages(pkgs, tmp, platform_independent = false, nonfinal = false)
28
+ new_pkgs = []
29
+ pkgs.each do |pkg|
30
+ if platform_independent
31
+ path = 'pkg'
32
+ else
33
+ platform_tag = Pkg::Paths.tag_from_artifact_path(pkg)
34
+ path = Pkg::Paths.artifacts_path(platform_tag, 'pkg', nonfinal)
35
+ end
36
+ FileUtils.mkdir_p File.join(tmp, path)
37
+ FileUtils.cp pkg, File.join(tmp, path)
38
+ new_pkgs << File.join(path, File.basename(pkg))
39
+ end
40
+ new_pkgs
41
+ end
42
+
43
+ # Take local packages and restructure them to the desired final path before
44
+ # shipping to the staging server
45
+ # @param [Array] pkg_exts the file globs for the files you want to ship
46
+ # For example, something like ['pkg/**/*.rpm', 'pkg/**/*.deb'] to ship
47
+ # the rpms and debs
48
+ # @param [String] staging_server The hostname to ship the packages to
49
+ # @param [String] remote_path The base path to ship the packages to on the
50
+ # staging_server, for example '/opt/downloads/windows' or
51
+ # '/opt/repository/yum'
52
+ # @param [Hash] opts Additional options that can be used when shipping
53
+ # packages
54
+ # @option opts [Array] :excludes File globs to exclude packages from shipping
55
+ # @option opts [Boolean] :chattr Whether or not to make the files immutable
56
+ # after shipping. Defaults to true.
57
+ # @option opts [Boolean] :platform_independent Whether or not the path the
58
+ # packages ship to has platform-dependent information in it. Defaults to
59
+ # false (most paths will be platform dependent), but set to true for gems
60
+ # and tarballs since those just land directly under /opt/downloads/<project>
61
+ #
62
+ # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
63
+ def ship_pkgs(pkg_exts, staging_server, remote_path, opts = {})
64
+ options = {
65
+ excludes: [],
66
+ chattr: true,
67
+ platform_independent: false,
68
+ nonfinal: false }.merge(opts)
69
+
70
+ # First find the packages to be shipped. We must find them before moving
71
+ # to our temporary staging directory
72
+ local_packages = collect_packages(pkg_exts, options[:excludes])
73
+ return false if local_packages.empty?
74
+
75
+ tmpdir = Dir.mktmpdir
76
+ staged_pkgs = reorganize_packages(local_packages, tmpdir, options[:platform_independent], options[:nonfinal])
77
+
78
+ puts staged_pkgs.sort
79
+ puts "Do you want to ship the above files to (#{staging_server})?"
80
+ if Pkg::Util.ask_yes_or_no
81
+ extra_flags = ['--ignore-existing', '--delay-updates']
82
+ extra_flags << '--dry-run' if ENV['DRYRUN']
83
+
84
+ staged_pkgs.each do |pkg|
85
+ Pkg::Util::Execution.retry_on_fail(times: 3) do
86
+ sub_string = 'pkg'
87
+ remote_pkg = pkg.sub(sub_string, remote_path)
88
+ remote_basepath = File.dirname(remote_pkg)
89
+ Pkg::Util::Net.remote_execute(staging_server, "mkdir -p #{remote_basepath}")
90
+ Pkg::Util::Net.rsync_to(
91
+ File.join(tmpdir, pkg),
92
+ staging_server,
93
+ remote_basepath,
94
+ extra_flags: extra_flags
95
+ )
96
+
97
+ Pkg::Util::Net.remote_set_ownership(staging_server, 'root', 'release', [remote_basepath, remote_pkg])
98
+ Pkg::Util::Net.remote_set_permissions(staging_server, '775', [remote_basepath])
99
+ Pkg::Util::Net.remote_set_permissions(staging_server, '0664', [remote_pkg])
100
+ Pkg::Util::Net.remote_set_immutable(staging_server, [remote_pkg]) if options[:chattr]
101
+ end
102
+ end
103
+ return true
104
+ end
105
+ end
106
+
107
+ def ship_rpms(local_staging_directory, remote_path, opts = {})
108
+ things_to_ship = [
109
+ "#{local_staging_directory}/**/*.rpm",
110
+ "#{local_staging_directory}/**/*.srpm"
111
+ ]
112
+ ship_pkgs(things_to_ship, Pkg::Config.yum_staging_server, remote_path, opts)
113
+ end
114
+
115
+ def ship_debs(local_staging_directory, remote_path, opts = {})
116
+ things_to_ship = [
117
+ "#{local_staging_directory}/**/*.debian.tar.gz",
118
+ "#{local_staging_directory}/**/*.orig.tar.gz",
119
+ "#{local_staging_directory}/**/*.dsc",
120
+ "#{local_staging_directory}/**/*.deb",
121
+ "#{local_staging_directory}/**/*.changes"
122
+ ]
123
+ ship_pkgs(things_to_ship, Pkg::Config.apt_signing_server, remote_path, opts)
124
+ end
125
+
126
+ def ship_svr4(local_staging_directory, remote_path, opts = {})
127
+ ship_pkgs(["#{local_staging_directory}/**/*.pkg.gz"], Pkg::Config.svr4_host, remote_path, opts)
128
+ end
129
+
130
+ def ship_p5p(local_staging_directory, remote_path, opts = {})
131
+ ship_pkgs(["#{local_staging_directory}/**/*.p5p"], Pkg::Config.p5p_host, remote_path, opts)
132
+ end
133
+
134
+ def ship_dmg(local_staging_directory, remote_path, opts = {})
135
+ packages_have_shipped = ship_pkgs(["#{local_staging_directory}/**/*.dmg"],
136
+ Pkg::Config.dmg_staging_server, remote_path, opts)
137
+
138
+ if packages_have_shipped
139
+ Pkg::Platforms.platform_tags_for_package_format('dmg').each do |platform_tag|
140
+ # Create the latest symlink for the current supported repo
141
+ Pkg::Util::Net.remote_create_latest_symlink(
142
+ Pkg::Config.project,
143
+ Pkg::Paths.artifacts_path(platform_tag, remote_path, opts[:nonfinal]),
144
+ 'dmg'
145
+ )
146
+ end
147
+ end
148
+ end
149
+
150
+ def ship_swix(local_staging_directory, remote_path, opts = {})
151
+ ship_pkgs(["#{local_staging_directory}/**/*.swix"], Pkg::Config.swix_staging_server, remote_path, opts)
152
+ end
153
+
154
+ def ship_msi(local_staging_directory, remote_path, opts = {})
155
+ packages_have_shipped = ship_pkgs(["#{local_staging_directory}/**/*.msi"], Pkg::Config.msi_staging_server, remote_path, opts)
156
+
157
+ if packages_have_shipped
158
+ # Create the symlinks for the latest supported repo
159
+ Pkg::Util::Net.remote_create_latest_symlink(Pkg::Config.project, Pkg::Paths.artifacts_path(Pkg::Platforms.generic_platform_tag('windows'), remote_path, opts[:nonfinal]), 'msi', arch: 'x64')
160
+ Pkg::Util::Net.remote_create_latest_symlink(Pkg::Config.project, Pkg::Paths.artifacts_path(Pkg::Platforms.generic_platform_tag('windows'), remote_path, opts[:nonfinal]), 'msi', arch: 'x86')
161
+ end
162
+ end
163
+
164
+ def ship_gem(local_staging_directory, remote_path, opts = {})
165
+ ship_pkgs(["#{local_staging_directory}/*.gem*"], Pkg::Config.gem_host, remote_path, opts)
166
+ end
167
+
168
+ def ship_tar(local_staging_directory, remote_path, opts = {})
169
+ ship_pkgs(["#{local_staging_directory}/*.tar.gz*"], Pkg::Config.tar_staging_server, remote_path, opts)
170
+ end
171
+
172
+ def rolling_repo_link_command(platform_tag, repo_path, nonfinal = false)
173
+ base_path, link_path = Pkg::Paths.artifacts_base_path_and_link_path(platform_tag, repo_path, nonfinal)
174
+
175
+ if link_path.nil?
176
+ puts "No link target set, not creating rolling repo link for #{base_path}"
177
+ return nil
178
+ end
179
+
180
+ cmd = <<-CMD
181
+ if [ ! -d #{base_path} ] ; then
182
+ echo "Link target '#{base_path}' does not exist; skipping"
183
+ exit 0
184
+ fi
185
+ # If it's a link but pointing to the wrong place, remove the link
186
+ # This is likely to happen around the transition times, like puppet5 -> puppet6
187
+ if [ -L #{link_path} ] && [ ! #{base_path} -ef #{link_path} ] ; then
188
+ rm #{link_path}
189
+ # This is the link you're looking for, nothing to see here
190
+ elif [ -L #{link_path} ] ; then
191
+ exit 0
192
+ # Don't want to delete it if it isn't a link, that could be destructive
193
+ # So, fail!
194
+ elif [ -e #{link_path} ] ; then
195
+ echo "#{link_path} exists but isn't a link, I don't know what to do with this" >&2
196
+ exit 1
197
+ fi
198
+ ln -s #{base_path} #{link_path}
199
+ CMD
200
+ end
201
+
202
+ def create_rolling_repo_link(platform_tag, staging_server, repo_path, nonfinal = false)
203
+ command = rolling_repo_link_command(platform_tag, repo_path, nonfinal)
204
+
205
+ Pkg::Util::Net.remote_execute(staging_server, command) unless command.nil?
206
+ rescue => e
207
+ fail "Failed to create rolling repo link for '#{platform_tag}'.\n#{e}\n#{e.backtrace}"
208
+ end
209
+
210
+ # create all of the rolling repo links in one step
211
+ def create_rolling_repo_links(nonfinal = false)
212
+ yum_path = Pkg::Paths.remote_repo_base(nonfinal: nonfinal, package_format: 'rpm')
213
+ dmg_path = Pkg::Paths.remote_repo_base(nonfinal: nonfinal, package_format: 'dmg')
214
+ swix_path = Pkg::Paths.remote_repo_base(nonfinal: nonfinal, package_format: 'swix')
215
+ msi_path = Pkg::Paths.remote_repo_base(nonfinal: nonfinal, package_format: 'msi')
216
+
217
+ create_rolling_repo_link(Pkg::Platforms.generic_platform_tag('el'), Pkg::Config.yum_staging_server, yum_path, nonfinal)
218
+ create_rolling_repo_link(Pkg::Platforms.generic_platform_tag('osx'), Pkg::Config.dmg_staging_server, dmg_path, nonfinal)
219
+ create_rolling_repo_link(Pkg::Platforms.generic_platform_tag('eos'), Pkg::Config.swix_staging_server, swix_path, nonfinal)
220
+ create_rolling_repo_link(Pkg::Platforms.generic_platform_tag('windows'), Pkg::Config.msi_staging_server, msi_path, nonfinal)
221
+
222
+ # We need to iterate through all the supported platforms here because of
223
+ # how deb repos are set up. Each codename will have its own link from the
224
+ # current versioned repo (e.g. puppet5) to the rolling repo. The one thing
225
+ # we don't care about is architecture, so we just grab the first supported
226
+ # architecture for the code name we're working with at the moment. [written
227
+ # by Melissa, copied by Molly]
228
+
229
+ apt_path = Pkg::Config.apt_repo_staging_path
230
+ if nonfinal
231
+ apt_path = Pkg::Config.nonfinal_apt_repo_staging_path
232
+ end
233
+ Pkg::Platforms.codenames.each do |codename|
234
+ create_rolling_repo_link(Pkg::Platforms.codename_to_tags(codename)[0], Pkg::Config.apt_signing_server, apt_path, nonfinal)
235
+ end
236
+ end
237
+
238
+ def update_release_package_symlinks(local_staging_directory, nonfinal = false)
239
+ local_packages = collect_packages(["#{local_staging_directory}/**/*.rpm", "#{local_staging_directory}/**/*.deb"])
240
+ local_packages.each do |package|
241
+ platform_tag = Pkg::Paths.tag_from_artifact_path(package)
242
+ package_format = Pkg::Platforms.package_format_for_tag(platform_tag)
243
+ case package_format
244
+ when 'rpm'
245
+ remote_base = Pkg::Paths.artifacts_path(platform_tag, Pkg::Paths.remote_repo_base(platform_tag, nonfinal: nonfinal), nonfinal)
246
+ when 'deb'
247
+ remote_base = Pkg::Paths.apt_package_base_path(platform_tag, Pkg::Paths.repo_name(nonfinal), Pkg::Config.project, nonfinal)
248
+ else
249
+ fail "Unexpected package format #{package_format}, cannot create symlinks."
250
+ end
251
+ remote_path = File.join(remote_base, File.basename(package))
252
+ link_path = Pkg::Paths.release_package_link_path(platform_tag, nonfinal)
253
+ link_command = <<-CMD
254
+ if [ ! -e #{remote_path} ]; then
255
+ echo "Uh oh! #{remote_path} doesn't exist! Can't create symlink."
256
+ exit 1
257
+ fi
258
+ if [ -e #{link_path} ] && [ ! -L #{link_path} ]; then
259
+ echo "Uh oh! #{link_path} exists but isn't a link, I don't know what to do with this."
260
+ exit 1
261
+ fi
262
+ if [ -L #{link_path} ] && [ ! #{remote_path} -ef #{link_path} ]; then
263
+ echo "Removing old link from $(readlink #{link_path}) to #{link_path} . . ."
264
+ rm #{link_path}
265
+ fi
266
+ ln -sf #{remote_path} #{link_path}
267
+ CMD
268
+ Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, link_command)
269
+ end
270
+ end
271
+
272
+ def test_ship(vm, ship_task)
273
+ command = 'getent group release || groupadd release'
274
+ Pkg::Util::Net.remote_execute(vm, command)
275
+ hosts_to_override = %w(
276
+ APT_HOST
277
+ DMG_HOST
278
+ GEM_HOST
279
+ IPS_HOST
280
+ MSI_HOST
281
+ P5P_HOST
282
+ SVR4_HOST
283
+ SWIX_HOST
284
+ TAR_HOST
285
+ YUM_HOST
286
+ APT_SIGNING_SERVER
287
+ APT_STAGING_SERVER
288
+ DMG_STAGING_SERVER
289
+ MSI_STAGING_SERVER
290
+ SWIX_STAGING_SERVER
291
+ TAR_STAGING_SERVER
292
+ YUM_STAGING_SERVER
293
+ STAGING_SERVER
294
+ )
295
+ hosts_to_override.each do |host|
296
+ ENV[host] = vm
297
+ end
298
+ Rake::Task[ship_task].invoke
299
+ end
300
+ end