packaging 0.99.61 → 0.99.66
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.
- checksums.yaml +4 -4
- data/lib/packaging/artifactory.rb +14 -82
- data/lib/packaging/artifactory/extensions.rb +94 -0
- data/lib/packaging/paths.rb +92 -82
- data/lib/packaging/platforms.rb +4 -110
- data/lib/packaging/util/ship.rb +30 -18
- data/spec/lib/packaging/artifactory_spec.rb +8 -11
- data/spec/lib/packaging/config_spec.rb +7 -9
- data/spec/lib/packaging/paths_spec.rb +19 -38
- data/spec/lib/packaging/platforms_spec.rb +12 -12
- data/spec/lib/packaging/retrieve_spec.rb +1 -1
- data/spec/lib/packaging/sign_spec.rb +0 -1
- data/spec/lib/packaging/util/ship_spec.rb +2 -6
- data/tasks/ship.rake +19 -39
- metadata +19 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 47aedaa86f3b67d8c5c0dac793bdc7ba76098d59a69a371d686ad040a82bcad7
|
|
4
|
+
data.tar.gz: 46903f549c65511da61bc15448809e2442d8569b9cc7c318b3a44c9d1389a4a8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2a4f6a1f1135c242cb3561b609943a44715f9bbf45653f76548c2682819dbf14c1a1f1909380a70b7c5b054eebbd871c0572760c8d76e104fae19b9fedb330d5
|
|
7
|
+
data.tar.gz: 69bb9b00a3e3711911fc98a4b68d175f9e79553e4c100db4a02ab4e57be3a6ed71c00b0014b19ff5ef5c30c22796e22db73efff32f9775ddf05b9204c12c6885
|
|
@@ -2,67 +2,7 @@ require 'artifactory'
|
|
|
2
2
|
require 'uri'
|
|
3
3
|
require 'open-uri'
|
|
4
4
|
require 'digest'
|
|
5
|
-
|
|
6
|
-
#
|
|
7
|
-
# [eric.griswold] This is unfortunate. The 'pattern_search' class method really does belong in
|
|
8
|
-
# the Artifactory gem. However, because of some of Chef's social policies,
|
|
9
|
-
# I am unwilling to contribute this code there. If that changes, I'll submit a PR. Until
|
|
10
|
-
# then, it'll live here.
|
|
11
|
-
#
|
|
12
|
-
module Artifactory
|
|
13
|
-
class Resource::Artifact
|
|
14
|
-
#
|
|
15
|
-
# Search for an artifact in a repo using an Ant-like pattern.
|
|
16
|
-
# Unlike many Artifactory searches, this one is restricted to a single
|
|
17
|
-
# repository.
|
|
18
|
-
#
|
|
19
|
-
# @example Search in a repository named 'foo_local' for an artifact in a directory containing
|
|
20
|
-
# the word "recent", named "artifact[0-9].txt"
|
|
21
|
-
# Artifact.pattern_search(pattern: '*recent*/artifact[0-9].txt',
|
|
22
|
-
# repo: 'foo_local')
|
|
23
|
-
#
|
|
24
|
-
# @param [Hash] options
|
|
25
|
-
# A hash of options, as follows:
|
|
26
|
-
#
|
|
27
|
-
# @option options [Artifactory::Client] :client
|
|
28
|
-
# the client object to make the request with
|
|
29
|
-
# @option options [String] :pattern
|
|
30
|
-
# the Ant-like pattern to use for finding artifacts within the repos. Note that the
|
|
31
|
-
# Ant pattern '**' is barred in this case by JFrog.
|
|
32
|
-
# @option options [String] :repo
|
|
33
|
-
# the repo to search
|
|
34
|
-
#
|
|
35
|
-
# @return [Array<Resource::Artifact>]
|
|
36
|
-
# a list of artifacts that match the query
|
|
37
|
-
#
|
|
38
|
-
def self.pattern_search(options = {})
|
|
39
|
-
client = extract_client!(options)
|
|
40
|
-
params = Util.slice(options, :pattern, :repo)
|
|
41
|
-
pattern_search_parameter = { :pattern => "#{params[:repo]}:#{params[:pattern]}" }
|
|
42
|
-
response = client.get('/api/search/pattern', pattern_search_parameter)
|
|
43
|
-
return [] if response['files'].nil? || response['files'].empty?
|
|
44
|
-
|
|
45
|
-
# A typical response:
|
|
46
|
-
# {
|
|
47
|
-
# "repoUri"=>"https:<artifactory endpoint>/<repo>",
|
|
48
|
-
# "sourcePattern"=>"<repo>:<provided search pattern>",
|
|
49
|
-
# "files"=>[<filename that matched pattern>, ...]
|
|
50
|
-
# }
|
|
51
|
-
#
|
|
52
|
-
# Inserting '/api/storage' before the repo makes the 'from_url' call work correctly.
|
|
53
|
-
#
|
|
54
|
-
repo_uri = response['repoUri']
|
|
55
|
-
unless repo_uri.include?('/api/storage/')
|
|
56
|
-
# rubocop:disable Style/PercentLiteralDelimiters
|
|
57
|
-
repo_uri.sub!(%r(/#{params[:repo]}$), "/api/storage/#{params[:repo]}")
|
|
58
|
-
end
|
|
59
|
-
response['files'].map do |file_path|
|
|
60
|
-
from_url("#{repo_uri}/#{file_path}", client: client)
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
5
|
+
require 'packaging/artifactory/extensions'
|
|
66
6
|
|
|
67
7
|
module Pkg
|
|
68
8
|
|
|
@@ -111,7 +51,6 @@ module Pkg
|
|
|
111
51
|
def location_for(platform_tag)
|
|
112
52
|
toplevel_repo = DEFAULT_REPO_TYPE
|
|
113
53
|
repo_subdirectories = File.join(@repo_base, @project, @project_version)
|
|
114
|
-
alternate_subdirectories = repo_subdirectories
|
|
115
54
|
|
|
116
55
|
unless platform_tag == DEFAULT_REPO_TYPE
|
|
117
56
|
format = Pkg::Platforms.package_format_for_tag(platform_tag)
|
|
@@ -122,20 +61,16 @@ module Pkg
|
|
|
122
61
|
when 'rpm'
|
|
123
62
|
toplevel_repo = 'rpm'
|
|
124
63
|
repo_subdirectories = File.join(repo_subdirectories, "#{platform}-#{version}-#{architecture}")
|
|
125
|
-
alternate_subdirectories = repo_subdirectories
|
|
126
64
|
when 'deb'
|
|
127
65
|
toplevel_repo = 'debian__local'
|
|
128
66
|
repo_subdirectories = File.join(repo_subdirectories, "#{platform}-#{version}")
|
|
129
|
-
alternate_subdirectories = File.join('pool', repo_subdirectories)
|
|
130
67
|
when 'swix', 'dmg', 'svr4', 'ips'
|
|
131
68
|
repo_subdirectories = File.join(repo_subdirectories, "#{platform}-#{version}-#{architecture}")
|
|
132
|
-
alternate_subdirectories = repo_subdirectories
|
|
133
69
|
when 'msi'
|
|
134
70
|
repo_subdirectories = File.join(repo_subdirectories, "#{platform}-#{architecture}")
|
|
135
|
-
alternate_subdirectories = repo_subdirectories
|
|
136
71
|
end
|
|
137
72
|
|
|
138
|
-
[toplevel_repo, repo_subdirectories
|
|
73
|
+
[toplevel_repo, repo_subdirectories]
|
|
139
74
|
end
|
|
140
75
|
|
|
141
76
|
# @param platform_tag [String] The platform tag specific to the information
|
|
@@ -150,8 +85,8 @@ module Pkg
|
|
|
150
85
|
end
|
|
151
86
|
end
|
|
152
87
|
|
|
153
|
-
repo_name, repo_subdirectories
|
|
154
|
-
full_artifactory_path = File.join(repo_name,
|
|
88
|
+
repo_name, repo_subdirectories = location_for(platform_tag)
|
|
89
|
+
full_artifactory_path = File.join(repo_name, repo_subdirectories)
|
|
155
90
|
|
|
156
91
|
{
|
|
157
92
|
platform: platform,
|
|
@@ -161,7 +96,6 @@ module Pkg
|
|
|
161
96
|
package_format: package_format,
|
|
162
97
|
repo_name: repo_name,
|
|
163
98
|
repo_subdirectories: repo_subdirectories,
|
|
164
|
-
alternate_subdirectories: alternate_subdirectories,
|
|
165
99
|
full_artifactory_path: full_artifactory_path
|
|
166
100
|
}
|
|
167
101
|
end
|
|
@@ -286,7 +220,7 @@ module Pkg
|
|
|
286
220
|
headers = { "X-Checksum-Md5" => artifact_md5 }
|
|
287
221
|
artifact.upload(
|
|
288
222
|
data[:repo_name],
|
|
289
|
-
File.join(data[:
|
|
223
|
+
File.join(data[:repo_subdirectories], File.basename(package)),
|
|
290
224
|
deploy_properties(platform_tag, File.basename(package)),
|
|
291
225
|
headers
|
|
292
226
|
)
|
|
@@ -420,21 +354,20 @@ module Pkg
|
|
|
420
354
|
manifest.each do |dist, packages|
|
|
421
355
|
puts "Grabbing the #{dist} packages from artifactory"
|
|
422
356
|
packages.each do |name, info|
|
|
423
|
-
|
|
357
|
+
filename = info['filename']
|
|
358
|
+
artifacts = Artifactory::Resource::Artifact.checksum_search(md5: "#{info["md5"]}", repos: ["rpm_enterprise__local", "debian_enterprise__local"], name: filename)
|
|
424
359
|
artifact_to_download = artifacts.select { |artifact| artifact.download_uri.include? remote_path }.first
|
|
425
360
|
# If we found matching artifacts, but not in the correct path, copy the artifact to the correct path
|
|
426
361
|
# This should help us keep repos up to date with the packages we are expecting to be there
|
|
427
362
|
# while helping us avoid 'what the hell, could not find package' errors
|
|
428
363
|
if artifact_to_download.nil? && !artifacts.empty?
|
|
429
364
|
artifact_to_copy = artifacts.first
|
|
430
|
-
filename = info['filename'] || File.basename(artifact_to_copy.download_uri)
|
|
431
365
|
copy_artifact(artifact_to_copy, artifact_to_copy.repo, "#{remote_path}/#{dist}/#{filename}")
|
|
432
|
-
artifacts = Artifactory::Resource::Artifact.checksum_search(md5: "#{info["md5"]}", repos: ["rpm_enterprise__local", "debian_enterprise__local"])
|
|
366
|
+
artifacts = Artifactory::Resource::Artifact.checksum_search(md5: "#{info["md5"]}", repos: ["rpm_enterprise__local", "debian_enterprise__local"], name: filename)
|
|
433
367
|
artifact_to_download = artifacts.select { |artifact| artifact.download_uri.include? remote_path }.first
|
|
434
368
|
end
|
|
435
369
|
|
|
436
370
|
if artifact_to_download.nil?
|
|
437
|
-
filename = info["filename"] || name
|
|
438
371
|
message = "Error: what the hell, could not find package #{filename} with md5sum #{info["md5"]}"
|
|
439
372
|
unless remote_path.empty?
|
|
440
373
|
message += " in #{remote_path}"
|
|
@@ -442,7 +375,6 @@ module Pkg
|
|
|
442
375
|
raise message
|
|
443
376
|
else
|
|
444
377
|
full_staging_path = "#{staging_directory}/#{dist}"
|
|
445
|
-
filename = info['filename'] || File.basename(artifact_to_download.download_uri)
|
|
446
378
|
puts "downloading #{artifact_to_download.download_uri} to #{File.join(full_staging_path, filename)}"
|
|
447
379
|
artifact_to_download.download(full_staging_path, filename: filename)
|
|
448
380
|
end
|
|
@@ -599,7 +531,7 @@ module Pkg
|
|
|
599
531
|
# @param target_path [String] path copy tarballs to, assumes same repo
|
|
600
532
|
def copy_final_pe_tarballs(pe_version, repo, remote_path, target_path)
|
|
601
533
|
check_authorization
|
|
602
|
-
final_tarballs = Artifactory::Resource::Artifact.search(name: pe_version, repos: repo)
|
|
534
|
+
final_tarballs = Artifactory::Resource::Artifact.search(name: pe_version, repos: repo, exact_match: false)
|
|
603
535
|
final_tarballs.each do |artifact|
|
|
604
536
|
next unless artifact.download_uri.include? remote_path
|
|
605
537
|
next if artifact.download_uri.include? "-rc"
|
|
@@ -646,12 +578,11 @@ module Pkg
|
|
|
646
578
|
manifest.each do |dist, packages|
|
|
647
579
|
puts "Copying #{dist} packages..."
|
|
648
580
|
packages.each do |name, info|
|
|
649
|
-
|
|
581
|
+
filename = info["filename"]
|
|
582
|
+
artifact = Artifactory::Resource::Artifact.checksum_search(md5: "#{info["md5"]}", repos: ["rpm_enterprise__local", "debian_enterprise__local"], name: filename).first
|
|
650
583
|
if artifact.nil?
|
|
651
|
-
filename = info["filename"] || name
|
|
652
584
|
raise "Error: what the hell, could not find package #{filename} with md5sum #{info["md5"]}"
|
|
653
585
|
end
|
|
654
|
-
filename = info["filename"] || File.basename(artifact.download_uri)
|
|
655
586
|
copy_artifact(artifact, artifact.repo, "#{target_path}/#{dist}/#{filename}")
|
|
656
587
|
end
|
|
657
588
|
end
|
|
@@ -681,7 +612,8 @@ module Pkg
|
|
|
681
612
|
manifest.each do |dist, packages|
|
|
682
613
|
packages.each do |package_name, info|
|
|
683
614
|
next unless package_name == package
|
|
684
|
-
|
|
615
|
+
filename = info["filename"]
|
|
616
|
+
artifacts = Artifactory::Resource::Artifact.checksum_search(md5: "#{info["md5"]}", repos: repos, name: filename)
|
|
685
617
|
artifacts.each do |artifact|
|
|
686
618
|
next unless artifact.download_uri.include? remote_path
|
|
687
619
|
puts "Removing reverted package #{artifact.download_uri}"
|
|
@@ -701,7 +633,7 @@ module Pkg
|
|
|
701
633
|
Dir.foreach("#{tarball_path}/") do |pe_tarball|
|
|
702
634
|
next if pe_tarball == '.' || pe_tarball == ".."
|
|
703
635
|
md5 = Digest::MD5.file("#{tarball_path}/#{pe_tarball}").hexdigest
|
|
704
|
-
artifacts_to_delete = Artifactory::Resource::Artifact.checksum_search(md5: md5, repos: pe_repo)
|
|
636
|
+
artifacts_to_delete = Artifactory::Resource::Artifact.checksum_search(md5: md5, repos: pe_repo, name: pe_tarball)
|
|
705
637
|
next if artifacts_to_delete.nil?
|
|
706
638
|
begin
|
|
707
639
|
artifacts_to_delete.each do |artifact|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
require 'artifactory'
|
|
2
|
+
|
|
3
|
+
module ArtifactoryExtensions
|
|
4
|
+
module ClassMethods
|
|
5
|
+
#
|
|
6
|
+
# Search for an artifact in a repo using an Ant-like pattern.
|
|
7
|
+
# Unlike many Artifactory searches, this one is restricted to a single
|
|
8
|
+
# repository.
|
|
9
|
+
#
|
|
10
|
+
# @example Search in a repository named 'foo_local' for an artifact in a directory containing
|
|
11
|
+
# the word "recent", named "artifact[0-9].txt"
|
|
12
|
+
# Artifact.pattern_search(pattern: '*recent*/artifact[0-9].txt',
|
|
13
|
+
# repo: 'foo_local')
|
|
14
|
+
#
|
|
15
|
+
# @param [Hash] options
|
|
16
|
+
# A hash of options, as follows:
|
|
17
|
+
#
|
|
18
|
+
# @option options [Artifactory::Client] :client
|
|
19
|
+
# the client object to make the request with
|
|
20
|
+
# @option options [String] :pattern
|
|
21
|
+
# the Ant-like pattern to use for finding artifacts within the repos. Note that the
|
|
22
|
+
# Ant pattern '**' is barred in this case by JFrog.
|
|
23
|
+
# @option options [String] :repo
|
|
24
|
+
# the repo to search
|
|
25
|
+
#
|
|
26
|
+
# @return [Array<Resource::Artifact>]
|
|
27
|
+
# a list of artifacts that match the query
|
|
28
|
+
#
|
|
29
|
+
def pattern_search(options = {})
|
|
30
|
+
client = extract_client!(options)
|
|
31
|
+
params = Artifactory::Util.slice(options, :pattern, :repo)
|
|
32
|
+
pattern_search_parameter = { :pattern => "#{params[:repo]}:#{params[:pattern]}" }
|
|
33
|
+
response = client.get('/api/search/pattern', pattern_search_parameter)
|
|
34
|
+
return [] if response['files'].nil? || response['files'].empty?
|
|
35
|
+
|
|
36
|
+
# A typical response:
|
|
37
|
+
# {
|
|
38
|
+
# "repoUri"=>"https:<artifactory endpoint>/<repo>",
|
|
39
|
+
# "sourcePattern"=>"<repo>:<provided search pattern>",
|
|
40
|
+
# "files"=>[<filename that matched pattern>, ...]
|
|
41
|
+
# }
|
|
42
|
+
#
|
|
43
|
+
# Inserting '/api/storage' before the repo makes the 'from_url' call work correctly.
|
|
44
|
+
#
|
|
45
|
+
repo_uri = response['repoUri']
|
|
46
|
+
unless repo_uri.include?('/api/storage/')
|
|
47
|
+
# rubocop:disable Style/PercentLiteralDelimiters
|
|
48
|
+
repo_uri.sub!(%r(/#{params[:repo]}$), "/api/storage/#{params[:repo]}")
|
|
49
|
+
end
|
|
50
|
+
response['files'].map do |file_path|
|
|
51
|
+
from_url("#{repo_uri}/#{file_path}", client: client)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# This adds the `exact_match` option to artifactory search, and defaults it
|
|
56
|
+
# to true. With `exact_match` set to `true` the artifact will only be
|
|
57
|
+
# returned if the name in the download uri matches the name we're trying to
|
|
58
|
+
# download
|
|
59
|
+
def search(options = {})
|
|
60
|
+
exact_match = options[:exact_match].nil? ? true : options[:exact_match]
|
|
61
|
+
artifacts = super
|
|
62
|
+
|
|
63
|
+
if exact_match
|
|
64
|
+
artifacts.select! { |artifact| File.basename(artifact.download_uri) == options[:name] }
|
|
65
|
+
end
|
|
66
|
+
artifacts
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# This adds the `name` option to artifactory checksum search. It defaults to
|
|
70
|
+
# unset. If set, the artifact is only returned if the download uri matches
|
|
71
|
+
# the passed name
|
|
72
|
+
def checksum_search(options = {})
|
|
73
|
+
artifacts = super
|
|
74
|
+
if options[:name]
|
|
75
|
+
artifacts.select! { |artifact| File.basename(artifact.download_uri) == options[:name] }
|
|
76
|
+
end
|
|
77
|
+
artifacts
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# needed to prepend class methods, see https://stackoverflow.com/questions/18683750/how-to-prepend-classmethods
|
|
82
|
+
def self.prepended(base)
|
|
83
|
+
class << base
|
|
84
|
+
prepend ClassMethods
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
module Artifactory
|
|
90
|
+
class Resource::Artifact
|
|
91
|
+
# use prepend instead of monkeypatching so we can call `super`
|
|
92
|
+
prepend ArtifactoryExtensions
|
|
93
|
+
end
|
|
94
|
+
end
|
data/lib/packaging/paths.rb
CHANGED
|
@@ -70,15 +70,6 @@ module Pkg::Paths
|
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
# Method to determine if files should be shipped to legacy or current path
|
|
74
|
-
# structures. Any repo name matching /^puppet/ is a current repo, everything
|
|
75
|
-
# else is should be shipped to legacy paths.
|
|
76
|
-
#
|
|
77
|
-
# @param repo_name The repo name to check
|
|
78
|
-
def is_legacy_repo?(repo_name)
|
|
79
|
-
repo_name !~ /^puppet/
|
|
80
|
-
end
|
|
81
|
-
|
|
82
73
|
# Method to determine the yum repo name. Maintains compatibility with legacy
|
|
83
74
|
# projects, where `Pkg::Config.yum_repo_name` is set instead of
|
|
84
75
|
# `Pkg::Config.repo_name`. Defaults to 'products' if nothing is set.
|
|
@@ -110,65 +101,83 @@ module Pkg::Paths
|
|
|
110
101
|
return Pkg::Config.repo_link_target
|
|
111
102
|
end
|
|
112
103
|
|
|
113
|
-
#
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
# --MAS 2017-08-16
|
|
121
|
-
def artifacts_base_path_and_link_path(platform_tag, path_prefix = 'artifacts', nonfinal = false)
|
|
122
|
-
platform, version, architecture = Pkg::Platforms.parse_platform_tag(platform_tag)
|
|
123
|
-
package_format = Pkg::Platforms.package_format_for_tag(platform_tag)
|
|
104
|
+
# Construct a platform-dependent symlink target path.
|
|
105
|
+
def construct_base_path(path_data)
|
|
106
|
+
package_format = path_data[:package_format]
|
|
107
|
+
prefix = path_data[:prefix]
|
|
108
|
+
is_nonfinal = path_data[:is_nonfinal]
|
|
109
|
+
platform_name = path_data[:platform_name]
|
|
110
|
+
platform_tag = path_data[:platform_tag]
|
|
124
111
|
|
|
125
112
|
case package_format
|
|
113
|
+
when 'deb'
|
|
114
|
+
debian_code_name = Pkg::Platforms.get_attribute(platform_tag, :codename)
|
|
115
|
+
return File.join(prefix, debian_code_name, apt_repo_name(is_nonfinal))
|
|
116
|
+
when 'dmg'
|
|
117
|
+
return File.join(prefix, 'mac', repo_name(is_nonfinal))
|
|
118
|
+
when 'msi'
|
|
119
|
+
return File.join(prefix, platform_name, repo_name(is_nonfinal))
|
|
126
120
|
when 'rpm'
|
|
127
|
-
|
|
128
|
-
[File.join(path_prefix, platform, version, yum_repo_name(nonfinal)), nil]
|
|
129
|
-
else
|
|
130
|
-
[File.join(path_prefix, yum_repo_name(nonfinal)), link_name(nonfinal).nil? ? nil : File.join(path_prefix, link_name(nonfinal))]
|
|
131
|
-
end
|
|
121
|
+
return File.join(prefix, yum_repo_name(is_nonfinal))
|
|
132
122
|
when 'swix'
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
123
|
+
return File.join(prefix, platform_name, repo_name(is_nonfinal))
|
|
124
|
+
when 'svr4', 'ips'
|
|
125
|
+
return File.join(prefix, 'solaris', repo_name(is_nonfinal))
|
|
126
|
+
else
|
|
127
|
+
raise "Error: Unknown package format '#{package_format}'"
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Construct a platform-dependent link path
|
|
132
|
+
def construct_link_path(path_data)
|
|
133
|
+
package_format = path_data[:package_format]
|
|
134
|
+
prefix = path_data[:prefix]
|
|
135
|
+
platform_name = path_data[:platform_name]
|
|
136
|
+
platform_tag = path_data[:platform_tag]
|
|
137
|
+
link = path_data[:link]
|
|
138
|
+
|
|
139
|
+
return nil if link.nil?
|
|
140
|
+
|
|
141
|
+
case package_format
|
|
142
|
+
when 'rpm'
|
|
143
|
+
return File.join(prefix, link)
|
|
144
|
+
when 'swix'
|
|
145
|
+
return File.join(prefix, platform_name, link)
|
|
138
146
|
when 'deb'
|
|
139
|
-
|
|
140
|
-
|
|
147
|
+
debian_code_name = Pkg::Platforms.get_attribute(platform_tag, :codename)
|
|
148
|
+
return File.join(prefix, debian_code_name, link)
|
|
141
149
|
when 'svr4', 'ips'
|
|
142
|
-
|
|
143
|
-
[File.join(path_prefix, 'solaris', repo_name(nonfinal), version), nil]
|
|
144
|
-
else
|
|
145
|
-
[File.join(path_prefix, 'solaris', repo_name(nonfinal)), link_name(nonfinal).nil? ? nil : File.join(path_prefix, 'solaris', link_name(nonfinal))]
|
|
146
|
-
end
|
|
150
|
+
return File.join(prefix, 'solaris', link)
|
|
147
151
|
when 'dmg'
|
|
148
|
-
|
|
149
|
-
[File.join(path_prefix, 'mac', version, repo_name(nonfinal)), nil]
|
|
150
|
-
else
|
|
151
|
-
[File.join(path_prefix, 'mac', repo_name(nonfinal)), link_name(nonfinal).nil? ? nil : File.join(path_prefix, 'mac', link_name(nonfinal))]
|
|
152
|
-
end
|
|
152
|
+
return File.join(prefix, 'mac', link)
|
|
153
153
|
when 'msi'
|
|
154
|
-
|
|
155
|
-
[File.join(path_prefix, 'windows'), nil]
|
|
156
|
-
else
|
|
157
|
-
[File.join(path_prefix, platform, repo_name(nonfinal)), link_name(nonfinal).nil? ? nil : File.join(path_prefix, platform, link_name(nonfinal))]
|
|
158
|
-
end
|
|
154
|
+
return File.join(prefix, platform_name, link)
|
|
159
155
|
else
|
|
160
|
-
raise "
|
|
156
|
+
raise "Error: Unknown package format '#{package_format}'"
|
|
161
157
|
end
|
|
162
158
|
end
|
|
163
159
|
|
|
164
|
-
#
|
|
165
|
-
#
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
160
|
+
# Given platform information, create symlink target (base_path) and link path in the
|
|
161
|
+
# form of a 2-element array
|
|
162
|
+
def artifacts_base_path_and_link_path(platform_tag, prefix = 'artifacts', is_nonfinal = false)
|
|
163
|
+
platform_name, _ = Pkg::Platforms.parse_platform_tag(platform_tag)
|
|
164
|
+
package_format = Pkg::Platforms.package_format_for_tag(platform_tag)
|
|
165
|
+
|
|
166
|
+
path_data = {
|
|
167
|
+
is_nonfinal: is_nonfinal,
|
|
168
|
+
link: link_name(is_nonfinal),
|
|
169
|
+
package_format: package_format,
|
|
170
|
+
platform_name: platform_name,
|
|
171
|
+
platform_tag: platform_tag,
|
|
172
|
+
prefix: prefix
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return [
|
|
176
|
+
construct_base_path(path_data),
|
|
177
|
+
construct_link_path(path_data)
|
|
178
|
+
]
|
|
179
|
+
end
|
|
180
|
+
|
|
172
181
|
def artifacts_path(platform_tag, path_prefix = 'artifacts', nonfinal = false)
|
|
173
182
|
base_path, _ = artifacts_base_path_and_link_path(platform_tag, path_prefix, nonfinal)
|
|
174
183
|
platform, version, architecture = Pkg::Platforms.parse_platform_tag(platform_tag)
|
|
@@ -176,31 +185,15 @@ module Pkg::Paths
|
|
|
176
185
|
|
|
177
186
|
case package_format
|
|
178
187
|
when 'rpm'
|
|
179
|
-
|
|
180
|
-
File.join(base_path, architecture)
|
|
181
|
-
else
|
|
182
|
-
File.join(base_path, platform, version, architecture)
|
|
183
|
-
end
|
|
188
|
+
File.join(base_path, platform, version, architecture)
|
|
184
189
|
when 'swix'
|
|
185
|
-
|
|
186
|
-
File.join(base_path, architecture)
|
|
187
|
-
else
|
|
188
|
-
File.join(base_path, version, architecture)
|
|
189
|
-
end
|
|
190
|
+
File.join(base_path, version, architecture)
|
|
190
191
|
when 'deb'
|
|
191
192
|
base_path
|
|
192
193
|
when 'svr4', 'ips'
|
|
193
|
-
|
|
194
|
-
base_path
|
|
195
|
-
else
|
|
196
|
-
File.join(base_path, version)
|
|
197
|
-
end
|
|
194
|
+
File.join(base_path, version)
|
|
198
195
|
when 'dmg'
|
|
199
|
-
|
|
200
|
-
File.join(base_path, architecture)
|
|
201
|
-
else
|
|
202
|
-
File.join(base_path, version, architecture)
|
|
203
|
-
end
|
|
196
|
+
File.join(base_path, version, architecture)
|
|
204
197
|
when 'msi'
|
|
205
198
|
base_path
|
|
206
199
|
else
|
|
@@ -268,16 +261,33 @@ module Pkg::Paths
|
|
|
268
261
|
end
|
|
269
262
|
end
|
|
270
263
|
|
|
271
|
-
def remote_repo_base(platform_tag, nonfinal
|
|
272
|
-
|
|
273
|
-
|
|
264
|
+
def remote_repo_base(platform_tag = nil, nonfinal: false, package_format: nil)
|
|
265
|
+
if platform_tag.nil? && package_format.nil?
|
|
266
|
+
raise "Pkg::Paths.remote_repo_base must have `platform_tag` or `package_format` specified."
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
package_format ||= Pkg::Platforms.package_format_for_tag(platform_tag)
|
|
270
|
+
|
|
271
|
+
repo_base = case package_format
|
|
274
272
|
when 'rpm'
|
|
275
273
|
nonfinal ? Pkg::Config.nonfinal_yum_repo_path : Pkg::Config.yum_repo_path
|
|
276
274
|
when 'deb'
|
|
277
275
|
nonfinal ? Pkg::Config.nonfinal_apt_repo_path : Pkg::Config.apt_repo_path
|
|
276
|
+
when 'dmg'
|
|
277
|
+
nonfinal ? Pkg::Config.nonfinal_dmg_path : Pkg::Config.dmg_path
|
|
278
|
+
when 'swix'
|
|
279
|
+
nonfinal ? Pkg::Config.nonfinal_swix_path : Pkg::Config.swix_path
|
|
280
|
+
when 'msi'
|
|
281
|
+
nonfinal ? Pkg::Config.nonfinal_msi_path : Pkg::Config.msi_path
|
|
278
282
|
else
|
|
279
283
|
raise "Can't determine remote repo base path for package format '#{package_format}'."
|
|
280
284
|
end
|
|
285
|
+
|
|
286
|
+
# normalize the path for things shipping to the downloads server
|
|
287
|
+
if repo_base.match(/^\/opt\/downloads\/\w+$/)
|
|
288
|
+
repo_base = '/opt/downloads'
|
|
289
|
+
end
|
|
290
|
+
repo_base
|
|
281
291
|
end
|
|
282
292
|
|
|
283
293
|
# This is where deb packages end up after freight repo updates
|
|
@@ -285,7 +295,7 @@ module Pkg::Paths
|
|
|
285
295
|
fail "Can't determine path for non-debian platform #{platform_tag}." unless Pkg::Platforms.package_format_for_tag(platform_tag) == 'deb'
|
|
286
296
|
platform, version, _ = Pkg::Platforms.parse_platform_tag(platform_tag)
|
|
287
297
|
codename = Pkg::Platforms.codename_for_platform_version(platform, version)
|
|
288
|
-
return File.join(remote_repo_base(platform_tag, nonfinal), 'pool', codename, repo_name, project[0], project)
|
|
298
|
+
return File.join(remote_repo_base(platform_tag, nonfinal: nonfinal), 'pool', codename, repo_name, project[0], project)
|
|
289
299
|
end
|
|
290
300
|
|
|
291
301
|
def release_package_link_path(platform_tag, nonfinal = false)
|
|
@@ -293,10 +303,10 @@ module Pkg::Paths
|
|
|
293
303
|
package_format = Pkg::Platforms.package_format_for_tag(platform_tag)
|
|
294
304
|
case package_format
|
|
295
305
|
when 'rpm'
|
|
296
|
-
return File.join(remote_repo_base(platform_tag, nonfinal), "#{repo_name(nonfinal)}-release-#{platform}-#{version}.noarch.rpm")
|
|
306
|
+
return File.join(remote_repo_base(platform_tag, nonfinal: nonfinal), "#{repo_name(nonfinal)}-release-#{platform}-#{version}.noarch.rpm")
|
|
297
307
|
when 'deb'
|
|
298
308
|
codename = Pkg::Platforms.codename_for_platform_version(platform, version)
|
|
299
|
-
return File.join(remote_repo_base(platform_tag, nonfinal), "#{repo_name(nonfinal)}-release-#{codename}.deb")
|
|
309
|
+
return File.join(remote_repo_base(platform_tag, nonfinal: nonfinal), "#{repo_name(nonfinal)}-release-#{codename}.deb")
|
|
300
310
|
else
|
|
301
311
|
warn "No release packages for package format '#{package_format}', skipping . . ."
|
|
302
312
|
return nil
|