From 28860695b7f045e0b04b57fdf78188b220cea9f8 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Mon, 9 Mar 2020 10:56:04 +0200 Subject: [PATCH] Lock files skip packages without cabal files This ties off the work fro #5210 --- ChangeLog.md | 1 + package.yaml | 2 +- src/Stack/Config.hs | 13 +++++++++++-- src/Stack/Init.hs | 3 ++- src/Stack/Unpack.hs | 4 ++-- stack-ghc-84.yaml | 3 ++- stack.cabal | 8 ++++---- stack.yaml | 3 ++- 8 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index e99c828fa5..be571e045a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -31,6 +31,7 @@ Behavior changes: * We now recommend checking in generated cabal files for repos. When generating lock files for extra-deps that only include `package.yaml` files, a deprecation warning will be generated. + Also, those packages will no longer be included in the generated lock files. See [#5210](https://github.com/commercialhaskell/stack/issues/5210). Other enhancements: diff --git a/package.yaml b/package.yaml index 668457b831..4c29f9d331 100644 --- a/package.yaml +++ b/package.yaml @@ -92,7 +92,7 @@ dependencies: - network-uri - open-browser - optparse-applicative -- pantry >= 0.3.1.0 +- pantry >= 0.4.0.0 - casa-client - casa-types - path diff --git a/src/Stack/Config.hs b/src/Stack/Config.hs index 51f23f377e..85758abbfc 100644 --- a/src/Stack/Config.hs +++ b/src/Stack/Config.hs @@ -592,8 +592,17 @@ fillProjectWanted stackYamlFP config project locCache snapCompiler snapPackages (deps0, mcompleted) <- fmap unzip . forM (projectDependencies project) $ \rpl -> do (pl, mCompleted) <- case rpl of RPLImmutable rpli -> do - compl <- maybe (completePackageLocation rpli) pure (Map.lookup rpli locCache) - pure (PLImmutable compl, Just (CompletedPLI rpli compl)) + (compl, mcompl) <- + case Map.lookup rpli locCache of + Just compl -> pure (compl, Just compl) + Nothing -> do + cpl <- completePackageLocation rpli + if cplHasCabalFile cpl + then pure (cplComplete cpl, Just $ cplComplete cpl) + else do + warnMissingCabalFile rpli + pure (cplComplete cpl, Nothing) + pure $ (PLImmutable compl, CompletedPLI rpli <$> mcompl) RPLMutable p -> pure (PLMutable p, Nothing) dp <- additionalDepPackage (shouldHaddockDeps bopts) pl diff --git a/src/Stack/Init.hs b/src/Stack/Init.hs index a145d3e07c..f920f75414 100644 --- a/src/Stack/Init.hs +++ b/src/Stack/Init.hs @@ -116,7 +116,8 @@ initProject currDir initOpts mresolver = do Map.mapMaybe (flip Map.lookup gpdByDir . resolvedAbsolute) rbundle deps <- for (Map.toList extraDeps) $ \(n, v) -> - PLImmutable <$> completePackageLocation (RPLIHackage (PackageIdentifierRevision n v CFILatest) Nothing) + (PLImmutable . cplComplete) <$> + completePackageLocation (RPLIHackage (PackageIdentifierRevision n v CFILatest) Nothing) let p = Project { projectUserMsg = if userMsg == "" then Nothing else Just userMsg diff --git a/src/Stack/Unpack.hs b/src/Stack/Unpack.hs index 5c5b5f9ad6..16309ae0a4 100644 --- a/src/Stack/Unpack.hs +++ b/src/Stack/Unpack.hs @@ -38,7 +38,7 @@ unpackPackages mSnapshot dest input = do let (errs1, (names, pirs1)) = fmap partitionEithers $ partitionEithers $ map parse input locs1 <- forM pirs1 $ \pir -> do - loc <- completePackageLocation $ RPLIHackage pir Nothing + loc <- fmap cplComplete $ completePackageLocation $ RPLIHackage pir Nothing pure (loc, packageLocationIdent loc) (errs2, locs2) <- partitionEithers <$> traverse toLoc names case errs1 ++ errs2 of @@ -97,7 +97,7 @@ unpackPackages mSnapshot dest input = do Nothing -> pure $ Left $ "Package does not appear in snapshot: " ++ packageNameString name Just sp -> do - loc <- completePackageLocation (rspLocation sp) + loc <- cplComplete <$> completePackageLocation (rspLocation sp) pure $ Right (loc, packageLocationIdent loc) -- Possible future enhancement: parse names as name + version range diff --git a/stack-ghc-84.yaml b/stack-ghc-84.yaml index a24a9cdb2d..a0dd51d29c 100644 --- a/stack-ghc-84.yaml +++ b/stack-ghc-84.yaml @@ -40,7 +40,8 @@ extra-deps: - rio-prettyprint-0.1.0.0@rev:0 - hi-file-parser-0.1.0.0@rev:0 - http-download-0.2.0.0@rev:0 -- pantry-0.3.1.0@rev:0 +- github: commercialhaskell/pantry + commit: 400ae05722f1c3f5b8d9de46008a1fe6db325179 - casa-client-0.0.1@rev:0 - casa-types-0.0.1@rev:0 - github: snoyberg/filelock diff --git a/stack.cabal b/stack.cabal index 97e231a6b8..766672b350 100644 --- a/stack.cabal +++ b/stack.cabal @@ -266,7 +266,7 @@ library , network-uri , open-browser , optparse-applicative - , pantry >=0.3.1.0 + , pantry >=0.4.0.0 , path , path-io , persistent @@ -386,7 +386,7 @@ executable stack , network-uri , open-browser , optparse-applicative - , pantry >=0.3.1.0 + , pantry >=0.4.0.0 , path , path-io , persistent @@ -505,7 +505,7 @@ executable stack-integration-test , open-browser , optparse-applicative , optparse-generic - , pantry >=0.3.1.0 + , pantry >=0.4.0.0 , path , path-io , persistent @@ -627,7 +627,7 @@ test-suite stack-test , network-uri , open-browser , optparse-applicative - , pantry >=0.3.1.0 + , pantry >=0.4.0.0 , path , path-io , persistent diff --git a/stack.yaml b/stack.yaml index 1aeb444d05..bbb9ebd0db 100644 --- a/stack.yaml +++ b/stack.yaml @@ -26,7 +26,8 @@ extra-deps: - http-download-0.2.0.0@rev:0 - github: snoyberg/filelock commit: 97e83ecc133cd60a99df8e1fa5a3c2739ad007dc -- pantry-0.3.1.0@rev:0 +- github: commercialhaskell/pantry + commit: 400ae05722f1c3f5b8d9de46008a1fe6db325179 - casa-client-0.0.1@rev:0 - casa-types-0.0.1@rev:0