apt_stage_artifacts 0.7.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e07591cdba596e6ea479e9fffd9d788bc8a1d2668ae675401db1a3f362962038
4
- data.tar.gz: 1d31595f5a4cfb6e5bc29705e13831c5f1e2cf2c0bba43210c5f0de0c1c23817
3
+ metadata.gz: d51905e7a2e23e20b04d1cd22a6e61edc8ec929177f1a5ccdee059af132232d0
4
+ data.tar.gz: fc6413ef75d8b67e8aa58c2bc02cb5f5c054d54da142041b369983ea8ee4b60d
5
5
  SHA512:
6
- metadata.gz: 6018fa54461f302802a629faf72b8cdde0736fdf0306a415913d47ce6851fdb32a4ada85786c07b9f56398051a0abd527133292ac204abf5c76aa78cc7248302
7
- data.tar.gz: 83b340241e531c8560de6691816693dad7626f523b28a9438c2f8b6c17dc2fd9ce4b0d529def0e89328933de77136a9703747a9911b7d8dc6cd104aee79e35de
6
+ metadata.gz: c407f46e72961f82815fda25d44bf691086028088755f54fc816685193833a6daf299aa5258523ba91981988ff3e3501e9cb21c3f8ce324784942fbd11b470e8
7
+ data.tar.gz: feae60918c1195903d34d210bb068d17333bb2ad353b09c74280f1c2d5512a6d6668915184247bdd9cd75d7611ca630f6a08ec92471c040d3fd10c9e2d07338a
data/.rubocop.yml CHANGED
@@ -3,150 +3,49 @@
3
3
  require: rubocop-rake
4
4
 
5
5
  AllCops:
6
+ TargetRubyVersion: 2.3
7
+
6
8
  Exclude:
7
9
  - Rakefile
8
10
  - Gemfile
9
11
  - bin/*
10
12
  - spec/**/*.rb
