diff --git a/.rubocop.yml b/.rubocop.yml index af93612..8ab3bdc 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -37,10 +37,12 @@ Metrics/AbcSize: # rspec RSpec/MultipleMemoizedHelpers: - Max: 10 + Max: 11 RSpec/MultipleExpectations: Enabled: false RSpec/ExampleLength: Enabled: false RSpec/MessageSpies: EnforcedStyle: receive +RSpec/NestedGroups: + Max: 4 diff --git a/Gemfile.lock b/Gemfile.lock index 4843a96..7d3932f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ood_packaging (0.13.1) + ood_packaging (0.13.2) rake (~> 13.0.1) GEM diff --git a/lib/ood_packaging/build.rb b/lib/ood_packaging/build.rb index 7a9fd77..e5a5981 100644 --- a/lib/ood_packaging/build.rb +++ b/lib/ood_packaging/build.rb @@ -275,6 +275,7 @@ def install_rpm_dependencies! def install_deb_dependencies! sh "sudo apt update -y#{cmd_suffix}" + extra_depends = config.fetch(:extra_depends, nil) tool = [ 'DEBIAN_FRONTEND=noninteractive apt-cudf-get --solver aspcud', '-o APT::Get::Assume-Yes=1 -o APT::Get::Allow-Downgrades=1', @@ -289,6 +290,7 @@ def install_deb_dependencies! "#{package}-build-deps*.changes" ] Dir.chdir(deb_work_dir) do + sh "sed -i 's|@EXTRA_DEPENDS@|#{extra_depends}|g' debian/control#{cmd_suffix}" unless extra_depends.nil? sh "#{cmd.join(' ')}#{cmd_suffix}" sh "rm -f #{cleanup.join(' ')}#{cmd_suffix}" end diff --git a/lib/ood_packaging/version.rb b/lib/ood_packaging/version.rb index 1adcb8d..dfa919b 100644 --- a/lib/ood_packaging/version.rb +++ b/lib/ood_packaging/version.rb @@ -2,7 +2,7 @@ # Version code for OodPackaging module OodPackaging - VERSION = '0.13.1' + VERSION = '0.13.2' PACKAGE_VERSION = { 'ondemand-release' => { '(ubuntu|debian)' => '3.1.0', diff --git a/spec/ood_packaging/build_spec.rb b/spec/ood_packaging/build_spec.rb index 17f4dd4..6779266 100644 --- a/spec/ood_packaging/build_spec.rb +++ b/spec/ood_packaging/build_spec.rb @@ -146,27 +146,48 @@ context 'when doing deb builds' do let(:dist) { 'ubuntu-20.04' } let(:version) { 'v0.0.1' } - - it 'installs DEB dependencies using apt' do + let(:cleanup) do + [ + 'ondemand-build-deps*.buildinfo', + 'ondemand-build-deps*.changes' + ] + end + let(:expected_cmd) do tool = [ 'DEBIAN_FRONTEND=noninteractive apt-cudf-get --solver aspcud', '-o APT::Get::Assume-Yes=1 -o APT::Get::Allow-Downgrades=1', '-o Debug::pkgProblemResolver=0 -o APT::Install-Recommends=0' ] - expected_cmd = [ + [ 'mk-build-deps', '--install', '--remove', '--root-cmd sudo', "--tool='#{tool.join(' ')}'", '2>/dev/null 1>/dev/null' ] - cleanup = [ - 'ondemand-build-deps*.buildinfo', - 'ondemand-build-deps*.changes' - ] + end + + it 'installs DEB dependencies using apt' do expect(build).to receive(:sh).with('sudo apt update -y 2>/dev/null 1>/dev/null') + expect(build).not_to receive(:sh).with(/^sed.+/) 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 + + 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' } }) + end + + it 'updates debian/control' do + 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(expected_cmd.join(' ')) + expect(build).to receive(:sh).with("rm -f #{cleanup.join(' ')} 2>/dev/null 1>/dev/null") + build.install_dependencies! + end + end end end