Skip to content

Commit a7fb9b9

Browse files
authored
Fix install of packages bundling generated source in dist/ (#4012)
Packages like `alex` include pre-generated lexer/parser source in their source tarball as e.g. dist/build/alex/alex-tmp/Scan.hs dist/build/alex/alex-tmp/Parser.hs to avoid having to have `alex` already installed before building `alex`... Unfortunately, 8dc39db broke packages relying on this accidental feature by changing where the distdir points to. This patch partly reverts that commit and therefore addresses the regression aspect of #4009. This fix was suggested by @dcoutts
1 parent c56e35a commit a7fb9b9

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

cabal-install/Distribution/Client/ProjectBuilding.hs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -744,16 +744,21 @@ withTarballLocalDirectory verbosity distDirLayout@DistDirLayout{..}
744744
tarball pkgid dparams buildstyle pkgTextOverride
745745
buildPkg =
746746
case buildstyle of
747-
-- In this case we make a couple temp dirs, unpack the tarball to one
748-
-- and build and install it from the other. We avoid nesting the
749-
-- builddir under the tarball src dir to keep path name lengths down.
747+
-- In this case we make a temp dir (e.g. tmp/src2345/), unpack
748+
-- the tarball to it (e.g. tmp/src2345/foo-1.0/), and for
749+
-- compatibility we put the dist dir within it
750+
-- (i.e. tmp/src2345/foo-1.0/dist/).
751+
--
752+
-- Unfortunately, a few custom Setup.hs scripts do not respect
753+
-- the --builddir flag and always look for it at ./dist/ so
754+
-- this way we avoid breaking those packages
750755
BuildAndInstall ->
751756
let tmpdir = distTempDirectory in
752-
withTempDirectory verbosity tmpdir "src" $ \unpackdir ->
753-
withTempDirectory verbosity tmpdir "build" $ \builddir -> do
757+
withTempDirectory verbosity tmpdir "src" $ \unpackdir -> do
754758
unpackPackageTarball verbosity tarball unpackdir
755759
pkgid pkgTextOverride
756760
let srcdir = unpackdir </> display pkgid
761+
builddir = srcdir </> "dist"
757762
buildPkg srcdir builddir
758763

759764
-- In this case we make sure the tarball has been unpacked to the

0 commit comments

Comments
 (0)