13
+ - '*.gemspec'
11
14
  - templates/*
12
15
 
13
- Gemspec/DateAssignment:
14
- Enabled: true
15
-
16
- Layout/FirstArrayElementIndentation:
16
+ Style/FrozenStringLiteralComment:
17
17
  Enabled: false
18
18
 
19
- Layout/MultilineMethodCallIndentation:
19
+ Style/MutableConstant:
20
20
  Enabled: false
21
21
 
22
- Layout/SpaceBeforeBrackets:
23
- Enabled: true
24
-
25
- Lint/AmbiguousAssignment:
26
- Enabled: true
27
-
28
- Lint/DeprecatedConstants:
29
- Enabled: true
30
-
31
- Lint/DuplicateBranch:
32
- Enabled: true
33
-
34
- Lint/DuplicateRegexpCharacterClassElement:
35
- Enabled: true
36
-
37
- Lint/EmptyBlock:
38
- Enabled: true
39
-
40
- Lint/EmptyClass:
41
- Enabled: true
42
-
43
- Lint/LambdaWithoutLiteralBlock:
44
- Enabled: true
45
-
46
- Lint/NoReturnInBeginEndBlocks:
47
- Enabled: true
48
-
49
- Lint/NumberedParameterAssignment:
50
- Enabled: true
51
-
52
- Lint/OrAssignmentToConstant:
53
- Enabled: true
54
-
55
- Lint/RedundantDirGlobSort:
56
- Enabled: true
22
+ Layout/LineLength:
23
+ Max: 100
57
24
 
58
- Lint/SymbolConversion:
59
- Enabled: true
60
-
61
- Lint/ToEnumArguments:
62
- Enabled: true
63
-
64
- Lint/TripleQuotes:
65
- Enabled: true
66
-
67
- Lint/UnexpectedBlockArity:
68
- Enabled: true
69
-
70
- Lint/UnmodifiedReduceAccumulator:
71
- Enabled: true
72
-
73
- Metrics/AbcSize:
74
- Enabled: false
75
-
76
- Metrics/ClassLength:
25
+ Style/Documentation:
77
26
  Enabled: false
78
27
 
79
- Metrics/CyclomaticComplexity:
28
+ Metrics/AbcSize:
80
29
  Enabled: false
81
30
 
82
31
  Metrics/MethodLength:
83
32
  Enabled: false
84
33
 
85
- Metrics/ModuleLength:
86
- Enabled: false
87
-
88
- Metrics/PerceivedComplexity:
89
- Enabled: false
90
-
91
- Style/ArgumentsForwarding:
92
- Enabled: true
93
-
94
- Style/CollectionCompact:
95
- Enabled: true
96
-
97
- Style/DocumentDynamicEvalDefinition:
98
- Enabled: true
99
-
100
- Style/Documentation:
101
- Enabled: false
102
-
103
- Style/EachWithObject:
104
- Enabled: false
105
-
106
- Style/EndlessMethod:
107
- Enabled: true
108
-
109
- Style/FormatString:
110
- Enabled: false
34
+ Style/CommandLiteral:
35
+ EnforcedStyle: percent_x
111
36
 
112
- Style/FormatStringToken:
37
+ Metrics/ClassLength:
113
38
  Enabled: false
114
39
 
115
- Style/FrozenStringLiteralComment:
40
+ Style/RedundantReturn:
116
41
  Enabled: false
117
42
 
118
- Style/HashConversion:
119
- Enabled: true
120
-
121
- Style/HashExcept:
122
- Enabled: true
43
+ Style/PercentLiteralDelimiters:
44
+ PreferredDelimiters:
45
+ default: '()'
123
46
 
124
47
  Style/IfUnlessModifier:
125
48
  Enabled: false
126
49
 
127
- Style/IfWithBooleanLiteralBranches:
128
- Enabled: true
129
-
130
- Style/MutableConstant:
131
- Enabled: false
132
-
133
- Style/NegatedIfElseCondition:
134
- Enabled: true
135
-
136
- Style/NilLambda:
137
- Enabled: true
138
-
139
- Style/RedundantArgument:
140
- Enabled: true
141
-
142
- Style/RedundantReturn:
143
- Enabled: false
144
-
145
- Style/StringChars:
146
- Enabled: true
147
-
148
- Style/SwapValues:
149
- Enabled: true
150
-
151
- Style/CommandLiteral:
50
+ Metrics/CyclomaticComplexity:
152
51
  Enabled: false
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
 
9
9
  spec.summary = 'Stages .deb artifacts to a remote freight repository'
10
10
  spec.homepage = 'https://github.com/puppetlabs/apt_stage_artifacts'
11
- spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
11
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
12
12
 
13
13
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
14
14
 
@@ -29,6 +29,10 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'pry-byebug', '~> 3.0'
30
30
  spec.add_development_dependency 'rake', '~> 13.0'
31
31
  spec.add_development_dependency 'rspec', '~> 3.0'
32
+
33
+ # Rubocop 0.81 as the last to support Ruby 2.3. Drop this whenever we can stop
34
+ # supporting older rubies
35
+ spec.add_development_dependency 'rubocop', '0.81'
32
36
  spec.add_development_dependency 'rubocop-rake'
33
37
  spec.add_development_dependency 'rubocop-rspec'
34
38
  spec.add_development_dependency 'yard', '~> 0.9'
@@ -92,9 +92,9 @@ class AptAddToFreightLibrary
92
92
 
93
93
  freight_config_file = File.join(
94
94
  AptStageArtifacts::FREIGHT_CONFIG_DIRECTORY,
95
- "puppet_#{@puppet_version}.conf"
95
+ "puppet#{@puppet_version}.conf"
96
96
  )
97
- fatal "Cannot read '#{freight_config_file} on #{`hostname`.chomp}." unless
97
+ fatal "Cannot read '#{freight_config_file} on #{%x(hostname).chomp}." unless
98
98
  File.readable?(freight_config_file)
99
99
 
100
100
  logger.info "Using '#{freight_config_file}'"
@@ -102,7 +102,7 @@ class AptAddToFreightLibrary
102
102
 
103
103
  Dir.mktmpdir do |temporary_directory|
104
104
  deb_artifacts.each do |artifact_path|
105
- logger.info "Adding #{artifact_path} to puppet_#{@puppet_version}/#{@apt_component}"
105
+ logger.info "Adding #{artifact_path} to puppet#{@puppet_version}/#{@apt_component}"
106
106
  deb_artifact_path = artifact_path
107
107
  if deb_artifact_path.start_with?('https://', 'http://')
108
108
  download_data = URI.parse(deb_artifact_path).open
@@ -115,9 +115,9 @@ class AptAddToFreightLibrary
115
115
  end
116
116
 
117
117
  freight_add_command = %W[
118
- sudo --user=jenkins --set-home
119
- #{AptStageArtifacts::FREIGHT_COMMAND} add #{@verbose} --conf="#{freight_config_file}"
120
- #{deb_artifact_path} "apt/#{@codename}/#{@apt_component}"
118
+ sudo --user=jenkins --set-home
119
+ #{AptStageArtifacts::FREIGHT_COMMAND} add #{@verbose} --conf="#{freight_config_file}"
120
+ #{deb_artifact_path} "apt/#{@codename}/#{@apt_component}"
121
121
  ].join(' ')
122
122
 
123
123
  %x(#{freight_add_command})
@@ -86,13 +86,15 @@ class AptStageArtifacts
86
86
  exit 1
87
87
  end
88
88
 
89
- logger.info "Searching for .deb packages in #{@top_directory}"
89
+ logger.info "Searching for puppetN/*.deb packages in #{@top_directory}"
90
90
  Dir.chdir(@top_directory) do
91
- @debian_artifacts = Dir['**/*.deb']
91
+ @debian_artifacts = Dir['*/puppet*/*.deb']
92
92
  end
