Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add import lists #112

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions int/Pantry/HPack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ import Data.Char ( isDigit, isSpace )
import qualified Hpack
import qualified Hpack.Config as Hpack
import Pantry.Types
( HasPantryConfig, HpackExecutable (..), PantryConfig (..)
, Version, pantryConfigL, parseVersionThrowing
)
import Path
( Abs, Dir, Path, (</>), filename, parseRelFile, toFilePath )
import Path.IO ( doesFileExist )
import RIO
import RIO.Process
( HasProcessContext, proc, readProcessStdout_, runProcess_
, withWorkingDir
)

hpackVersion ::
(HasPantryConfig env, HasLogFunc env, HasProcessContext env)
Expand Down
4 changes: 2 additions & 2 deletions int/Pantry/SHA256.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ module Pantry.SHA256
, toRaw
) where

import Conduit
import Conduit ( ConduitT )
import qualified Crypto.Hash as Hash ( Digest, SHA256, hash, hashlazy )
import qualified Crypto.Hash.Conduit as Hash ( hashFile, sinkHash )
import Data.Aeson
import Data.Aeson ( FromJSON (..), ToJSON (..), withText )
import qualified Data.ByteArray
import qualified Data.ByteArray.Encoding as Mem
import Data.StaticBytes
Expand Down
6 changes: 4 additions & 2 deletions int/Pantry/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,13 @@ module Pantry.Types
) where

