diff options
-rwxr-xr-x | install.rb | 25 | ||||
-rw-r--r-- | lib/puppet/util/run_mode.rb | 4 | ||||
-rwxr-xr-x | spec/unit/util/run_mode_spec.rb | 4 |
3 files changed, 23 insertions, 10 deletions
diff --git a/install.rb b/install.rb index 784ec8c9b..3d109b9a7 100755 --- a/install.rb +++ b/install.rb @@ -243,6 +243,9 @@ def prepare_installation if not InstallOptions.configdir.nil? configdir = InstallOptions.configdir + elsif $operatingsystem == "windows" + require 'win32/dir' + configdir = File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "etc") else configdir = "/etc/puppet" end @@ -283,18 +286,18 @@ def prepare_installation if not InstallOptions.destdir.nil? destdir = InstallOptions.destdir # To be deprecated once people move over to using --destdir option - elsif ENV['DESTDIR'] != nil? + elsif not ENV['DESTDIR'].nil? destdir = ENV['DESTDIR'] warn "DESTDIR is deprecated. Use --destdir instead." else destdir = '' end - configdir = "#{destdir}#{configdir}" - bindir = "#{destdir}#{bindir}" - sbindir = "#{destdir}#{sbindir}" - mandir = "#{destdir}#{mandir}" - sitelibdir = "#{destdir}#{sitelibdir}" + configdir = join(destdir, configdir) + bindir = join(destdir, bindir) + sbindir = join(destdir, sbindir) + mandir = join(destdir, mandir) + sitelibdir = join(destdir, sitelibdir) FileUtils.makedirs(configdir) if InstallOptions.configs FileUtils.makedirs(bindir) @@ -314,6 +317,16 @@ def prepare_installation end ## +# Join two paths. On Windows, dir must be converted to a relative path, +# by stripping the drive letter, but only if the basedir is not empty. +# +def join(basedir, dir) + return "#{basedir}#{dir[2..-1]}" if $operatingsystem == "windows" and basedir.length > 0 and dir.length > 2 + + "#{basedir}#{dir}" +end + +## # Build the rdoc documentation. Also, try to build the RI documentation. # def build_rdoc(files) diff --git a/lib/puppet/util/run_mode.rb b/lib/puppet/util/run_mode.rb index 450cbf1a6..6028aef29 100644 --- a/lib/puppet/util/run_mode.rb +++ b/lib/puppet/util/run_mode.rb @@ -27,14 +27,14 @@ module Puppet def conf_dir which_dir( - (Puppet.features.microsoft_windows? ? File.join(Dir::WINDOWS, "puppet", "etc") : "/etc/puppet"), + (Puppet.features.microsoft_windows? ? File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "etc") : "/etc/puppet"), "~/.puppet" ) end def var_dir which_dir( - (Puppet.features.microsoft_windows? ? File.join(Dir::WINDOWS, "puppet", "var") : "/var/lib/puppet"), + (Puppet.features.microsoft_windows? ? File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "var") : "/var/lib/puppet"), "~/.puppet/var" ) end diff --git a/spec/unit/util/run_mode_spec.rb b/spec/unit/util/run_mode_spec.rb index 5d9a3d058..f2303ccc2 100755 --- a/spec/unit/util/run_mode_spec.rb +++ b/spec/unit/util/run_mode_spec.rb @@ -8,7 +8,7 @@ describe Puppet::Util::RunMode do it "should have confdir /etc/puppet when run as root" do Puppet.features.stubs(:root?).returns(true) - etcdir = Puppet.features.microsoft_windows? ? File.join(Dir::WINDOWS, "puppet", "etc") : '/etc/puppet' + etcdir = Puppet.features.microsoft_windows? ? File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "etc") : '/etc/puppet' # REMIND: issue with windows backslashes @run_mode.conf_dir.should == File.expand_path(etcdir) end @@ -21,7 +21,7 @@ describe Puppet::Util::RunMode do it "should have vardir /var/lib/puppet when run as root" do Puppet.features.stubs(:root?).returns(true) - vardir = Puppet.features.microsoft_windows? ? File.join(Dir::WINDOWS, "puppet", "var") : '/var/lib/puppet' + vardir = Puppet.features.microsoft_windows? ? File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "var") : '/var/lib/puppet' # REMIND: issue with windows backslashes @run_mode.var_dir.should == File.expand_path(vardir) end |