93
93
  return unless @debian_artifacts.empty?
94
94
 
95
- logger.error 'No .deb files found. Nothing to do.'
95
+ logger.warn 'This project does not contain artifacts suitable for shipping to the ' \
96
+ 'APT server. Expected repo layout is "pkg/<debian codename>/puppet<N>/*.deb". ' \
97
+ 'Skipping.'
96
98
  exit 0
97
99
  end
98
100
 
@@ -137,7 +139,7 @@ class AptStageArtifacts
137
139
  when /^puppet(\d+)+$/
138
140
  puppet_version = Regexp.last_match(1)
139
141
  else
140
- fatal("Unknown repo name \"#{repo_name}\" in #{deb_file_path}")
142
+ fatal "Puppet version not found in \"#{deb_file_path}\"."
141
143
  end
142
144
 
143
145
  codename = deb_file_path.split('/')[-3]
@@ -153,6 +155,10 @@ class AptStageArtifacts
153
155
  }
154
156
  end
155
157
 
158
+ if manifest.empty?
159
+ fatal 'No manifest was generated from the artifact list. This is unexpected.'
160
+ end
161
+
156
162
  manifest_path = File.join(@top_directory, AptStageArtifacts::MANIFEST_JSON_FILENAME)
157
163
  File.open(manifest_path, 'w') do |f|
158
164
  f.write(manifest.to_json)
@@ -190,7 +196,9 @@ class AptStageArtifacts
190
196
 
191
197
  # Invoke the remote staging of the sent artifacts
192
198
  def invoke_remote_staging
