From 4aa5f88618a29cb53b988a8ae859caa2c70a6e62 Mon Sep 17 00:00:00 2001 From: Francesco Gazzetta Date: Mon, 24 Jul 2023 17:28:36 +0200 Subject: [PATCH] PD check: do not treat library names as package names (#9132) Fixes #9122 --- Cabal/src/Distribution/PackageDescription/Check.hs | 7 +------ .../PackageTests/Regression/T9122/p/p.cabal | 6 ++++++ .../PackageTests/Regression/T9122/q/q.cabal | 10 ++++++++++ .../PackageTests/Regression/T9122/setup.cabal.out | 11 +++++++++++ .../PackageTests/Regression/T9122/setup.out | 11 +++++++++++ .../PackageTests/Regression/T9122/setup.test.hs | 5 +++++ changelog.d/issue-9122 | 4 ++++ 7 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 cabal-testsuite/PackageTests/Regression/T9122/p/p.cabal create mode 100644 cabal-testsuite/PackageTests/Regression/T9122/q/q.cabal create mode 100644 cabal-testsuite/PackageTests/Regression/T9122/setup.cabal.out create mode 100644 cabal-testsuite/PackageTests/Regression/T9122/setup.out create mode 100644 cabal-testsuite/PackageTests/Regression/T9122/setup.test.hs create mode 100644 changelog.d/issue-9122 diff --git a/Cabal/src/Distribution/PackageDescription/Check.hs b/Cabal/src/Distribution/PackageDescription/Check.hs index e8be60fcbc5..4c2701d95c3 100644 --- a/Cabal/src/Distribution/PackageDescription/Check.hs +++ b/Cabal/src/Distribution/PackageDescription/Check.hs @@ -1352,18 +1352,13 @@ checkFields pkg = , isNoVersion vr ] - internalLibraries = - map - (maybe (packageName pkg) unqualComponentNameToPackageName . libraryNameString . libName) - (allLibraries pkg) - internalExecutables = map exeName $ executables pkg internalLibDeps = [ dep | bi <- allBuildInfo pkg , dep@(Dependency name _ _) <- targetBuildDepends bi - , name `elem` internalLibraries + , name == packageName pkg ] internalExeDeps = diff --git a/cabal-testsuite/PackageTests/Regression/T9122/p/p.cabal b/cabal-testsuite/PackageTests/Regression/T9122/p/p.cabal new file mode 100644 index 00000000000..1100690129a --- /dev/null +++ b/cabal-testsuite/PackageTests/Regression/T9122/p/p.cabal @@ -0,0 +1,6 @@ +cabal-version: 3.4 +name: p +Version: 2 +Build-Type: Simple + +library diff --git a/cabal-testsuite/PackageTests/Regression/T9122/q/q.cabal b/cabal-testsuite/PackageTests/Regression/T9122/q/q.cabal new file mode 100644 index 00000000000..d9bd9b331e5 --- /dev/null +++ b/cabal-testsuite/PackageTests/Regression/T9122/q/q.cabal @@ -0,0 +1,10 @@ +cabal-version: 3.4 +name: q +Version: 1 +Build-Type: Simple + +library + build-depends: q:p + +library p + build-depends: p:p == 2 diff --git a/cabal-testsuite/PackageTests/Regression/T9122/setup.cabal.out b/cabal-testsuite/PackageTests/Regression/T9122/setup.cabal.out new file mode 100644 index 00000000000..1367a55a1a0 --- /dev/null +++ b/cabal-testsuite/PackageTests/Regression/T9122/setup.cabal.out @@ -0,0 +1,11 @@ +# Setup configure +Configuring p-2... +# Setup build +Preprocessing library for p-2... +Building library for p-2... +# Setup copy +Installing library in +# Setup register +Registering library for p-2... +# Setup configure +Configuring q-1... diff --git a/cabal-testsuite/PackageTests/Regression/T9122/setup.out b/cabal-testsuite/PackageTests/Regression/T9122/setup.out new file mode 100644 index 00000000000..1367a55a1a0 --- /dev/null +++ b/cabal-testsuite/PackageTests/Regression/T9122/setup.out @@ -0,0 +1,11 @@ +# Setup configure +Configuring p-2... +# Setup build +Preprocessing library for p-2... +Building library for p-2... +# Setup copy +Installing library in +# Setup register +Registering library for p-2... +# Setup configure +Configuring q-1... diff --git a/cabal-testsuite/PackageTests/Regression/T9122/setup.test.hs b/cabal-testsuite/PackageTests/Regression/T9122/setup.test.hs new file mode 100644 index 00000000000..93a4a976b3b --- /dev/null +++ b/cabal-testsuite/PackageTests/Regression/T9122/setup.test.hs @@ -0,0 +1,5 @@ +import Test.Cabal.Prelude + +main = setupAndCabalTest $ withPackageDb $ do + withDirectory "p" $ setup_install [] + withDirectory "q" $ setup "configure" [] diff --git a/changelog.d/issue-9122 b/changelog.d/issue-9122 new file mode 100644 index 00000000000..c8d82af1d86 --- /dev/null +++ b/changelog.d/issue-9122 @@ -0,0 +1,4 @@ +synopsis: Fix dependency on an external package when an internal library with the same name exists +packages: Cabal +issues: #9122 +prs: #9132