Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the self-upgrade check. #2090

Merged
merged 1 commit into from
Oct 19, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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?"
]