193
- %x(ssh #{@staging_server} #{@remote_staging_command} #{@remote_tarball_path})
199
+ # Do this in a login shell so we get rvm PATH goodness
200
+ staging_command = "#{@remote_staging_command} #{@remote_tarball_path}"
201
+ %x(ssh #{@staging_server} '/bin/bash -l -c "#{staging_command}"')
194
202
  return if $CHILD_STATUS.success?
195
203
 
196
204
  fatal "'ssh #{@staging_server} #{@remote_staging_command} #{@remote_tarball_path}' failed."
@@ -31,7 +31,7 @@ class AptStageFromTarball
31
31
  extract_tarball
32
32
  add_artifacts_to_freight_library
33
33
  update_freight_cache
34
- # cleanup_tarball_directory
34
+ cleanup_tarball_directory
35
35
  logger.info 'Freight artifact staging successful.'
36
36
  end
37
37
 
@@ -46,9 +46,10 @@ class AptStageFromTarball
46
46
  end
47
47
 
48
48
  def extract_tarball
49
- fatal "'#{@tarball_path}' does not exist." unless File.exist?(@tarball_path)
50
- fatal "'#{@tarball_path}' is not a regular file." unless File.file?(@tarball_path)
51
- fatal "'#{@tarball_path}' is not readable." unless File.readable?(@tarball_path)
49
+ fatal "Missing tarball_path command argument." if !@tarball_path
50
+ fatal "'#{@tarball_path}' does not exist" unless File.exist?(@tarball_path)
51
+ fatal "'#{@tarball_path}' is not a regular file" unless File.file?(@tarball_path)
52
+ fatal "'#{@tarball_path}' is not readable" unless File.readable?(@tarball_path)
52
53
 
53
54
  @tarball_directory = File.dirname(@tarball_path)
54
55
 
@@ -69,6 +70,11 @@ class AptStageFromTarball
69
70
  logger.info("'#{@tarball_path}' extracted.")
70
71
  end
71
72
 
73
+ def cleanup_tarball_directory
74
+ FileUtils.rm_r @tarball_directory
75
+ logger.info("'#{@tarball_directory}' deleted.")
76
+ end
77
+
72
78
  # Read through the staging manifest, adding each line into the correct apt freight
73
79
  # library.
74
80
  def add_artifacts_to_freight_library
@@ -76,12 +82,12 @@ class AptStageFromTarball
76
82
  manifest_file = File.read(@manifest_path)
77
83
  JSON.parse(manifest_file, symbolize_names: true).each do |artifact|
78
84
  add_to_freight_library_command = %W[
79
- #{@apt_add_to_freight_library_command}
80
- --verbose
81
- --puppet-version=#{artifact[:puppet_version]}
82
- --component=#{artifact[:apt_component]}
83
- --codename=#{artifact[:codename]}
84
- #{File.join(Dir.pwd, artifact[:deb_file_path])}
85
+ #{@apt_add_to_freight_library_command}
86
+ --verbose
87
+ --puppet-version=#{artifact[:puppet_version]}
88
+ --component=#{artifact[:apt_component]}
89
+ --codename=#{artifact[:codename]}
90
+ #{File.join(Dir.pwd, artifact[:deb_file_path])}
85
91
  ].join(' ')
86
92
 
87
93
  %x(#{add_to_freight_library_command})
@@ -102,7 +108,7 @@ class AptStageFromTarball
102
108
  #{@apt_update_freight_cache_command}
103
109
  --verbose
104
110
  --puppet-version=#{puppet_version}
105
- ].join(' ')
111
+ ].join(' ')
106
112
 
107
113
  %x(#{update_freight_cache_command})
108
114
  fatal "#{update_freight_cache_command} failed." unless $CHILD_STATUS.success?
@@ -71,8 +71,8 @@ class AptUpdateFreightCache
71
71
  fatal "Invalid Puppet version '#{@puppet_version}'"
72
72
  end
73
73
 
74
- freight_config_file = "/etc/freight.conf.d/puppet_#{@puppet_version}.conf"
75
- fatal "Cannot read '#{freight_config_file} on #{`hostname`.chomp}." unless
74
+ freight_config_file = "/etc/freight.conf.d/puppet#{@puppet_version}.conf"
75
+ fatal "Cannot read '#{freight_config_file} on #{%x(hostname).chomp}." unless
76
76
  File.readable?(freight_config_file)
77
77
 
78
78
  logger.info "Using '#{freight_config_file}'"
@@ -21,7 +21,7 @@ class AptStageArtifacts
21
21
 
22
22
  # From freight-add:
23
23
  # freight-add registers package with one or more manager/distro[/component] pairs (or triples).
24
- # component is optional and for apt defaults to 'main'.
24
+ # component is optional and for apt defaults to 'stable'.
25
25
 
26
26
  # These are valid APT components. We use 'stable' instead of 'main' established by convention
27
27
  # from docker dists (see https://download.docker.com/linux/ubuntu/dists/groovy)
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class AptStageArtifacts
2
- VERSION = '0.7.0'
2
+ VERSION = '0.10.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apt_stage_artifacts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Release Engineering
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-26 00:00:00.000000000 Z
11
+ date: 2021-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: '0.81'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: '0.81'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rubocop-rake
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -172,14 +186,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
186
  requirements:
173
187
  - - ">="
174
188
  - !ruby/object:Gem::Version
175
- version: 2.5.0
189
+ version: 2.3.0
176
190
  required_rubygems_version: !ruby/object:Gem::Requirement
177
191
  requirements:
178
192
  - - ">="
179
193
  - !ruby/object:Gem::Version
180
194
  version: '0'
181
195
  requirements: []
182
- rubygems_version: 3.1.6
196
+ rubyforge_project:
197
+ rubygems_version: 2.7.6
183
198
  signing_key:
184
199
  specification_version: 4
185
200
  summary: Stages .deb artifacts to a remote freight repository