From f4a0af16eaa30571662017cab7e106a96b99988d Mon Sep 17 00:00:00 2001 From: Elias Lutfallah Date: Sat, 5 Mar 2011 15:07:39 -0600 Subject: Refactoring duplicate code and logic in prep for DESTDIR deprecation. 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 --- install.rb | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) (limited to 'install.rb') diff --git a/install.rb b/install.rb index 7627a8d11..d20b7cda7 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 -- cgit From 1b1e803b4d2bf1e87b8796556439e3c0bada57ea Mon Sep 17 00:00:00 2001 From: Elias Lutfallah Date: Sat, 5 Mar 2011 15:23:06 -0600 Subject: (5724) Prep for deprecation of DESTDIR In preparation of deprecating the DESTDIR env variable, I've added a warning when the DESTDIR variable is being used. --- install.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'install.rb') diff --git a/install.rb b/install.rb index d20b7cda7..e8755e07a 100755 --- a/install.rb +++ b/install.rb @@ -306,6 +306,7 @@ def prepare_installation # To be deprecated once people move over to using --destdir option elsif ENV['DESTDIR'] != nil? destdir = ENV['DESTDIR'] + warn "DESTDIR is deprecated. Use --destdir instead." else destdir = '' end -- cgit