forked from haskell/cabal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement offline mode for the 'install' command.
When in offline mode, 'cabal install' only installs packages from the local tarball cache. Offline mode can be enabled with the '--offline' flag. Fixes haskell#2566.
- Loading branch information
Showing
3 changed files
with
32 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ import Data.List | |
( isPrefixOf, unfoldr, nub, sort, (\\) ) | ||
import qualified Data.Set as S | ||
import Data.Maybe | ||
( isJust, fromMaybe, mapMaybe, catMaybes ) | ||
( catMaybes, isJust, isNothing, fromMaybe, mapMaybe ) | ||
import Control.Exception as Exception | ||
( Exception(toException), bracket, catches | ||
, Handler(Handler), handleJust, IOException, SomeException ) | ||
|
@@ -54,7 +54,7 @@ import Data.Traversable | |
( traverse ) | ||
#endif | ||
import Control.Monad | ||
( forM_, when, unless ) | ||
( filterM, forM_, when, unless ) | ||
import System.Directory | ||
( getTemporaryDirectory, doesDirectoryExist, doesFileExist, | ||
createDirectoryIfMissing, removeFile, renameDirectory ) | ||
|
@@ -509,6 +509,22 @@ checkPrintPlan verbosity comp installed installPlan sourcePkgDb | |
else unless dryRun $ warn verbosity | ||
"Note that reinstalls are always dangerous. Continuing anyway..." | ||
|
||
-- If we are explicitly told to not download anything, check that all packages | ||
-- are already fetched. | ||
let offline = fromFlagOrDefault False (installOfflineMode installFlags) | ||
when offline $ do | ||
let pkgs = [ sourcePkg | ||
| InstallPlan.Configured (ConfiguredPackage sourcePkg _ _ _) | ||
<- InstallPlan.toList installPlan ] | ||
notFetched <- fmap (map packageInfoId) | ||
. filterM (fmap isNothing . checkFetched . packageSource) | ||
$ pkgs | ||
unless (null notFetched) $ | ||
die $ "Can't download packages in offline mode. " | ||
++ "Must download the following packages to proceed:\n" | ||
++ intercalate ", " (map display notFetched) | ||
++ "\nTry running 'cabal install --only-dependencies'." | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
23Skidoo
Author
Owner
|
||
|
||
where | ||
nothingToInstall = null (InstallPlan.ready installPlan) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 comment
on commit 993a008
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Or could suggest
cabal fetch
, which just downloads things.