stackage-sandbox 0.1.3 → 0.1.4
raw patch · 3 files changed
+41/−1 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +4/−0
- main/Sandbox.hs +36/−0
- stackage-sandbox.cabal +1/−1
ChangeLog.md view
@@ -1,3 +1,7 @@+## 0.1.4++* Added temporary solution for detecting wrong ghc version on path. (#1)+ ## 0.1.3 * Added stk sandbox print (#3)
main/Sandbox.hs view
@@ -61,6 +61,7 @@ | InvalidSnapshot Snapshot | GhcVersionFail | PackageDbNotFound+ | WrongGhc Text Text Snapshot deriving (Show, Typeable) instance Exception SandboxException @@ -172,6 +173,8 @@ when cabalSandboxConfigExists $ do throwIO ConfigAlreadyExists + verifyGhcCompat msnapshot+ cabalConfigExists <- doesFileExist "cabal.config" configAdded <- if (not cabalConfigExists) then do@@ -186,6 +189,7 @@ Just s -> throwIO $ SnapshotMismatch s configSnapshot Nothing -> return configSnapshot + -- TODO: MonadLogger T.putStrLn $ "Initializing at snapshot: " <> snapshot dir <- getSnapshotDir snapshot@@ -504,6 +508,34 @@ then putStrLn sandbox else putStrLn path +-- TODO: replace with functionality from stackage-common.+approxSnapshotFor :: Maybe Snapshot -> IO Snapshot+approxSnapshotFor Nothing = return "lts"+approxSnapshotFor (Just s) = return s++-- TODO: replace with functionality from stackage-common.+approxGhcVersionFor :: Snapshot -> IO Text+approxGhcVersionFor s =+ if T.isPrefixOf "lts-2" s || T.isPrefixOf "lts-1" s || T.isPrefixOf "lts-0" s ||+ T.isPrefixOf "lts/2" s || T.isPrefixOf "lts/1" s || T.isPrefixOf "lts/0" s ||+ s == "lts" -- assumption: current lts = 2+ then return "ghc-7.8.4"+ else+ case T.stripPrefix "nightly" s of+ Nothing -> return "ghc-7.8.4" -- Not sure what to do, default to 7.8+ Just "" -> return "ghc-7.10.1"+ Just s' | s' < "-2015-05-05" -> return "ghc-7.8.4"+ Just _ | otherwise -> return "ghc-7.10.1"++verifyGhcCompat :: Maybe Snapshot -> IO ()+verifyGhcCompat mSnapshot = do+ ghcVersion <- getGhcVersion+ snapshot <- approxSnapshotFor mSnapshot+ ghcVersion' <- approxGhcVersionFor snapshot+ when (ghcVersion /= ghcVersion') $ do+ throwIO $ WrongGhc ghcVersion ghcVersion' snapshot++ handleSandboxExceptions :: SandboxException -> IO () handleSandboxExceptions NoHomeEnvironmentVariable = do hPutStrLn stderr "Couldn't find the HOME environment variable"@@ -548,6 +580,10 @@ exitFailure handleSandboxExceptions PackageDbNotFound = do hPutStrLn stderr $ "Couldn't find sandbox package-db"+ exitFailure+handleSandboxExceptions (WrongGhc old new snapshot) = do+ T.hPutStrLn stderr $ "Found " <> old <> " on path"+ T.hPutStrLn stderr $ "Need " <> new <> " to use snapshot " <> snapshot exitFailure handlePluginExceptions :: PluginException -> IO ()
stackage-sandbox.cabal view
@@ -1,5 +1,5 @@ name: stackage-sandbox-version: 0.1.3+version: 0.1.4 synopsis: Work with shared stackage sandboxes description: