From a03b4a7fb88ba0430645e627770e2ce7d808c8c6 Mon Sep 17 00:00:00 2001 From: Cody Casterline Date: Fri, 13 Mar 2015 01:34:12 +0000 Subject: dmd: install the correct configuration. dmd.conf hard-codes a path to DMD library files, which includes the keg version in the path. Upgrades via bottle would leave the old dmd.conf in place, which would result in a broken dmd. Closes #37663. Signed-off-by: Mike McQuaid --- Library/Formula/dmd.rb | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'Library/Formula') diff --git a/Library/Formula/dmd.rb b/Library/Formula/dmd.rb index 16a84ef1a..ebf53f68b 100644 --- a/Library/Formula/dmd.rb +++ b/Library/Formula/dmd.rb @@ -35,16 +35,16 @@ class Dmd < Formula prefix.install "samples" man.install Dir["docs/man/*"] - conf = etc/"dmd.conf" - - if conf.exist? - inreplace conf, /^DFLAGS=.+$/, "DFLAGS=-I#{include}/d2 -L-L#{lib}" - else - conf.write <<-EOS.undent + # A proper dmd.conf is required for later build steps: + conf = buildpath/"dmd.conf" + # Can't use opt_include or opt_lib here because dmd won't have been + # linked into opt by the time this build runs: + conf.write <<-EOS.undent [Environment] DFLAGS=-I#{include}/d2 -L-L#{lib} EOS - end + etc.install conf + install_new_dmd_conf make_args.unshift "DMD=#{bin}/dmd" @@ -65,6 +65,29 @@ class Dmd < Formula end end + # Previous versions of this formula may have left in place an incorrect + # dmd.conf. If it differs from the newly generated one, move it out of place + # and warn the user. + # This must be idempotent because it may run from both install() and + # post_install() if the user is running `brew install --build-from-source`. + def install_new_dmd_conf + conf = etc/"dmd.conf" + + # If the new file differs from conf, etc.install drops it here: + new_conf = etc/"dmd.conf.default" + # Else, we're already using the latest version: + return unless new_conf.exist? + + backup = etc/"dmd.conf.old" + opoo "An old dmd.conf was found and will be moved to #{backup}." + mv conf, backup + mv new_conf, conf + end + + def post_install + install_new_dmd_conf + end + test do system bin/"dmd", prefix/"samples/hello.d" system "./hello" -- cgit v1.2.3