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

Add full Amazon 2 support #1887

Merged
merged 1 commit into from
Jun 4, 2024
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 lib/beaker/host/unix/pkg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def install_package(name, cmdline_args = '', version = nil, opts = {})
when /amazon-2023|el-(8|9|1[0-9])|fedora/
name = "#{name}-#{version}" if version
execute("dnf -y #{cmdline_args} install #{name}", opts)
when /amazon-7|centos|redhat|el-[1-7]-/
when /amazon-(2|7)|centos|redhat|el-[1-7]-/
name = "#{name}-#{version}" if version
execute("yum -y #{cmdline_args} install #{name}", opts)
when /ubuntu|debian/
Expand Down Expand Up @@ -167,7 +167,7 @@ def uninstall_package(name, cmdline_args = '', opts = {})
execute("zypper --non-interactive rm #{name}", opts)
when /amazon-2023|el-(8|9|1[0-9])|fedora/
execute("dnf -y #{cmdline_args} remove #{name}", opts)
when /amazon-7|centos|redhat|el-[1-7]-/
when /amazon-(2|7)|centos|redhat|el-[1-7]-/
execute("yum -y #{cmdline_args} remove #{name}", opts)
when /ubuntu|debian/
execute("apt-get purge #{cmdline_args} -y #{name}", opts)
Expand Down
12 changes: 10 additions & 2 deletions spec/beaker/host/unix/pkg_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,22 @@ def exec
expect(instance.install_package(pkg)).to eq "hello"
end

it "uses yum on amazon linux 2" do
it "uses yum on misnamed amazon linux 7" do
@opts = { 'platform' => "amazon-7-is-me" }
pkg = 'amazon_package'
expect(Beaker::Command).to receive(:new).with("yum -y install #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
expect(instance.install_package(pkg)).to eq "hello"
end

it "uses yum on amazon linux 2" do
@opts = { 'platform' => "amazon-2-is-me" }
pkg = 'amazon_package'
expect(Beaker::Command).to receive(:new).with("yum -y install #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
expect(instance.install_package(pkg)).to eq "hello"
end

it "uses pacman on archlinux" do
@opts = { 'platform' => 'archlinux-is-me' }
pkg = 'archlinux_package'
Expand Down Expand Up @@ -281,7 +289,7 @@ def exec

it 'Amazon Linux 2 uses yum' do
@platform = platform
@version = '7'
@version = '2'
package_file = 'test_123.yay'
expect(instance).to receive(:execute).with(/^yum.*#{package_file}$/)
instance.install_local_package(package_file)
Expand Down
1 change: 1 addition & 0 deletions spec/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ module PlatformHelpers

REDHATPLATFORMS = %w[
amazon-2023
amazon-2
fedora
el-
centos
Expand Down