From ee373b4b87647842b50206a21ef0f30d2cef42aa Mon Sep 17 00:00:00 2001 From: "Boris M. Yartsev" Date: Sat, 1 Jul 2017 18:18:57 +0300 Subject: [PATCH] Added allupdate command, that updates stackage and hackage alltogether --- REPL/index-project.cabal | 5 ++--- REPL/src/AllCommands.hs | 42 +++++++++++++++++++++++++++++++++++++ REPL/src/HackageCommands.hs | 1 + REPL/src/REPL.hs | 4 ++++ 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 REPL/src/AllCommands.hs diff --git a/REPL/index-project.cabal b/REPL/index-project.cabal index 69689d0..c6d5e42 100644 --- a/REPL/index-project.cabal +++ b/REPL/index-project.cabal @@ -15,10 +15,9 @@ cabal-version: >=1.10 library hs-source-dirs: src - other-modules: Common, FileUtils, HttpDownload, HackageUpdate, REPL - , HackageCommands, StackageUpdate, StackageCommands, StackageArchive + other-modules: Common, FileUtils, HttpDownload, HackageUpdate, REPL, StackageUpdate - exposed-modules: IndexProject, HackageArchive + exposed-modules: IndexProject, HackageArchive, StackageArchive, HackageCommands, StackageCommands, AllCommands build-depends: base >= 4.7 && < 5 , directory , containers diff --git a/REPL/src/AllCommands.hs b/REPL/src/AllCommands.hs new file mode 100644 index 0000000..52a710f --- /dev/null +++ b/REPL/src/AllCommands.hs @@ -0,0 +1,42 @@ +module AllCommands(totalUpdate) where + +import Common +import qualified HackageCommands as HC +import qualified StackageCommands as SC +import qualified HackageArchive as HA + +totalUpdate :: UpdateInfo -> IO() +totalUpdate ui = do + putStrLn "Total update of a system!" + + putStrLn "Stackage update..." + SC.updatePersistentMapFromLTS sud ltsFileDir ltsURL snapshotsURL + + putStrLn "Hackage update..." + HC.updateTotalArchive updateCommand unzipCommand persistCommand + + where + sud = (getLTSPersistDir.sui) ui + ltsFileDir = getLTSFilesDir (sui ui) + ltsURL = suiLTSURL (sui ui) + snapshotsURL = (getSnapshotURL.sui) ui + + arch = (getArchive.iuh) ui + archURL = (iuhArchiveURL.iuh) ui + snapURL = (iuhSnapshotURL.iuh) ui + trFile = (getTar.iuh) ui + ud = (getArchivePersistDir.iuh) ui + + updateCommand = HC.updateArchive snapURL archURL arch + unzipCommand = HC.unzipArchive arch trFile + persistCommand = HC.updatePersistentFromTar ud trFile +{- +queryCombinedData :: UpdateInfo -> PackageName -> IO() +queryCombinedData ui package = do + value <- HA.queryPersistentMap hUpdateDir package + return () + where + sUpdateDir = (getLTSPersistDir.sui) ui + hUpdateDir = (getArchivePersistDir.iuh) ui + +-} \ No newline at end of file diff --git a/REPL/src/HackageCommands.hs b/REPL/src/HackageCommands.hs index 61caa87..2716bab 100644 --- a/REPL/src/HackageCommands.hs +++ b/REPL/src/HackageCommands.hs @@ -148,3 +148,4 @@ showPersistentTarCompare updateDir tarFile = do newTar <- loadTar tarFile let newMap = buildHackageMap newTar (buildPreHackageMap newTar) printPersistentDiffMap updateDir newMap + diff --git a/REPL/src/REPL.hs b/REPL/src/REPL.hs index dac2d1c..224b1e2 100644 --- a/REPL/src/REPL.hs +++ b/REPL/src/REPL.hs @@ -15,6 +15,7 @@ import Network.HTTP.Client(HttpException) import Common import qualified HackageCommands as HC import qualified StackageCommands as SC +import qualified AllCommands as AC processREPLCycle :: UpdateInfo -> IO () processREPLCycle ui = forever $ do @@ -34,6 +35,8 @@ buildCommand :: UpdateInfo -> (String -> IO()) buildCommand ui = processCommand where processCommand command + -- updates all + | chk "allupdate" = AC.totalUpdate ui -- checks the current hackage gzip archive and understands what to download | chk "check" = HC.showUpdateData arch snapURL -- updates the gzip archive file, unpacks it to tar and loads in the permanent storage @@ -119,6 +122,7 @@ buildCommand ui = processCommand updateCommand = HC.updateArchive snapURL archURL arch unzipCommand = HC.unzipArchive arch trFile persistCommand = HC.updatePersistentFromTar ud trFile + ltsFileDir = getLTSFilesDir (sui ui) ltsURL = suiLTSURL (sui ui) sud = (getLTSPersistDir.sui) ui