Signed-off-by: James Turnbull <[email protected]>
---
lib/puppet/application/puppetrun.rb | 15 +++------------
lib/puppet/external/pson/pure.rb | 5 +----
lib/puppet/feature/base.rb | 3 +++
lib/puppet/feature/iconv.rb | 6 ++++++
lib/puppet/feature/selinux.rb | 6 ++++++
lib/puppet/sslcertificates.rb | 6 +-----
lib/puppet/util/selinux.rb | 6 +-----
7 files changed, 21 insertions(+), 26 deletions(-)
create mode 100644 lib/puppet/feature/iconv.rb
create mode 100644 lib/puppet/feature/selinux.rb
diff --git a/lib/puppet/application/puppetrun.rb
b/lib/puppet/application/puppetrun.rb
index 2dbd803..1a7e5d0 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'
+raise Puppet::Error, "RubyGems not installed" unless Puppet.features.rubygems?
+raise Puppet::Error, "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/external/pson/pure.rb b/lib/puppet/external/pson/pure.rb
index 7bb18aa..03a0504 100644
--- a/lib/puppet/external/pson/pure.rb
+++ b/lib/puppet/external/pson/pure.rb
@@ -4,15 +4,12 @@ require 'puppet/external/pson/pure/generator'
module PSON
begin
- require 'iconv'
+ raise Puppet::Error, "You must have iconv installed" unless
Puppet.features.iconv?
# An iconv instance to convert from UTF8 to UTF16 Big Endian.
UTF16toUTF8 = Iconv.new('utf-8', 'utf-16be') # :nodoc:
# An iconv instance to convert from UTF16 Big Endian to UTF8.
UTF8toUTF16 = Iconv.new('utf-16be', 'utf-8') # :nodoc:
UTF8toUTF16.iconv('no bom')
- rescue LoadError
- # We actually don't care
- Puppet.warning "iconv couldn't be loaded, which is required for
UTF-8/UTF-16 conversions"
rescue Errno::EINVAL, Iconv::InvalidEncoding
# Iconv doesn't support big endian utf-16. Let's try to hack this manually
# into the converters.
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/iconv.rb b/lib/puppet/feature/iconv.rb
new file mode 100644
index 0000000..fbedd63
--- /dev/null
+++ b/lib/puppet/feature/iconv.rb
@@ -0,0 +1,6 @@
+# Created by Luke Kanies on 2006-11-07.
+# Copyright (c) 2006. All rights reserved.
+
+require 'puppet/util/feature'
+
+Puppet.features.add(:iconv, :libs => "iconv")
diff --git a/lib/puppet/feature/selinux.rb b/lib/puppet/feature/selinux.rb
new file mode 100644
index 0000000..39dcc97
--- /dev/null
+++ b/lib/puppet/feature/selinux.rb
@@ -0,0 +1,6 @@
+# Created by Luke Kanies on 2006-11-07.
+# Copyright (c) 2006. All rights reserved.
+
+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..9bf8624 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
+raise Puppet::Error, "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.