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

Merge pull request #2000 from kini/upgrade-available

Better message when new cabal-install available
parents 0da666f3 9052ff49
......@@ -39,7 +39,9 @@ import qualified Data.ByteString.Lazy as BS
import Distribution.Client.GZipUtils (maybeDecompress)
import qualified Data.Map as Map
import System.FilePath (dropExtension)
import Data.List (intercalate)
import Data.Maybe (fromMaybe)
import Data.Version (showVersion)
import Control.Monad (unless)
-- | 'update' downloads the package list from all known servers
......@@ -73,13 +75,18 @@ checkForSelfUpgrade verbosity repos = do
preferredVersionRange = fromMaybe anyVersion (Map.lookup self prefs)
currentVersion = Paths_cabal_install.version
laterPreferredVersions =
[ packageVersion pkg
[ version
| pkg <- PackageIndex.lookupPackageName sourcePkgIndex self
, let version = packageVersion pkg
, version > currentVersion
, version `withinRange` preferredVersionRange ]
, version `withinRange` preferredVersionRange
]
unless (null laterPreferredVersions) $
notice verbosity $
"Note: there is a new version of cabal-install available.\n"
++ "To upgrade, run: cabal install cabal-install"
unless (null laterPreferredVersions) $ mapM_ (notice verbosity)
[ "Note: You are not currently running the latest version of cabal-install."
, "The currently running version is: " ++ showVersion currentVersion
, "These available versions are newer: "
++ (intercalate ", " . map showVersion) laterPreferredVersion
, "If you have already installed a newer version, and intended "
++ "to run it, maybe check your PATH environment variable?"
]
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