Skip to content

Commit 20fd636

Browse files
authored
Merge pull request #20 from silug/issue_19
Add fix for package running dnf5 on fedora
2 parents 856b9aa + 26d3405 commit 20fd636

File tree

3 files changed

+19
-22
lines changed

3 files changed

+19
-22
lines changed

lib/puppet/provider/package/dnfmodule.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def self.prefetch(packages)
3535

3636
def self.instances
3737
packages = []
38-
cmd = "#{command(:dnf)} module list -y -d 0 -e #{error_level}"
38+
cmd = "#{command(:dnf)} module list -y"
3939
execute(cmd).each_line do |line|
4040
# select only lines with actual packages since DNF clutters the output
4141
next unless line =~ /\[[eix]\][, ]/
@@ -90,7 +90,7 @@ def install
9090
enable(args)
9191
else
9292
begin
93-
execute([command(:dnf), 'module', 'install', '-d', '0', '-e', self.class.error_level, '-y', args])
93+
execute([command(:dnf), 'module', 'install', '-y', args])
9494
rescue Puppet::ExecutionFailure => e
9595
# module has no default profile and no profile was requested, so just enable the stream
9696
# DNF versions prior to 4.2.8 do not need this workaround
@@ -117,20 +117,20 @@ def insync?(is)
117117
end
118118

119119
def enable(args = @resource[:name])
120-
execute([command(:dnf), 'module', 'enable', '-d', '0', '-e', self.class.error_level, '-y', args])
120+
execute([command(:dnf), 'module', 'enable', '-y', args])
121121
end
122122

123123
def uninstall
124-
execute([command(:dnf), 'module', 'remove', '-d', '0', '-e', self.class.error_level, '-y', @resource[:name]])
124+
execute([command(:dnf), 'module', 'remove', '-y', @resource[:name]])
125125
reset # reset module to the default stream
126126
end
127127

128128
def disable(args = @resource[:name])
129-
execute([command(:dnf), 'module', 'disable', '-d', '0', '-e', self.class.error_level, '-y', args])
129+
execute([command(:dnf), 'module', 'disable', '-y', args])
130130
end
131131

132132
def reset
133-
execute([command(:dnf), 'module', 'reset', '-d', '0', '-e', self.class.error_level, '-y', @resource[:name]])
133+
execute([command(:dnf), 'module', 'reset', '-y', @resource[:name]])
134134
end
135135

136136
def flavor

lib/puppet/provider/package/yum.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def install
247247
update_command = self.class.update_command
248248
# If not allowing virtual packages, do a query to ensure a real package exists
249249
unless @resource.allow_virtual?
250-
execute([command(:cmd), '-d', '0', '-e', error_level, '-y', install_options, :list, wanted].compact)
250+
execute([command(:cmd), '-y', install_options, :list, wanted].compact)
251251
end
252252

253253
should = @resource.should(:ensure)
@@ -307,10 +307,7 @@ def install
307307
end
308308
end
309309

310-
# Yum on el-4 and el-5 returns exit status 0 when trying to install a package it doesn't recognize;
311-
# ensure we capture output to check for errors.
312-
no_debug = Puppet.runtime[:facter].value('os.release.major').to_i > 5 ? ["-d", "0"] : []
313-
command = [command(:cmd)] + no_debug + ["-e", error_level, "-y", install_options, operation, wanted].compact
310+
command = [command(:cmd)] + ["-y", install_options, operation, wanted].compact
314311
output = execute(command)
315312

316313
if output.to_s =~ /^No package #{wanted} available\.$/

spec/unit/provider/package/yum_spec.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@
363363

364364
it 'selects best_version' do
365365
expect(provider).to receive(:execute).with(
366-
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, 'myresource-18.3.2']
366+
['/usr/bin/yum', '-y', :install, 'myresource-18.3.2']
367367
)
368368
provider.install
369369
end
@@ -374,7 +374,7 @@
374374

375375
it 'treats no epoch as zero' do
376376
expect(provider).to receive(:execute).with(
377-
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, 'myresource-18.3.2']
377+
['/usr/bin/yum', '-y', :install, 'myresource-18.3.2']
378378
)
379379
provider.install
380380
end
@@ -387,7 +387,7 @@
387387

388388
it 'selects best_version and removes epoch' do
389389
expect(provider).to receive(:execute).with(
390-
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, 'myresource-18.3.2']
390+
['/usr/bin/yum', '-y', :install, 'myresource-18.3.2']
391391
)
392392
provider.install
393393
end
@@ -399,14 +399,14 @@
399399

400400
it 'uses requested version' do
401401
expect(provider).to receive(:execute).with(
402-
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, "myresource->18.1 <19"]
402+
['/usr/bin/yum', '-y', :install, "myresource->18.1 <19"]
403403
)
404404
provider.install
405405
end
406406

407407
it 'logs a debug message' do
408408
allow(provider).to receive(:execute).with(
409-
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, "myresource->18.1 <19"]
409+
['/usr/bin/yum', '-y', :install, "myresource->18.1 <19"]
410410
)
411411

412412
expect(Puppet).to receive(:debug).with(
@@ -422,7 +422,7 @@
422422

423423
it 'passes the version to yum command' do
424424
expect(provider).to receive(:execute).with(
425-
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, "myresource-1:18.12"]
425+
['/usr/bin/yum', '-y', :install, "myresource-1:18.12"]
426426
)
427427
provider.install
428428
end
@@ -440,7 +440,7 @@
440440

441441
it 'adds update flag to install command' do
442442
expect(provider).to receive(:execute).with(
443-
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', 'update', 'myresource-18.3.2']
443+
['/usr/bin/yum', '-y', 'update', 'myresource-18.3.2']
444444
)
445445
provider.install
446446
end
@@ -458,7 +458,7 @@
458458

459459
it 'adds downgrade flag to install command' do
460460
expect(provider).to receive(:execute).with(
461-
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :downgrade, 'myresource-18.3.2']
461+
['/usr/bin/yum', '-y', :downgrade, 'myresource-18.3.2']
462462
)
463463
provider.install
464464
end
@@ -470,7 +470,7 @@
470470
context 'when execute command fails' do
471471
before do
472472
allow(provider).to receive(:execute).with(
473-
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, "myresource-20"]
473+
['/usr/bin/yum', '-y', :install, "myresource-20"]
474474
).and_return('No package myresource-20 available.')
475475
end
476476

@@ -484,7 +484,7 @@
484484
before do
485485
allow(provider).to receive(:query)
486486
allow(provider).to receive(:execute).with(
487-
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, "myresource-20"]
487+
['/usr/bin/yum', '-y', :install, "myresource-20"]
488488
)
489489
end
490490

@@ -497,7 +497,7 @@
497497
context 'when package is not installed' do
498498
before do
499499
allow(provider).to receive(:execute).with(
500-
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, "myresource-20"]
500+
['/usr/bin/yum', '-y', :install, "myresource-20"]
501501
)
502502
allow(provider).to receive(:insync?).and_return(false)
503503
end

0 commit comments

Comments
 (0)