From e5b16b26fff6b8b358975d27d46a274407891a69 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Sat, 22 Mar 2008 15:00:19 +1100 Subject: Ported #198 man page creation functionality to 0.24.x branch --- install.rb | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'install.rb') diff --git a/install.rb b/install.rb index 6c418119b..c7472a111 100755 --- a/install.rb +++ b/install.rb @@ -47,6 +47,18 @@ rescue LoadError $haverdoc = false end +begin + if $haverdoc + rst2man = %x{which rst2man.py} + $haveman = true + else + $haveman = false + end +rescue + puts "Missing rst2man; skipping man page creation" + $haveman = false +end + PREREQS = %w{openssl facter xmlrpc/client xmlrpc/server cgi} InstallOptions = OpenStruct.new @@ -112,6 +124,17 @@ def prepare_installation 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| @@ -123,6 +146,9 @@ def prepare_installation 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 @@ -212,6 +238,30 @@ def build_ri(files) end end +def build_man(bins) + return unless $haveman + begin + # Locate rst2man + rst2man = %x{which rst2man.py} + rst2man.chomp! + # Create puppet.conf.8 man page + %x{bin/puppetdoc --reference configuration > ./puppet.conf.rst} + %x{#{rst2man} ./puppet.conf.rst ./man/man8/puppet.conf.8} + File.unlink("./puppet.conf.rst") + + # 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") + end + rescue SystemCallError + $stderr.puts "Couldn't build man pages: " + $! + $stderr.puts "Continuing with install..." + end +end + def run_tests(test_list) begin require 'test/unit/ui/console/testrunner' @@ -309,6 +359,7 @@ prepare_installation run_tests(tests) if InstallOptions.tests #build_rdoc(rdoc) if InstallOptions.rdoc #build_ri(ri) if InstallOptions.ri +build_man(bins) if InstallOptions.man do_bins(sbins, InstallOptions.sbin_dir) do_bins(bins, InstallOptions.bin_dir) do_libs(libs) -- cgit From 5a3195941375645f1e0949b02bbfe5bd29816767 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Sat, 22 Mar 2008 17:49:28 +1100 Subject: Added man pages and man page creation logic to install.rb --- install.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'install.rb') diff --git a/install.rb b/install.rb index c7472a111..576303f51 100755 --- a/install.rb +++ b/install.rb @@ -76,6 +76,7 @@ sbins = glob(%w{sbin/*}) bins = glob(%w{bin/*}) rdoc = glob(%w{bin/* sbin/* lib/**/*.rb README README-library CHANGELOG TODO Install}).reject { |e| e=~ /\.(bat|cmd)$/ } ri = glob(%w(bin/*.rb sbin/* lib/**/*.rb)).reject { |e| e=~ /\.(bat|cmd)$/ } +man = glob(%w{man/man8/*}) libs = glob(%w{lib/**/*.rb lib/**/*.py}) tests = glob(%w{tests/**/*.rb}) @@ -96,6 +97,19 @@ def do_libs(libs, strip = 'lib/') 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} #{omf}} + end +end + # Verify that all of the prereqs are installed def check_prereqs PREREQS.each { |pre| @@ -189,15 +203,18 @@ def prepare_installation if (destdir = ENV['DESTDIR']) bindir = "#{destdir}#{Config::CONFIG['bindir']}" sbindir = "#{destdir}#{Config::CONFIG['sbindir']}" + mandir = "#{destdir}#{Config::CONFIG['mandir']}" sitelibdir = "#{destdir}#{sitelibdir}" tmpdirs << bindir FileUtils.makedirs(bindir) FileUtils.makedirs(sbindir) + FileUtils.makedirs(mandir) FileUtils.makedirs(sitelibdir) else bindir = Config::CONFIG['bindir'] sbindir = Config::CONFIG['sbindir'] + mandir = Config::CONFIG['mandir'] tmpdirs << Config::CONFIG['bindir'] end @@ -206,6 +223,7 @@ def prepare_installation InstallOptions.bin_dir = bindir InstallOptions.sbin_dir = sbindir InstallOptions.lib_dir = libdir + InstallOptions.man_dir = mandir end ## @@ -363,3 +381,4 @@ build_man(bins) if InstallOptions.man do_bins(sbins, InstallOptions.sbin_dir) do_bins(bins, InstallOptions.bin_dir) do_libs(libs) +do_man(man) -- cgit From bd3f6ec87cfb6ccca976e3ab5d8cc13fd8c273a8 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Tue, 25 Mar 2008 08:03:11 +1100 Subject: Disabled man page creation by default and updated CHANGELOG --- install.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'install.rb') diff --git a/install.rb b/install.rb index 576303f51..087c3c860 100755 --- a/install.rb +++ b/install.rb @@ -377,7 +377,7 @@ prepare_installation run_tests(tests) if InstallOptions.tests #build_rdoc(rdoc) if InstallOptions.rdoc #build_ri(ri) if InstallOptions.ri -build_man(bins) if InstallOptions.man +#build_man(bins) if InstallOptions.man do_bins(sbins, InstallOptions.sbin_dir) do_bins(bins, InstallOptions.bin_dir) do_libs(libs) -- cgit