Signed-off-by: James Turnbull <[email protected]>
---
 lib/puppet/application/puppetrun.rb |   15 +++------------
 lib/puppet/feature/base.rb          |    3 +++
 lib/puppet/feature/selinux.rb       |    3 +++
 lib/puppet/sslcertificates.rb       |    6 +-----
 lib/puppet/util/selinux.rb          |    6 +-----
 5 files changed, 11 insertions(+), 22 deletions(-)
 create mode 100644 lib/puppet/feature/selinux.rb

diff --git a/lib/puppet/application/puppetrun.rb 
b/lib/puppet/application/puppetrun.rb
index 2dbd803..41ebf9f 100644
--- a/lib/puppet/application/puppetrun.rb
+++ b/lib/puppet/application/puppetrun.rb
@@ -1,18 +1,9 @@
-begin
-    require 'rubygems'
-rescue LoadError
-    # Nothing; we were just doing this just in case
-end
-
-begin
-    require 'ldap'
-rescue LoadError
-    $stderr.puts "Failed to load ruby LDAP library. LDAP functionality will 
not be available"
-end
-
 require 'puppet'
 require 'puppet/application'
 
+Puppet.warning "RubyGems not installed" unless Puppet.features.rubygems?
+Puppet.warning "Failed to load ruby LDAP library. LDAP functionality will not 
be available" unless Puppet.features.ldap?
+
 Puppet::Application.new(:puppetrun) do
 
     should_not_parse_config
diff --git a/lib/puppet/feature/base.rb b/lib/puppet/feature/base.rb
index c3fb9a2..aac04f2 100644
--- a/lib/puppet/feature/base.rb
+++ b/lib/puppet/feature/base.rb
@@ -28,3 +28,6 @@ Puppet.features.add(:augeas, :libs => ["augeas"])
 
 # We have RRD available
 Puppet.features.add(:rrd, :libs => ["RRDtool"])
+
+# We have OpenSSL
+Puppet.features.add(:openssl, :libs => ["openssl"])
diff --git a/lib/puppet/feature/selinux.rb b/lib/puppet/feature/selinux.rb
new file mode 100644
index 0000000..84be239
--- /dev/null
+++ b/lib/puppet/feature/selinux.rb
@@ -0,0 +1,3 @@
+require 'puppet/util/feature'
+
+Puppet.features.add(:selinux, :libs => ["selinux"])
diff --git a/lib/puppet/sslcertificates.rb b/lib/puppet/sslcertificates.rb
index fb5c1b7..62cfad1 100755
--- a/lib/puppet/sslcertificates.rb
+++ b/lib/puppet/sslcertificates.rb
@@ -2,11 +2,7 @@
 
 require 'puppet'
 
-begin
-    require 'openssl'
-rescue LoadError
-    raise Puppet::Error, "You must have the Ruby openssl library installed"
-end
+raise Puppet::Error, "You must have the Ruby openssl library installed" unless 
Puppet.features.openssl?
 
 module Puppet::SSLCertificates
     #def self.mkcert(type, name, dnsnames, ttl, issuercert, issuername, 
serial, publickey)
diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb
index f1336f9..331c8eb 100644
--- a/lib/puppet/util/selinux.rb
+++ b/lib/puppet/util/selinux.rb
@@ -7,11 +7,7 @@
 # was abysmal.  At this time (2008-11-02) the only distribution providing
 # these Ruby SELinux bindings which I am aware of is Fedora (in 
libselinux-ruby).
 
-begin
-    require 'selinux'
-rescue LoadError
-    # Nothing
-end
+Puppet.warning "SELinux not installed" unless Puppet.features.selinux?
 
 require 'pathname'
 
-- 
1.6.5.2

--

You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.


Reply via email to