From eee1a9cdaa5cab6222c8e6ab087d319f976fa4e3 Mon Sep 17 00:00:00 2001 From: Nigel Kersten Date: Tue, 30 Nov 2010 14:19:04 -0800 Subject: (#5424) Ship auth.conf as part of installing from source Add --configdir which defaults to /etc/puppet Add --no-configs to suppress config file installation. We're only shipping auth.conf at this stage, but in the future we may start shipping other config files. --- install.rb | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) (limited to 'install.rb') diff --git a/install.rb b/install.rb index f7541c854..7627a8d11 100755 --- a/install.rb +++ b/install.rb @@ -79,6 +79,7 @@ def glob(list) end # Set these values to what you want installed. +configs = glob(%w{conf/auth.conf}) 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)$/ } @@ -87,6 +88,14 @@ man = glob(%w{man/man[0-9]/*}) libs = glob(%w{lib/**/*.rb lib/**/*.py lib/puppet/util/command_line/*}) tests = glob(%w{test/**/*.rb}) +def do_configs(configs, target, strip = 'conf/') + Dir.mkdir(target) unless File.directory? target + configs.each do |cf| + ocf = File.join(InstallOptions.config_dir, cf.gsub(/#{strip}/, '')) + File.install(cf, ocf, 0644, true) + end +end + def do_bins(bins, target, strip = 's?bin/') Dir.mkdir(target) unless File.directory? target bins.each do |bf| @@ -157,6 +166,8 @@ end def prepare_installation $operatingsystem = Facter["operatingsystem"].value + InstallOptions.configs = true + # Only try to do docs if we're sure they have rdoc if $haverdoc InstallOptions.rdoc = true @@ -193,9 +204,15 @@ def prepare_installation opts.on('--[no-]tests', 'Prevents the execution of unit tests.', 'Default on.') do |ontest| InstallOptions.tests = ontest end + opts.on('--[no-]configs', 'Prevents the installation of config files', 'Default off.') do |ontest| + InstallOptions.configs = ontest + end opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir| InstallOptions.destdir = destdir end + opts.on('--configdir[=OPTIONAL]', 'Installation directory for config files', 'Default /etc/puppet') do |configdir| + InstallOptions.configdir = configdir + end opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides Config::CONFIG["bindir"]') do |bindir| InstallOptions.bindir = bindir end @@ -209,15 +226,17 @@ def prepare_installation 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 + InstallOptions.rdoc = false + InstallOptions.ri = false + InstallOptions.tests = false + InstallOptions.configs = true end opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full| - InstallOptions.rdoc = true - InstallOptions.man = true - InstallOptions.ri = true - InstallOptions.tests = true + InstallOptions.rdoc = true + InstallOptions.man = true + InstallOptions.ri = true + InstallOptions.tests = true + InstallOptions.configs = true end opts.separator("") opts.on_tail('--help', "Shows this help text.") do @@ -243,6 +262,12 @@ def prepare_installation Config::CONFIG['sbindir'] = "/usr/sbin" end + if not InstallOptions.configdir.nil? + configdir = InstallOptions.configdir + else + configdir = "/etc/puppet" + end + if not InstallOptions.bindir.nil? bindir = InstallOptions.bindir else @@ -277,22 +302,26 @@ def prepare_installation # To be deprecated once people move over to using --destdir option if (destdir = ENV['DESTDIR']) + configdir = "#{destdir}#{configdir}" bindir = "#{destdir}#{bindir}" sbindir = "#{destdir}#{sbindir}" mandir = "#{destdir}#{mandir}" sitelibdir = "#{destdir}#{sitelibdir}" + FileUtils.makedirs(configdir) if InstallOptions.configs FileUtils.makedirs(bindir) FileUtils.makedirs(sbindir) FileUtils.makedirs(mandir) FileUtils.makedirs(sitelibdir) # This is the new way forward elsif (destdir = InstallOptions.destdir) + configdir = "#{destdir}#{configdir}" bindir = "#{destdir}#{bindir}" sbindir = "#{destdir}#{sbindir}" mandir = "#{destdir}#{mandir}" sitelibdir = "#{destdir}#{sitelibdir}" + FileUtils.makedirs(configdir) if InstallOptions.configs FileUtils.makedirs(bindir) FileUtils.makedirs(sbindir) FileUtils.makedirs(mandir) @@ -303,6 +332,7 @@ def prepare_installation InstallOptions.tmp_dirs = tmpdirs.compact InstallOptions.site_dir = sitelibdir + InstallOptions.config_dir = configdir InstallOptions.bin_dir = bindir InstallOptions.sbin_dir = sbindir InstallOptions.lib_dir = libdir @@ -459,6 +489,7 @@ prepare_installation #build_rdoc(rdoc) if InstallOptions.rdoc #build_ri(ri) if InstallOptions.ri #build_man(bins, sbins) if InstallOptions.man +do_configs(configs, InstallOptions.config_dir) if InstallOptions.configs do_bins(sbins, InstallOptions.sbin_dir) do_bins(bins, InstallOptions.bin_dir) do_libs(libs) -- cgit