Skip to content

Commit d23d6db

Browse files
committed
(PUP-10152) Prevent Pacman package provider doing partial upgrades
Using the `-y` switch in Pacman refreshes the catalog, but doesn't upgrade existing packages. This causes a "partial upgrade". From the Arch Linux wiki: [Partial upgrades are unsupported](https://wiki.archlinux.org/index.php/System_maintenance#Partial_upgrades_are_unsupported) This change removes the `-y` switch. It will be up to the user to refresh the catalog and upgrade the system _explicitly_. The other approach would be to have both the `-y` _and_ `-u` switches, but that would mean that installing a package through Puppet would implicitly upgrade the whole of the system - I don't think that would be desirable.
1 parent 30768e4 commit d23d6db

File tree

2 files changed

+8
-26
lines changed

2 files changed

+8
-26
lines changed

lib/puppet/provider/package/pacman.rb

+2-5
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ def update
132132

133133
# We rescue the main check from Pacman with a check on the AUR using yaourt, if installed
134134
def latest
135-
# Synchronize the database
136-
pacman "-Sy"
137-
138135
resource_name = @resource[:name]
139136

140137
# If target is a group, construct the group version
@@ -243,7 +240,7 @@ def install_from_file
243240
else
244241
fail _("Source %{source} is not supported by pacman") % { source: source }
245242
end
246-
pacman "--noconfirm", "--noprogressbar", "-Sy"
243+
pacman "--noconfirm", "--noprogressbar", "-S"
247244
pacman "--noconfirm", "--noprogressbar", "-U", source
248245
end
249246

@@ -255,7 +252,7 @@ def install_from_repo
255252

256253
cmd = %w{--noconfirm --needed --noprogressbar}
257254
cmd += install_options if @resource[:install_options]
258-
cmd << "-Sy" << resource_name
255+
cmd << "-S" << resource_name
259256

260257
if self.class.yaourt?
261258
yaourt(*cmd)

spec/unit/provider/package/pacman_spec.rb

+6-21
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
end
2727

2828
it "should call pacman to install the right package quietly when yaourt is not installed" do
29-
args = ['--noconfirm', '--needed', '--noprogressbar', '-Sy', resource[:name]]
29+
args = ['--noconfirm', '--needed', '--noprogressbar', '-S', resource[:name]]
3030
expect(provider).to receive(:pacman).at_least(:once).with(*args).and_return('')
3131
provider.install
3232
end
3333

3434
it "should call yaourt to install the right package quietly when yaourt is installed" do
3535
allow(described_class).to receive(:yaourt?).and_return(true)
36-
args = ['--noconfirm', '--needed', '--noprogressbar', '-Sy', resource[:name]]
36+
args = ['--noconfirm', '--needed', '--noprogressbar', '-S', resource[:name]]
3737
expect(provider).to receive(:yaourt).at_least(:once).with(*args).and_return('')
3838
provider.install
3939
end
@@ -68,14 +68,14 @@
6868
end
6969

7070
it "should call pacman to install the right package quietly when yaourt is not installed" do
71-
args = ['--noconfirm', '--needed', '--noprogressbar', '-x', '--arg=value', '-Sy', resource[:name]]
71+
args = ['--noconfirm', '--needed', '--noprogressbar', '-x', '--arg=value', '-S', resource[:name]]
7272
expect(provider).to receive(:pacman).at_least(:once).with(*args).and_return('')
7373
provider.install
7474
end
7575

7676
it "should call yaourt to install the right package quietly when yaourt is installed" do
7777
expect(described_class).to receive(:yaourt?).and_return(true)
78-
args = ['--noconfirm', '--needed', '--noprogressbar', '-x', '--arg=value', '-Sy', resource[:name]]
78+
args = ['--noconfirm', '--needed', '--noprogressbar', '-x', '--arg=value', '-S', resource[:name]]
7979
expect(provider).to receive(:yaourt).at_least(:once).with(*args).and_return('')
8080
provider.install
8181
end
@@ -94,7 +94,7 @@
9494
resource[:source] = source
9595

9696
expect(executor).to receive(:execute).
97-
with(include("-Sy") & include("--noprogressbar"), no_extra_options).
97+
with(include("-S") & include("--noprogressbar"), no_extra_options).
9898
ordered.
9999
and_return("")
100100

@@ -117,7 +117,7 @@
117117

118118
it "should install from the path segment of the URL" do
119119
expect(executor).to receive(:execute).
120-
with(include("-Sy") & include("--noprogressbar") & include("--noconfirm"),
120+
with(include("-S") & include("--noprogressbar") & include("--noconfirm"),
121121
no_extra_options).
122122
ordered.
123123
and_return("")
@@ -348,21 +348,7 @@
348348
end
349349

350350
describe "when determining the latest version" do
351-
it "should refresh package list" do
352-
expect(executor).to receive(:execute).
353-
ordered.
354-
with(['/usr/bin/pacman', '-Sy'], no_extra_options)
355-
356-
expect(executor).to receive(:execute).
357-
ordered.
358-
and_return("")
359-
360-
provider.latest
361-
end
362-
363351
it "should get query pacman for the latest version" do
364-
expect(executor).to receive(:execute).ordered
365-
366352
expect(executor).to receive(:execute).
367353
ordered.
368354
with(['/usr/bin/pacman', '-Sp', '--print-format', '%v', resource[:name]], no_extra_options).
@@ -379,7 +365,6 @@
379365

380366
it "should return a virtual group version when resource is a package group" do
381367
allow(described_class).to receive(:group?).and_return(true)
382-
expect(executor).to receive(:execute).with(['/usr/bin/pacman', '-Sy'], no_extra_options).ordered
383368
expect(executor).to receive(:execute).with(['/usr/bin/pacman', '-Sp', '--print-format', '%n %v', resource[:name]], no_extra_options).ordered.
384369
and_return(<<EOF)
385370
package2 1.0.1

0 commit comments

Comments
 (0)