Skip to content

Commit

Permalink
Remove the self-upgrade check.
Browse files Browse the repository at this point in the history
Fixes #2089.
  • Loading branch information
23Skidoo committed Oct 19, 2014
1 parent a256fb1 commit b5bbf5a
Showing 1 changed file with 2 additions and 39 deletions.
41 changes: 2 additions & 39 deletions cabal-install/Distribution/Client/Update.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,22 @@ module Distribution.Client.Update
) where

import Distribution.Client.Types
( Repo(..), RemoteRepo(..), LocalRepo(..), SourcePackageDb(..) )
( Repo(..), RemoteRepo(..), LocalRepo(..) )
import Distribution.Client.HttpUtils
( DownloadResult(..) )
import Distribution.Client.FetchUtils
( downloadIndex )
import qualified Distribution.Client.PackageIndex as PackageIndex
import Distribution.Client.IndexUtils
( getSourcePackages, updateRepoIndexCache )
import qualified Paths_cabal_install
( version )
( updateRepoIndexCache )

import Distribution.Package
( PackageName(..), packageVersion )
import Distribution.Version
( anyVersion, withinRange )
import Distribution.Simple.Utils
( writeFileAtomic, warn, notice )
import Distribution.Verbosity
( Verbosity )

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
update :: Verbosity -> [Repo] -> IO ()
Expand All @@ -51,7 +39,6 @@ update verbosity [] =
++ "you would have one specified in the config file."
update verbosity repos = do
mapM_ (updateRepo verbosity) repos
checkForSelfUpgrade verbosity repos

updateRepo :: Verbosity -> Repo -> IO ()
updateRepo verbosity repo = case repoKind repo of
Expand All @@ -66,27 +53,3 @@ updateRepo verbosity repo = case repoKind repo of
writeFileAtomic (dropExtension indexPath) . maybeDecompress
=<< BS.readFile indexPath
updateRepoIndexCache verbosity repo

checkForSelfUpgrade :: Verbosity -> [Repo] -> IO ()
checkForSelfUpgrade verbosity repos = do
SourcePackageDb sourcePkgIndex prefs <- getSourcePackages verbosity repos

let self = PackageName "cabal-install"
preferredVersionRange = fromMaybe anyVersion (Map.lookup self prefs)
currentVersion = Paths_cabal_install.version
laterPreferredVersions =
[ version
| pkg <- PackageIndex.lookupPackageName sourcePkgIndex self
, let version = packageVersion pkg
, version > currentVersion
, version `withinRange` preferredVersionRange
]

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) laterPreferredVersions
, "If you have already installed a newer version, and intended "
++ "to run it, maybe check your PATH environment variable?"
]

0 comments on commit b5bbf5a

Please sign in to comment.