facter 1.5.4 → 1.5.5
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.
- data/CHANGELOG +75 -22
- data/COPYING +289 -623
- data/Rakefile +60 -55
- data/bin/facter +39 -26
- data/conf/osx/PackageInfo.plist +30 -30
- data/conf/osx/createpackage.sh +17 -17
- data/conf/osx/preflight +1 -1
- data/install.rb +226 -226
- data/lib/facter.rb +12 -12
- data/lib/facter/architecture.rb +14 -3
- data/lib/facter/ec2.rb +35 -0
- data/lib/facter/hardwareisa.rb +1 -1
- data/lib/facter/id.rb +1 -1
- data/lib/facter/ipaddress.rb +41 -41
- data/lib/facter/kernel.rb +2 -2
- data/lib/facter/kernelmajversion.rb +5 -0
- data/lib/facter/lsb.rb +5 -5
- data/lib/facter/lsbmajdistrelease.rb +1 -1
- data/lib/facter/macaddress.rb +6 -6
- data/lib/facter/manufacturer.rb +8 -8
- data/lib/facter/memory.rb +5 -4
- data/lib/facter/netmask.rb +4 -4
- data/lib/facter/network.rb +4 -5
- data/lib/facter/operatingsystem.rb +13 -7
- data/lib/facter/operatingsystemrelease.rb +5 -5
- data/lib/facter/selinux.rb +45 -0
- data/lib/facter/timezone.rb +1 -1
- data/lib/facter/uniqueid.rb +2 -2
- data/lib/facter/uptime.rb +3 -3
- data/lib/facter/util/confine.rb +12 -12
- data/lib/facter/util/ip.rb +18 -22
- data/lib/facter/util/macosx.rb +5 -0
- data/lib/facter/util/manufacturer.rb +37 -37
- data/lib/facter/util/plist/generator.rb +181 -179
- data/lib/facter/util/plist/parser.rb +162 -163
- data/lib/facter/util/resolution.rb +2 -2
- data/lib/facter/util/uptime.rb +10 -12
- data/lib/facter/util/values.rb +14 -0
- data/lib/facter/virtual.rb +54 -34
- data/spec/unit/data/darwin_ifconfig_all_with_multiple_interfaces +10 -0
- data/spec/unit/operatingsystem.rb +36 -0
- data/spec/unit/selinux.rb +48 -0
- data/spec/unit/util/confine.rb +70 -5
- data/spec/unit/util/ip.rb +29 -3
- metadata +89 -77
- data/documentation/custom.page +0 -22
- data/documentation/index.page +0 -19
data/Rakefile
CHANGED
@@ -1,70 +1,75 @@
|
|
1
1
|
# Rakefile for facter
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
$: << File.expand_path('lib')
|
4
|
+
|
5
|
+
require './lib/facter.rb'
|
6
|
+
require 'rake'
|
7
|
+
require 'rake/packagetask'
|
8
|
+
require 'rake/gempackagetask'
|
9
|
+
|
10
|
+
FILES = FileList[
|
11
|
+
'[A-Z]*',
|
12
|
+
'install.rb',
|
13
|
+
'bin/**/*',
|
14
|
+
'lib/**/*',
|
15
|
+
'conf/**/*',
|
16
|
+
'etc/**/*',
|
17
|
+
'spec/**/*'
|
18
|
+
]
|
19
|
+
|
20
|
+
spec = Gem::Specification.new do |spec|
|
21
|
+
spec.platform = Gem::Platform::RUBY
|
22
|
+
spec.name = 'facter'
|
23
|
+
spec.files = FILES.to_a
|
24
|
+
spec.version = Facter::FACTERVERSION
|
25
|
+
spec.summary = 'Facter, a system inventory tool'
|
26
|
+
spec.author = 'Reductive Labs'
|
27
|
+
spec.email = 'puppet@reductivelabs.com'
|
28
|
+
spec.homepage = 'http://reductivelabs.com'
|
29
|
+
spec.rubyforge_project = 'facter'
|
30
|
+
spec.has_rdoc = true
|
31
|
+
spec.rdoc_options <<
|
32
|
+
'--title' << 'Facter - System Inventory Tool' <<
|
33
|
+
'--main' << 'README' <<
|
34
|
+
'--line-numbers'
|
10
35
|
end
|
11
36
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
Operating system.
|
17
|
-
EOF
|
18
|
-
|
19
|
-
p.filelist = [
|
20
|
-
'install.rb',
|
21
|
-
'[A-Z]*',
|
22
|
-
'bin/**/*',
|
23
|
-
'lib/facter.rb',
|
24
|
-
'lib/**/*.rb',
|
25
|
-
'test/**/*.rb',
|
26
|
-
'spec/**/*',
|
27
|
-
'conf/**/*',
|
28
|
-
'documentation/**/*',
|
29
|
-
'etc/*'
|
30
|
-
]
|
31
|
-
|
37
|
+
Rake::PackageTask.new("facter", Facter::FACTERVERSION) do |pkg|
|
38
|
+
pkg.package_dir = 'pkg'
|
39
|
+
pkg.need_tar_gz = true
|
40
|
+
pkg.package_files = FILES.to_a
|
32
41
|
end
|
33
42
|
|
34
|
-
|
35
|
-
gem.require_path = 'lib' # Use these for libraries.
|
36
|
-
|
37
|
-
gem.bindir = "bin" # Use these for applications.
|
38
|
-
gem.executables = ["facter"]
|
39
|
-
gem.default_executable = "facter"
|
40
|
-
|
41
|
-
gem.author = "Luke Kanies"
|
43
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
42
44
|
end
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
desc "Run the specs under spec/"
|
47
|
+
task :spec do
|
48
|
+
require 'spec'
|
49
|
+
require 'spec/rake/spectask'
|
50
|
+
# require 'rcov'
|
51
|
+
Spec::Rake::SpecTask.new do |t|
|
52
|
+
t.spec_opts = ['--format','s', '--loadby','mtime']
|
53
|
+
t.spec_files = FileList['spec/**/*.rb']
|
54
|
+
end
|
48
55
|
end
|
49
56
|
|
50
|
-
|
51
|
-
|
52
|
-
desc "Run the CI prep tasks"
|
53
|
-
task :prep do
|
57
|
+
desc "Prep CI RSpec tests"
|
58
|
+
task :ci_prep do
|
54
59
|
require 'rubygems'
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
sh "cd spec; rake all; exit 0"
|
64
|
-
end
|
65
|
-
|
60
|
+
begin
|
61
|
+
gem 'ci_reporter'
|
62
|
+
require 'ci/reporter/rake/rspec'
|
63
|
+
require 'ci/reporter/rake/test_unit'
|
64
|
+
ENV['CI_REPORTS'] = 'results'
|
65
|
+
rescue LoadError
|
66
|
+
puts 'Missing ci_reporter gem. You must have the ci_reporter gem installed to run the CI spec tests'
|
67
|
+
end
|
66
68
|
end
|
67
69
|
|
70
|
+
desc "Run the CI RSpec tests"
|
71
|
+
task :ci_spec => [:ci_prep, 'ci:setup:rpsec', :spec]
|
72
|
+
|
68
73
|
desc "Send patch information to the puppet-dev list"
|
69
74
|
task :mail_patches do
|
70
75
|
if Dir.glob("00*.patch").length > 0
|
@@ -75,7 +80,7 @@ task :mail_patches do
|
|
75
80
|
raise "Could not get branch from 'git status'"
|
76
81
|
end
|
77
82
|
branch = $1
|
78
|
-
|
83
|
+
|
79
84
|
unless branch =~ %r{^([^\/]+)/([^\/]+)/([^\/]+)$}
|
80
85
|
raise "Branch name does not follow <type>/<parent>/<name> model; cannot autodetect parent branch"
|
81
86
|
end
|
data/bin/facter
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
#
|
3
3
|
# = Synopsis
|
4
4
|
#
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# about a system from within the shell or within Ruby.
|
16
16
|
#
|
17
17
|
# If no facts are specifically asked for, then all facts will be returned.
|
18
|
-
#
|
18
|
+
#
|
19
19
|
# = Options
|
20
20
|
#
|
21
21
|
# debug::
|
@@ -58,39 +58,52 @@ rescue Exception
|
|
58
58
|
$haveusage = false
|
59
59
|
end
|
60
60
|
|
61
|
+
def load_puppet
|
62
|
+
require 'puppet'
|
63
|
+
Puppet.parse_config
|
64
|
+
|
65
|
+
# If you've set 'vardir' but not 'libdir' in your
|
66
|
+
# puppet.conf, then the hook to add libdir to $:
|
67
|
+
# won't get triggered. This makes sure that it's setup
|
68
|
+
# correctly.
|
69
|
+
unless $LOAD_PATH.include?(Puppet[:libdir])
|
70
|
+
$LOAD_PATH << Puppet[:libdir]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
61
74
|
$debug = 0
|
62
75
|
|
63
76
|
config = nil
|
64
77
|
|
65
78
|
result = GetoptLong.new(
|
66
|
-
[ "--version",
|
67
|
-
[ "--help",
|
68
|
-
[ "--debug",
|
69
|
-
[ "--yaml",
|
70
|
-
[ "--config",
|
71
|
-
[ "--puppet",
|
79
|
+
[ "--version", "-v", GetoptLong::NO_ARGUMENT ],
|
80
|
+
[ "--help", "-h", GetoptLong::NO_ARGUMENT ],
|
81
|
+
[ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
|
82
|
+
[ "--yaml", "-y", GetoptLong::NO_ARGUMENT ],
|
83
|
+
[ "--config", "-c", GetoptLong::REQUIRED_ARGUMENT ],
|
84
|
+
[ "--puppet", "-p", GetoptLong::NO_ARGUMENT ]
|
72
85
|
)
|
73
86
|
|
74
87
|
options = {
|
75
88
|
:yaml => false
|
76
89
|
}
|
77
90
|
|
78
|
-
begin
|
79
|
-
|
80
|
-
|
91
|
+
begin
|
92
|
+
result.each { |opt,arg|
|
93
|
+
case opt
|
81
94
|
when "--version"
|
82
|
-
|
83
|
-
|
95
|
+
puts "%s" % Facter.version
|
96
|
+
exit
|
84
97
|
when "--puppet"
|
85
|
-
|
86
|
-
|
98
|
+
begin
|
99
|
+
load_puppet()
|
87
100
|
rescue LoadError => detail
|
88
101
|
$stderr.puts "Could not load Puppet: %s" % detail
|
89
102
|
end
|
90
103
|
when "--yaml"
|
91
|
-
|
104
|
+
options[:yaml] = true
|
92
105
|
when "--debug"
|
93
|
-
|
106
|
+
Facter.debugging(1)
|
94
107
|
when "--help"
|
95
108
|
if $haveusage
|
96
109
|
RDoc::usage && exit
|
@@ -101,24 +114,24 @@ begin
|
|
101
114
|
else
|
102
115
|
$stderr.puts "Invalid option '#{opt}'"
|
103
116
|
exit(12)
|
104
|
-
|
105
|
-
|
117
|
+
end
|
118
|
+
}
|
106
119
|
rescue
|
107
|
-
|
120
|
+
exit(12)
|
108
121
|
end
|
109
122
|
|
110
123
|
names = []
|
111
124
|
|
112
125
|
unless config.nil?
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
126
|
+
File.open(config) { |file|
|
127
|
+
names = file.readlines.collect { |line|
|
128
|
+
line.chomp
|
129
|
+
}
|
130
|
+
}
|
118
131
|
end
|
119
132
|
|
120
133
|
ARGV.each { |item|
|
121
|
-
|
134
|
+
names.push item
|
122
135
|
}
|
123
136
|
|
124
137
|
if names.empty?
|
data/conf/osx/PackageInfo.plist
CHANGED
@@ -2,35 +2,35 @@
|
|
2
2
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
3
|
<plist version="1.0">
|
4
4
|
<dict>
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
5
|
+
<key>CFBundleIdentifier</key>
|
6
|
+
<string>com.reductivelabs.facter</string>
|
7
|
+
<key>CFBundleShortVersionString</key>
|
8
|
+
<string>{SHORTVERSION}</string>
|
9
|
+
<key>IFMajorVersion</key>
|
10
|
+
<integer>{MAJORVERSION}</integer>
|
11
|
+
<key>IFMinorVersion</key>
|
12
|
+
<integer>{MINORVERSION}</integer>
|
13
|
+
<key>IFPkgFlagAllowBackRev</key>
|
14
|
+
<false/>
|
15
|
+
<key>IFPkgFlagAuthorizationAction</key>
|
16
|
+
<string>RootAuthorization</string>
|
17
|
+
<key>IFPkgFlagDefaultLocation</key>
|
18
|
+
<string>/</string>
|
19
|
+
<key>IFPkgFlagFollowLinks</key>
|
20
|
+
<true/>
|
21
|
+
<key>IFPkgFlagInstallFat</key>
|
22
|
+
<false/>
|
23
|
+
<key>IFPkgFlagIsRequired</key>
|
24
|
+
<false/>
|
25
|
+
<key>IFPkgFlagOverwritePermissions</key>
|
26
|
+
<false/>
|
27
|
+
<key>IFPkgFlagRelocatable</key>
|
28
|
+
<false/>
|
29
|
+
<key>IFPkgFlagRestartAction</key>
|
30
|
+
<string>None</string>
|
31
|
+
<key>IFPkgFlagRootVolumeOnly</key>
|
32
|
+
<true/>
|
33
|
+
<key>IFPkgFlagUpdateInstalledLanguages</key>
|
34
|
+
<false/>
|
35
35
|
</dict>
|
36
36
|
</plist>
|
data/conf/osx/createpackage.sh
CHANGED
@@ -7,13 +7,13 @@
|
|
7
7
|
# Last Updated: 2008-07-31
|
8
8
|
#
|
9
9
|
# Copyright 2008 Google Inc.
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
12
12
|
# you may not use this file except in compliance with the License.
|
13
13
|
# You may obtain a copy of the License at
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# http://www.apache.org/licenses/LICENSE-2.0
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# Unless required by applicable law or agreed to in writing, software
|
18
18
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
19
19
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -30,7 +30,7 @@ PREFLIGHT="preflight"
|
|
30
30
|
|
31
31
|
|
32
32
|
function find_installer() {
|
33
|
-
# we walk up three directories to make this executable from the root,
|
33
|
+
# we walk up three directories to make this executable from the root,
|
34
34
|
# root/conf or root/conf/osx
|
35
35
|
if [ -f "./${INSTALLRB}" ]; then
|
36
36
|
installer="$(pwd)/${INSTALLRB}"
|
@@ -64,7 +64,7 @@ function prepare_package() {
|
|
64
64
|
# to look at for package creation and substitue the version strings out.
|
65
65
|
# Major/Minor versions can only be integers, so we have "1" and "50" for
|
66
66
|
# facter version 1.5
|
67
|
-
# Note too that for 10.5 compatibility this Info.plist *must* be set to
|
67
|
+
# Note too that for 10.5 compatibility this Info.plist *must* be set to
|
68
68
|
# follow symlinks.
|
69
69
|
VER1=$(echo ${facter_version} | awk -F "." '{print $1}')
|
70
70
|
VER2=$(echo ${facter_version} | awk -F "." '{print $2}')
|
@@ -75,12 +75,12 @@ function prepare_package() {
|
|
75
75
|
sed -i '' "s/{SHORTVERSION}/${facter_version}/g" "${pkgtemp}/${PROTO_PLIST}"
|
76
76
|
sed -i '' "s/{MAJORVERSION}/${major_version}/g" "${pkgtemp}/${PROTO_PLIST}"
|
77
77
|
sed -i '' "s/{MINORVERSION}/${minor_version}/g" "${pkgtemp}/${PROTO_PLIST}"
|
78
|
-
|
78
|
+
|
79
79
|
# We need to create a preflight script to remove traces of previous
|
80
80
|
# facter installs due to limitations in Apple's pkg format.
|
81
81
|
mkdir "${pkgtemp}/scripts"
|
82
82
|
cp "${facter_root}/conf/osx/${PREFLIGHT}" "${pkgtemp}/scripts"
|
83
|
-
|
83
|
+
|
84
84
|
# substitute in the sitelibdir specified above on the assumption that this
|
85
85
|
# is where any previous facter install exists that should be cleaned out.
|
86
86
|
sed -i '' "s|{SITELIBDIR}|${SITELIBDIR}|g" "${pkgtemp}/scripts/${PREFLIGHT}"
|
@@ -124,44 +124,44 @@ function main() {
|
|
124
124
|
fi
|
125
125
|
|
126
126
|
find_installer
|
127
|
-
|
127
|
+
|
128
128
|
if [ ! "${installer}" ]; then
|
129
129
|
echo "Unable to find ${INSTALLRB}"
|
130
130
|
cleanup_and_exit 1
|
131
131
|
fi
|
132
132
|
|
133
133
|
find_facter_root
|
134
|
-
|
134
|
+
|
135
135
|
if [ ! "${facter_root}" ]; then
|
136
136
|
echo "Unable to find facter repository root."
|
137
137
|
cleanup_and_exit 1
|
138
138
|
fi
|
139
|
-
|
139
|
+
|
140
140
|
pkgroot=$(mktemp -d -t facterpkg)
|
141
|
-
|
141
|
+
|
142
142
|
if [ ! "${pkgroot}" ]; then
|
143
143
|
echo "Unable to create temporary package root."
|
144
144
|
cleanup_and_exit 1
|
145
145
|
fi
|
146
|
-
|
146
|
+
|
147
147
|
pkgtemp=$(mktemp -d -t factertmp)
|
148
|
-
|
148
|
+
|
149
149
|
if [ ! "${pkgtemp}" ]; then
|
150
150
|
echo "Unable to create temporary package root."
|
151
151
|
cleanup_and_exit 1
|
152
152
|
fi
|
153
|
-
|
153
|
+
|
154
154
|
install_facter
|
155
155
|
get_facter_version
|
156
|
-
|
156
|
+
|
157
157
|
if [ ! "${facter_version}" ]; then
|
158
158
|
echo "Unable to retrieve facter version"
|
159
159
|
cleanup_and_exit 1
|
160
160
|
fi
|
161
|
-
|
161
|
+
|
162
162
|
prepare_package
|
163
163
|
create_package
|
164
|
-
|
164
|
+
|
165
165
|
cleanup_and_exit 0
|
166
166
|
}
|
167
167
|
|
data/conf/osx/preflight
CHANGED
data/install.rb
CHANGED
@@ -81,33 +81,33 @@ libs = glob(%w{lib/**/*.rb lib/**/*.py})
|
|
81
81
|
tests = glob(%w{tests/**/*.rb})
|
82
82
|
|
83
83
|
def do_bins(bins, target, strip = 's?bin/')
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
84
|
+
bins.each do |bf|
|
85
|
+
obf = bf.gsub(/#{strip}/, '')
|
86
|
+
install_binfile(bf, obf, target)
|
87
|
+
end
|
88
88
|
end
|
89
89
|
|
90
90
|
def do_libs(libs, strip = 'lib/')
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
91
|
+
libs.each do |lf|
|
92
|
+
olf = File.join(InstallOptions.site_dir, lf.gsub(/#{strip}/, ''))
|
93
|
+
op = File.dirname(olf)
|
94
|
+
File.makedirs(op, true)
|
95
|
+
File.chmod(0755, op)
|
96
|
+
File.install(lf, olf, 0644, true)
|
97
|
+
end
|
98
98
|
end
|
99
99
|
|
100
100
|
def do_man(man, strip = 'man/')
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
101
|
+
man.each do |mf|
|
102
|
+
omf = File.join(InstallOptions.man_dir, mf.gsub(/#{strip}/, ''))
|
103
|
+
om = File.dirname(omf)
|
104
|
+
File.makedirs(om, true)
|
105
|
+
File.chmod(0644, om)
|
106
|
+
File.install(mf, omf, 0644, true)
|
107
|
+
gzip = %x{which gzip}
|
108
|
+
gzip.chomp!
|
109
|
+
%x{#{gzip} -f #{omf}}
|
110
|
+
end
|
111
111
|
end
|
112
112
|
|
113
113
|
# Verify that all of the prereqs are installed
|
@@ -126,158 +126,158 @@ end
|
|
126
126
|
# Prepare the file installation.
|
127
127
|
#
|
128
128
|
def prepare_installation
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
129
|
+
# Only try to do docs if we're sure they have rdoc
|
130
|
+
if $haverdoc
|
131
|
+
InstallOptions.rdoc = true
|
132
|
+
if RUBY_PLATFORM == "i386-mswin32"
|
133
|
+
InstallOptions.ri = false
|
134
|
+
else
|
135
|
+
InstallOptions.ri = true
|
136
|
+
end
|
137
|
+
else
|
138
|
+
InstallOptions.rdoc = false
|
133
139
|
InstallOptions.ri = false
|
134
|
-
else
|
135
|
-
InstallOptions.ri = true
|
136
|
-
end
|
137
|
-
else
|
138
|
-
InstallOptions.rdoc = false
|
139
|
-
InstallOptions.ri = false
|
140
|
-
end
|
141
|
-
|
142
|
-
|
143
|
-
if $haveman
|
144
|
-
InstallOptions.man = true
|
145
|
-
if RUBY_PLATFORM == "i386-mswin32"
|
146
|
-
InstallOptions.man = false
|
147
|
-
end
|
148
|
-
else
|
149
|
-
InstallOptions.man = false
|
150
|
-
end
|
151
|
-
|
152
|
-
InstallOptions.tests = true
|
153
|
-
|
154
|
-
ARGV.options do |opts|
|
155
|
-
opts.banner = "Usage: #{File.basename($0)} [options]"
|
156
|
-
opts.separator ""
|
157
|
-
opts.on('--[no-]rdoc', 'Prevents the creation of RDoc output.', 'Default on.') do |onrdoc|
|
158
|
-
InstallOptions.rdoc = onrdoc
|
159
|
-
end
|
160
|
-
opts.on('--[no-]ri', 'Prevents the creation of RI output.', 'Default off on mswin32.') do |onri|
|
161
|
-
InstallOptions.ri = onri
|
162
140
|
end
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides Config::CONFIG["bindir"]') do |bindir|
|
173
|
-
InstallOptions.bindir = bindir
|
141
|
+
|
142
|
+
|
143
|
+
if $haveman
|
144
|
+
InstallOptions.man = true
|
145
|
+
if RUBY_PLATFORM == "i386-mswin32"
|
146
|
+
InstallOptions.man = false
|
147
|
+
end
|
148
|
+
else
|
149
|
+
InstallOptions.man = false
|
174
150
|
end
|
175
|
-
|
176
|
-
|
151
|
+
|
152
|
+
InstallOptions.tests = true
|
153
|
+
|
154
|
+
ARGV.options do |opts|
|
155
|
+
opts.banner = "Usage: #{File.basename($0)} [options]"
|
156
|
+
opts.separator ""
|
157
|
+
opts.on('--[no-]rdoc', 'Prevents the creation of RDoc output.', 'Default on.') do |onrdoc|
|
158
|
+
InstallOptions.rdoc = onrdoc
|
159
|
+
end
|
160
|
+
opts.on('--[no-]ri', 'Prevents the creation of RI output.', 'Default off on mswin32.') do |onri|
|
161
|
+
InstallOptions.ri = onri
|
162
|
+
end
|
163
|
+
opts.on('--[no-]man', 'Presents the creation of man pages.', 'Default on.') do |onman|
|
164
|
+
InstallOptions.man = onman
|
165
|
+
end
|
166
|
+
opts.on('--[no-]tests', 'Prevents the execution of unit tests.', 'Default on.') do |ontest|
|
167
|
+
InstallOptions.tests = ontest
|
168
|
+
end
|
169
|
+
opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir|
|
170
|
+
InstallOptions.destdir = destdir
|
171
|
+
end
|
172
|
+
opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides Config::CONFIG["bindir"]') do |bindir|
|
173
|
+
InstallOptions.bindir = bindir
|
174
|
+
end
|
175
|
+
opts.on('--sbindir[=OPTIONAL]', 'Installation directory for system binaries', 'overrides Config::CONFIG["sbindir"]') do |sbindir|
|
176
|
+
InstallOptions.sbindir = sbindir
|
177
|
+
end
|
178
|
+
opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides Config::CONFIG["sitelibdir"]') do |sitelibdir|
|
179
|
+
InstallOptions.sitelibdir = sitelibdir
|
180
|
+
end
|
181
|
+
opts.on('--mandir[=OPTIONAL]', 'Installation directory for man pages', 'overrides Config::CONFIG["mandir"]') do |mandir|
|
182
|
+
InstallOptions.mandir = mandir
|
183
|
+
end
|
184
|
+
opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick|
|
185
|
+
InstallOptions.rdoc = false
|
186
|
+
InstallOptions.ri = false
|
187
|
+
InstallOptions.tests = false
|
188
|
+
end
|
189
|
+
opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full|
|
190
|
+
InstallOptions.rdoc = true
|
191
|
+
InstallOptions.ri = true
|
192
|
+
InstallOptions.tests = true
|
193
|
+
end
|
194
|
+
opts.separator("")
|
195
|
+
opts.on_tail('--help', "Shows this help text.") do
|
196
|
+
$stderr.puts opts
|
197
|
+
exit
|
198
|
+
end
|
199
|
+
|
200
|
+
opts.parse!
|
177
201
|
end
|
178
|
-
|
179
|
-
|
202
|
+
|
203
|
+
tmpdirs = [".", ENV['TMP'], ENV['TEMP'], "/tmp", "/var/tmp"]
|
204
|
+
|
205
|
+
version = [Config::CONFIG["MAJOR"], Config::CONFIG["MINOR"]].join(".")
|
206
|
+
libdir = File.join(Config::CONFIG["libdir"], "ruby", version)
|
207
|
+
|
208
|
+
# Mac OS X 10.5 declares bindir and sbindir as
|
209
|
+
# /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin
|
210
|
+
# /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/sbin
|
211
|
+
# which is not generally where people expect executables to be installed
|
212
|
+
if RUBY_PLATFORM == "universal-darwin9.0"
|
213
|
+
Config::CONFIG['bindir'] = "/usr/bin"
|
214
|
+
Config::CONFIG['sbindir'] = "/usr/sbin"
|
180
215
|
end
|
181
|
-
|
182
|
-
|
216
|
+
|
217
|
+
if not InstallOptions.bindir.nil?
|
218
|
+
bindir = InstallOptions.bindir
|
219
|
+
else
|
220
|
+
bindir = Config::CONFIG['bindir']
|
183
221
|
end
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
222
|
+
|
223
|
+
if not InstallOptions.sbindir.nil?
|
224
|
+
sbindir = InstallOptions.sbindir
|
225
|
+
else
|
226
|
+
sbindir = Config::CONFIG['sbindir']
|
188
227
|
end
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
228
|
+
|
229
|
+
if not InstallOptions.sitelibdir.nil?
|
230
|
+
sitelibdir = InstallOptions.sitelibdir
|
231
|
+
else
|
232
|
+
sitelibdir = Config::CONFIG["sitelibdir"]
|
233
|
+
if sitelibdir.nil?
|
234
|
+
sitelibdir = $:.find { |x| x =~ /site_ruby/ }
|
235
|
+
if sitelibdir.nil?
|
236
|
+
sitelibdir = File.join(libdir, "site_ruby")
|
237
|
+
elsif sitelibdir !~ Regexp.quote(version)
|
238
|
+
sitelibdir = File.join(sitelibdir, version)
|
239
|
+
end
|
240
|
+
end
|
193
241
|
end
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
242
|
+
|
243
|
+
if not InstallOptions.mandir.nil?
|
244
|
+
mandir = InstallOptions.mandir
|
245
|
+
else
|
246
|
+
mandir = Config::CONFIG['mandir']
|
198
247
|
end
|
199
248
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
if not InstallOptions.sbindir.nil?
|
224
|
-
sbindir = InstallOptions.sbindir
|
225
|
-
else
|
226
|
-
sbindir = Config::CONFIG['sbindir']
|
227
|
-
end
|
228
|
-
|
229
|
-
if not InstallOptions.sitelibdir.nil?
|
230
|
-
sitelibdir = InstallOptions.sitelibdir
|
231
|
-
else
|
232
|
-
sitelibdir = Config::CONFIG["sitelibdir"]
|
233
|
-
if sitelibdir.nil?
|
234
|
-
sitelibdir = $:.find { |x| x =~ /site_ruby/ }
|
235
|
-
if sitelibdir.nil?
|
236
|
-
sitelibdir = File.join(libdir, "site_ruby")
|
237
|
-
elsif sitelibdir !~ Regexp.quote(version)
|
238
|
-
sitelibdir = File.join(sitelibdir, version)
|
239
|
-
end
|
249
|
+
# To be deprecated once people move over to using --destdir option
|
250
|
+
if (destdir = ENV['DESTDIR'])
|
251
|
+
bindir = "#{destdir}#{bindir}"
|
252
|
+
sbindir = "#{destdir}#{sbindir}"
|
253
|
+
mandir = "#{destdir}#{mandir}"
|
254
|
+
sitelibdir = "#{destdir}#{sitelibdir}"
|
255
|
+
|
256
|
+
FileUtils.makedirs(bindir)
|
257
|
+
FileUtils.makedirs(sbindir)
|
258
|
+
FileUtils.makedirs(mandir)
|
259
|
+
FileUtils.makedirs(sitelibdir)
|
260
|
+
# This is the new way forward
|
261
|
+
elsif (destdir = InstallOptions.destdir)
|
262
|
+
bindir = "#{destdir}#{bindir}"
|
263
|
+
sbindir = "#{destdir}#{sbindir}"
|
264
|
+
mandir = "#{destdir}#{mandir}"
|
265
|
+
sitelibdir = "#{destdir}#{sitelibdir}"
|
266
|
+
|
267
|
+
FileUtils.makedirs(bindir)
|
268
|
+
FileUtils.makedirs(sbindir)
|
269
|
+
FileUtils.makedirs(mandir)
|
270
|
+
FileUtils.makedirs(sitelibdir)
|
240
271
|
end
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
if (destdir = ENV['DESTDIR'])
|
251
|
-
bindir = "#{destdir}#{bindir}"
|
252
|
-
sbindir = "#{destdir}#{sbindir}"
|
253
|
-
mandir = "#{destdir}#{mandir}"
|
254
|
-
sitelibdir = "#{destdir}#{sitelibdir}"
|
255
|
-
|
256
|
-
FileUtils.makedirs(bindir)
|
257
|
-
FileUtils.makedirs(sbindir)
|
258
|
-
FileUtils.makedirs(mandir)
|
259
|
-
FileUtils.makedirs(sitelibdir)
|
260
|
-
# This is the new way forward
|
261
|
-
elsif (destdir = InstallOptions.destdir)
|
262
|
-
bindir = "#{destdir}#{bindir}"
|
263
|
-
sbindir = "#{destdir}#{sbindir}"
|
264
|
-
mandir = "#{destdir}#{mandir}"
|
265
|
-
sitelibdir = "#{destdir}#{sitelibdir}"
|
266
|
-
|
267
|
-
FileUtils.makedirs(bindir)
|
268
|
-
FileUtils.makedirs(sbindir)
|
269
|
-
FileUtils.makedirs(mandir)
|
270
|
-
FileUtils.makedirs(sitelibdir)
|
271
|
-
end
|
272
|
-
|
273
|
-
tmpdirs << bindir
|
274
|
-
|
275
|
-
InstallOptions.tmp_dirs = tmpdirs.compact
|
276
|
-
InstallOptions.site_dir = sitelibdir
|
277
|
-
InstallOptions.bin_dir = bindir
|
278
|
-
InstallOptions.sbin_dir = sbindir
|
279
|
-
InstallOptions.lib_dir = libdir
|
280
|
-
InstallOptions.man_dir = mandir
|
272
|
+
|
273
|
+
tmpdirs << bindir
|
274
|
+
|
275
|
+
InstallOptions.tmp_dirs = tmpdirs.compact
|
276
|
+
InstallOptions.site_dir = sitelibdir
|
277
|
+
InstallOptions.bin_dir = bindir
|
278
|
+
InstallOptions.sbin_dir = sbindir
|
279
|
+
InstallOptions.lib_dir = libdir
|
280
|
+
InstallOptions.man_dir = mandir
|
281
281
|
end
|
282
282
|
|
283
283
|
##
|
@@ -323,10 +323,10 @@ def build_man(bins)
|
|
323
323
|
|
324
324
|
# Create binary man pages
|
325
325
|
bins.each do |bin|
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
326
|
+
b = bin.gsub( "bin/", "")
|
327
|
+
%x{#{bin} --help > ./#{b}.rst}
|
328
|
+
%x{#{rst2man} ./#{b}.rst ./man/man8/#{b}.8}
|
329
|
+
File.unlink("./#{b}.rst")
|
330
330
|
end
|
331
331
|
rescue SystemCallError
|
332
332
|
$stderr.puts "Couldn't build man pages: " + $!
|
@@ -335,24 +335,24 @@ def build_man(bins)
|
|
335
335
|
end
|
336
336
|
|
337
337
|
def run_tests(test_list)
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
338
|
+
begin
|
339
|
+
require 'test/unit/ui/console/testrunner'
|
340
|
+
$:.unshift "lib"
|
341
|
+
test_list.each do |test|
|
342
|
+
next if File.directory?(test)
|
343
|
+
require test
|
344
|
+
end
|
345
|
+
|
346
|
+
tests = []
|
347
|
+
ObjectSpace.each_object { |o| tests << o if o.kind_of?(Class) }
|
348
|
+
tests.delete_if { |o| !o.ancestors.include?(Test::Unit::TestCase) }
|
349
|
+
tests.delete_if { |o| o == Test::Unit::TestCase }
|
350
|
+
|
351
|
+
tests.each { |test| Test::Unit::UI::Console::TestRunner.run(test) }
|
352
|
+
$:.shift
|
353
|
+
rescue LoadError
|
354
|
+
puts "Missing testrunner library; skipping tests"
|
355
|
+
end
|
356
356
|
end
|
357
357
|
|
358
358
|
##
|
@@ -361,57 +361,57 @@ end
|
|
361
361
|
# (e.g., bin/rdoc becomes rdoc); the shebang line handles running it. Under
|
362
362
|
# windows, we add an '.rb' extension and let file associations do their stuff.
|
363
363
|
def install_binfile(from, op_file, target)
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
364
|
+
tmp_dir = nil
|
365
|
+
InstallOptions.tmp_dirs.each do |t|
|
366
|
+
if File.directory?(t) and File.writable?(t)
|
367
|
+
tmp_dir = t
|
368
|
+
break
|
369
|
+
end
|
369
370
|
end
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
371
|
+
|
372
|
+
fail "Cannot find a temporary directory" unless tmp_dir
|
373
|
+
tmp_file = File.join(tmp_dir, '_tmp')
|
374
|
+
ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
375
|
+
|
376
|
+
File.open(from) do |ip|
|
377
|
+
File.open(tmp_file, "w") do |op|
|
378
|
+
ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
379
|
+
op.puts "#!#{ruby}"
|
380
|
+
contents = ip.readlines
|
381
|
+
if contents[0] =~ /^#!/
|
382
|
+
contents.shift
|
383
|
+
end
|
384
|
+
op.write contents.join()
|
385
|
+
end
|
385
386
|
end
|
386
|
-
end
|
387
387
|
|
388
|
-
|
389
|
-
|
388
|
+
if Config::CONFIG["target_os"] =~ /win/io and Config::CONFIG["target_os"] !~ /darwin/io
|
389
|
+
installed_wrapper = false
|
390
390
|
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
391
|
+
if File.exists?("#{from}.bat")
|
392
|
+
FileUtils.install("#{from}.bat", File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
|
393
|
+
installed_wrapper = true
|
394
|
+
end
|
395
395
|
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
396
|
+
if File.exists?("#{from}.cmd")
|
397
|
+
FileUtils.install("#{from}.cmd", File.join(target, "#{op_file}.cmd"), :mode => 0755, :verbose => true)
|
398
|
+
installed_wrapper = true
|
399
|
+
end
|
400
400
|
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
401
|
+
if not installed_wrapper
|
402
|
+
tmp_file2 = File.join(tmp_dir, '_tmp_wrapper')
|
403
|
+
cwn = File.join(Config::CONFIG['bindir'], op_file)
|
404
|
+
cwv = CMD_WRAPPER.gsub('<ruby>', ruby.gsub(%r{/}) { "\\" }).gsub!('<command>', cwn.gsub(%r{/}) { "\\" } )
|
405
405
|
|
406
|
-
|
407
|
-
|
406
|
+
File.open(tmp_file2, "wb") { |cw| cw.puts cwv }
|
407
|
+
FileUtils.install(tmp_file2, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
|
408
408
|
|
409
|
-
|
410
|
-
|
409
|
+
File.unlink(tmp_file2)
|
410
|
+
installed_wrapper = true
|
411
|
+
end
|
411
412
|
end
|
412
|
-
|
413
|
-
|
414
|
-
File.unlink(tmp_file)
|
413
|
+
FileUtils.install(tmp_file, File.join(target, op_file), :mode => 0755, :verbose => true)
|
414
|
+
File.unlink(tmp_file)
|
415
415
|
end
|
416
416
|
|
417
417
|
CMD_WRAPPER = <<-EOS
|