Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
devops committed Jul 25, 2024
2 parents 741d007 + 698c143 commit a2990b6
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 362 deletions.
24 changes: 12 additions & 12 deletions booster/tools/rpc-client/RpcClient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module RpcClient (
) where

import Codec.Archive.Tar qualified as Tar
import Codec.Archive.Tar.Check qualified as Tar
import Codec.Archive.Tar.Entry qualified as Tar
import Codec.Compression.BZip qualified as BZ2
import Codec.Compression.GZip qualified as GZip
import Control.Exception
Expand Down Expand Up @@ -505,20 +505,24 @@ runTarball common (Just sock) tarFile keepGoing runOnly compareDetails = do
| ".tar.bz2" `isSuffixOf` takeExtensions tarFile = Tar.read . BZ2.decompress
| otherwise = Tar.read

containedFiles <- unpackTar <$> BS.readFile tarFile
let checked = Tar.checkSecurity containedFiles
entries <- Tar.decodeLongNames . unpackTar <$> BS.readFile tarFile
-- probe server connection before doing anything, display
-- instructions unless server was found.
runAllRequests checked sock
runAllRequests entries sock
where
runAllRequests ::
Tar.Entries (Either Tar.FormatError Tar.FileNameError) -> Socket -> IO ()
Tar.GenEntries
FilePath
a
(Either Tar.FormatError Tar.DecodeLongNamesError) ->
Socket ->
IO ()
runAllRequests checked skt = cancelIfInterrupted skt $ do
withTempDir $ \tmp -> withLogLevel common.logLevel $ do
-- unpack relevant tar files (rpc_* directories only)
logInfo_ $ unwords ["unpacking json files from tarball", tarFile, "into", tmp]
(jsonFiles, sequenceMap) <-
liftIO $ Tar.foldEntries (unpackIfRpc tmp) (pure mempty) throwAnyError checked
liftIO $ Tar.foldEntries (unpackIfRpc tmp) (pure mempty) (error . show) checked
logInfo_ $ "RPC data:" <> show jsonFiles
logInfo_ $ "Sequence data:" <> show sequenceMap

Expand All @@ -543,10 +547,6 @@ runTarball common (Just sock) tarFile keepGoing runOnly compareDetails = do
liftIO $ shutdown skt ShutdownReceive
liftIO $ exitWith (if all isNothing results then ExitSuccess else ExitFailure 2)

-- complain on any errors in the tarball
throwAnyError :: Either Tar.FormatError Tar.FileNameError -> IO a
throwAnyError = either throwIO throwIO

compareSequence :: Ord a => Ord b => Map.Map a b -> a -> a -> Ordering
compareSequence seqMap a b = case (Map.lookup a seqMap, Map.lookup b seqMap) of
(Nothing, Nothing) -> compare a b
Expand All @@ -557,11 +557,11 @@ runTarball common (Just sock) tarFile keepGoing runOnly compareDetails = do
-- unpack all */*.json files into dir and return their names
unpackIfRpc ::
FilePath ->
Tar.Entry ->
Tar.GenEntry FilePath a ->
IO ([FilePath], Map.Map FilePath Int) ->
IO ([FilePath], Map.Map FilePath Int)
unpackIfRpc tmpDir entry acc = do
case splitFileName (Tar.entryPath entry) of
case splitFileName (Tar.entryTarPath entry) of
-- unpack all directories "<something>" containing "*.json" files
(dir, "") -- directory
| Tar.Directory <- Tar.entryContent entry -> do
Expand Down
12 changes: 9 additions & 3 deletions cabal.project.freeze
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ constraints: any.Cabal ==3.10.3.0,
any.bytesmith ==0.3.11.1,
any.bytestring ==0.11.5.3,
any.bz2 ==1.0.1.2,
any.cabal-doctest ==1.0.9,
any.cabal-doctest ==1.0.10,
any.call-stack ==0.4.0,
any.case-insensitive ==1.2.1.0,
any.casing ==0.1.4.1,
Expand Down Expand Up @@ -81,6 +81,7 @@ constraints: any.Cabal ==3.10.3.0,
any.extra ==1.7.16,
any.fast-logger ==3.2.3,
any.fgl ==5.8.2.0,
any.file-embed ==0.0.11.2,
any.filepath ==1.4.300.1,
any.free ==5.2,
any.generic-lens ==2.2.2.0,
Expand All @@ -91,6 +92,7 @@ constraints: any.Cabal ==3.10.3.0,
any.ghc-compact ==0.1.0.0,
any.ghc-events ==0.19.0.1,
any.ghc-prim ==0.10.0,
any.ghc-prof ==1.4.1.12,
any.ghc-trace-events ==0.1.2.9,
any.gitrev ==1.3.1,
any.graphviz ==2999.20.2.0,
Expand All @@ -117,6 +119,7 @@ constraints: any.Cabal ==3.10.3.0,
any.integer-logarithms ==1.0.3.1,
any.intern ==0.9.5,
any.invariant ==0.6.3,
any.js-jquery ==3.3.1,
any.json-rpc ==1.0.4,
any.junit-xml ==0.1.0.3,
any.kan-extensions ==5.2.6,
Expand Down Expand Up @@ -148,6 +151,7 @@ constraints: any.Cabal ==3.10.3.0,
any.old-locale ==1.0.0.7,
any.old-time ==1.1.0.4,
any.optparse-applicative ==0.18.1.0,
any.os-string ==2.0.2.2,
any.parallel ==3.2.2.0,
any.parsec ==3.1.16.1,
any.parser-combinators ==1.3.0,
Expand All @@ -162,6 +166,8 @@ constraints: any.Cabal ==3.10.3.0,
any.primitive-offset ==0.2.0.1,
any.primitive-unlifted ==2.1.0.0,
any.process ==1.6.19.0,
any.profiteur ==0.4.7.0,
profiteur +embed-data-files,
any.profunctors ==5.6.2,
any.quickcheck-instances ==0.3.30,
quickcheck-instances -bytestring-builder,
Expand Down Expand Up @@ -198,7 +204,7 @@ constraints: any.Cabal ==3.10.3.0,
any.string-conversions ==0.4.0.1,
any.syb ==0.7.2.4,
any.tagged ==0.8.8,
any.tar ==0.5.1.1,
any.tar ==0.6.3.0,
any.tasty ==1.4.3,
tasty +unix,
any.tasty-discover ==5.0.0,
Expand Down Expand Up @@ -254,4 +260,4 @@ constraints: any.Cabal ==3.10.3.0,
any.yaml ==0.11.11.2,
any.zigzag ==0.0.1.0,
any.zlib ==0.6.3.0
index-state: hackage.haskell.org 2024-05-24T09:11:31Z
index-state: hackage.haskell.org 2024-07-22T06:21:59Z
27 changes: 0 additions & 27 deletions dev-tools/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,33 +173,6 @@ executables:
- hs-backend-booster
ghc-options:
- -rtsopts
tarball-compare:
source-dirs: tarball-compare
main: Main
dependencies:
- aeson
- aeson-pretty
- base
- bytestring
- bz2
- clock
- containers
- directory
- extra
- filepath
- hs-backend-booster
- kore-rpc-types
- monad-logger
- optparse-applicative
- prettyprinter
- recursion-schemes
- tar
- text
- transformers
- vector
- zlib
ghc-options:
- -rtsopts
kore-rpc-dev:
source-dirs: kore-rpc-dev
main: Server.hs
Expand Down
Loading

0 comments on commit a2990b6

Please sign in to comment.