aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula
diff options
context:
space:
mode:
authorCody Casterline2015-03-13 01:34:12 +0000
committerMike McQuaid2015-03-15 16:13:06 +0000
commita03b4a7fb88ba0430645e627770e2ce7d808c8c6 (patch)
treebe1300d0fe9c77d3204fef0c05a75f7e82f0e604 /Library/Formula
parentef9de7a43b944a83004be607ef064a64a162b3c5 (diff)
downloadhomebrew-a03b4a7fb88ba0430645e627770e2ce7d808c8c6.tar.bz2
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 <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Formula')
-rw-r--r--Library/Formula/dmd.rb37
1 files changed, 30 insertions, 7 deletions
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"