facter 1.6.1 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of facter might be problematic. Click here for more details.

Files changed (88) hide show
  1. data/CHANGELOG +31 -0
  2. data/Rakefile +41 -36
  3. data/conf/redhat/facter.spec +11 -4
  4. data/conf/solaris/pkginfo +1 -1
  5. data/install.rb +286 -286
  6. data/lib/facter.rb +211 -211
  7. data/lib/facter/Cfkey.rb +24 -24
  8. data/lib/facter/application.rb +1 -0
  9. data/lib/facter/architecture.rb +21 -29
  10. data/lib/facter/domain.rb +34 -34
  11. data/lib/facter/facterversion.rb +1 -1
  12. data/lib/facter/fqdn.rb +8 -8
  13. data/lib/facter/hardwareisa.rb +2 -2
  14. data/lib/facter/hardwaremodel.rb +12 -12
  15. data/lib/facter/hostname.rb +14 -14
  16. data/lib/facter/id.rb +3 -3
  17. data/lib/facter/interfaces.rb +13 -13
  18. data/lib/facter/ipaddress.rb +101 -101
  19. data/lib/facter/iphostnumber.rb +12 -12
  20. data/lib/facter/kernel.rb +7 -7
  21. data/lib/facter/kernelmajversion.rb +3 -3
  22. data/lib/facter/kernelrelease.rb +12 -12
  23. data/lib/facter/kernelversion.rb +5 -5
  24. data/lib/facter/lsb.rb +14 -14
  25. data/lib/facter/lsbmajdistrelease.rb +8 -8
  26. data/lib/facter/macaddress.rb +44 -44
  27. data/lib/facter/macosx.rb +21 -21
  28. data/lib/facter/manufacturer.rb +28 -28
  29. data/lib/facter/memory.rb +143 -115
  30. data/lib/facter/netmask.rb +4 -4
  31. data/lib/facter/network.rb +4 -4
  32. data/lib/facter/operatingsystem.rb +73 -69
  33. data/lib/facter/operatingsystemrelease.rb +85 -79
  34. data/lib/facter/osfamily.rb +31 -0
  35. data/lib/facter/path.rb +3 -3
  36. data/lib/facter/physicalprocessorcount.rb +8 -0
  37. data/lib/facter/processor.rb +91 -72
  38. data/lib/facter/ps.rb +3 -3
  39. data/lib/facter/puppetversion.rb +7 -7
  40. data/lib/facter/rubysitedir.rb +5 -5
  41. data/lib/facter/rubyversion.rb +1 -1
  42. data/lib/facter/ssh.rb +16 -16
  43. data/lib/facter/timezone.rb +3 -3
  44. data/lib/facter/uniqueid.rb +2 -2
  45. data/lib/facter/util/collection.rb +96 -96
  46. data/lib/facter/util/confine.rb +30 -30
  47. data/lib/facter/util/fact.rb +95 -95
  48. data/lib/facter/util/ip.rb +173 -173
  49. data/lib/facter/util/loader.rb +88 -88
  50. data/lib/facter/util/macosx.rb +46 -46
  51. data/lib/facter/util/manufacturer.rb +78 -78
  52. data/lib/facter/util/memory.rb +63 -63
  53. data/lib/facter/util/netmask.rb +34 -34
  54. data/lib/facter/util/plist.rb +1 -1
  55. data/lib/facter/util/plist/generator.rb +177 -177
  56. data/lib/facter/util/plist/parser.rb +166 -166
  57. data/lib/facter/util/processor.rb +88 -0
  58. data/lib/facter/util/resolution.rb +154 -154
  59. data/lib/facter/util/uptime.rb +42 -42
  60. data/lib/facter/util/values.rb +9 -9
  61. data/lib/facter/util/virtual.rb +68 -58
  62. data/lib/facter/util/vlans.rb +17 -17
  63. data/lib/facter/virtual.rb +105 -110
  64. data/lib/facter/vlans.rb +6 -6
  65. data/spec/fixtures/cpuinfo/amd64dual +57 -0
  66. data/spec/fixtures/cpuinfo/amd64quad +79 -0
  67. data/spec/fixtures/cpuinfo/amd64solo +23 -0
  68. data/spec/fixtures/cpuinfo/amd64tri +86 -0
  69. data/spec/fixtures/cpuinfo/bbg3-armel +12 -0
  70. data/spec/fixtures/cpuinfo/beaglexm-armel +12 -0
  71. data/spec/fixtures/cpuinfo/panda-armel +17 -0
  72. data/spec/fixtures/cpuinfo/ppc64 +19 -0
  73. data/spec/fixtures/cpuinfo/sparc +10 -0
  74. data/spec/fixtures/processorcount/solaris-sparc-kstat-cpu-info +1216 -0
  75. data/spec/fixtures/processorcount/solaris-x86_64-kstat-cpu-info +225 -0
  76. data/spec/integration/facter_spec.rb +18 -18
  77. data/spec/spec_helper.rb +10 -1
  78. data/spec/unit/architecture_spec.rb +54 -0
  79. data/spec/unit/domain_spec.rb +23 -0
  80. data/spec/unit/memory_spec.rb +78 -1
  81. data/spec/unit/physicalprocessorcount_spec.rb +41 -35
  82. data/spec/unit/processor_spec.rb +183 -2
  83. data/spec/unit/util/processor_spec.rb +62 -0
  84. data/spec/unit/util/uptime_spec.rb +4 -4
  85. data/spec/unit/util/virtual_spec.rb +26 -5
  86. data/spec/unit/virtual_spec.rb +47 -2
  87. data/spec/watchr.rb +125 -0
  88. metadata +20 -4
