Commit 132b8d20 authored by Caleb Tennis's avatar Caleb Tennis Committed by Bryan McLellan
Browse files

[CHEF-2826] - Add support for custom arch repos

parent 8ec6d971
......@@ -53,10 +53,19 @@ class Chef
def candidate_version
return @candidate_version if @candidate_version
repos = ["extra","core","community"]
if(::File.exists?("/etc/pacman.conf"))
pacman = ::File.read("/etc/pacman.conf")
repos = pacman.scan(/\[(.+)\]/).flatten
end
package_repos = repos.join("|")
status = popen4("pacman -Ss #{@new_resource.package_name}") do |pid, stdin, stdout, stderr|
stdout.each do |line|
case line
when /^(extra|core|community)\/#{Regexp.escape(@new_resource.package_name)} (.+)$/
when /^(#{package_repos})\/#{Regexp.escape(@new_resource.package_name)} (.+)$/
# $2 contains a string like "4.4.0-1 (kde kdenetwork)" or "3.10-4 (base)"
# simply split by space and use first token
@candidate_version = $2.split(" ").first
......
......@@ -103,6 +103,35 @@ PACMAN
@provider.candidate_version.should eql("2.2.3-1")
end
it "should use pacman.conf to determine valid repo names for package versions" do
@pacman_conf = <<-PACMAN_CONF
[options]
HoldPkg = pacman glibc
Architecture = auto
[customrepo]
Server = https://my.custom.repo
[core]
Include = /etc/pacman.d/mirrorlist
[extra]
Include = /etc/pacman.d/mirrorlist
[community]
Include = /etc/pacman.d/mirrorlist
PACMAN_CONF
::File.stub!(:exists?).with("/etc/pacman.conf").and_return(true)
::File.stub!(:read).with("/etc/pacman.conf").and_return(@pacman_conf)
@stdout.stub!(:each).and_yield("customrepo/nano 1.2.3-4").
and_yield(" My custom package")
@provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
@provider.candidate_version.should eql("1.2.3-4")
end
it "should raise an exception if pacman fails" do
@status.should_receive(:exitstatus).and_return(2)
lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Package)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment