Commit 4817297b authored by Michael Hanus 's avatar Michael Hanus
Browse files

CPM updated

parent 46076a52
......@@ -766,6 +766,7 @@ install (InstallOptions Nothing Nothing _ instexec False) cfg repo gc =
getLocalPackageSpec "." |>= \pkgdir ->
cleanCurryPathCache pkgdir |>
installLocalDependencies cfg repo gc pkgdir |>= \ (pkg,_) ->
saveBaseVersionToCache cfg pkgdir >>
writePackageConfig cfg pkgdir pkg |>
if instexec then installExecutable cfg repo pkg else succeedIO ()
-- Install executable only:
......@@ -1353,13 +1354,15 @@ computePackageLoadPath cfg pkgdir getRepoGC =
debugMessage "Computing load path for package..." >>
getRepoGC >>= \ (repo,gc) ->
loadPackageSpec pkgdir |>= \pkg ->
resolveAndCopyDependenciesForPackage cfg repo gc pkgdir pkg |>= \allpkgs ->
loadBaseVersionFromCache pkgdir >>= \cbv ->
let cfg' = if null cbv then cfg else cfg { baseVersion = cbv } in
resolveAndCopyDependenciesForPackage cfg' repo gc pkgdir pkg |>= \allpkgs ->
getAbsolutePath pkgdir >>= \abs -> succeedIO () |>
let srcdirs = map (abs </>) (sourceDirsOf pkg)
-- remove 'base' package if it is the same as in current config:
pkgs = filter notCurrentBase allpkgs
currypath = joinSearchPath (srcdirs ++ dependencyPathsSeparate pkgs abs)
in saveCurryPathToCache cfg pkgdir currypath >> succeedIO currypath
in saveCurryPathToCache cfg' pkgdir currypath >> succeedIO currypath
where
notCurrentBase pkg = name pkg /= "base" ||
showVersion (version pkg) /= compilerBaseVersion cfg
......@@ -1454,6 +1457,28 @@ compatPackageNotFoundFailure cfg pkgname helpcmt =
curryPathCacheFile :: String -> String
curryPathCacheFile pkgdir = pkgdir </> ".cpm" </> "CURRYPATH_CACHE"
--- The name of the cache file for the base version in a package directory.
baseVersionCacheFile :: String -> String
baseVersionCacheFile pkgdir = pkgdir </> ".cpm" </> "BASEVERSION_CACHE"
--- Saves baseVersion of config in local cache file in the given package dir.
saveBaseVersionToCache :: Config -> String -> IO ()
saveBaseVersionToCache cfg pkgdir = do
let cpmdir = pkgdir </> ".cpm"
createDirectoryIfMissing False cpmdir
writeFile (baseVersionCacheFile pkgdir) (baseVersion cfg ++ "\n")
--- Loads baseVersion from local cache file in the given package dir.
loadBaseVersionFromCache :: String -> IO String
loadBaseVersionFromCache pkgdir = do
let cachefile = baseVersionCacheFile pkgdir
excache <- doesFileExist cachefile
if excache
then do bv <- safeReadFile cachefile >>= return . either (const "") id
debugMessage $ "Base version loaded from cache: " ++ bv
return bv
else return ""
--- Saves package CURRYPATH in local cache file in the given package dir.
saveCurryPathToCache :: Config -> String -> String -> IO ()
saveCurryPathToCache cfg pkgdir path = do
......@@ -1489,8 +1514,10 @@ loadCurryPathFromCache cfg pkgdir = do
--- for upgrade/install/link commands.
cleanCurryPathCache :: String -> IO (ErrorLogger ())
cleanCurryPathCache pkgdir = do
let cachefile = curryPathCacheFile pkgdir
whenFileExists cachefile $ removeFile cachefile
let pathcachefile = curryPathCacheFile pkgdir
basecachefile = baseVersionCacheFile pkgdir
whenFileExists pathcachefile $ removeFile pathcachefile
whenFileExists basecachefile $ removeFile basecachefile
succeedIO ()
---------------------------------------------------------------------------
......@@ -24,7 +24,8 @@ import Maybe
import Text.Pretty
import Test.EasyCheck
import CPM.Config (Config, defaultConfig, compilerVersion)
import CPM.Config ( Config, defaultConfig, compilerVersion
, compilerBaseVersion )
import CPM.ErrorLogger
import CPM.LookupSet
import CPM.Package
......@@ -39,14 +40,18 @@ resolveDependenciesFromLookupSet cfg pkg lookupSet =
else failIO $ showResult result
--- Resolves the dependencies of a package using packages from a lookup set.
--- The base package of the current compiler is removed from the result set.
resolve :: Config -> Package -> LookupSet -> ResolutionResult
resolve cfg pkg ls = case resolvedPkgs of
Just pkgs -> ResolutionSuccess pkg pkgs
Just pkgs -> ResolutionSuccess pkg (deleteBase pkgs)
Nothing -> ResolutionFailure labeledTree
where
labeledTree = labelConflicts cfg $ candidateTree pkg ls
noConflicts = prune ((/= Nothing) . clConflict) labeledTree
resolvedPkgs = maybeHead . map stPackages . filter stComplete . leaves . mapTree clState $ noConflicts
resolvedPkgs = maybeHead . map stPackages . filter stComplete . leaves
. mapTree clState $ noConflicts
deleteBase = filter (\p -> name p /= "base" ||
showVersion (version p) /= compilerBaseVersion cfg)
--- Gives a list of all activated packages for a successful resolution.
resolvedPackages :: ResolutionResult -> [Package]
......
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