packaging 0.99.58 → 0.99.59
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 +52 -20
- data/lib/packaging/paths.rb +12 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0f37ea2f3dd50cd5a9e64bf12c3046212317ec540c00570c2407c5280db76fd0
|
|
4
|
+
data.tar.gz: 2e9bb139d99cff830d21affc34c307edb786cb32688965e678c9593babb6c5ea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 819a3182d71f837ca6ba1757e0f37d283fca7fc452437cf45de2f105c436170b7f8913ac98e9f12157ad9327776b9b2e287b2e3ddc65456b8d96cc0120830a73
|
|
7
|
+
data.tar.gz: 2973cc69e5ed2789059ef672edb76133c7bcadfa8a9c7503ffecb19589ab6c87fa8d33870a1a9b6c376ea9313c8cb1f248a07b1df0820318245fd6b88cc1e305
|
|
@@ -408,15 +408,33 @@ module Pkg
|
|
|
408
408
|
# Using the manifest provided by enterprise-dist, grab the appropropriate packages from artifactory based on md5sum
|
|
409
409
|
# @param staging_directory [String] location to download packages to
|
|
410
410
|
# @param manifest [File] JSON file containing information about what packages to download and the corresponding md5sums
|
|
411
|
-
|
|
411
|
+
# @param remote_path [String] Optional partial path on the remote host containing packages
|
|
412
|
+
# Used to specify which subdirectories packages will be downloaded from.
|
|
413
|
+
def download_packages(staging_directory, manifest, remote_path = '')
|
|
412
414
|
check_authorization
|
|
413
415
|
manifest.each do |dist, packages|
|
|
414
416
|
puts "Grabbing the #{dist} packages from artifactory"
|
|
415
417
|
packages.each do |name, info|
|
|
416
|
-
|
|
418
|
+
artifacts = Artifactory::Resource::Artifact.checksum_search(md5: "#{info["md5"]}", repos: ["rpm_enterprise__local", "debian_enterprise__local"])
|
|
419
|
+
artifact_to_download = artifacts.select { |artifact| artifact.download_uri.include? remote_path }.first
|
|
420
|
+
# If we found matching artifacts, but not in the correct path, copy the artifact to the correct path
|
|
421
|
+
# This should help us keep repos up to date with the packages we are expecting to be there
|
|
422
|
+
# while helping us avoid 'what the hell, could not find package' errors
|
|
423
|
+
if artifact_to_download.nil? && !artifacts.empty?
|
|
424
|
+
artifact_to_copy = artifacts.first
|
|
425
|
+
filename = info['filename'] || File.basename(artifact_to_copy.download_uri)
|
|
426
|
+
copy_artifact(artifact_to_copy, artifact_to_copy.repo, "#{remote_path}/#{dist}/#{filename}")
|
|
427
|
+
artifacts = Artifactory::Resource::Artifact.checksum_search(md5: "#{info["md5"]}", repos: ["rpm_enterprise__local", "debian_enterprise__local"])
|
|
428
|
+
artifact_to_download = artifacts.select { |artifact| artifact.download_uri.include? remote_path }.first
|
|
429
|
+
end
|
|
430
|
+
|
|
417
431
|
if artifact_to_download.nil?
|
|
418
|
-
filename = info["filename"] ||
|
|
419
|
-
|
|
432
|
+
filename = info["filename"] || name
|
|
433
|
+
message = "Error: what the hell, could not find package #{filename} with md5sum #{info["md5"]}"
|
|
434
|
+
unless remote_path.empty?
|
|
435
|
+
message += " in #{remote_path}"
|
|
436
|
+
end
|
|
437
|
+
raise message
|
|
420
438
|
else
|
|
421
439
|
full_staging_path = "#{staging_directory}/#{dist}"
|
|
422
440
|
filename = info['filename'] || File.basename(artifact_to_download.download_uri)
|
|
@@ -583,6 +601,33 @@ module Pkg
|
|
|
583
601
|
end
|
|
584
602
|
end
|
|
585
603
|
|
|
604
|
+
# Copy an artifact to a target repo/path
|
|
605
|
+
#
|
|
606
|
+
# @param artifact [Artifactory::Resource::Artifact] The artifact to be copied
|
|
607
|
+
# @param target_repo [String] The repository to copy the artifact to
|
|
608
|
+
# @param target_path [String] The path in the target repository to copy the artifact to
|
|
609
|
+
# @param target_debian_component [String] `deb.component` property to set on the copied artifact
|
|
610
|
+
# defaults to `Pkg::Paths.debian_component_from_path(target_path)`
|
|
611
|
+
def copy_artifact(artifact, target_repo, target_path, target_debian_component = nil)
|
|
612
|
+
filename = File.basename(artifact.download_uri)
|
|
613
|
+
artifactory_target_path = "#{target_repo}/#{target_path}"
|
|
614
|
+
puts "Copying #{artifact.download_uri} to #{artifactory_target_path}"
|
|
615
|
+
begin
|
|
616
|
+
artifact.copy(artifactory_target_path)
|
|
617
|
+
rescue Artifactory::Error::HTTPError
|
|
618
|
+
STDERR.puts "Could not copy #{artifactory_target_path}. Source and destination are the same. Skipping..."
|
|
619
|
+
end
|
|
620
|
+
|
|
621
|
+
if File.extname(filename) == '.deb'
|
|
622
|
+
target_debian_component ||= Pkg::Paths.debian_component_from_path(target_path)
|
|
623
|
+
copied_artifact_search = search_with_path(filename, target_repo, target_path)
|
|
624
|
+
fail "Error: what the hell, could not find just-copied package #{filename} under #{target_repo}/#{target_path}" if copied_artifact_search.empty?
|
|
625
|
+
copied_artifact = copied_artifact_search.first
|
|
626
|
+
properties = { 'deb.component' => target_debian_component }
|
|
627
|
+
copied_artifact.properties(properties)
|
|
628
|
+
end
|
|
629
|
+
end
|
|
630
|
+
|
|
586
631
|
# When we cut a new PE branch, we need to copy the pe components into <pe_version>/{repos,feature,release}/<platform>
|
|
587
632
|
# @param manifest [File] JSON file containing information about what packages to download and the corresponding md5sums
|
|
588
633
|
# @param target_path [String] path on artifactory to copy components to, e.g. <pe_version>/release
|
|
@@ -593,24 +638,11 @@ module Pkg
|
|
|
593
638
|
packages.each do |name, info|
|
|
594
639
|
artifact = Artifactory::Resource::Artifact.checksum_search(md5: "#{info["md5"]}", repos: ["rpm_enterprise__local", "debian_enterprise__local"]).first
|
|
595
640
|
if artifact.nil?
|
|
596
|
-
filename = info["filename"] ||
|
|
641
|
+
filename = info["filename"] || name
|
|
597
642
|
raise "Error: what the hell, could not find package #{filename} with md5sum #{info["md5"]}"
|
|
598
643
|
end
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
artifact_target_path = "#{artifact.repo}/#{target_path}/#{dist}/#{filename}"
|
|
602
|
-
puts "Copying #{artifact.download_uri} to #{artifact_target_path}"
|
|
603
|
-
artifact.copy(artifact_target_path)
|
|
604
|
-
rescue Artifactory::Error::HTTPError
|
|
605
|
-
STDERR.puts "Could not copy #{artifact_target_path}. Source and destination are the same. Skipping..."
|
|
606
|
-
end
|
|
607
|
-
if File.extname(filename) == '.deb'
|
|
608
|
-
copied_artifact_search = Artifactory::Resource::Artifact.pattern_search(repo: 'debian_enterprise__local', pattern: "#{target_path}/*/#{filename}")
|
|
609
|
-
fail "Error: what the hell, could not find just-copied package #{filename} under debian_enterprise__local/#{target_path}" if copied_artifact_search.nil?
|
|
610
|
-
copied_artifact = copied_artifact_search.first
|
|
611
|
-
properties = { 'deb.component' => Pkg::Paths.debian_component_from_path(target_path) }
|
|
612
|
-
copied_artifact.properties(properties)
|
|
613
|
-
end
|
|
644
|
+
filename = info["filename"] || File.basename(artifact.download_uri)
|
|
645
|
+
copy_artifact(artifact, artifact.repo, "#{target_path}/#{dist}/#{filename}")
|
|
614
646
|
end
|
|
615
647
|
end
|
|
616
648
|
end
|
data/lib/packaging/paths.rb
CHANGED
|
@@ -304,9 +304,18 @@ module Pkg::Paths
|
|
|
304
304
|
end
|
|
305
305
|
|
|
306
306
|
def debian_component_from_path(path)
|
|
307
|
-
|
|
307
|
+
# substitute '.' and '/' since those aren't valid characters for debian components
|
|
308
|
+
matches = path.match(/([\d+\.\d+|master])\/(\w+)/)
|
|
309
|
+
regex_for_substitution = /[\.\/]/
|
|
308
310
|
fail "Error: Could not determine Debian Component from path #{path}" if matches.nil?
|
|
309
|
-
|
|
310
|
-
|
|
311
|
+
base_component = matches[1]
|
|
312
|
+
component_qualifier = matches[2]
|
|
313
|
+
full_component = "#{base_component}/#{component_qualifier}"
|
|
314
|
+
unless regex_for_substitution.nil?
|
|
315
|
+
base_component.gsub!(regex_for_substitution, '_')
|
|
316
|
+
full_component.gsub!(regex_for_substitution, '_')
|
|
317
|
+
end
|
|
318
|
+
return base_component if component_qualifier == 'repos'
|
|
319
|
+
return full_component
|
|
311
320
|
end
|
|
312
321
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: packaging
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.99.
|
|
4
|
+
version: 0.99.59
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Puppet Labs
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-03-
|
|
11
|
+
date: 2020-03-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|