import Casa.Client ( CasaRepoPrefix )
import Database.Persist
import Database.Persist.Sql
import Database.Persist.Class.PersistField ( PersistField (..) )
import Database.Persist.PersistValue ( PersistValue (..) )
import Database.Persist.Sql ( PersistFieldSql (..), SqlBackend )
#if MIN_VERSION_persistent(2, 13, 0)
import Database.Persist.SqlBackend.Internal ( connRDBMS )
#endif
import Database.Persist.Types ( SqlType (..) )
import Data.Aeson.Encoding.Internal ( unsafeToEncoding )
import Data.Aeson.Types
( FromJSON (..), FromJSONKey (..), FromJSONKeyFunction (..)
Expand Down
10 changes: 7 additions & 3 deletions src/Hackage/Security/Client/Repository/HttpLib/HttpClient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ module Hackage.Security.Client.Repository.HttpLib.HttpClient
( httpLib
) where

import Control.Exception
import Control.Exception ( handle )
import Control.Monad ( void )
import Data.ByteString ( ByteString )
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS.C8
import Hackage.Security.Client hiding ( Header )
import Hackage.Security.Client ( SomeRemoteError (..) )
import Hackage.Security.Client.Repository.HttpLib
( BodyReader, HttpLib (..), HttpRequestHeader (..)
, HttpResponseHeader (..), HttpStatus (..)
)
import Hackage.Security.Util.Checked
import Network.URI
( Throws, handleChecked, throwChecked )
import Network.URI ( URI )
import qualified Pantry.HTTP as HTTP

{-------------------------------------------------------------------------------
Expand Down
72 changes: 61 additions & 11 deletions src/Pantry.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ module Pantry
, CabalFileInfo (..)
, Revision (..)
, PackageIdentifierRevision (..)
, UsePreferredVersions (..)
, UsePreferredVersions

-- ** Archives
, RawArchive (..)
Expand Down Expand Up @@ -180,7 +180,7 @@ module Pantry
-- * Hackage index
, updateHackageIndex
, DidUpdateOccur (..)
, RequireHackageIndex (..)
, RequireHackageIndex
, hackageIndexTarballL
, getHackagePackageVersions
, getLatestHackageVersion
Expand All @@ -196,7 +196,7 @@ module Pantry
) where

import Casa.Client ( CasaRepoPrefix, thParserCasaRepo )
import Conduit
import Conduit ( (.|), mapC, mapMC, runConduitRes, sinkList, sumC )
import Control.Applicative ( empty )
import Control.Arrow ( right )
import Control.Monad.State.Strict ( State, execState, get, modify' )
Expand All @@ -214,7 +214,7 @@ import Data.Monoid ( Endo (..) )
import Data.Time ( diffUTCTime, getCurrentTime )
import qualified Data.Yaml as Yaml
import Data.Yaml.Include ( decodeFileWithWarnings )
import Database.Persist ( entityKey )
import Database.Persist.Class.PersistEntity ( entityKey )
import Distribution.PackageDescription
( FlagName, GenericPackageDescription )
import qualified Distribution.PackageDescription as D
Expand All @@ -223,17 +223,66 @@ import qualified Hpack
import qualified Hpack.Config as Hpack
import Hpack.Error ( formatHpackError )
import Hpack.Yaml ( formatWarning )
import Network.HTTP.Download
import Network.HTTP.Download ( download, redownload )
import Pantry.Archive
import Pantry.Casa
import Pantry.HTTP
( fetchArchives, findCabalOrHpackFile, getArchive
, getArchiveKey, getArchivePackage
)
import Pantry.Casa ( casaBlobSource, casaLookupKey, casaLookupTree )
import Pantry.HTTP ( httpSinkChecked, parseRequest )
import Pantry.Hackage
( DidUpdateOccur (..), RequireHackageIndex
, UsePreferredVersions, getHackageCabalFile
, getHackagePackageVersionRevisions
, getHackagePackageVersions, getHackageTarball
, getHackageTarballKey, getHackageTypoCorrections
, hackageIndexTarballL, htrPackage, updateHackageIndex
)
import Pantry.Repo
( fetchRepos, fetchReposRaw, getRepo, getRepoKey, withRepo )
import qualified Pantry.SHA256 as SHA256
import Pantry.Storage hiding
( TreeEntry, PackageName, Version, findOrGenerateCabalFile )
import Pantry.Tree
import Pantry.Storage
( getSnapshotCacheByHash, getSnapshotCacheId, getTreeForKey
, initStorage, loadBlob, loadCachedTree
, loadExposedModulePackages, loadPackageById, loadURLBlob
, storeSnapshotModuleCache, storeTree, storeURLBlob
, withStorage
)
import Pantry.Tree ( rawParseGPD, unpackTree )
import Pantry.Types as P
( Archive (..), ArchiveLocation (..), BlobKey (..)
, CabalFileInfo (..), CabalString (..), FileSize (..)
, FuzzyResults (..), HackageSecurityConfig (..)
, HasPantryConfig (..), HpackExecutable (..), Mismatch (..)
, ModuleName, Package (..), PackageCabal (..)
, PackageIdentifier (..), PackageIdentifierRevision (..)
, PackageIndexConfig (..), PackageLocation (..)
, PackageLocationImmutable (..), PackageMetadata (..)
, PackageName, PantryConfig (..), PantryException (..)
, PHpack (..), PrintWarnings (..), RawArchive (..)
, RawPackageLocation (..), RawPackageLocationImmutable (..)
, RawPackageMetadata (..), RawSnapshot (..)
, RawSnapshotLayer (..), RawSnapshotLocation (..)
, RawSnapshotPackage (..), RelFilePath (..), Repo (..)
, RepoType (..), ResolvedPath (..), Revision (..)
, SafeFilePath, SHA256, SimpleRepo (..), SnapName (..)
, Snapshot (..), SnapshotCacheHash (..), SnapshotLayer (..)
, SnapshotLocation (..), SnapshotPackage (..), Tree (..)
, TreeEntry (..), TreeKey (..), Unresolved, Version
, WantedCompiler (..), bsToBlobKey, cabalFileName
, defaultHackageSecurityConfig, defaultSnapshotLocation
, flagNameString, getGlobalHintsFile, mkSafeFilePath
, moduleNameString, packageIdentifierString
, packageNameString, parseFlagName, parseHackageText
, parsePackageIdentifier, parsePackageIdentifierRevision
, parsePackageName, parsePackageNameThrowing
, parseRawSnapshotLocation, parseSnapName, parseTreeM
, parseVersion, parseVersionThrowing, parseWantedCompiler
, pirForHash, resolvePaths, snapshotLocation
, toCabalStringMap, toRawPL, toRawPLI, toRawPM, toRawSL
, toRawSnapshotLayer, unCabalStringMap, unSafeFilePath
, versionString, warnMissingCabalFile
)
import Path
( Abs, Dir, File, Path, (</>), filename, parent, parseAbsDir
, parseRelFile, toFilePath
Expand All @@ -249,6 +298,7 @@ import RIO.PrettyPrint ( HasTerm (..) )
import RIO.PrettyPrint.StylesUpdate
( HasStylesUpdate (..), StylesUpdate )
import RIO.Process
( HasProcessContext (..), proc, runProcess_, withWorkingDir )
import qualified RIO.Set as Set
import RIO.Text ( unpack )
import qualified RIO.Text as T
Expand Down Expand Up @@ -992,7 +1042,7 @@ tryLoadPackageRawViaCasa rlpi treeKey' = runMaybeT $ do
lift $ fetchTreeKeys [rlpi]
tryViaLocalDb treeKey'' <|> warn treeKey''
where
tryViaLocalDb = MaybeT . (tryLoadPackageRawViaLocalDb rlpi)
tryViaLocalDb = MaybeT . tryLoadPackageRawViaLocalDb rlpi
warn treeKey'' = do
lift $ logWarn $
"Did not find tree key in DB after pulling it from Casa: "
Expand Down
27 changes: 22 additions & 5 deletions src/Pantry/Archive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,43 @@ module Pantry.Archive

import qualified Codec.Archive.Zip as Zip
import Conduit
( ConduitT, (.|), runConduit, sinkHandle, sinkList
, sourceHandle, sourceLazy, withSourceFile
)
import Data.Bits ( (.&.), shiftR )
import qualified Data.Conduit.Tar as Tar
import Data.Conduit.Zlib ( ungzip )
import qualified Data.Digest.CRC32 as CRC32
import Distribution.PackageDescription ( package, packageDescription )
import qualified Hpack.Config as Hpack
import Pantry.HPack ( hpackVersion )
import Pantry.HTTP
import Pantry.HTTP ( httpSinkChecked )
import Pantry.Internal ( makeTarRelative, normalizeParents )
import qualified Pantry.SHA256 as SHA256
import Pantry.Storage hiding
( Tree, TreeEntry, findOrGenerateCabalFile )
import Pantry.Tree
import Pantry.Storage
( BlobId, CachedTree (..), TreeId, hpackToCabal
, loadArchiveCache, loadBlob, loadCabalBlobKey
, loadCachedTree, loadPackageById, storeArchiveCache
, storeBlob, storeHPack, storeTree, unCachedTree, withStorage
)
import Pantry.Tree ( rawParseGPD )
import Pantry.Types
( Archive, ArchiveLocation (..), BlobKey, BuildFile (..)
, FileSize (..), FileType (..), HasPantryConfig
, Mismatch (..), Package (..), PackageCabal (..)
, PackageIdentifier (..), PackageMetadata (..)
, PantryException (..), PHpack (..), RawArchive (..)
, RawPackageLocationImmutable (..), RawPackageMetadata (..)
, ResolvedPath (..), SHA256, Tree (..), TreeEntry (..)
, TreeKey, cabalFileName, hpackSafeFilePath, mkSafeFilePath
, toRawArchive, toRawPM, unSafeFilePath
)
import Path ( toFilePath )
import RIO
import qualified RIO.ByteString.Lazy as BL
import qualified RIO.List as List
import qualified RIO.Map as Map
import RIO.Process
import RIO.Process ( HasProcessContext )
import qualified RIO.Set as Set
import qualified RIO.Text as T
import qualified RIO.Text.Partial as T
Expand Down
4 changes: 3 additions & 1 deletion src/Pantry/Casa.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

module Pantry.Casa where

import Database.Persist.Sql ( SqlBackend )
import qualified Casa.Client as Casa
import qualified Casa.Types as Casa
import Conduit
( ConduitT, ResourceT, (.|), await, mapMC, runConduitRes )
import qualified Data.HashMap.Strict as HM
import qualified Pantry.SHA256 as SHA256
import Pantry.Storage hiding ( findOrGenerateCabalFile )
import Pantry.Storage ( storeBlob, withStorage )
import Pantry.Types as P
import RIO
import qualified RIO.ByteString as B
Expand Down
4 changes: 3 additions & 1 deletion src/Pantry/HTTP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Pantry.HTTP
, httpSinkChecked
) where

import Conduit
import Conduit ( ConduitT, ZipSink (..), await, getZipSink )
import Network.HTTP.Client as Export
( BodyReader, HttpExceptionContent (StatusCodeException)
, parseRequest, parseUrlThrow
Expand All @@ -28,6 +28,8 @@ import Network.HTTP.Types as Export
)
import qualified Pantry.SHA256 as SHA256
import Pantry.Types
( FileSize (..), Mismatch (..), PantryException (..), SHA256
)
import RIO
import qualified RIO.ByteString as B
import qualified RIO.Text as T
Expand Down
43 changes: 36 additions & 7 deletions src/Pantry/Hackage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@ module Pantry.Hackage
) where

import Conduit
( ZipSink (..), (.|), getZipSink, runConduit, sinkLazy
, sinkList, sourceHandle, takeC, takeCE
)
import Data.Aeson
( FromJSON (..), Value (..), (.:), eitherDecode'
, withObject
)
import Data.Conduit.Tar
( FileInfo (..), FileType (..), untar )
import qualified Data.List.NonEmpty as NE
import Data.Text.Metrics (damerauLevenshtein)
import Data.Text.Unsafe ( unsafeTail )
import Data.Time ( getCurrentTime )
import Database.Persist.Sql ( SqlBackend )
import Distribution.PackageDescription ( GenericPackageDescription )
import qualified Distribution.PackageDescription as Cabal
import qualified Distribution.Text
Expand All @@ -40,13 +48,34 @@ import qualified Hackage.Security.Client.Repository.Remote as HS
import qualified Hackage.Security.Util.Path as HS
import qualified Hackage.Security.Util.Pretty as HS
import Network.URI ( parseURI )
import Pantry.Archive
import Pantry.Casa
import Pantry.Archive ( getArchive )
import Pantry.Casa ( casaLookupKey )
import qualified Pantry.SHA256 as SHA256
import Pantry.Storage hiding
( PackageName, TreeEntry, Version, findOrGenerateCabalFile )
import Pantry.Tree
import Pantry.Types hiding ( FileType (..) )
import Pantry.Storage
( CachedTree (..), TreeId, BlobId, clearHackageRevisions
, countHackageCabals, getBlobKey, loadBlobById, loadBlobBySHA
, loadHackagePackageVersion, loadHackagePackageVersions
, loadHackageTarballInfo, loadHackageTree, loadHackageTreeKey
, loadLatestCacheUpdate, loadPreferredVersion
, sinkHackagePackageNames, storeBlob, storeCacheUpdate
, storeHackageRevision, storeHackageTarballInfo
, storeHackageTree, storePreferredVersion, storeTree
, unCachedTree, withStorage
)
import Pantry.Tree ( rawParseGPD )
import Pantry.Types
( ArchiveLocation (..), BlobKey (..), BuildFile (..)
, CabalFileInfo (..), FileSize (..), FuzzyResults (..)
, HackageSecurityConfig (..), HasPantryConfig (..)
, Mismatch (..), Package (..), PackageCabal (..)
, PackageIdentifier (..), PackageIdentifierRevision (..)
, PackageIndexConfig (..), PackageName, PantryConfig (..)
, PantryException (..), RawArchive (..)
, RawPackageLocationImmutable (..), RawPackageMetadata (..)
, Revision, SHA256, Storage (..), TreeEntry (..), TreeKey
, Version, cabalFileName, packageNameString, parsePackageName
, unSafeFilePath
)
import Path
( Abs, Dir, File, Path, Rel, (</>), parseRelDir, parseRelFile
, toFilePath
Expand All @@ -55,7 +84,7 @@ import RIO
import qualified RIO.ByteString as B
import qualified RIO.ByteString.Lazy as BL
import qualified RIO.Map as Map
import RIO.Process
import RIO.Process ( HasProcessContext )
import qualified RIO.Text as T
#if !MIN_VERSION_rio(0,1,16)
-- Now provided by RIO from the rio package. Resolvers before lts-15.16
Expand Down
19 changes: 17 additions & 2 deletions src/Pantry/Repo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,20 @@ module Pantry.Repo
) where

import Database.Persist ( Entity (..) )
import Pantry.Archive
import Pantry.Storage hiding ( findOrGenerateCabalFile )
import Pantry.Archive ( getArchivePackage )
import Pantry.Storage
( getTreeForKey, loadPackageById, loadRepoCache
, storeRepoCache, withStorage
)
import Pantry.Types
( AggregateRepo (..), ArchiveLocation (..), HasPantryConfig
, Package (..), PackageMetadata (..), PantryException (..)
, RawArchive (..), RawPackageLocationImmutable (..)
, RawPackageMetadata (..), RelFilePath (..), Repo (..)
, RepoType (..), ResolvedPath (..), SimpleRepo (..)
, TreeKey (..), arToSimpleRepo, rToSimpleRepo
, toAggregateRepos, toRawPM
)
import Path.IO ( resolveFile' )
import RIO
import RIO.ByteString ( isInfixOf )
Expand All @@ -27,6 +38,10 @@ import RIO.Directory ( doesDirectoryExist )
import RIO.FilePath ( (</>) )
import qualified RIO.Map as Map
import RIO.Process
( ExitCodeException (..), HasProcessContext, proc
, readProcess, readProcess_, withModifyEnvVars
, withWorkingDir
)
import qualified RIO.Text as T
import System.Console.ANSI ( hSupportsANSIWithoutEmulation )
import System.IsWindows ( osIsWindows )
Expand Down
4 changes: 4 additions & 0 deletions src/Pantry/SQLite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ module Pantry.SQLite
import Control.Concurrent.Companion
( Companion, onCompanionDone, withCompanion )
import Database.Persist.Sqlite
( Migration, extraPragmas, fkEnabled, mkSqliteConnectionInfo
, runMigrationSilent, runSqlConn, walEnabled
, withSqliteConnInfo
)
import Pantry.Types
( PantryException (MigrationFailure), Storage (..) )
import Path ( Abs, File, Path, parent, toFilePath )
Expand Down
Loading