From 3149b00c7fc655e9aa77d670cd73d900b122bbad Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Tue, 23 Jul 2024 15:17:20 +0200 Subject: [PATCH] Debian: Replace apt-get with apt for updates This replaces the old `apt-get update` with the newer `apt update`. This works on all modern Debian versions we support. Also `-qq` was added, to only output errors. This makes the beaker run a bit more readable. --- lib/beaker/host/unix/pkg.rb | 6 ++++-- lib/beaker/host_prebuilt_steps.rb | 3 ++- spec/beaker/host/unix/pkg_spec.rb | 4 ++-- spec/beaker/host_prebuilt_steps_spec.rb | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/beaker/host/unix/pkg.rb b/lib/beaker/host/unix/pkg.rb index a41605ed5..59873483d 100644 --- a/lib/beaker/host/unix/pkg.rb +++ b/lib/beaker/host/unix/pkg.rb @@ -62,7 +62,8 @@ def update_apt_if_needed return unless /debian|ubuntu/.match?(self['platform']) return unless @apt_needs_update - execute("apt-get update") + # -qq: Only output errors to stdout + execute("apt-get update -qq") @apt_needs_update = false end @@ -263,7 +264,8 @@ def install_local_package(onhost_package_file, onhost_copy_dir = nil) execute("zypper --non-interactive --no-gpg-checks in #{onhost_package_file}") when /^(debian|ubuntu)$/ execute("dpkg -i --force-all #{onhost_package_file}") - execute("apt-get update") + # -qq: Only output errors to stdout + execute("apt-get update -qq") when /^solaris$/ self.solaris_install_local_package(onhost_package_file, onhost_copy_dir) when /^osx$/ diff --git a/lib/beaker/host_prebuilt_steps.rb b/lib/beaker/host_prebuilt_steps.rb index acb2e60b3..a08c87694 100644 --- a/lib/beaker/host_prebuilt_steps.rb +++ b/lib/beaker/host_prebuilt_steps.rb @@ -204,7 +204,8 @@ def sync_root_keys host, opts # @param [Host, Array] hosts One or more hosts to act upon def apt_get_update hosts block_on hosts do |host| - host.exec(Command.new("apt-get update")) if /ubuntu|debian/.match?(host[:platform]) + # -qq: Only output errors to stdout + host.exec(Command.new("apt-get update -qq")) if /ubuntu|debian/.match?(host[:platform]) end end diff --git a/spec/beaker/host/unix/pkg_spec.rb b/spec/beaker/host/unix/pkg_spec.rb index c20c8069a..258cc208d 100644 --- a/spec/beaker/host/unix/pkg_spec.rb +++ b/spec/beaker/host/unix/pkg_spec.rb @@ -128,7 +128,7 @@ def exec it "calls update for #{platform}" do @opts = { 'platform' => platform } instance.instance_variable_set(:@apt_needs_update, true) - expect(instance).to receive('execute').with("apt-get update") + expect(instance).to receive('execute').with("apt-get update -qq") expect { instance.update_apt_if_needed }.not_to raise_error end end @@ -309,7 +309,7 @@ def exec %w[debian ubuntu].each do |platform| @platform = platform expect(instance).to receive(:execute).with(/^dpkg.*#{package_file}$/) - expect(instance).to receive(:execute).with('apt-get update') + expect(instance).to receive(:execute).with('apt-get update -qq') instance.install_local_package(package_file) end end diff --git a/spec/beaker/host_prebuilt_steps_spec.rb b/spec/beaker/host_prebuilt_steps_spec.rb index a96da9928..0abbd1c29 100644 --- a/spec/beaker/host_prebuilt_steps_spec.rb +++ b/spec/beaker/host_prebuilt_steps_spec.rb @@ -227,7 +227,7 @@ it "can perform apt-get on ubuntu hosts" do host = make_host('testhost', { :platform => 'ubuntu' }) - expect(Beaker::Command).to receive(:new).with("apt-get update").once + expect(Beaker::Command).to receive(:new).with("apt-get update -qq").once subject.apt_get_update(host) end @@ -235,7 +235,7 @@ it "can perform apt-get on debian hosts" do host = make_host('testhost', { :platform => 'debian' }) - expect(Beaker::Command).to receive(:new).with("apt-get update").once + expect(Beaker::Command).to receive(:new).with("apt-get update -qq").once subject.apt_get_update(host) end