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"]
pacman ="/etc/pacman.conf")
repos = pacman.scan(/\[(.+)\]/).flatten
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")
it "should use pacman.conf to determine valid repo names for package versions" do
@pacman_conf = <<-PACMAN_CONF
HoldPkg = pacman glibc
Architecture = auto
Server = https://my.custom.repo
Include = /etc/pacman.d/mirrorlist
Include = /etc/pacman.d/mirrorlist
Include = /etc/pacman.d/mirrorlist
@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.candidate_version.should eql("1.2.3-4")
it "should raise an exception if pacman fails" do
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