From 4339b46558cf861ad3b5a52fa41cb2adf4e53e85 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 29 Sep 2006 16:12:00 +0000 Subject: Fixing #26 -- using Resolution.exec instead of executing directly, and also calling lsb_release for every fact, instead of just once at startup git-svn-id: http://reductivelabs.com/svn/facter/trunk@177 1f5c1d6a-bddf-0310-8f58-fc49e503516a --- lib/facter.rb | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/facter.rb b/lib/facter.rb index cc340d4..012dfb3 100644 --- a/lib/facter.rb +++ b/lib/facter.rb @@ -608,20 +608,23 @@ class Facter setcode 'uname -r' end - {"LSBRelease" => "^LSB Version:\t(.*)$", "LSBDistId" => "^Distributor ID:\t(.*)$", - "LSBDistRelease" => "^Release:\t(.*)$", "LSBDistDescription" => "^Description:\t(.*)$", - "LSBDistCodeName" => "^Codename:\t(.*)$"}.each { |fact, pattern| - output = %x{lsb_release -a 2>&1} - if $? == 0 - Facter.add(fact) do - setcode do - if $? == 0 and output =~ /#{pattern}/ - $1 - end + { "LSBRelease" => "^LSB Version:\t(.*)$", + "LSBDistId" => "^Distributor ID:\t(.*)$", + "LSBDistRelease" => "^Release:\t(.*)$", + "LSBDistDescription" => "^Description:\t(.*)$", + "LSBDistCodeName" => "^Codename:\t(.*)$" + }.each do |fact, pattern| + Facter.add(fact) do + setcode do + output = Resolution.exec('lsb_release -a 2>/dev/null') + if output =~ /#{pattern}/ + $1 + else + nil end - end # end of add + end end - } + end Facter.add("OperatingSystem") do # Default to just returning the kernel as the operating system -- cgit