DESTDIR is slated to be deprecated. The block of code that checks for
DESTDIR contained duplicate code as the block that checks for --destdir.

The dupe code has been moved out of the destdir checks.

I have also flipped the order of checking. Previously, if the DESTDIR env was 
set
it would be used regardless of whether or not the --destdir flag was set.

No env, no flag:
./install.rb
destdir = nil

Env only:
DESTDIR="foo" ./install.rb
destdir = foo

Flag only:
./install.rb --destdir="bar"
destdir = bar

Both (uses flag):
DESTDIR="foo" ./install.rb --destdir="bar"
destdir = bar

Signed-off-by: Elias Lutfallah <elias.lutfal...@orbitz.com>
---
 install.rb |   44 +++++++++++++++++++-------------------------
 1 files changed, 19 insertions(+), 25 deletions(-)

diff --git a/install.rb b/install.rb
index 7627a8d..d20b7cd 100755
--- a/install.rb
+++ b/install.rb
@@ -300,34 +300,28 @@ def prepare_installation
     mandir = Config::CONFIG['mandir']
   end
 
-  # 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)
-    FileUtils.makedirs(sitelibdir)
+  if not InstallOptions.destdir.nil?
+    destdir = InstallOptions.destdir
+  # To be deprecated once people move over to using --destdir option
+  elsif ENV['DESTDIR'] != nil?
+    destdir = ENV['DESTDIR']
+  else
+    destdir = ''
   end
 
+  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)
+
   tmpdirs << bindir
 
   InstallOptions.tmp_dirs = tmpdirs.compact
-- 
1.7.3.5

-- 
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.

Reply via email to