diff options
author | Elias Lutfallah <elias.lutfallah@orbitz.com> | 2011-03-05 15:07:39 -0600 |
---|---|---|
committer | Elias Lutfallah <elias.lutfallah@orbitz.com> | 2011-03-05 15:28:23 -0600 |
commit | f4a0af16eaa30571662017cab7e106a96b99988d (patch) | |
tree | d44a3e00c206c055dd7a67b5d01b59aa600bff68 /install.rb | |
parent | 609ddcf2b1ae0c835973a584ac20796d962334f6 (diff) | |
download | puppet-f4a0af16eaa30571662017cab7e106a96b99988d.tar.gz puppet-f4a0af16eaa30571662017cab7e106a96b99988d.tar.xz puppet-f4a0af16eaa30571662017cab7e106a96b99988d.zip |
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
Diffstat (limited to 'install.rb')
-rwxr-xr-x | install.rb | 44 |
1 files changed, 19 insertions, 25 deletions
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 |