pantry 0.5.7 → 0.6.0
raw patch · 5 files changed
+277/−221 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Pantry: [hscDownloadPrefix] :: HackageSecurityConfig -> !Text
- Pantry.Internal.Stackage: [pcHackageSecurity] :: PantryConfig -> !HackageSecurityConfig
+ Pantry: PackageIndexConfig :: !Text -> !HackageSecurityConfig -> PackageIndexConfig
+ Pantry: [picDownloadPrefix] :: PackageIndexConfig -> !Text
+ Pantry: [picHackageSecurityConfig] :: PackageIndexConfig -> !HackageSecurityConfig
+ Pantry: data PackageIndexConfig
+ Pantry: defaultDownloadPrefix :: Text
+ Pantry: defaultPackageIndexConfig :: PackageIndexConfig
+ Pantry.Internal.Stackage: [pcPackageIndex] :: PantryConfig -> !PackageIndexConfig
- Pantry: HackageSecurityConfig :: ![Text] -> !Int -> !Text -> !Bool -> HackageSecurityConfig
+ Pantry: HackageSecurityConfig :: ![Text] -> !Int -> !Bool -> HackageSecurityConfig
- Pantry: withPantryConfig :: HasLogFunc env => Path Abs Dir -> HackageSecurityConfig -> HpackExecutable -> Int -> CasaRepoPrefix -> Int -> (SnapName -> RawSnapshotLocation) -> (PantryConfig -> RIO env a) -> RIO env a
+ Pantry: withPantryConfig :: HasLogFunc env => Path Abs Dir -> PackageIndexConfig -> HpackExecutable -> Int -> CasaRepoPrefix -> Int -> (SnapName -> RawSnapshotLocation) -> (PantryConfig -> RIO env a) -> RIO env a
- Pantry.Internal.Stackage: PantryConfig :: !HackageSecurityConfig -> !HpackExecutable -> !Path Abs Dir -> !Storage -> !MVar Bool -> !IORef (Map RawPackageLocationImmutable GenericPackageDescription) -> !IORef (Map (Path Abs Dir) (PrintWarnings -> IO GenericPackageDescription, PackageName, Path Abs File)) -> !Int -> !CasaRepoPrefix -> !Int -> (SnapName -> RawSnapshotLocation) -> PantryConfig
+ Pantry.Internal.Stackage: PantryConfig :: !PackageIndexConfig -> !HpackExecutable -> !Path Abs Dir -> !Storage -> !MVar Bool -> !IORef (Map RawPackageLocationImmutable GenericPackageDescription) -> !IORef (Map (Path Abs Dir) (PrintWarnings -> IO GenericPackageDescription, PackageName, Path Abs File)) -> !Int -> !CasaRepoPrefix -> !Int -> (SnapName -> RawSnapshotLocation) -> PantryConfig
Files
- ChangeLog.md +14/−0
- pantry.cabal +185/−185
- src/Pantry.hs +25/−23
- src/Pantry/Hackage.hs +2/−2
- src/Pantry/Types.hs +51/−11
ChangeLog.md view
@@ -1,5 +1,19 @@ # Changelog for pantry +## v0.6.0 + +* Rename `HackageSecurityConfig` as `PackageIndexConfig`, + `defaultHackageSecurityConfig` as `defaultPackageIndexConfig`, and + `pcHackageSecurity` field of `PantryConfig` as `pcPackageIndex`. +* Expose new `HackageSecurityConfig` and `defaultHackageSecurityConfig`. The + former represents Hackage Security configurations (only - no download prefix). +* Change the data constructor of `PackageIndexConfig` to have fields for a + download prefix (type `Text`) and of type `HackageSecurityConfig`. +* The `WithJSONWarnings PackageIndexConfig` instance of `FromJSON` now assigns + default value `defaultHackageSecurityConfig` if the `hackage-security` key is + absent from the JSON object. +* Expose `defaultDownloadPrefix`, for the official Hackage server. + ## v0.5.7 * Expose `loadAndCompleteSnapshotRaw'` and `loadAndCompleteSnapshot'`, which
pantry.cabal view
@@ -1,186 +1,186 @@ cabal-version: 1.12 ---- This file has been generated from package.yaml by hpack version 0.35.0.------ see: https://github.com/sol/hpack--name: pantry-version: 0.5.7-synopsis: Content addressable Haskell package management-description: Please see the README on GitHub at <https://github.com/commercialhaskell/pantry#readme>-category: Development-homepage: https://github.com/commercialhaskell/pantry#readme-bug-reports: https://github.com/commercialhaskell/pantry/issues-author: Michael Snoyman-maintainer: michael@snoyman.com-copyright: 2018-2022 FP Complete-license: BSD3-license-file: LICENSE-build-type: Simple-extra-source-files:- README.md- ChangeLog.md- attic/hpack-0.1.2.3.tar.gz- attic/package-0.1.2.3.tar.gz- attic/symlink-to-dir.tar.gz--source-repository head- type: git- location: https://github.com/commercialhaskell/pantry--library- exposed-modules:- Pantry- Pantry.SHA256- Pantry.Internal- Pantry.Internal.StaticBytes- Pantry.Internal.Stackage- Pantry.Internal.Companion- Pantry.Internal.AesonExtended- other-modules:- Hackage.Security.Client.Repository.HttpLib.HttpClient- Pantry.Archive- Pantry.HTTP- Pantry.HPack- Pantry.Hackage- Pantry.Repo- Pantry.SQLite- Pantry.Storage- Pantry.Casa- Pantry.Tree- Pantry.Types- hs-source-dirs:- src/- ghc-options: -Wall- build-depends:- Cabal >=3 && <3.9- , aeson- , ansi-terminal- , base >=4.10 && <5- , bytestring- , casa-client- , casa-types- , conduit- , conduit-extra- , containers- , cryptonite- , cryptonite-conduit- , digest- , filelock- , generic-deriving- , hackage-security- , hpack >=0.31.2- , http-client- , http-client-tls- , http-conduit- , http-download- , http-types- , memory- , mtl- , network-uri- , path- , path-io- , persistent- , persistent-sqlite >=2.9.3- , persistent-template- , primitive- , resourcet- , rio- , rio-orphans- , rio-prettyprint- , tar-conduit- , text- , text-metrics- , time- , transformers- , unix-compat- , unliftio- , unordered-containers- , vector- , yaml- , zip-archive- default-language: Haskell2010- if os(windows)- other-modules:- System.IsWindows- hs-source-dirs:- src/windows/- else- other-modules:- System.IsWindows- hs-source-dirs:- src/unix/--test-suite spec- type: exitcode-stdio-1.0- main-is: Spec.hs- other-modules:- Pantry.ArchiveSpec- Pantry.BuildPlanSpec- Pantry.CabalSpec- Pantry.CasaSpec- Pantry.FileSpec- Pantry.GlobalHintsSpec- Pantry.HackageSpec- Pantry.Internal.StaticBytesSpec- Pantry.InternalSpec- Pantry.TreeSpec- Pantry.TypesSpec- Paths_pantry- hs-source-dirs:- test- ghc-options: -Wall- build-depends:- Cabal >=3 && <3.9- , QuickCheck- , aeson- , ansi-terminal- , base >=4.10 && <5- , bytestring- , casa-client- , casa-types- , conduit- , conduit-extra- , containers- , cryptonite- , cryptonite-conduit- , digest- , exceptions- , filelock- , generic-deriving- , hackage-security- , hedgehog- , hpack >=0.31.2- , hspec- , http-client- , http-client-tls- , http-conduit- , http-download- , http-types- , memory- , mtl- , network-uri- , pantry- , path- , path-io- , persistent- , persistent-sqlite >=2.9.3- , persistent-template- , primitive- , raw-strings-qq- , resourcet- , rio- , rio-orphans- , rio-prettyprint- , tar-conduit- , text- , text-metrics- , time- , transformers- , unix-compat- , unliftio- , unordered-containers- , vector- , yaml- , zip-archive- default-language: Haskell2010+ +-- This file has been generated from package.yaml by hpack version 0.35.0. +-- +-- see: https://github.com/sol/hpack + +name: pantry +version: 0.6.0 +synopsis: Content addressable Haskell package management +description: Please see the README on GitHub at <https://github.com/commercialhaskell/pantry#readme> +category: Development +homepage: https://github.com/commercialhaskell/pantry#readme +bug-reports: https://github.com/commercialhaskell/pantry/issues +author: Michael Snoyman +maintainer: michael@snoyman.com +copyright: 2018-2022 FP Complete +license: BSD3 +license-file: LICENSE +build-type: Simple +extra-source-files: + README.md + ChangeLog.md + attic/hpack-0.1.2.3.tar.gz + attic/package-0.1.2.3.tar.gz + attic/symlink-to-dir.tar.gz + +source-repository head + type: git + location: https://github.com/commercialhaskell/pantry + +library + exposed-modules: + Pantry + Pantry.SHA256 + Pantry.Internal + Pantry.Internal.StaticBytes + Pantry.Internal.Stackage + Pantry.Internal.Companion + Pantry.Internal.AesonExtended + other-modules: + Hackage.Security.Client.Repository.HttpLib.HttpClient + Pantry.Archive + Pantry.HTTP + Pantry.HPack + Pantry.Hackage + Pantry.Repo + Pantry.SQLite + Pantry.Storage + Pantry.Casa + Pantry.Tree + Pantry.Types + hs-source-dirs: + src/ + ghc-options: -Wall + build-depends: + Cabal >=3 && <3.9 + , aeson + , ansi-terminal + , base >=4.10 && <5 + , bytestring + , casa-client + , casa-types + , conduit + , conduit-extra + , containers + , cryptonite + , cryptonite-conduit + , digest + , filelock + , generic-deriving + , hackage-security + , hpack >=0.31.2 + , http-client + , http-client-tls + , http-conduit + , http-download + , http-types + , memory + , mtl + , network-uri + , path + , path-io + , persistent + , persistent-sqlite >=2.9.3 + , persistent-template + , primitive + , resourcet + , rio + , rio-orphans + , rio-prettyprint + , tar-conduit + , text + , text-metrics + , time + , transformers + , unix-compat + , unliftio + , unordered-containers + , vector + , yaml + , zip-archive + default-language: Haskell2010 + if os(windows) + other-modules: + System.IsWindows + hs-source-dirs: + src/windows/ + else + other-modules: + System.IsWindows + hs-source-dirs: + src/unix/ + +test-suite spec + type: exitcode-stdio-1.0 + main-is: Spec.hs + other-modules: + Pantry.ArchiveSpec + Pantry.BuildPlanSpec + Pantry.CabalSpec + Pantry.CasaSpec + Pantry.FileSpec + Pantry.GlobalHintsSpec + Pantry.HackageSpec + Pantry.Internal.StaticBytesSpec + Pantry.InternalSpec + Pantry.TreeSpec + Pantry.TypesSpec + Paths_pantry + hs-source-dirs: + test + ghc-options: -Wall + build-depends: + Cabal >=3 && <3.9 + , QuickCheck + , aeson + , ansi-terminal + , base >=4.10 && <5 + , bytestring + , casa-client + , casa-types + , conduit + , conduit-extra + , containers + , cryptonite + , cryptonite-conduit + , digest + , exceptions + , filelock + , generic-deriving + , hackage-security + , hedgehog + , hpack >=0.31.2 + , hspec + , http-client + , http-client-tls + , http-conduit + , http-download + , http-types + , memory + , mtl + , network-uri + , pantry + , path + , path-io + , persistent + , persistent-sqlite >=2.9.3 + , persistent-template + , primitive + , raw-strings-qq + , resourcet + , rio + , rio-orphans + , rio-prettyprint + , tar-conduit + , text + , text-metrics + , time + , transformers + , unix-compat + , unliftio + , unordered-containers + , vector + , yaml + , zip-archive + default-language: Haskell2010
src/Pantry.hs view
@@ -10,7 +10,10 @@ module Pantry ( -- * Running PantryConfig + , PackageIndexConfig (..) , HackageSecurityConfig (..) + , defaultPackageIndexConfig + , defaultDownloadPrefix , defaultHackageSecurityConfig , defaultCasaRepoPrefix , defaultCasaMaxPerRequest @@ -177,6 +180,7 @@ , getHackageTypoCorrections , loadGlobalHints , partitionReplacedDependencies + -- * Snapshot cache , SnapshotCacheHash (..) , withSnapshotCache @@ -232,9 +236,9 @@ => Path Abs Dir -- ^ pantry root directory, where the SQLite database and Hackage -- downloads are kept. - -> HackageSecurityConfig - -- ^ Hackage configuration. You probably want - -- 'defaultHackageSecurityConfig'. + -> PackageIndexConfig + -- ^ Package index configuration. You probably want + -- 'defaultPackageIndexConfig'. -> HpackExecutable -- ^ When converting an hpack @package.yaml@ file to a cabal file, -- what version of hpack should we use? @@ -249,7 +253,7 @@ -> (PantryConfig -> RIO env a) -- ^ What to do with the config -> RIO env a -withPantryConfig root hsc he count pullURL maxPerRequest snapLoc inner = do +withPantryConfig root pic he count pullURL maxPerRequest snapLoc inner = do env <- ask pantryRelFile <- parseRelFile "pantry.sqlite3" -- Silence persistent's logging output, which is really noisy @@ -258,7 +262,7 @@ ref1 <- newIORef mempty ref2 <- newIORef mempty inner PantryConfig - { pcHackageSecurity = hsc + { pcPackageIndex = pic , pcHpackExecutable = he , pcRootDir = root , pcStorage = storage @@ -283,23 +287,21 @@ defaultCasaMaxPerRequest :: Int defaultCasaMaxPerRequest = 1280 --- | Default 'HackageSecurityConfig' value using the official Hackage server. +-- | Default 'PackageIndexConfig' value using the official Hackage server. -- --- @since 0.1.0.0 -defaultHackageSecurityConfig :: HackageSecurityConfig -defaultHackageSecurityConfig = HackageSecurityConfig - { hscKeyIds = - [ "0a5c7ea47cd1b15f01f5f51a33adda7e655bc0f0b0615baa8e271f4c3351e21d" - , "1ea9ba32c526d1cc91ab5e5bd364ec5e9e8cb67179a471872f6e26f0ae773d42" - , "2c6c3627bd6c982990239487f1abd02e08a02e6cf16edb105a8012d444d870c3" - , "51f0161b906011b52c6613376b1ae937670da69322113a246a09f807c62f6921" - , "fe331502606802feac15e514d9b9ea83fee8b6ffef71335479a2e68d84adc6b0" - ] - , hscKeyThreshold = 3 - , hscDownloadPrefix = "https://hackage.haskell.org/" - , hscIgnoreExpiry = False +-- @since 0.6.0 +defaultPackageIndexConfig :: PackageIndexConfig +defaultPackageIndexConfig = PackageIndexConfig + { picDownloadPrefix = defaultDownloadPrefix + , picHackageSecurityConfig = defaultHackageSecurityConfig } +-- | The download prefix for the official Hackage server. +-- +-- @since 0.6.0 +defaultDownloadPrefix :: Text +defaultDownloadPrefix = "https://hackage.haskell.org/" + -- | Returns the latest version of the given package available from -- Hackage. -- @@ -666,7 +668,7 @@ toPretty :: Path Abs File -> PWarning -> Utf8Builder toPretty src (PWarning _type pos msg) = - "Cabal file warning in" <> + "Cabal file warning in " <> fromString (toFilePath src) <> "@" <> fromString (showPos pos) <> ": " <> fromString msg @@ -1203,7 +1205,7 @@ -> RIO env (Snapshot, [CompletedSL], [CompletedPLI]) loadAndCompleteSnapshotRaw = loadAndCompleteSnapshotRaw' True --- As for 'loadAndCompleteSnapshotRaw' but allows toggling of the debug output +-- | As for 'loadAndCompleteSnapshotRaw' but allows toggling of the debug output -- of the raw snapshot layer. -- -- @since 0.5.7 @@ -1709,7 +1711,7 @@ root <- parseAbsDir $ stack FilePath.</> "pantry" withPantryConfig root - defaultHackageSecurityConfig + defaultPackageIndexConfig HpackBundled maxConnCount casaRepoPrefix @@ -1736,7 +1738,7 @@ root <- resolveDir' dir withPantryConfig root - defaultHackageSecurityConfig + defaultPackageIndexConfig HpackBundled 8 defaultCasaRepoPrefix
src/Pantry/Hackage.hs view
@@ -125,7 +125,7 @@ gateUpdate $ withWriteLock_ storage $ do for_ mreason logInfo pc <- view pantryConfigL - let HackageSecurityConfig keyIds threshold url ignoreExpiry = pcHackageSecurity pc + let PackageIndexConfig url (HackageSecurityConfig keyIds threshold ignoreExpiry) = pcPackageIndex pc root <- view hackageDirL tarball <- view hackageIndexTarballL baseURI <- @@ -606,7 +606,7 @@ Nothing -> throwIO exc Just pair2 -> pure pair2 pc <- view pantryConfigL - let urlPrefix = hscDownloadPrefix $ pcHackageSecurity pc + let urlPrefix = picDownloadPrefix $ pcPackageIndex pc url = mconcat [ urlPrefix
src/Pantry/Types.hs view
@@ -15,7 +15,9 @@ {-# LANGUAGE NamedFieldPuns #-} module Pantry.Types ( PantryConfig (..) + , PackageIndexConfig (..) , HackageSecurityConfig (..) + , defaultHackageSecurityConfig , Storage (..) , HasPantryConfig (..) , BlobKey (..) @@ -248,7 +250,7 @@ -- -- @since 0.1.0.0 data PantryConfig = PantryConfig - { pcHackageSecurity :: !HackageSecurityConfig + { pcPackageIndex :: !PackageIndexConfig , pcHpackExecutable :: !HpackExecutable , pcRootDir :: !(Path Abs Dir) , pcStorage :: !Storage @@ -607,32 +609,70 @@ [x, y] | not (T.null x || T.null y) -> return (GitHubRepo s) _ -> fail "expecting \"user/repo\"" --- | Configuration for Hackage Security to securely download package --- metadata and contents from Hackage. For most purposes, you'll want --- to use the default Hackage settings via --- @defaultHackageSecurityConfig@. +-- | Configuration to securely download package metadata and contents. For most +-- purposes, you'll want to use the default Hackage settings via +-- @defaultPackageIndexConfig@. -- -- /NOTE/ It's highly recommended to only use the official Hackage -- server or a mirror. See -- <https://github.com/commercialhaskell/stack/issues/4137>. -- --- @since 0.1.0.0 +-- @since 0.6.0 +data PackageIndexConfig = PackageIndexConfig + { picDownloadPrefix :: !Text + , picHackageSecurityConfig :: !HackageSecurityConfig + } + deriving Show + +-- | If the @hackage-security@ key is absent from the JSON object, assigns +-- default value 'defaultHackageSecurityConfig'. +-- +-- @since 0.6.0 +instance FromJSON (WithJSONWarnings PackageIndexConfig) where + parseJSON = withObjectWarnings "PackageIndexConfig" $ \o -> do + picDownloadPrefix <- o ..: "download-prefix" + picHackageSecurityConfig <- jsonSubWarnings $ + o ..:? "hackage-security" ..!= noJSONWarnings defaultHackageSecurityConfig + pure PackageIndexConfig {..} + +-- | Default 'HackageSecurityConfig' value using the official Hackage server. +-- +-- @since 0.6.0 +defaultHackageSecurityConfig :: HackageSecurityConfig +defaultHackageSecurityConfig = HackageSecurityConfig + { hscKeyIds = + [ "0a5c7ea47cd1b15f01f5f51a33adda7e655bc0f0b0615baa8e271f4c3351e21d" + , "1ea9ba32c526d1cc91ab5e5bd364ec5e9e8cb67179a471872f6e26f0ae773d42" + , "2c6c3627bd6c982990239487f1abd02e08a02e6cf16edb105a8012d444d870c3" + , "51f0161b906011b52c6613376b1ae937670da69322113a246a09f807c62f6921" + , "fe331502606802feac15e514d9b9ea83fee8b6ffef71335479a2e68d84adc6b0" + ] + , hscKeyThreshold = 3 + , hscIgnoreExpiry = False + } + +-- | Configuration for Hackage Security to securely download package metadata +-- and contents. For most purposes, you'll want to use the default Hackage +-- settings via @defaultHackageSecurityConfig@. +-- +-- /NOTE/ It's highly recommended to only use the official Hackage +-- server or a mirror. See +-- <https://github.com/commercialhaskell/stack/issues/4137>. +-- +-- @since 0.6.0 data HackageSecurityConfig = HackageSecurityConfig { hscKeyIds :: ![Text] , hscKeyThreshold :: !Int - , hscDownloadPrefix :: !Text , hscIgnoreExpiry :: !Bool } deriving Show + instance FromJSON (WithJSONWarnings HackageSecurityConfig) where - parseJSON = withObjectWarnings "HackageSecurityConfig" $ \o' -> do - hscDownloadPrefix <- o' ..: "download-prefix" - Object o <- o' ..: "hackage-security" + parseJSON = withObjectWarnings "HackageSecurityConfig" $ \o -> do hscKeyIds <- o ..: "keyids" hscKeyThreshold <- o ..: "key-threshold" hscIgnoreExpiry <- o ..:? "ignore-expiry" ..!= True pure HackageSecurityConfig {..} - -- | An environment which contains a 'PantryConfig'. --