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 added the deprecation warning if the DESTDIR environment variable is specified (to match the puppet install.rb script). Reviewed-by: Cameron Thomas <came...@puppetlabs.com> Signed-off-by: Josh Cooper <j...@puppetlabs.com> --- Local-branch: feature/master/facter-windows install.rb | 27 +++++++++++++++++++-------- 1 files changed, 19 insertions(+), 8 deletions(-) diff --git a/install.rb b/install.rb index ccfcb87..37154ba 100755 --- a/install.rb +++ b/install.rb @@ -260,10 +260,11 @@ def prepare_installation # 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}" + warn "DESTDIR is deprecated. Use --destdir instead." + bindir = join(destdir, bindir) + sbindir = join(destdir, sbindir) + mandir = join(destdir, mandir) + sitelibdir = join(destdir, sitelibdir) FileUtils.makedirs(bindir) FileUtils.makedirs(sbindir) @@ -271,10 +272,10 @@ def prepare_installation 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}" + bindir = join(destdir, bindir) + sbindir = join(destdir, sbindir) + mandir = join(destdir, mandir) + sitelibdir = join(destdir, sitelibdir) FileUtils.makedirs(bindir) FileUtils.makedirs(sbindir) @@ -293,6 +294,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 is_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) -- 1.7.5.4 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.