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

Allow local installs of mutable snapshot packages #4588

Merged
merged 3 commits into from
Feb 18, 2019
Merged
Show file tree
Hide file tree
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
10 changes: 2 additions & 8 deletions src/Stack/Build/ConstructPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ combineSourceInstalled :: PackageSource
-> PackageInfo
combineSourceInstalled ps (location, installed) =
assert (psVersion ps == installedVersion installed) $
assert (psLocation ps == location) $
case location of
-- Always trust something in the snapshot
Snap -> PIOnlyInstalled location installed
Expand Down Expand Up @@ -208,7 +207,7 @@ constructPlan baseConfigOpts0 localDumpPkgs loadPackage0 sourceMap installedMap
return $ takeSubset Plan
{ planTasks = tasks
, planFinals = M.fromList finals
, planUnregisterLocal = mkUnregisterLocal tasks dirtyReason localDumpPkgs sourceMap initialBuildSteps
, planUnregisterLocal = mkUnregisterLocal tasks dirtyReason localDumpPkgs initialBuildSteps
, planInstallExes =
if boptsInstallExes (bcoBuildOpts baseConfigOpts0) ||
boptsInstallCompilerTool (bcoBuildOpts baseConfigOpts0)
Expand Down Expand Up @@ -276,12 +275,11 @@ mkUnregisterLocal :: Map PackageName Task
-- ^ Reasons why packages are dirty and must be rebuilt
-> [DumpPackage () () ()]
-- ^ Local package database dump
-> SourceMap
-> Bool
-- ^ If true, we're doing a special initialBuildSteps
-- build - don't unregister target packages.
-> Map GhcPkgId (PackageIdentifier, Text)
mkUnregisterLocal tasks dirtyReason localDumpPkgs sourceMap initialBuildSteps =
mkUnregisterLocal tasks dirtyReason localDumpPkgs initialBuildSteps =
-- We'll take multiple passes through the local packages. This
-- will allow us to detect that a package should be unregistered,
-- as well as all packages directly or transitively depending on
Expand Down Expand Up @@ -330,10 +328,6 @@ mkUnregisterLocal tasks dirtyReason localDumpPkgs sourceMap initialBuildSteps =
= if initialBuildSteps && taskIsTarget task && taskProvides task == ident
then Nothing
else Just $ fromMaybe "" $ Map.lookup name dirtyReason
-- Check if we're no longer using the local version
| Just (dpLocation -> PLImmutable _) <- Map.lookup name (smDeps sourceMap)
-- FIXME:qrilka do git/archive count as snapshot installed?
= Just "Switching to snapshot installed package"
-- Check if a dependency is going to be unregistered
| (dep, _):_ <- mapMaybe (`Map.lookup` toUnregister) deps
= Just $ "Dependency being unregistered: " <> T.pack (packageIdentifierString dep)
Expand Down
8 changes: 6 additions & 2 deletions src/Stack/Build/Installed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,15 @@ getInstalled opts installMap = do
Nothing -> m
Just (iLoc, iVersion)
-- Not the version we want, ignore it
| version /= iVersion || loc /= iLoc -> Map.empty
| version /= iVersion || mismatchingLoc loc iLoc -> Map.empty

| otherwise -> m
where
m = Map.singleton name (loc, Executable $ PackageIdentifier name version)
mismatchingLoc installed target | target == installed = False
| installed == Local = False -- snapshot dependency could end up
-- in a local install as being mutable
| otherwise = True
exesSnap <- getInstalledExes Snap
exesLocal <- getInstalledExes Local
let installedMap = Map.unions
Expand Down Expand Up @@ -261,7 +265,7 @@ isAllowed opts mcache installMap mloc dp
PackageIdentifier name version = dpPackageIdent dp
-- Ensure that the installed location matches where the sourceMap says it
-- should be installed
checkLocation Snap = mloc /= Just (InstalledTo Local) -- we can allow either global or snap
checkLocation Snap = True -- snapshot deps could become mutable after getting any mutable dependency
checkLocation Local = mloc == Just (InstalledTo Local) || mloc == Just ExtraGlobal -- 'locally' installed snapshot packages can come from extra dbs
-- Check if a package is allowed if it is found in the sourceMap
checkFound (installLoc, installVer)
Expand Down