data/CHANGELOG CHANGED
@@ -1,3 +1,34 @@
1
+ 1.6.2
2
+ ===
3
+ d7c00f6 (#9852) Fixing watchr on facter
4
+ abf636e (#9555) Change all cases of tabs and 4 space indentation to 2 space indentation.
5
+ db1b5af (#9830) Add sshecdsakey fact
6
+ 1b69791 (#9404) Add memory & update processor facts for DragonFly and OpenBSD.
7
+ bce2c69 (#9404) De-clumsify CPU count detection and swap detection on OpenBSD.
8
+ cd0ae15 (#9404) Efficiency cleanups for DragonFly facts.
9
+ d5511f6 (#9404) Add cross-fact support to facter for DragonFly BSD.
10
+ 0dfc4e9 (#6728) Improve openvz/cloudlinux detection.
11
+ 2c5ad52 (#6728) Facter improperly detects openvzve on CloudLinux systems
12
+ 9101e46 (#7951) added OS support for Amazon Linux
13
+ b3784f7 add operatingsystema and operatingsystemrelease support for cloudlinux
14
+ 8605bba (#9787) Change rspec format so we use the default, not document
15
+ b579613 (#7726) Silence prtconf error message inside zones
16
+ db3c606 (#9786) Add aliases: specs, tests, test in rake that points at 'spec'.
17
+ dfda9be (#4980, #6470) Fix architecture in Darwin and Ubuntu
18
+ 8f938c1 (#6792) Added osfamily fact.
19
+ af1ef43 (#6515) Fix for ruby-1.8.5. Switched use of 'line.each' to 'each_line'.
20
+ 328ff75 (#6515 and #2945) Fix processorcount for arm, sparc & ppc for linux.
21
+ 51329b8 (#3856) Detect VirtualBox on Darwin as well as Linux and SunOS
22
+ 83498b5 (#7996) Restrict solaris cpu processor detection
23
+ 6e29ff7 (#8615) ENV hash is now local to tests
24
+ 124a09b (#8240) Fixed regex pattern for domain
25
+ fd93c5f (#7996) Add solaris processor facts
26
+ 3f1a163 (#9593) Require rubygems to handle json output for ruby 1.8.7.
27
+ c4fe415 (#9295) Added spec tests for Hyper-V detection
28
+ ea23417 (#9295) Initial detection of Hyper-V hypervisor
29
+ 82351ab Stub out OS and HW model to avoid test failures. Only stub vmware -v (don't expect it) since it needn't be invoked if we already identified Xen or something else.
30
+ 16a8cab (#2747) Fix detection of xen0 vs xenu in Xen 3.2.
31
+
1
32
  1.6.1
2
33
  ===
3
34
  1f009e0 Updated CHANGELOG for 1.6.1rc4
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rubygems'
7
7
  require 'rspec'
8
8
  require 'rspec/core/rake_task'
9
9
  begin
10
- require 'rcov'
10
+ require 'rcov'
11
11
  rescue LoadError
12
12
  end
13
13
 
@@ -18,60 +18,65 @@ require 'rake/packagetask'
18
18
  require 'rake/gempackagetask'
19
19
 
20
20
  module Facter
21
- FACTERVERSION = File.read('lib/facter.rb')[/FACTERVERSION *= *'(.*)'/,1] or fail "Couldn't find FACTERVERSION"
21
+ FACTERVERSION = File.read('lib/facter.rb')[/FACTERVERSION *= *'(.*)'/,1] or fail "Couldn't find FACTERVERSION"
22
22
  end
23
23
 
24
24
  FILES = FileList[
25
- '[A-Z]*',
26
- 'install.rb',
27
- 'bin/**/*',
28
- 'lib/**/*',
29
- 'conf/**/*',
30
- 'etc/**/*',
31
- 'spec/**/*'
25
+ '[A-Z]*',
26
+ 'install.rb',
27
+ 'bin/**/*',
28
+ 'lib/**/*',
29
+ 'conf/**/*',
30
+ 'etc/**/*',
31
+ 'spec/**/*'
32
32
  ]
33
33
 
34
34
  spec = Gem::Specification.new do |spec|
35
- spec.platform = Gem::Platform::RUBY
36
- spec.name = 'facter'
37
- spec.files = FILES.to_a
38
- spec.executables = %w{facter}
39
- spec.version = Facter::FACTERVERSION
40
- spec.summary = 'Facter, a system inventory tool'
41
- spec.author = 'Puppet Labs'
42
- spec.email = 'info@puppetlabs.com'
43
- spec.homepage = 'http://puppetlabs.com'
44
- spec.rubyforge_project = 'facter'
45
- spec.has_rdoc = true
46
- spec.rdoc_options <<
47
- '--title' << 'Facter - System Inventory Tool' <<
48
- '--main' << 'README' <<
49
- '--line-numbers'
35
+ spec.platform = Gem::Platform::RUBY
36
+ spec.name = 'facter'
37
+ spec.files = FILES.to_a
38
+ spec.executables = %w{facter}
39
+ spec.version = Facter::FACTERVERSION
40
+ spec.summary = 'Facter, a system inventory tool'
41
+ spec.author = 'Puppet Labs'
42
+ spec.email = 'info@puppetlabs.com'
43
+ spec.homepage = 'http://puppetlabs.com'
44
+ spec.rubyforge_project = 'facter'
45
+ spec.has_rdoc = true
46
+ spec.rdoc_options <<
47
+ '--title' << 'Facter - System Inventory Tool' <<
48
+ '--main' << 'README' <<
49
+ '--line-numbers'
50
50
  end
51
51
 
52
52
  Rake::PackageTask.new("facter", Facter::FACTERVERSION) do |pkg|
53
- pkg.package_dir = 'pkg'
54
- pkg.need_tar_gz = true
55
- pkg.package_files = FILES.to_a
53
+ pkg.package_dir = 'pkg'
54
+ pkg.need_tar_gz = true
55
+ pkg.package_files = FILES.to_a
56
56
  end
57
57
 
58
58
  Rake::GemPackageTask.new(spec) do |pkg|
59
59
  end
60
60
 
61
61
  task :default do
62
- sh %{rake -T}
62
+ sh %{rake -T}
63
63
  end
64
64
 
65
+ # Aliases for spec
66
+ task :test => [:spec]
67
+ task :tests => [:spec]
68
+ task :specs => [:spec]
69
+
65
70
  RSpec::Core::RakeTask.new do |t|
66
- t.pattern ='spec/{unit,integration}/**/*_spec.rb'
67
- t.fail_on_error = true
71
+ t.pattern ='spec/{unit,integration}/**/*_spec.rb'
72
+ t.fail_on_error = true
68
73
  end
69
74
 
70
75
  RSpec::Core::RakeTask.new('spec:rcov') do |t|
71
- t.pattern ='spec/{unit,integration}/**/*_spec.rb'
72
- t.fail_on_error = true
73
- if defined?(Rcov)
74
- t.rcov = true
75
- t.rcov_opts = ['--exclude', 'spec/*,test/*,results/*,/usr/lib/*,/usr/local/lib/*,gems/*']
76
- end
76
+ t.pattern ='spec/{unit,integration}/**/*_spec.rb'
77
+ t.fail_on_error = true
78
+ if defined?(Rcov)
79
+ t.rcov = true
80
+ t.rcov_opts = ['--exclude', 'spec/*,test/*,results/*,/usr/lib/*,/usr/local/lib/*,gems/*']
81
+ end
77
82
  end
@@ -2,16 +2,17 @@
2
2
 
3
3
  %define has_ruby_abi 0%{?fedora} || 0%{?rhel} >= 5
4
4
  %define has_ruby_noarch %has_ruby_abi
5
+ %global _ver 1.6.2
5
6
 
6
7
  Summary: Ruby module for collecting simple facts about a host operating system
7
8
  Name: facter
8
- Version: 1.6.0
9
+ Version: 1.6.2
9
10
  Release: 1%{?dist}
10
11
  License: Apache 2.0
11
12
  Group: System Environment/Base
12
13
  URL: http://www.puppetlabs.com/puppet/related-projects/%{name}/
13
- Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}.tar.gz
14
- Source1: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}.tar.gz.sign
14
+ Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{_ver}.tar.gz
15
+ #Source1: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}.tar.gz.sign
15
16
 
16
17
  BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
17
18
  %if %has_ruby_noarch
@@ -31,7 +32,7 @@ system. Some of the facts are preconfigured, such as the hostname and the
31
32
  operating system. Additional facts can be added through simple Ruby scripts
32
33
 
33
34
  %prep
34
- %setup -q
35
+ %setup -q -n %{name}-%{_ver}
35
36
 
36
37
  %build
37
38
 
@@ -52,6 +53,12 @@ rm -rf %{buildroot}
52
53
 
53
54
 
54
55
  %changelog
56
+ * Mon Oct 10 2011 Michael Stahnke <stahnma@puppetlabs.com> - 1.6.2-1
57
+ - Update to 1.6.2
58
+
59
+ * Mon Oct 03 2011 Michael Stahnke <stahnma@puppetlabs.com> - 1.6.2-0.1rc1
60
+ - Updates for 1.6.2-0.1rc1
61
+
55
62
  * Thu Jun 23 2011 Michael Stahnke <stahnma@puppetlabs.com> - 1.6.0-1
56
63
  - Update to 1.6.0
57
64
 
@@ -1,6 +1,6 @@
1
1
  PKG=CSWfacter
2
2
  NAME=facter - System Fact Gatherer
3
- VERSION=1.6.0
3
+ VERSION=1.6.2
4
4
  CATEGORY=application
5
5
  VENDOR=http://www.puppetlabs.com/puppet/related-projects/facter
6
6
  HOTLINE=http://puppetlabs.com/cgi-bin/facter.cgi
data/install.rb CHANGED
@@ -12,23 +12,23 @@
12
12
  # In most cases, if you have a typical project layout, you will need to do
13
13
  # absolutely nothing to make this work for you. This layout is:
14
14
  #
15
- # bin/ # executable files -- "commands"
16
- # lib/ # the source of the library
15
+ # bin/ # executable files -- "commands"
16
+ # lib/ # the source of the library
17
17
  # tests/ # unit tests
18
18
  #
19
19
  # The default behaviour:
20
20
  # 1) Run all unit test files (ending in .rb) found in all directories under
21
- # tests/.
21
+ # tests/.
22
22
  # 2) Build Rdoc documentation from all files in bin/ (excluding .bat and .cmd),
23
- # all .rb files in lib/, ./README, ./ChangeLog, and ./Install.
23
+ # all .rb files in lib/, ./README, ./ChangeLog, and ./Install.
24
24
  # 3) Build ri documentation from all files in bin/ (excluding .bat and .cmd),
25
- # and all .rb files in lib/. This is disabled by default on Win32.
25
+ # and all .rb files in lib/. This is disabled by default on Win32.
26
26
  # 4) Install commands from bin/ into the Ruby bin directory. On Windows, if a
27
- # if a corresponding batch file (.bat or .cmd) exists in the bin directory,
28
- # it will be copied over as well. Otherwise, a batch file (always .bat) will
29
- # be created to run the specified command.
27
+ # if a corresponding batch file (.bat or .cmd) exists in the bin directory,
28
+ # it will be copied over as well. Otherwise, a batch file (always .bat) will
29
+ # be created to run the specified command.
30
30
  # 5) Install all library files ending in .rb from lib/ into Ruby's
31
- # site_lib/version directory.
31
+ # site_lib/version directory.
32
32
  #
33
33
  #++
34
34
 
@@ -39,23 +39,23 @@ require 'optparse'
39
39
  require 'ostruct'
40
40
 
41
41
  begin
42
- require 'rdoc/rdoc'
43
- $haverdoc = true
42
+ require 'rdoc/rdoc'
43
+ $haverdoc = true
44
44
  rescue LoadError
45
- puts "Missing rdoc; skipping documentation"
46
- $haverdoc = false
45
+ puts "Missing rdoc; skipping documentation"
46
+ $haverdoc = false
47
47
  end
48
48
 
49
49
  begin
50
- if $haverdoc
51
- rst2man = %x{which rst2man.py}
52
- $haveman = true
53
- else
54
- $haveman = false
55
- end
50
+ if $haverdoc
51
+ rst2man = %x{which rst2man.py}
52
+ $haveman = true
53
+ else
54
+ $haveman = false
55
+ end
56
56
  rescue
57
- puts "Missing rst2man; skipping man page creation"
58
- $haveman = false
57
+ puts "Missing rst2man; skipping man page creation"
58
+ $haveman = false
59
59
  end
60
60
 
61
61
  $LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
@@ -67,66 +67,66 @@ PREREQS = %w{openssl xmlrpc/client xmlrpc/server cgi}
67
67
  InstallOptions = OpenStruct.new
68
68
 
69
69
  def glob(list)
70
- g = list.map { |i| Dir.glob(i) }
71
- g.flatten!
72
- g.compact!
73
- g.reject! { |e| e =~ /\.svn/ }
74
- g
70
+ g = list.map { |i| Dir.glob(i) }
71
+ g.flatten!
72
+ g.compact!
73
+ g.reject! { |e| e =~ /\.svn/ }
74
+ g
75
75
  end
76
76
 
77
77
  # Set these values to what you want installed.
78
78
  sbins = glob(%w{sbin/*})
79
79
  bins = glob(%w{bin/*})
80
80
  rdoc = glob(%w{bin/* sbin/* lib/**/*.rb README README-library CHANGELOG TODO Install}).reject { |e| e=~ /\.(bat|cmd)$/ }
81
- ri = glob(%w(bin/*.rb sbin/* lib/**/*.rb)).reject { |e| e=~ /\.(bat|cmd)$/ }
81
+ ri = glob(%w(bin/*.rb sbin/* lib/**/*.rb)).reject { |e| e=~ /\.(bat|cmd)$/ }
82
82
  man = glob(%w{man/man8/*})
83
83
  libs = glob(%w{lib/**/*.rb lib/**/*.py})
84
84
  tests = glob(%w{tests/**/*.rb})
85
85
 
86
86
  def do_bins(bins, target, strip = 's?bin/')
87
- bins.each do |bf|
88
- obf = bf.gsub(/#{strip}/, '')
89
- install_binfile(bf, obf, target)
90
- end
87
+ bins.each do |bf|
88
+ obf = bf.gsub(/#{strip}/, '')
89
+ install_binfile(bf, obf, target)
90
+ end
91
91
  end
92
92
 
93
93
  def do_libs(libs, strip = 'lib/')
94
- libs.each do |lf|
95
- olf = File.join(InstallOptions.site_dir, lf.gsub(/#{strip}/, ''))
96
- op = File.dirname(olf)
97
- FileUtils.makedirs(op, {:mode => 0755, :verbose => true})
98
- FileUtils.chmod(0755, op)
99
- FileUtils.install(lf, olf, {:mode => 0644, :verbose => true})
100
- end
94
+ libs.each do |lf|
95
+ olf = File.join(InstallOptions.site_dir, lf.gsub(/#{strip}/, ''))
96
+ op = File.dirname(olf)
97
+ FileUtils.makedirs(op, {:mode => 0755, :verbose => true})
98
+ FileUtils.chmod(0755, op)
99
+ FileUtils.install(lf, olf, {:mode => 0644, :verbose => true})
100
+ end
101
101
  end
102
102
 
103
103
  def do_man(man, strip = 'man/')
104
104
  if (InstallOptions.man == true)
105
- man.each do |mf|
106
- omf = File.join(InstallOptions.man_dir, mf.gsub(/#{strip}/, ''))
107
- om = File.dirname(omf)
108
- FileUtils.makedirs(om, {:mode => 0755, :verbose => true})
109
- FileUtils.chmod(0755, om)
110
- FileUtils.install(mf, omf, {:mode => 0644, :verbose => true})
111
- gzip = %x{which gzip}
112
- gzip.chomp!
113
- %x{#{gzip} -f #{omf}}
114
- end
105
+ man.each do |mf|
106
+ omf = File.join(InstallOptions.man_dir, mf.gsub(/#{strip}/, ''))
107
+ om = File.dirname(omf)
108
+ FileUtils.makedirs(om, {:mode => 0755, :verbose => true})
109
+ FileUtils.chmod(0755, om)
110
+ FileUtils.install(mf, omf, {:mode => 0644, :verbose => true})
111
+ gzip = %x{which gzip}
112
+ gzip.chomp!
113
+ %x{#{gzip} -f #{omf}}
114
+ end
115
115
  else
116
- puts "Skipping Man Page Generation"
116
+ puts "Skipping Man Page Generation"
117
117
  end
118
118
  end
119
119
 
120
120
  # Verify that all of the prereqs are installed
121
121
  def check_prereqs
122
- PREREQS.each { |pre|
123
- begin
124
- require pre
125
- rescue LoadError
126
- puts "Could not load #{pre} Ruby library; cannot install"
127
- exit -1
128
- end
129
- }
122
+ PREREQS.each { |pre|
123
+ begin
124
+ require pre
125
+ rescue LoadError
126
+ puts "Could not load #{pre} Ruby library; cannot install"
127
+ exit -1
128
+ end
129
+ }
130
130
  end
131
131
 
132
132
  def is_windows?
@@ -137,160 +137,160 @@ end
137
137
  # Prepare the file installation.
138
138
  #
139
139
  def prepare_installation
140
- # Only try to do docs if we're sure they have rdoc
141
- if $haverdoc
142
- InstallOptions.rdoc = true
143
- if is_windows?
144
- InstallOptions.ri = false
145
- else
146
- InstallOptions.ri = true
147
- end
140
+ # Only try to do docs if we're sure they have rdoc
141
+ if $haverdoc
142
+ InstallOptions.rdoc = true
143
+ if is_windows?
144
+ InstallOptions.ri = false
148
145
  else
149
- InstallOptions.rdoc = false
150
- InstallOptions.ri = false
146
+ InstallOptions.ri = true
151
147
  end
148
+ else
149
+ InstallOptions.rdoc = false
150
+ InstallOptions.ri = false
151
+ end
152
152
 
153
153
 
154
- if $haveman
155
- InstallOptions.man = true
156
- if is_windows?
157
- InstallOptions.man = false
158
- end
159
- else
160
- InstallOptions.man = false
154
+ if $haveman
155
+ InstallOptions.man = true
156
+ if is_windows?
157
+ InstallOptions.man = false
161
158
  end
159
+ else
160
+ InstallOptions.man = false
161
+ end
162
+
163
+ InstallOptions.tests = true
162
164
 
163
- InstallOptions.tests = true
164
-
165
- ARGV.options do |opts|
166
- opts.banner = "Usage: #{File.basename($0)} [options]"
167
- opts.separator ""
168
- opts.on('--[no-]rdoc', 'Prevents the creation of RDoc output.', 'Default on.') do |onrdoc|
169
- InstallOptions.rdoc = onrdoc
170
- end
171
- opts.on('--[no-]ri', 'Prevents the creation of RI output.', 'Default off on mswin32.') do |onri|
172
- InstallOptions.ri = onri
173
- end
174
- opts.on('--[no-]man', 'Presents the creation of man pages.', 'Default on.') do |onman|
175
- InstallOptions.man = onman
176
- end
177
- opts.on('--[no-]tests', 'Prevents the execution of unit tests.', 'Default on.') do |ontest|
178
- InstallOptions.tests = ontest
179
- end
180
- opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir|
181
- InstallOptions.destdir = destdir
182
- end
183
- opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides Config::CONFIG["bindir"]') do |bindir|
184
- InstallOptions.bindir = bindir
185
- end
186
- opts.on('--sbindir[=OPTIONAL]', 'Installation directory for system binaries', 'overrides Config::CONFIG["sbindir"]') do |sbindir|
187
- InstallOptions.sbindir = sbindir
188
- end
189
- opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides Config::CONFIG["sitelibdir"]') do |sitelibdir|
190
- InstallOptions.sitelibdir = sitelibdir
191
- end
192
- opts.on('--mandir[=OPTIONAL]', 'Installation directory for man pages', 'overrides Config::CONFIG["mandir"]') do |mandir|
193
- InstallOptions.mandir = mandir
194
- end
195
- opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick|
196
- InstallOptions.rdoc = false
197
- InstallOptions.ri = false
198
- InstallOptions.tests = false
199
- end
200
- opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full|
201
- InstallOptions.rdoc = true
202
- InstallOptions.ri = true
203
- InstallOptions.tests = true
204
- end
205
- opts.separator("")
206
- opts.on_tail('--help', "Shows this help text.") do
207
- $stderr.puts opts
208
- exit
209
- end
210
-
211
- opts.parse!
165
+ ARGV.options do |opts|
166
+ opts.banner = "Usage: #{File.basename($0)} [options]"
167
+ opts.separator ""
168
+ opts.on('--[no-]rdoc', 'Prevents the creation of RDoc output.', 'Default on.') do |onrdoc|
169
+ InstallOptions.rdoc = onrdoc
170
+ end
171
+ opts.on('--[no-]ri', 'Prevents the creation of RI output.', 'Default off on mswin32.') do |onri|
172
+ InstallOptions.ri = onri
173
+ end
174
+ opts.on('--[no-]man', 'Presents the creation of man pages.', 'Default on.') do |onman|
175
+ InstallOptions.man = onman
176
+ end
177
+ opts.on('--[no-]tests', 'Prevents the execution of unit tests.', 'Default on.') do |ontest|
178
+ InstallOptions.tests = ontest
179
+ end
180
+ opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir|
181
+ InstallOptions.destdir = destdir
182
+ end
183
+ opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides Config::CONFIG["bindir"]') do |bindir|
184
+ InstallOptions.bindir = bindir
185
+ end
186
+ opts.on('--sbindir[=OPTIONAL]', 'Installation directory for system binaries', 'overrides Config::CONFIG["sbindir"]') do |sbindir|
187
+ InstallOptions.sbindir = sbindir
188
+ end
189
+ opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides Config::CONFIG["sitelibdir"]') do |sitelibdir|
190
+ InstallOptions.sitelibdir = sitelibdir
191
+ end
192
+ opts.on('--mandir[=OPTIONAL]', 'Installation directory for man pages', 'overrides Config::CONFIG["mandir"]') do |mandir|
193
+ InstallOptions.mandir = mandir
194
+ end
195
+ opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick|
196
+ InstallOptions.rdoc = false
197
+ InstallOptions.ri = false
198
+ InstallOptions.tests = false
199
+ end
200
+ opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full|
201
+ InstallOptions.rdoc = true
202
+ InstallOptions.ri = true
203
+ InstallOptions.tests = true
204
+ end
205
+ opts.separator("")
206
+ opts.on_tail('--help', "Shows this help text.") do
207
+ $stderr.puts opts
208
+ exit
212
209
  end
213
210
 
214
- tmpdirs = [ENV['TMP'], ENV['TEMP'], "/tmp", "/var/tmp", "."]
211
+ opts.parse!
212
+ end
215
213
 
216
- version = [Config::CONFIG["MAJOR"], Config::CONFIG["MINOR"]].join(".")
217
- libdir = File.join(Config::CONFIG["libdir"], "ruby", version)
214
+ tmpdirs = [ENV['TMP'], ENV['TEMP'], "/tmp", "/var/tmp", "."]
218
215
 
219
- # Mac OS X 10.5 and higher declare bindir and sbindir as
220
- # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin
221
- # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/sbin
222
- # which is not generally where people expect executables to be installed
223
- # These settings are appropriate defaults for all OS X versions.
224
- if RUBY_PLATFORM =~ /^universal-darwin[\d\.]+$/
225
- Config::CONFIG['bindir'] = "/usr/bin"
226
- Config::CONFIG['sbindir'] = "/usr/sbin"
227
- end
216
+ version = [Config::CONFIG["MAJOR"], Config::CONFIG["MINOR"]].join(".")
217
+ libdir = File.join(Config::CONFIG["libdir"], "ruby", version)
228
218
 
229
- if not InstallOptions.bindir.nil?
230
- bindir = InstallOptions.bindir
231
- else
232
- bindir = Config::CONFIG['bindir']
233
- end
219
+ # Mac OS X 10.5 and higher declare bindir and sbindir as
220
+ # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin
221
+ # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/sbin
222
+ # which is not generally where people expect executables to be installed
223
+ # These settings are appropriate defaults for all OS X versions.
224
+ if RUBY_PLATFORM =~ /^universal-darwin[\d\.]+$/
225
+ Config::CONFIG['bindir'] = "/usr/bin"
226
+ Config::CONFIG['sbindir'] = "/usr/sbin"
227
+ end
234
228
 
235
- if not InstallOptions.sbindir.nil?
236
- sbindir = InstallOptions.sbindir
237
- else
238
- sbindir = Config::CONFIG['sbindir']
239
- end
229
+ if not InstallOptions.bindir.nil?
230
+ bindir = InstallOptions.bindir
231
+ else
232
+ bindir = Config::CONFIG['bindir']
233
+ end
240
234
 
241
- if not InstallOptions.sitelibdir.nil?
242
- sitelibdir = InstallOptions.sitelibdir
243
- else
244
- sitelibdir = Config::CONFIG["sitelibdir"]
245
- if sitelibdir.nil?
246
- sitelibdir = $:.find { |x| x =~ /site_ruby/ }
247
- if sitelibdir.nil?
248
- sitelibdir = File.join(libdir, "site_ruby")
249
- elsif sitelibdir !~ Regexp.quote(version)
250
- sitelibdir = File.join(sitelibdir, version)
251
- end
252
- end
253
- end
235
+ if not InstallOptions.sbindir.nil?
236
+ sbindir = InstallOptions.sbindir
237
+ else
238
+ sbindir = Config::CONFIG['sbindir']
239
+ end
254
240
 
255
- if not InstallOptions.mandir.nil?
256
- mandir = InstallOptions.mandir
257
- else
258
- mandir = Config::CONFIG['mandir']
241
+ if not InstallOptions.sitelibdir.nil?
242
+ sitelibdir = InstallOptions.sitelibdir
243
+ else
244
+ sitelibdir = Config::CONFIG["sitelibdir"]
245
+ if sitelibdir.nil?
246
+ sitelibdir = $:.find { |x| x =~ /site_ruby/ }
247
+ if sitelibdir.nil?
248
+ sitelibdir = File.join(libdir, "site_ruby")
249
+ elsif sitelibdir !~ Regexp.quote(version)
250
+ sitelibdir = File.join(sitelibdir, version)
251
+ end
259
252
  end
253
+ end
260
254
 
261
- # To be deprecated once people move over to using --destdir option
262
- if (destdir = ENV['DESTDIR'])
263
- warn "DESTDIR is deprecated. Use --destdir instead."
264
- bindir = join(destdir, bindir)
265
- sbindir = join(destdir, sbindir)
266
- mandir = join(destdir, mandir)
267
- sitelibdir = join(destdir, sitelibdir)
268
-
269
- FileUtils.makedirs(bindir)
270
- FileUtils.makedirs(sbindir)
271
- FileUtils.makedirs(mandir)
272
- FileUtils.makedirs(sitelibdir)
273
- # This is the new way forward
274
- elsif (destdir = InstallOptions.destdir)
275
- bindir = join(destdir, bindir)
276
- sbindir = join(destdir, sbindir)
277
- mandir = join(destdir, mandir)
278
- sitelibdir = join(destdir, sitelibdir)
279
-
280
- FileUtils.makedirs(bindir)
281
- FileUtils.makedirs(sbindir)
282
- FileUtils.makedirs(mandir)
283
- FileUtils.makedirs(sitelibdir)
284
- end
255
+ if not InstallOptions.mandir.nil?
256
+ mandir = InstallOptions.mandir
257
+ else
258
+ mandir = Config::CONFIG['mandir']
259
+ end
260
+
261
+ # To be deprecated once people move over to using --destdir option
262
+ if (destdir = ENV['DESTDIR'])
263
+ warn "DESTDIR is deprecated. Use --destdir instead."
264
+ bindir = join(destdir, bindir)
265
+ sbindir = join(destdir, sbindir)
266
+ mandir = join(destdir, mandir)
267
+ sitelibdir = join(destdir, sitelibdir)
268
+
269
+ FileUtils.makedirs(bindir)
270
+ FileUtils.makedirs(sbindir)
271
+ FileUtils.makedirs(mandir)
272
+ FileUtils.makedirs(sitelibdir)
273
+ # This is the new way forward
274
+ elsif (destdir = InstallOptions.destdir)
275
+ bindir = join(destdir, bindir)
276
+ sbindir = join(destdir, sbindir)
277
+ mandir = join(destdir, mandir)
278
+ sitelibdir = join(destdir, sitelibdir)
279
+
280
+ FileUtils.makedirs(bindir)
281
+ FileUtils.makedirs(sbindir)
282
+ FileUtils.makedirs(mandir)
283
+ FileUtils.makedirs(sitelibdir)
284
+ end
285
285
 
286
- tmpdirs << bindir
286
+ tmpdirs << bindir
287
287
 
288
- InstallOptions.tmp_dirs = tmpdirs.compact
289
- InstallOptions.site_dir = sitelibdir
290
- InstallOptions.bin_dir = bindir
291
- InstallOptions.sbin_dir = sbindir
292
- InstallOptions.lib_dir = libdir
293
- InstallOptions.man_dir = mandir
288
+ InstallOptions.tmp_dirs = tmpdirs.compact
289
+ InstallOptions.site_dir = sitelibdir
290
+ InstallOptions.bin_dir = bindir
291
+ InstallOptions.sbin_dir = sbindir
292
+ InstallOptions.lib_dir = libdir
293
+ InstallOptions.man_dir = mandir
294
294
  end
295
295
 
296
296
  ##
@@ -307,69 +307,69 @@ end
307
307
  # Build the rdoc documentation. Also, try to build the RI documentation.
308
308
  #
309
309
  def build_rdoc(files)
310
- return unless $haverdoc
311
- begin
312
- r = RDoc::RDoc.new
313
- r.document(["--main", "README", "--title",
314
- "Puppet -- Site Configuration Management", "--line-numbers"] + files)
315
- rescue RDoc::RDocError => e
316
- $stderr.puts e.message
317
- rescue Exception => e
318
- $stderr.puts "Couldn't build RDoc documentation\n#{e.message}"
319
- end
310
+ return unless $haverdoc
311
+ begin
312
+ r = RDoc::RDoc.new
313
+ r.document(["--main", "README", "--title",
314
+ "Puppet -- Site Configuration Management", "--line-numbers"] + files)
315
+ rescue RDoc::RDocError => e
316
+ $stderr.puts e.message
317
+ rescue Exception => e
318
+ $stderr.puts "Couldn't build RDoc documentation\n#{e.message}"
319
+ end
320
320
  end
321
321
 
322
322
  def build_ri(files)
323
- return unless $haverdoc
324
- begin
325
- ri = RDoc::RDoc.new
326
- #ri.document(["--ri-site", "--merge"] + files)
327
- ri.document(["--ri-site"] + files)
328
- rescue RDoc::RDocError => e
329
- $stderr.puts e.message
330
- rescue Exception => e
331
- $stderr.puts "Couldn't build Ri documentation\n#{e.message}"
332
- $stderr.puts "Continuing with install..."
333
- end
323
+ return unless $haverdoc
324
+ begin
325
+ ri = RDoc::RDoc.new
326
+ #ri.document(["--ri-site", "--merge"] + files)
327
+ ri.document(["--ri-site"] + files)
328
+ rescue RDoc::RDocError => e
329
+ $stderr.puts e.message
330
+ rescue Exception => e
331
+ $stderr.puts "Couldn't build Ri documentation\n#{e.message}"
332
+ $stderr.puts "Continuing with install..."
333
+ end
334
334
  end
335
335
 
336
336
  def build_man(bins)
337
- return unless $haveman
338
- begin
339
- # Locate rst2man
340
- rst2man = %x{which rst2man.py}
341
- rst2man.chomp!
342
- bins.each do |bin|
343
- b = bin.gsub( "bin/", "")
344
- %x{#{bin} --help > ./#{b}.rst}
345
- %x{#{rst2man} ./#{b}.rst ./man/man8/#{b}.8}
346
- File.unlink("./#{b}.rst")
347
- end
348
- rescue SystemCallError
349
- $stderr.puts "Couldn't build man pages: " + $!
350
- $stderr.puts "Continuing with install..."
337
+ return unless $haveman
338
+ begin
339
+ # Locate rst2man
340
+ rst2man = %x{which rst2man.py}
341
+ rst2man.chomp!
342
+ bins.each do |bin|
343
+ b = bin.gsub( "bin/", "")
344
+ %x{#{bin} --help > ./#{b}.rst}
345
+ %x{#{rst2man} ./#{b}.rst ./man/man8/#{b}.8}
346
+ File.unlink("./#{b}.rst")
351
347
  end
348
+ rescue SystemCallError
349
+ $stderr.puts "Couldn't build man pages: " + $!
350
+ $stderr.puts "Continuing with install..."
351
+ end
352
352
  end
353
353
 
354
354
  def run_tests(test_list)
355
- begin
356
- require 'test/unit/ui/console/testrunner'
357
- $:.unshift "lib"
358
- test_list.each do |test|
359
- next if File.directory?(test)
360
- require test
361
- end
362
-
363
- tests = []
364
- ObjectSpace.each_object { |o| tests << o if o.kind_of?(Class) }
365
- tests.delete_if { |o| !o.ancestors.include?(Test::Unit::TestCase) }
366
- tests.delete_if { |o| o == Test::Unit::TestCase }
367
-
368
- tests.each { |test| Test::Unit::UI::Console::TestRunner.run(test) }
369
- $:.shift
370
- rescue LoadError
371
- puts "Missing testrunner library; skipping tests"
355
+ begin
356
+ require 'test/unit/ui/console/testrunner'
357
+ $:.unshift "lib"
358
+ test_list.each do |test|
359
+ next if File.directory?(test)
360
+ require test
372
361
  end
362
+
363
+ tests = []
364
+ ObjectSpace.each_object { |o| tests << o if o.kind_of?(Class) }
365
+ tests.delete_if { |o| !o.ancestors.include?(Test::Unit::TestCase) }
366
+ tests.delete_if { |o| o == Test::Unit::TestCase }
367
+
368
+ tests.each { |test| Test::Unit::UI::Console::TestRunner.run(test) }
369
+ $:.shift
370
+ rescue LoadError
371
+ puts "Missing testrunner library; skipping tests"
372
+ end
373
373
  end
374
374
 
375
375
  ##
@@ -378,57 +378,57 @@ end
378
378
  # (e.g., bin/rdoc becomes rdoc); the shebang line handles running it. Under
379
379
  # windows, we add an '.rb' extension and let file associations do their stuff.
380
380
  def install_binfile(from, op_file, target)
381
- tmp_dir = nil
382
- InstallOptions.tmp_dirs.each do |t|
383
- if File.directory?(t) and File.writable?(t)
384
- tmp_dir = t
385
- break
386
- end
381
+ tmp_dir = nil
382
+ InstallOptions.tmp_dirs.each do |t|
383
+ if File.directory?(t) and File.writable?(t)
384
+ tmp_dir = t
385
+ break
387
386
  end
387
+ end
388
388
 
389
- fail "Cannot find a temporary directory" unless tmp_dir
390
- tmp_file = File.join(tmp_dir, '_tmp')
391
- ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
392
-
393
- File.open(from) do |ip|
394
- File.open(tmp_file, "w") do |op|
395
- ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
396
- op.puts "#!#{ruby}"
397
- contents = ip.readlines
398
- if contents[0] =~ /^#!/
399
- contents.shift
400
- end
401
- op.write contents.join()
402
- end
389
+ fail "Cannot find a temporary directory" unless tmp_dir
390
+ tmp_file = File.join(tmp_dir, '_tmp')
391
+ ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
392
+
393
+ File.open(from) do |ip|
394
+ File.open(tmp_file, "w") do |op|
395
+ ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
396
+ op.puts "#!#{ruby}"
397
+ contents = ip.readlines
398
+ if contents[0] =~ /^#!/
399
+ contents.shift
400
+ end
401
+ op.write contents.join()
403
402
  end
403
+ end
404
404
 
405
- if is_windows?
406
- installed_wrapper = false
405
+ if is_windows?
406
+ installed_wrapper = false
407
407
 
408
- if File.exists?("#{from}.bat")
409
- FileUtils.install("#{from}.bat", File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
410
- installed_wrapper = true
411
- end
408
+ if File.exists?("#{from}.bat")
409
+ FileUtils.install("#{from}.bat", File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
410
+ installed_wrapper = true
411
+ end
412
412
 
413
- if File.exists?("#{from}.cmd")
414
- FileUtils.install("#{from}.cmd", File.join(target, "#{op_file}.cmd"), :mode => 0755, :verbose => true)
415
- installed_wrapper = true
416
- end
413
+ if File.exists?("#{from}.cmd")
414
+ FileUtils.install("#{from}.cmd", File.join(target, "#{op_file}.cmd"), :mode => 0755, :verbose => true)
415
+ installed_wrapper = true
416
+ end
417
417
 
418
- if not installed_wrapper
419
- tmp_file2 = File.join(tmp_dir, '_tmp_wrapper')
420
- cwn = File.join(Config::CONFIG['bindir'], op_file)
421
- cwv = CMD_WRAPPER.gsub('<ruby>', ruby.gsub(%r{/}) { "\\" }).gsub!('<command>', cwn.gsub(%r{/}) { "\\" } )
418
+ if not installed_wrapper
419
+ tmp_file2 = File.join(tmp_dir, '_tmp_wrapper')
420
+ cwn = File.join(Config::CONFIG['bindir'], op_file)
421
+ cwv = CMD_WRAPPER.gsub('<ruby>', ruby.gsub(%r{/}) { "\\" }).gsub!('<command>', cwn.gsub(%r{/}) { "\\" } )
422
422
 
423
- File.open(tmp_file2, "wb") { |cw| cw.puts cwv }
424
- FileUtils.install(tmp_file2, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
423
+ File.open(tmp_file2, "wb") { |cw| cw.puts cwv }
424
+ FileUtils.install(tmp_file2, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
425
425
 
426
- File.unlink(tmp_file2)
427
- installed_wrapper = true
428
- end
426
+ File.unlink(tmp_file2)
427
+ installed_wrapper = true
429
428
  end
430
- FileUtils.install(tmp_file, File.join(target, op_file), :mode => 0755, :verbose => true)
431
- File.unlink(tmp_file)
429
+ end
430
+ FileUtils.install(tmp_file, File.join(target, op_file), :mode => 0755, :verbose => true)
431
+ File.unlink(tmp_file)
432
432
  end
433
433
 
434
434
  CMD_WRAPPER = <<-EOS