Commit 5a640009 authored by Michael Hanus 's avatar Michael Hanus
Browse files

CPM updated

parent f0ff0b01
......@@ -36,8 +36,8 @@ import CPM.PackageCache.Global ( GlobalCache, readInstalledPackagesFromDir
import CPM.Package
import CPM.Resolution ( isCompatibleToCompiler, showResult )
import CPM.Repository ( Repository, readRepository, findVersion, listPackages
, findLatestVersion, updateRepository, searchPackages
, updateRepositoryCache )
, findAllVersions, findLatestVersion, updateRepository
, searchPackages, updateRepositoryCache )
import CPM.PackageCache.Runtime ( dependencyPathsSeparate, writePackageConfig )
import CPM.PackageCopy
import CPM.Diff.API as APIDiff
......@@ -723,10 +723,15 @@ infoCmd opts cfg getRepoGC = case (infoPackage opts, infoVersion opts) of
infoCmdRepoGC :: String -> Maybe Version -> Bool -> Bool -> Config
-> Repository -> GlobalCache -> IO (ErrorLogger ())
infoCmdRepoGC pkg Nothing allinfos plain cfg repo gc =
case findLatestVersion cfg repo pkg False of
Nothing -> packageNotFoundFailure pkg
Just p -> printInfo allinfos plain (Just (isPackageInstalled gc p)) p
infoCmdRepoGC pkgname Nothing allinfos plain cfg repo gc =
case findAllVersions repo pkgname False of
[] -> packageNotFoundFailure pkgname
ps -> case filter (isCompatibleToCompiler cfg) ps of
[] -> let lvers = showVersion (version (head ps))
in compatPackageNotFoundFailure cfg pkgname
("Use 'info " ++ pkgname ++ " " ++ lvers ++
"' to print info about the latest version.")
(p:_) -> printInfo allinfos plain (Just (isPackageInstalled gc p)) p
infoCmdRepoGC pkg (Just v) allinfos plain _ repo gc =
case findVersion repo pkg v of
Nothing -> packageNotFoundFailure $ pkg ++ "-" ++ showVersion v
......@@ -742,10 +747,12 @@ printInfo allinfos plain mbinstalled pkg =
-- `checkout` command:
checkout :: CheckoutOptions -> Config -> Repository -> GlobalCache
-> IO (ErrorLogger ())
checkout (CheckoutOptions pkg Nothing pre) cfg repo gc =
case findLatestVersion cfg repo pkg pre of
Nothing -> packageNotFoundFailure pkg
Just p -> acquireAndInstallPackageWithDependencies cfg repo gc p |>
checkout (CheckoutOptions pkgname Nothing pre) cfg repo gc =
case findAllVersions repo pkgname pre of
[] -> packageNotFoundFailure pkgname
ps -> case filter (isCompatibleToCompiler cfg) ps of
[] -> compatPackageNotFoundFailure cfg pkgname cpmUpdate
(p:_) -> acquireAndInstallPackageWithDependencies cfg repo gc p |>
checkoutPackage cfg repo gc p
checkout (CheckoutOptions pkg (Just ver) _) cfg repo gc =
case findVersion repo pkg ver of
......@@ -808,7 +815,8 @@ installapp opts cfg repo gc = do
checkCompiler :: Config -> Package -> IO ()
checkCompiler cfg pkg =
unless (isCompatibleToCompiler cfg pkg)
(error $ "Compiler incompatible to package: " ++ showCompilerVersion cfg)
(error $ "Current compiler '" ++ showCompilerVersion cfg ++
"' incompatible to package specification!")
--- Installs the executable specified in the package in the
--- bin directory of CPM (compare .cpmrc).
......@@ -1052,11 +1060,13 @@ useForce = "Use option '-f' or '--force' to overwrite it."
addDependencyCmd :: String -> Bool -> Config -> IO (ErrorLogger ())
addDependencyCmd pkgname force config =
readRepository config >>= \repo ->
case findLatestVersion config repo pkgname False of
Nothing -> packageNotFoundFailure pkgname
Just p -> searchLocalPackageSpec "." |>=
maybe (genNewLocalPackage (version p))
(addDepToLocalPackage (version p))
case findAllVersions repo pkgname False of
[] -> packageNotFoundFailure pkgname
ps -> case filter (isCompatibleToCompiler config) ps of
[] -> compatPackageNotFoundFailure config pkgname cpmUpdate
(p:_) -> searchLocalPackageSpec "." |>=
maybe (genNewLocalPackage (version p))
(addDepToLocalPackage (version p))
where
addDepToLocalPackage vers pkgdir =
loadPackageSpec pkgdir |>= \pkgSpec ->
......@@ -1265,6 +1275,7 @@ diff :: DiffOptions -> Config -> Repository -> GlobalCache
diff opts cfg repo gc =
getLocalPackageSpec "." |>= \specDir ->
loadPackageSpec specDir |>= \localSpec ->
checkCompiler cfg localSpec >>
let localname = name localSpec
localv = version localSpec
showlocalv = showVersion localv
......@@ -1279,9 +1290,11 @@ diff opts cfg repo gc =
where
getDiffVersion localname = case diffVersion opts of
Nothing -> case findLatestVersion cfg repo localname False of
Nothing -> failIO $ "No other version of local package '" ++
localname ++ "' found in package repository."
Just p -> succeedIO (version p)
Nothing -> failIO $
"No other version of local package '" ++ localname ++
"' compatible to '" ++ showCompilerVersion cfg ++
"' found in package repository."
Just p -> succeedIO (version p)
Just v -> succeedIO v
diffAPIIfEnabled specDir localSpec diffversion =
......@@ -1423,6 +1436,13 @@ packageNotFoundFailure pkgname =
failIO $ "Package '" ++ pkgname ++ "' not found in package repository.\n" ++
cpmUpdate
--- Fail with a "compatible package not found" message and a comment
compatPackageNotFoundFailure :: Config -> String -> String -> IO (ErrorLogger _)
compatPackageNotFoundFailure cfg pkgname helpcmt =
failIO $ "No version of package '" ++ pkgname ++ "' compatible to '" ++
showCompilerVersion cfg ++ "' found!\n" ++
helpcmt
---------------------------------------------------------------------------
-- Caching the current CURRYPATH of a package for faster startup.
-- The file `.cpm/CURRYPATH_CACHE` contains the following lines:
......
......@@ -12,8 +12,7 @@ module CPM.Repository
, emptyRepository
, allPackages
, readRepository
, findVersion
, findLatestVersion
, findAllVersions, findVersion, findLatestVersion
, searchPackages
, listPackages
, updateRepository
......
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