Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle extra_depends a little more gracefully #259

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Metrics/ModuleLength:
Metrics/BlockLength:
Enabled: false
Metrics/MethodLength:
Max: 20
Max: 22
CountAsOne:
- 'heredoc'
Metrics/ClassLength:
Expand All @@ -37,7 +37,7 @@ Metrics/AbcSize:

# rspec
RSpec/MultipleMemoizedHelpers:
Max: 11
Max: 12
RSpec/MultipleExpectations:
Enabled: false
RSpec/ExampleLength:
Expand Down
7 changes: 7 additions & 0 deletions lib/ood_packaging/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,15 @@ def install_rpm_dependencies!
sh "#{cmd.join(' ')}#{cmd_suffix}"
end

# rubocop:disable Metrics/MethodLength
def install_deb_dependencies!
sh "sudo apt update -y#{cmd_suffix}"
extra_depends = config.fetch(:extra_depends, nil)
unless extra_depends.nil?
extra_depends = extra_depends.split(',').map(&:strip) if extra_depends.is_a?(String)
extra_depends.unshift('')
extra_depends = extra_depends.join(', ')
end
tool = [
'DEBIAN_FRONTEND=noninteractive apt-cudf-get --solver aspcud',
'-o APT::Get::Assume-Yes=1 -o APT::Get::Allow-Downgrades=1',
Expand All @@ -295,6 +301,7 @@ def install_deb_dependencies!
sh "rm -f #{cleanup.join(' ')}#{cmd_suffix}"
end
end
# rubocop:enable Metrics/MethodLength

def rpmbuild!
puts "== RPM build spec=#{spec_file} ==".blue
Expand Down
24 changes: 20 additions & 4 deletions spec/ood_packaging/build_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
let(:arch) { 'x86_64' }
let(:version) { 'v0.0.1-2' }
let(:build) { described_class.new }
let(:cmd_suffix) { ' 2>/dev/null 1>/dev/null' }

before do
ENV['DIST'] = dist
Expand Down Expand Up @@ -176,13 +177,28 @@
context 'when extra_depends is defined' do
let(:dist) { 'debian-12' }

before do
allow(build).to receive(:packaging_config).and_return({ 'debian-12' => { 'extra_depends' => 'npm' } })
it 'updates debian/control' do
allow(build).to receive(:packaging_config).and_return(
{
'debian-12' => { 'extra_depends' => 'npm' }
}
)
expect(build).to receive(:sh).with('sudo apt update -y 2>/dev/null 1>/dev/null')
expect(build).to receive(:sh).with("sed -i 's|@EXTRA_DEPENDS@|, npm|g' debian/control#{cmd_suffix}")
expect(build).to receive(:sh).with(expected_cmd.join(' '))
expect(build).to receive(:sh).with("rm -f #{cleanup.join(' ')} 2>/dev/null 1>/dev/null")
build.install_dependencies!
end

it 'updates debian/control' do
it 'updates debian/control from array of extra_depends' do
allow(build).to receive(:packaging_config).and_return(
{
'debian-12' => { 'extra_depends' => ['npm', 'foo'] }
}
)
depends = ', npm, foo'
expect(build).to receive(:sh).with('sudo apt update -y 2>/dev/null 1>/dev/null')
expect(build).to receive(:sh).with("sed -i 's|@EXTRA_DEPENDS@|npm|g' debian/control 2>/dev/null 1>/dev/null")
expect(build).to receive(:sh).with("sed -i 's|@EXTRA_DEPENDS@|#{depends}|g' debian/control#{cmd_suffix}")
expect(build).to receive(:sh).with(expected_cmd.join(' '))
expect(build).to receive(:sh).with("rm -f #{cleanup.join(' ')} 2>/dev/null 1>/dev/null")
build.install_dependencies!
Expand Down
Loading