summaryrefslogtreecommitdiffstats
path: root/install.rb
diff options
context:
space:
mode:
authorJosh Cooper <josh@puppetlabs.com>2011-07-29 09:42:57 -0700
committerJosh Cooper <josh@puppetlabs.com>2011-07-29 10:45:38 -0700
commitf6006177a85766cfb3387db6c3d337bf97b52f17 (patch)
tree754c8edc6f064a5ea79258bb4b3e764d8e673579 /install.rb
parent95b21dfde7d77a61633555f20f2e3b9675d48415 (diff)
downloadpuppet-f6006177a85766cfb3387db6c3d337bf97b52f17.tar.gz
puppet-f6006177a85766cfb3387db6c3d337bf97b52f17.tar.xz
puppet-f6006177a85766cfb3387db6c3d337bf97b52f17.zip
(#8660) Fix destdir option on Windows
Specifying the --destdir option failed on windows because the install script attempted to concatenate two absolute paths together. On Unix, this is fine, but on Windows, it fails because the colon (part of the drive specifier) is not a valid filename character. This commit adds a method to join two paths, stripping off the drive specifier, if present. Also fixed a minor bug, which caused a deprecation warning to always be printed when the --destdir option is omitted, which is the default case. Reviewed-by: Cameron Thomas <cameron@puppetlabs.com>
Diffstat (limited to 'install.rb')
-rwxr-xr-xinstall.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/install.rb b/install.rb
index 03bcfa06b..3d109b9a7 100755
--- a/install.rb
+++ b/install.rb
@@ -286,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)
@@ -317,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)