aboutsummaryrefslogtreecommitdiff
path: root/src/CabalHelper/Compiletime/Program/CabalInstall.hs
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2019-08-06 19:39:23 +0200
committerDaniel Gröber <dxld@darkboxed.org>2020-05-10 21:50:44 +0200
commitbda559bf059ee42e3e01c1280f7a64dd2673d725 (patch)
treebdfe97db7a53bd68638a6a7f102cd0942456e948 /src/CabalHelper/Compiletime/Program/CabalInstall.hs
parentf606584fd104f864694e4fb9b943ef13904cdc96 (diff)
Refactor Program versions handling
This mainly renames the program version getters to get* and make them consistenly return Version directly. Such that wrappers like GhcVersion have to be added at the callsites of the relevant functions.
Diffstat (limited to 'src/CabalHelper/Compiletime/Program/CabalInstall.hs')
-rw-r--r--src/CabalHelper/Compiletime/Program/CabalInstall.hs17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/CabalHelper/Compiletime/Program/CabalInstall.hs b/src/CabalHelper/Compiletime/Program/CabalInstall.hs
index 40f0561..36d6c63 100644
--- a/src/CabalHelper/Compiletime/Program/CabalInstall.hs
+++ b/src/CabalHelper/Compiletime/Program/CabalInstall.hs
@@ -57,11 +57,16 @@ newtype CabalInstallVersion = CabalInstallVersion { cabalInstallVer :: Version }
data HEAD = HEAD deriving (Eq, Show)
-cabalInstallVersion :: (Verbose, Progs) => IO CabalInstallVersion
-cabalInstallVersion = do
- CabalInstallVersion . parseVer . trim
+getCabalInstallVersion :: (Verbose, Progs) => IO Version
+getCabalInstallVersion = do
+ parseVer . trim
<$> readProcess' (cabalProgram ?progs) ["--numeric-version"] ""
+getCabalInstallBuiltinCabalVersion :: (Verbose, Progs) => IO Version
+getCabalInstallBuiltinCabalVersion =
+ parseVer . trim <$> readProcess' (cabalProgram ?progs)
+ ["act-as-setup", "--", "--numeric-version"] ""
+
installCabalLibV1 :: Env => GhcVersion -> UnpackedCabalVersion -> IO PackageDbDir
installCabalLibV1 ghcVer cabalVer = do
withSystemTempDirectory "cabal-helper.install-cabal-tmp" $ \tmpdir -> do
@@ -117,7 +122,7 @@ callCabalInstallV1
ghcVer
unpackedCabalVer
= do
- civ@CabalInstallVersion {..} <- cabalInstallVersion
+ cabalInstallVer <- getCabalInstallVersion
cabal_opts <- return $ concat
[
[ "--package-db=clear"
@@ -140,7 +145,7 @@ callCabalInstallV1
callProcessStderr (Just "/") [] (cabalProgram ?progs) cabal_opts
- runSetupHs ghcVer db srcdir unpackedCabalVer civ
+ runSetupHs ghcVer db srcdir unpackedCabalVer $ CabalInstallVersion cabalInstallVer
hPutStrLn stderr "done"
@@ -221,7 +226,7 @@ installCabalLibV2 _ghcVer cv (PackageEnvFile env_file) = do
return $ ("Cabal-"++showVersion cabalVer, "/")
CabalHEAD (_commitid, CabalSourceDir srcdir) -> do
return (".", srcdir)
- CabalInstallVersion {..} <- cabalInstallVersion
+ cabalInstallVer <- getCabalInstallVersion
cabal_opts <- return $ concat
[ if cabalInstallVer >= Version [1,20] []
then ["--no-require-sandbox"]