Skip to content

Commit

Permalink
Try to fix haskell#3436.
Browse files Browse the repository at this point in the history
  • Loading branch information
grayjay committed Jun 12, 2016
1 parent 6607bb7 commit 9f6cbea
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions cabal-install/Distribution/Client/SetupWrapper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ import Control.Applicative ( (<$>), (<*>) )
import Data.Monoid ( mempty )
#endif
import Control.Monad ( when, unless )
import Data.List ( foldl1' )
import Data.List ( find, foldl1' )
import Data.Maybe ( fromMaybe, isJust )
import Data.Char ( isSpace )
import Distribution.Client.Compat.ExecutablePath ( getExecutablePath )
Expand Down Expand Up @@ -384,23 +384,30 @@ externalSetupMethod verbosity options pkg bt mkargs = do
cabalLibVersionToUse :: IO (Version, (Maybe UnitId)
,SetupScriptOptions)
cabalLibVersionToUse =
case useCabalSpecVersion options of
Just version -> do
case find hasCabal (useDependencies options) of
Just (unitId, pkgId) -> do
let version = pkgVersion pkgId
updateSetupScript version bt
writeFile setupVersionFile (show version ++ "\n")
return (version, Nothing, options)
Nothing -> do
savedVer <- savedVersion
case savedVer of
Just version | version `withinRange` useCabalVersion options
-> do updateSetupScript version bt
-- Does the previously compiled setup executable still exist
-- and is it up-to date?
useExisting <- canUseExistingSetup version
if useExisting
then return (version, Nothing, options)
else installedVersion
_ -> installedVersion
return (version, Just unitId, options)
Nothing ->
case useCabalSpecVersion options of
Just version -> do
updateSetupScript version bt
writeFile setupVersionFile (show version ++ "\n")
return (version, Nothing, options)
Nothing -> do
savedVer <- savedVersion
case savedVer of
Just version | version `withinRange` useCabalVersion options
-> do updateSetupScript version bt
-- Does the previously compiled setup executable still exist
-- and is it up-to date?
useExisting <- canUseExistingSetup version
if useExisting
then return (version, Nothing, options)
else installedVersion
_ -> installedVersion
where
-- This check duplicates the checks in 'getCachedSetupExecutable' /
-- 'compileSetupExecutable'. Unfortunately, we have to perform it twice
Expand All @@ -416,6 +423,9 @@ externalSetupMethod verbosity options pkg bt mkargs = do
(&&) <$> setupProgFile `existsAndIsMoreRecentThan` setupHs
<*> setupProgFile `existsAndIsMoreRecentThan` setupVersionFile

hasCabal (_, PackageIdentifier (PackageName "Cabal") _) = True
hasCabal _ = False

installedVersion :: IO (Version, Maybe UnitId
,SetupScriptOptions)
installedVersion = do
Expand Down

0 comments on commit 9f6cbea

Please sign in to comment.