summaryrefslogtreecommitdiffstats
path: root/install.rb
diff options
context:
space:
mode:
authorIan Taylor <ian@lorf.org>2009-02-17 19:22:54 -0500
committerJames Turnbull <james@lovedthanlost.net>2009-02-28 09:35:20 +1100
commitb6f0f9949be9056ea8823b10b86a2b9ea848fad7 (patch)
tree82d396fdaf87423c06dab8f8f9344ad4a80af881 /install.rb
parent9bc174faffcdb412e07e2dde1686cdec9a4d638c (diff)
downloadfacter-b6f0f9949be9056ea8823b10b86a2b9ea848fad7.tar.gz
facter-b6f0f9949be9056ea8823b10b86a2b9ea848fad7.tar.xz
facter-b6f0f9949be9056ea8823b10b86a2b9ea848fad7.zip
more consistent indentation and alignment. also removal of trailing whitespace
Diffstat (limited to 'install.rb')
-rwxr-xr-xinstall.rb452
1 files changed, 226 insertions, 226 deletions
diff --git a/install.rb b/install.rb
index 3e0d810..d38aede 100755
--- a/install.rb
+++ b/install.rb
@@ -81,33 +81,33 @@ libs = glob(%w{lib/**/*.rb lib/**/*.py})
tests = glob(%w{tests/**/*.rb})
def do_bins(bins, target, strip = 's?bin/')
- bins.each do |bf|
- obf = bf.gsub(/#{strip}/, '')
- install_binfile(bf, obf, target)
- end
+ bins.each do |bf|
+ obf = bf.gsub(/#{strip}/, '')
+ install_binfile(bf, obf, target)
+ end
end
def do_libs(libs, strip = 'lib/')
- libs.each do |lf|
- olf = File.join(InstallOptions.site_dir, lf.gsub(/#{strip}/, ''))
- op = File.dirname(olf)
- File.makedirs(op, true)
- File.chmod(0755, op)
- File.install(lf, olf, 0755, true)
- end
+ libs.each do |lf|
+ olf = File.join(InstallOptions.site_dir, lf.gsub(/#{strip}/, ''))
+ op = File.dirname(olf)
+ File.makedirs(op, true)
+ File.chmod(0755, op)
+ File.install(lf, olf, 0755, true)
+ end
end
def do_man(man, strip = 'man/')
- man.each do |mf|
- omf = File.join(InstallOptions.man_dir, mf.gsub(/#{strip}/, ''))
- om = File.dirname(omf)
- File.makedirs(om, true)
- File.chmod(0644, om)
- File.install(mf, omf, 0644, true)
- gzip = %x{which gzip}
- gzip.chomp!
- %x{#{gzip} -f #{omf}}
- end
+ man.each do |mf|
+ omf = File.join(InstallOptions.man_dir, mf.gsub(/#{strip}/, ''))
+ om = File.dirname(omf)
+ File.makedirs(om, true)
+ File.chmod(0644, om)
+ File.install(mf, omf, 0644, true)
+ gzip = %x{which gzip}
+ gzip.chomp!
+ %x{#{gzip} -f #{omf}}
+ end
end
# Verify that all of the prereqs are installed
@@ -126,158 +126,158 @@ end
# Prepare the file installation.
#
def prepare_installation
- # Only try to do docs if we're sure they have rdoc
- if $haverdoc
- InstallOptions.rdoc = true
- if RUBY_PLATFORM == "i386-mswin32"
+ # Only try to do docs if we're sure they have rdoc
+ if $haverdoc
+ InstallOptions.rdoc = true
+ if RUBY_PLATFORM == "i386-mswin32"
+ InstallOptions.ri = false
+ else
+ InstallOptions.ri = true
+ end
+ else
+ InstallOptions.rdoc = false
InstallOptions.ri = false
- else
- InstallOptions.ri = true
- end
- else
- InstallOptions.rdoc = false
- InstallOptions.ri = false
- end
-
-
- if $haveman
- InstallOptions.man = true
- if RUBY_PLATFORM == "i386-mswin32"
- InstallOptions.man = false
- end
- else
- InstallOptions.man = false
- end
-
- InstallOptions.tests = true
-
- ARGV.options do |opts|
- opts.banner = "Usage: #{File.basename($0)} [options]"
- opts.separator ""
- opts.on('--[no-]rdoc', 'Prevents the creation of RDoc output.', 'Default on.') do |onrdoc|
- InstallOptions.rdoc = onrdoc
- end
- opts.on('--[no-]ri', 'Prevents the creation of RI output.', 'Default off on mswin32.') do |onri|
- InstallOptions.ri = onri
end
- opts.on('--[no-]man', 'Presents the creation of man pages.', 'Default on.') do |onman|
- InstallOptions.man = onman
- end
- opts.on('--[no-]tests', 'Prevents the execution of unit tests.', 'Default on.') do |ontest|
- InstallOptions.tests = ontest
- end
- opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir|
- InstallOptions.destdir = destdir
- end
- opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides Config::CONFIG["bindir"]') do |bindir|
- InstallOptions.bindir = bindir
+
+
+ if $haveman
+ InstallOptions.man = true
+ if RUBY_PLATFORM == "i386-mswin32"
+ InstallOptions.man = false
+ end
+ else
+ InstallOptions.man = false
end
- opts.on('--sbindir[=OPTIONAL]', 'Installation directory for system binaries', 'overrides Config::CONFIG["sbindir"]') do |sbindir|
- InstallOptions.sbindir = sbindir
+
+ InstallOptions.tests = true
+
+ ARGV.options do |opts|
+ opts.banner = "Usage: #{File.basename($0)} [options]"
+ opts.separator ""
+ opts.on('--[no-]rdoc', 'Prevents the creation of RDoc output.', 'Default on.') do |onrdoc|
+ InstallOptions.rdoc = onrdoc
+ end
+ opts.on('--[no-]ri', 'Prevents the creation of RI output.', 'Default off on mswin32.') do |onri|
+ InstallOptions.ri = onri
+ end
+ opts.on('--[no-]man', 'Presents the creation of man pages.', 'Default on.') do |onman|
+ InstallOptions.man = onman
+ end
+ opts.on('--[no-]tests', 'Prevents the execution of unit tests.', 'Default on.') do |ontest|
+ InstallOptions.tests = ontest
+ end
+ opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir|
+ InstallOptions.destdir = destdir
+ end
+ opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides Config::CONFIG["bindir"]') do |bindir|
+ InstallOptions.bindir = bindir
+ end
+ opts.on('--sbindir[=OPTIONAL]', 'Installation directory for system binaries', 'overrides Config::CONFIG["sbindir"]') do |sbindir|
+ InstallOptions.sbindir = sbindir
+ end
+ opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides Config::CONFIG["sitelibdir"]') do |sitelibdir|
+ InstallOptions.sitelibdir = sitelibdir
+ end
+ opts.on('--mandir[=OPTIONAL]', 'Installation directory for man pages', 'overrides Config::CONFIG["mandir"]') do |mandir|
+ InstallOptions.mandir = mandir
+ end
+ opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick|
+ InstallOptions.rdoc = false
+ InstallOptions.ri = false
+ InstallOptions.tests = false
+ end
+ opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full|
+ InstallOptions.rdoc = true
+ InstallOptions.ri = true
+ InstallOptions.tests = true
+ end
+ opts.separator("")
+ opts.on_tail('--help', "Shows this help text.") do
+ $stderr.puts opts
+ exit
+ end
+
+ opts.parse!
end
- opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides Config::CONFIG["sitelibdir"]') do |sitelibdir|
- InstallOptions.sitelibdir = sitelibdir
+
+ tmpdirs = [".", ENV['TMP'], ENV['TEMP'], "/tmp", "/var/tmp"]
+
+ version = [Config::CONFIG["MAJOR"], Config::CONFIG["MINOR"]].join(".")
+ libdir = File.join(Config::CONFIG["libdir"], "ruby", version)
+
+ # Mac OS X 10.5 declares bindir and sbindir as
+ # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin
+ # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/sbin
+ # which is not generally where people expect executables to be installed
+ if RUBY_PLATFORM == "universal-darwin9.0"
+ Config::CONFIG['bindir'] = "/usr/bin"
+ Config::CONFIG['sbindir'] = "/usr/sbin"
end
- opts.on('--mandir[=OPTIONAL]', 'Installation directory for man pages', 'overrides Config::CONFIG["mandir"]') do |mandir|
- InstallOptions.mandir = mandir
+
+ if not InstallOptions.bindir.nil?
+ bindir = InstallOptions.bindir
+ else
+ bindir = Config::CONFIG['bindir']
end
- opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick|
- InstallOptions.rdoc = false
- InstallOptions.ri = false
- InstallOptions.tests = false
+
+ if not InstallOptions.sbindir.nil?
+ sbindir = InstallOptions.sbindir
+ else
+ sbindir = Config::CONFIG['sbindir']
end
- opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full|
- InstallOptions.rdoc = true
- InstallOptions.ri = true
- InstallOptions.tests = true
+
+ if not InstallOptions.sitelibdir.nil?
+ sitelibdir = InstallOptions.sitelibdir
+ else
+ sitelibdir = Config::CONFIG["sitelibdir"]
+ if sitelibdir.nil?
+ sitelibdir = $:.find { |x| x =~ /site_ruby/ }
+ if sitelibdir.nil?
+ sitelibdir = File.join(libdir, "site_ruby")
+ elsif sitelibdir !~ Regexp.quote(version)
+ sitelibdir = File.join(sitelibdir, version)
+ end
+ end
end
- opts.separator("")
- opts.on_tail('--help', "Shows this help text.") do
- $stderr.puts opts
- exit
+
+ if not InstallOptions.mandir.nil?
+ mandir = InstallOptions.mandir
+ else
+ mandir = Config::CONFIG['mandir']
end
- opts.parse!
- end
-
- tmpdirs = [".", ENV['TMP'], ENV['TEMP'], "/tmp", "/var/tmp"]
-
- version = [Config::CONFIG["MAJOR"], Config::CONFIG["MINOR"]].join(".")
- libdir = File.join(Config::CONFIG["libdir"], "ruby", version)
-
- # Mac OS X 10.5 declares bindir and sbindir as
- # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin
- # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/sbin
- # which is not generally where people expect executables to be installed
- if RUBY_PLATFORM == "universal-darwin9.0"
- Config::CONFIG['bindir'] = "/usr/bin"
- Config::CONFIG['sbindir'] = "/usr/sbin"
- end
-
- if not InstallOptions.bindir.nil?
- bindir = InstallOptions.bindir
- else
- bindir = Config::CONFIG['bindir']
- end
-
- if not InstallOptions.sbindir.nil?
- sbindir = InstallOptions.sbindir
- else
- sbindir = Config::CONFIG['sbindir']
- end
-
- if not InstallOptions.sitelibdir.nil?
- sitelibdir = InstallOptions.sitelibdir
- else
- sitelibdir = Config::CONFIG["sitelibdir"]
- if sitelibdir.nil?
- sitelibdir = $:.find { |x| x =~ /site_ruby/ }
- if sitelibdir.nil?
- sitelibdir = File.join(libdir, "site_ruby")
- elsif sitelibdir !~ Regexp.quote(version)
- sitelibdir = File.join(sitelibdir, version)
- end
+ # To be deprecated once people move over to using --destdir option
+ if (destdir = ENV['DESTDIR'])
+ bindir = "#{destdir}#{bindir}"
+ sbindir = "#{destdir}#{sbindir}"
+ mandir = "#{destdir}#{mandir}"
+ sitelibdir = "#{destdir}#{sitelibdir}"
+
+ FileUtils.makedirs(bindir)
+ FileUtils.makedirs(sbindir)
+ FileUtils.makedirs(mandir)
+ FileUtils.makedirs(sitelibdir)
+ # This is the new way forward
+ elsif (destdir = InstallOptions.destdir)
+ bindir = "#{destdir}#{bindir}"
+ sbindir = "#{destdir}#{sbindir}"
+ mandir = "#{destdir}#{mandir}"
+ sitelibdir = "#{destdir}#{sitelibdir}"
+
+ FileUtils.makedirs(bindir)
+ FileUtils.makedirs(sbindir)
+ FileUtils.makedirs(mandir)
+ FileUtils.makedirs(sitelibdir)
end
- end
-
- if not InstallOptions.mandir.nil?
- mandir = InstallOptions.mandir
- else
- mandir = Config::CONFIG['mandir']
- end
-
- # To be deprecated once people move over to using --destdir option
- if (destdir = ENV['DESTDIR'])
- bindir = "#{destdir}#{bindir}"
- sbindir = "#{destdir}#{sbindir}"
- mandir = "#{destdir}#{mandir}"
- sitelibdir = "#{destdir}#{sitelibdir}"
-
- FileUtils.makedirs(bindir)
- FileUtils.makedirs(sbindir)
- FileUtils.makedirs(mandir)
- FileUtils.makedirs(sitelibdir)
- # This is the new way forward
- elsif (destdir = InstallOptions.destdir)
- bindir = "#{destdir}#{bindir}"
- sbindir = "#{destdir}#{sbindir}"
- mandir = "#{destdir}#{mandir}"
- sitelibdir = "#{destdir}#{sitelibdir}"
-
- FileUtils.makedirs(bindir)
- FileUtils.makedirs(sbindir)
- FileUtils.makedirs(mandir)
- FileUtils.makedirs(sitelibdir)
- end
-
- tmpdirs << bindir
-
- InstallOptions.tmp_dirs = tmpdirs.compact
- InstallOptions.site_dir = sitelibdir
- InstallOptions.bin_dir = bindir
- InstallOptions.sbin_dir = sbindir
- InstallOptions.lib_dir = libdir
- InstallOptions.man_dir = mandir
+
+ tmpdirs << bindir
+
+ InstallOptions.tmp_dirs = tmpdirs.compact
+ InstallOptions.site_dir = sitelibdir
+ InstallOptions.bin_dir = bindir
+ InstallOptions.sbin_dir = sbindir
+ InstallOptions.lib_dir = libdir
+ InstallOptions.man_dir = mandir
end
##
@@ -323,10 +323,10 @@ def build_man(bins)
# Create binary man pages
bins.each do |bin|
- b = bin.gsub( "bin/", "")
- %x{#{bin} --help > ./#{b}.rst}
- %x{#{rst2man} ./#{b}.rst ./man/man8/#{b}.8}
- File.unlink("./#{b}.rst")
+ b = bin.gsub( "bin/", "")
+ %x{#{bin} --help > ./#{b}.rst}
+ %x{#{rst2man} ./#{b}.rst ./man/man8/#{b}.8}
+ File.unlink("./#{b}.rst")
end
rescue SystemCallError
$stderr.puts "Couldn't build man pages: " + $!
@@ -335,24 +335,24 @@ def build_man(bins)
end
def run_tests(test_list)
- begin
- require 'test/unit/ui/console/testrunner'
- $:.unshift "lib"
- test_list.each do |test|
- next if File.directory?(test)
- require test
- end
-
- tests = []
- ObjectSpace.each_object { |o| tests << o if o.kind_of?(Class) }
- tests.delete_if { |o| !o.ancestors.include?(Test::Unit::TestCase) }
- tests.delete_if { |o| o == Test::Unit::TestCase }
-
- tests.each { |test| Test::Unit::UI::Console::TestRunner.run(test) }
- $:.shift
- rescue LoadError
- puts "Missing testrunner library; skipping tests"
- end
+ begin
+ require 'test/unit/ui/console/testrunner'
+ $:.unshift "lib"
+ test_list.each do |test|
+ next if File.directory?(test)
+ require test
+ end
+
+ tests = []
+ ObjectSpace.each_object { |o| tests << o if o.kind_of?(Class) }
+ tests.delete_if { |o| !o.ancestors.include?(Test::Unit::TestCase) }
+ tests.delete_if { |o| o == Test::Unit::TestCase }
+
+ tests.each { |test| Test::Unit::UI::Console::TestRunner.run(test) }
+ $:.shift
+ rescue LoadError
+ puts "Missing testrunner library; skipping tests"
+ end
end
##
@@ -361,57 +361,57 @@ end
# (e.g., bin/rdoc becomes rdoc); the shebang line handles running it. Under
# windows, we add an '.rb' extension and let file associations do their stuff.
def install_binfile(from, op_file, target)
- tmp_dir = nil
- InstallOptions.tmp_dirs.each do |t|
- if File.directory?(t) and File.writable?(t)
- tmp_dir = t
- break
+ tmp_dir = nil
+ InstallOptions.tmp_dirs.each do |t|
+ if File.directory?(t) and File.writable?(t)
+ tmp_dir = t
+ break
+ end
end
- end
-
- fail "Cannot find a temporary directory" unless tmp_dir
- tmp_file = File.join(tmp_dir, '_tmp')
- ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
-
- File.open(from) do |ip|
- File.open(tmp_file, "w") do |op|
- ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
- op.puts "#!#{ruby}"
- contents = ip.readlines
- if contents[0] =~ /^#!/
- contents.shift
- end
- op.write contents.join()
+
+ fail "Cannot find a temporary directory" unless tmp_dir
+ tmp_file = File.join(tmp_dir, '_tmp')
+ ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
+
+ File.open(from) do |ip|
+ File.open(tmp_file, "w") do |op|
+ ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
+ op.puts "#!#{ruby}"
+ contents = ip.readlines
+ if contents[0] =~ /^#!/
+ contents.shift
+ end
+ op.write contents.join()
+ end
end
- end
- if Config::CONFIG["target_os"] =~ /win/io and Config::CONFIG["target_os"] !~ /darwin/io
- installed_wrapper = false
+ if Config::CONFIG["target_os"] =~ /win/io and Config::CONFIG["target_os"] !~ /darwin/io
+ installed_wrapper = false
- if File.exists?("#{from}.bat")
- FileUtils.install("#{from}.bat", File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
- installed_wrapper = true
- end
+ if File.exists?("#{from}.bat")
+ FileUtils.install("#{from}.bat", File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
+ installed_wrapper = true
+ end
- if File.exists?("#{from}.cmd")
- FileUtils.install("#{from}.cmd", File.join(target, "#{op_file}.cmd"), :mode => 0755, :verbose => true)
- installed_wrapper = true
- end
+ if File.exists?("#{from}.cmd")
+ FileUtils.install("#{from}.cmd", File.join(target, "#{op_file}.cmd"), :mode => 0755, :verbose => true)
+ installed_wrapper = true
+ end
- if not installed_wrapper
- tmp_file2 = File.join(tmp_dir, '_tmp_wrapper')
- cwn = File.join(Config::CONFIG['bindir'], op_file)
- cwv = CMD_WRAPPER.gsub('<ruby>', ruby.gsub(%r{/}) { "\\" }).gsub!('<command>', cwn.gsub(%r{/}) { "\\" } )
+ if not installed_wrapper
+ tmp_file2 = File.join(tmp_dir, '_tmp_wrapper')
+ cwn = File.join(Config::CONFIG['bindir'], op_file)
+ cwv = CMD_WRAPPER.gsub('<ruby>', ruby.gsub(%r{/}) { "\\" }).gsub!('<command>', cwn.gsub(%r{/}) { "\\" } )
- File.open(tmp_file2, "wb") { |cw| cw.puts cwv }
- FileUtils.install(tmp_file2, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
+ File.open(tmp_file2, "wb") { |cw| cw.puts cwv }
+ FileUtils.install(tmp_file2, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
- File.unlink(tmp_file2)
- installed_wrapper = true
+ File.unlink(tmp_file2)
+ installed_wrapper = true
+ end
end
- end
- FileUtils.install(tmp_file, File.join(target, op_file), :mode => 0755, :verbose => true)
- File.unlink(tmp_file)
+ FileUtils.install(tmp_file, File.join(target, op_file), :mode => 0755, :verbose => true)
+ File.unlink(tmp_file)
end
CMD_WRAPPER = <<-EOS