Commit dd8c0946 authored by Mikhail Glushenkov's avatar Mikhail Glushenkov
Browse files

Make maybeRegister a separate function.

parent 8f782971
......@@ -1239,21 +1239,7 @@ installUnpackedPackage verbosity buildLimit installLock numJobs
-- Install phase
onFailure InstallFailed $ criticalSection installLock $ do
-- Capture installed package configuration file
maybePkgConf <-
if shouldRegister then do
tmp <- getTemporaryDirectory
withTempFile tmp (tempTemplate "pkgConf") $ \pkgConfFile handle -> do
hClose handle
let registerFlags' version = (registerFlags version) {
Cabal.regGenPkgConf = toFlag (Just pkgConfFile)
}
setup Cabal.registerCommand registerFlags'
withFileContents pkgConfFile $ \pkgConfText ->
case Installed.parseInstalledPackageInfo pkgConfText of
Installed.ParseFailed perror -> error (show perror)
-- FIXME: Should we do something with warnings?
Installed.ParseOk _warnings pkgConf -> return (Just pkgConf)
else return Nothing
maybePkgConf <- maybeRegister
-- Actual installation
withWin32SelfUpgrade verbosity configFlags compid platform pkg $ do
......@@ -1309,6 +1295,23 @@ installUnpackedPackage verbosity buildLimit installLock numJobs
userInstall = fromFlagOrDefault defaultUserInstall
(configUserInstall configFlags')
maybeRegister :: IO (Maybe Installed.InstalledPackageInfo)
maybeRegister =
if shouldRegister then do
tmp <- getTemporaryDirectory
withTempFile tmp (tempTemplate "pkgConf") $ \pkgConfFile handle -> do
hClose handle
let registerFlags' version = (registerFlags version) {
Cabal.regGenPkgConf = toFlag (Just pkgConfFile)
}
setup Cabal.registerCommand registerFlags'
withFileContents pkgConfFile $ \pkgConfText ->
case Installed.parseInstalledPackageInfo pkgConfText of
Installed.ParseFailed perror -> error (show perror)
-- FIXME: Should we do something with warnings?
Installed.ParseOk _warnings pkgConf -> return (Just pkgConf)
else return Nothing
setup cmd flags = do
Exception.bracket
(case useLogFile of
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment