diff --git a/.rubocop.yml b/.rubocop.yml index 8ab3bdc..14e1588 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -25,7 +25,7 @@ Metrics/ModuleLength: Metrics/BlockLength: Enabled: false Metrics/MethodLength: - Max: 20 + Max: 22 CountAsOne: - 'heredoc' Metrics/ClassLength: @@ -37,7 +37,7 @@ Metrics/AbcSize: # rspec RSpec/MultipleMemoizedHelpers: - Max: 11 + Max: 12 RSpec/MultipleExpectations: Enabled: false RSpec/ExampleLength: diff --git a/lib/ood_packaging/build.rb b/lib/ood_packaging/build.rb index e5a5981..fb7a3bc 100644 --- a/lib/ood_packaging/build.rb +++ b/lib/ood_packaging/build.rb @@ -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', @@ -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 diff --git a/spec/ood_packaging/build_spec.rb b/spec/ood_packaging/build_spec.rb index 6779266..c19949f 100644 --- a/spec/ood_packaging/build_spec.rb +++ b/spec/ood_packaging/build_spec.rb @@ -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 @@ -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!