apt_stage_artifacts 0.8.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +17 -118
- data/apt_stage_artifacts.gemspec +5 -1
- data/lib/apt_add_to_freight_library.rb +6 -6
- data/lib/apt_stage_artifacts.rb +18 -7
- data/lib/apt_stage_from_tarball.rb +17 -11
- data/lib/apt_update_freight_cache.rb +1 -1
- data/lib/mixins/constants.rb +3 -3
- data/lib/version.rb +1 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4f50352d05718bbbe350ea4c6dfc1bca13c3286d
|
4
|
+
data.tar.gz: 021f50e22c595261541fec6db58c9fe9ffff7588
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1222f2be4b58acfa9fb5c42afa719b5025e7504351e3ae8d42e3048d116ea7c8ac3658558411835650fa712f624b035c00f3d4c18c0cf6618ae4fb05bc15bb17
|
7
|
+
data.tar.gz: 11ee72ca13adbbb277edad093915a4febc524cc61e179a8c895616407cf8278e8434da55641c14632f37f698354ebddd352762f30999710e8aae51fc5599ccfe
|
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
|
-
|
14
|
-
Enabled: true
|
15
|
-
|
16
|
-
Layout/FirstArrayElementIndentation:
|
16
|
+
Style/FrozenStringLiteralComment:
|
17
17
|
Enabled: false
|
18
18
|
|
19
|
-
|
19
|
+
Style/MutableConstant:
|
20
20
|
Enabled: false
|
21
21
|
|
22
|
-
Layout/
|
23
|
-
|
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
|
-
|
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/
|
28
|
+
Metrics/AbcSize:
|
80
29
|
Enabled: false
|
81
30
|
|
82
31
|
Metrics/MethodLength:
|
83
32
|
Enabled: false
|
84
33
|
|
85
|
-
|
86
|
-
|
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
|
-
|
37
|
+
Metrics/ClassLength:
|
113
38
|
Enabled: false
|
114
39
|
|
115
|
-
Style/
|
40
|
+
Style/RedundantReturn:
|
116
41
|
Enabled: false
|
117
42
|
|
118
|
-
Style/
|
119
|
-
|
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
|
-
|
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
|
data/apt_stage_artifacts.gemspec
CHANGED
@@ -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.
|
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
|
-
"
|
95
|
+
"puppet#{@puppet_version}.conf"
|
96
96
|
)
|
97
|
-
fatal "Cannot read '#{freight_config_file} on #{
|
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
|
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
|
-
|
119
|
-
|
120
|
-
|
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})
|
data/lib/apt_stage_artifacts.rb
CHANGED
@@ -77,22 +77,27 @@ 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.
|
86
|
-
exit
|
88
|
+
logger.warn 'Cannot find .deb artifacts. Neither pkg/deb nor output/deb exist. Skipping.'
|
89
|
+
exit 0
|
87
90
|
end
|
88
91
|
|
89
|
-
logger.info "Searching for
|
92
|
+
logger.info "Searching for puppetN/*.deb packages in #{@top_directory}"
|
90
93
|
Dir.chdir(@top_directory) do
|
91
|
-
@debian_artifacts = Dir['
|
94
|
+
@debian_artifacts = Dir['*/puppet*/*.deb']
|
92
95
|
end
|
93
96
|
return unless @debian_artifacts.empty?
|
94
97
|
|
95
|
-
logger.
|
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.'
|
96
101
|
exit 0
|
97
102
|
end
|
98
103
|
|
@@ -137,7 +142,7 @@ class AptStageArtifacts
|
|
137
142
|
when /^puppet(\d+)+$/
|
138
143
|
puppet_version = Regexp.last_match(1)
|
139
144
|
else
|
140
|
-
fatal
|
145
|
+
fatal "Puppet version not found in \"#{deb_file_path}\"."
|
141
146
|
end
|
142
147
|
|
143
148
|
codename = deb_file_path.split('/')[-3]
|
@@ -153,6 +158,10 @@ class AptStageArtifacts
|
|
153
158
|
}
|
154
159
|
end
|
155
160
|
|
161
|
+
if manifest.empty?
|
162
|
+
fatal 'No manifest was generated from the artifact list. This is unexpected.'
|
163
|
+
end
|
164
|
+
|
156
165
|
manifest_path = File.join(@top_directory, AptStageArtifacts::MANIFEST_JSON_FILENAME)
|
157
166
|
File.open(manifest_path, 'w') do |f|
|
158
167
|
f.write(manifest.to_json)
|
@@ -190,7 +199,9 @@ class AptStageArtifacts
|
|
190
199
|
|
191
200
|
# Invoke the remote staging of the sent artifacts
|
192
201
|
def invoke_remote_staging
|
193
|
-
|
202
|
+
# Do this in a login shell so we get rvm PATH goodness
|
203
|
+
staging_command = "#{@remote_staging_command} #{@remote_tarball_path}"
|
204
|
+
%x(ssh #{@staging_server} '/bin/bash -l -c "#{staging_command}"')
|
194
205
|
return if $CHILD_STATUS.success?
|
195
206
|
|
196
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
|
-
|
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 "
|
50
|
-
fatal "'#{@tarball_path}'
|
51
|
-
fatal "'#{@tarball_path}' is not
|
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
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
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
|
-
|
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 #{
|
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}'"
|
data/lib/mixins/constants.rb
CHANGED
@@ -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]
|
17
17
|
VALID_CODENAMES = DEBIAN_CODENAMES | UBUNTU_CODENAMES
|
18
18
|
|
19
19
|
# Validation constraints
|
@@ -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 '
|
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
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.
|
4
|
+
version: 0.10.1
|
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-
|
11
|
+
date: 2021-10-13 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.
|
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
|
-
|
196
|
+
rubyforge_project:
|
197
|
+
rubygems_version: 2.6.11
|
183
198
|
signing_key:
|
184
199
|
specification_version: 4
|
185
200
|
summary: Stages .deb artifacts to a remote freight repository
|