apt_stage_artifacts 0.9.0 → 0.11.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: e22e83a8811e9598f4dc9fd27b639c743451fdc06e0502092daceb5cea04a9f8
4
- data.tar.gz: 9d19f393ac7f403a8dbdd7e56e6888e6392d556a8da28c9b5190eefc0c0a6098
3
+ metadata.gz: aab821806d4c6d510c44ab92fb338d00480aeca0bd9739cc4fd399d232d7da3b
4
+ data.tar.gz: f80728f81a04388c1656d40ff2efc1d636b1211c950885ae760d86e7bc2a77a5
5
5
  SHA512:
6
- metadata.gz: ae8a11f11b2a4698b684c169d74943770945b9e1f04489c4eaf8a1e3bf28cdfb64d5fdd3629c5febb6eba5f84e4bc5a8e9dd9e3ad1cbab6f659b62eeeabf5a8b
7
- data.tar.gz: dcc70849ba88e635c3fbf8d3022f74d0e136fab374f0f06d166208601479858b834765b6833265e7583638f6c0ae0245e8061a96d02ef48a76104896115df1c7
6
+ metadata.gz: d76bdf2c262e71b58b8b7dd46fef2fbc349e48d7172007ec2989d795f49df582a85dec43e30c2e5de6f8b76d48c7fcb4984e6d9e6b80f9c7f3b3c2022ce6c5c1
7
+ data.tar.gz: ed1f6177067eed7aaa6391a6b666e30753d9e60eb580b1e2e22302875f9a57cbbd325b18179d91a152fe0b3dcf29ab2dbd9d9218da5860dc8c9bca9b3636dd82
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'
@@ -94,7 +94,7 @@ class AptAddToFreightLibrary
94
94
  AptStageArtifacts::FREIGHT_CONFIG_DIRECTORY,
95
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}'"
@@ -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})
@@ -77,13 +77,16 @@ class AptStageArtifacts
77
77
  if File.directory?(File.join(@top_directory, 'deb'))
78
78
  @top_directory = File.join(@top_directory, 'deb')
79
79
  end
80
+ unless File.directory?(@top_directory)
81
+ fatal "Artifact directory \"#{@top_directory}\" does not exist"
82
+ end
80
83
  elsif File.directory?('./output/deb')
81
84
  @top_directory = './output/deb'
82
85
  elsif File.directory?('./pkg/deb')
83
86
  @top_directory = './pkg/deb'
84
87
  else
85
- logger.error 'Cannot find .deb artifacts. Neither pkg/deb nor output/deb exist.'
86
- exit 1
88
+ logger.warn 'Cannot find .deb artifacts. Neither pkg/deb nor output/deb exist. Skipping.'
89
+ exit 0
87
90
  end
88
91
 
89
92
  logger.info "Searching for puppetN/*.deb packages in #{@top_directory}"
@@ -92,9 +95,9 @@ class AptStageArtifacts
92
95
  end
93
96
  return unless @debian_artifacts.empty?
94
97
 
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."
98
+ logger.warn 'This project does not contain artifacts suitable for shipping to the ' \
99
+ 'APT server. Expected repo layout is "pkg/<debian codename>/puppet<N>/*.deb". ' \
100
+ 'Skipping.'
98
101
  exit 0
99
102
  end
100
103
 
@@ -197,7 +200,8 @@ class AptStageArtifacts
197
200
  # Invoke the remote staging of the sent artifacts
198
201
  def invoke_remote_staging
199
202
  # Do this in a login shell so we get rvm PATH goodness
200
- %x(ssh #{@staging_server} '/bin/bash -l -c "#{@remote_staging_command} #{@remote_tarball_path}"')
203
+ staging_command = "#{@remote_staging_command} #{@remote_tarball_path}"
204
+ %x(ssh #{@staging_server} '/bin/bash -l -c "#{staging_command}"')
201
205
  return if $CHILD_STATUS.success?
202
206
 
203
207
  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?
@@ -72,7 +72,7 @@ class AptUpdateFreightCache
72
72
  end
73
73
 
74
74
  freight_config_file = "/etc/freight.conf.d/puppet#{@puppet_version}.conf"
75
- fatal "Cannot read '#{freight_config_file} on #{`hostname`.chomp}." unless
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}'"
@@ -12,8 +12,8 @@ class AptStageArtifacts
12
12
 
13
13
  # Debian/Ubuntu codenames that we care about.
14
14
  # Some codenames are skipped because we don't/haven't shipped for them.
15
- DEBIAN_CODENAMES = %w[jessie stretch buster bullseye bookworm trixie]
16
- UBUNTU_CODENAMES = %w[xenial bionic focal groovy]
15
+ DEBIAN_CODENAMES = %w[wheezy jessie stretch buster bullseye bookworm trixie]
16
+ UBUNTU_CODENAMES = %w[lucid precise trusty xenial bionic focal groovy jammy]
17
17
  VALID_CODENAMES = DEBIAN_CODENAMES | UBUNTU_CODENAMES
18
18
 
19
19
  # Validation constraints
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class AptStageArtifacts
2
- VERSION = '0.9.0'
2
+ VERSION = '0.11.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.9.0
4
+ version: 0.11.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-09-29 00:00:00.000000000 Z
11
+ date: 2022-05-31 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,14 @@ 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.2.28
196
+ rubygems_version: 3.1.6
183
197
  signing_key:
184
198
  specification_version: 4
185
199
  summary: Stages .deb artifacts to a remote freight repository