Commit dcedbf85 authored by Michael Hanus 's avatar Michael Hanus

Fix for installbin command

parent 01f9b50b
......@@ -9,7 +9,8 @@ import Directory ( doesFileExist, getAbsolutePath, doesDirectoryExist
, createDirectory, createDirectoryIfMissing
, getDirectoryContents, getModificationTime
, renameFile, removeFile, setCurrentDirectory )
import Distribution ( installDir, stripCurrySuffix, addCurrySubdir )
import Distribution ( installDir, stripCurrySuffix, addCurrySubdir
, curryCompiler )
import Either
import FilePath ( (</>), splitSearchPath, takeExtension )
import IO ( hFlush, stdout )
......@@ -43,7 +44,7 @@ cpmBanner :: String
cpmBanner = unlines [bannerLine,bannerText,bannerLine]
where
bannerText =
"Curry Package Manager <curry-language.org/tools/cpm> (version of 03/03/2017)"
"Curry Package Manager <curry-language.org/tools/cpm> (version of 27/03/2017)"
bannerLine = take (length bannerText) (repeat '-')
main :: IO ()
......@@ -80,10 +81,11 @@ runWithArgs opts = do
setLogLevel $ optLogLevel opts
(msgs, result) <- case optCommand opts of
NoCommand -> failIO "NoCommand"
Update -> updateRepository config
Compiler o -> compiler o config getRepo getGC
Exec o -> exec o config getRepo getGC
Test o -> test o config getRepo getGC
Clean -> cleanPackage
Clean -> cleanPackage Info
New -> newPackage
_ -> do repo <- getRepo
case optCommand opts of
......@@ -98,7 +100,6 @@ runWithArgs opts = do
Install o -> install o config repo globalCache
Diff o -> diff o config repo globalCache
Uninstall o -> uninstall o config repo globalCache
Update -> update config repo globalCache
Upgrade o -> upgrade o config repo globalCache
Link o -> link o config repo globalCache
_ -> error "Internal command processing error!"
......@@ -558,7 +559,8 @@ installbin opts cfg repo gc = do
(checkout opts cfg repo gc |>
log Debug ("Change into directory " ++ copkgdir) |>
(setCurrentDirectory copkgdir >> succeedIO ()) |>
install (InstallOptions Nothing Nothing False) cfg repo gc)
install (InstallOptions Nothing Nothing False) cfg repo gc |>
cleanPackage Debug)
where
binpkgdir = binPackageDir cfg
copkgdir = binpkgdir </> coPackage opts
......@@ -568,7 +570,7 @@ install :: InstallOptions -> Config -> Repository -> GlobalCache
install (InstallOptions Nothing Nothing _) cfg repo gc =
tryFindLocalPackageSpec "." |>= \specDir ->
installLocalDependencies cfg repo gc specDir |>= \ (pkg,_) ->
installExecutable cfg repo gc pkg specDir
installExecutable cfg repo pkg specDir
install (InstallOptions (Just pkg) Nothing pre) cfg repo gc = do
fileExists <- doesFileExist pkg
if fileExists
......@@ -587,16 +589,22 @@ install (InstallOptions Nothing (Just _) _) _ _ _ =
--- Installs the executable specified in the package in the
--- bin directory of CPM (compare .cpmrc).
installExecutable :: Config -> Repository -> GlobalCache -> Package -> String
installExecutable :: Config -> Repository -> Package -> String
-> IO (ErrorLogger ())
installExecutable cfg repo gc pkg pkgdir =
installExecutable cfg repo pkg pkgdir =
-- we read the global cache again since it might be modified by
-- the installation of the package:
getGlobalCache cfg >>= \gc ->
maybe (succeedIO ())
(\ (PackageExecutable name mainmod) ->
getLogLevel >>= \lvl ->
getEnviron "PATH" >>= \path ->
log Info ("Compiling main module: " ++ mainmod) |>
let cmd = unwords [":set", if levelGte Debug lvl then "v1" else "v0",
":load", mainmod, ":save", ":quit"]
let cmd = unwords $
[":set", if levelGte Debug lvl then "v1" else "v0"] ++
(if curryCompiler == "pakcs" && not (levelGte Debug lvl)
then [":set","-warn"] else []) ++
[":load", mainmod, ":save", ":quit"]
bindir = binInstallDir cfg
binexec = bindir </> name
in writePackageConfig cfg pkgdir pkg |>
......@@ -649,9 +657,6 @@ tryFindVersion pkg ver repo = case findVersion repo pkg ver of
"' not found in package repository."
Just p -> succeedIO $ p
update :: Config -> Repository -> GlobalCache -> IO (ErrorLogger ())
update cfg _ _ = updateRepository cfg
--- Lists all packages in the given repository.
listCmd :: ListOptions -> Config -> Repository -> IO (ErrorLogger ())
listCmd (ListOptions lv csv) _ repo = putStr rendered >> succeedIO ()
......@@ -826,9 +831,8 @@ execWithPkgDir o cfg getRepo getGC specDir =
-- Clean auxiliary files in the current package
cleanPackage :: --ExecOptions -> Config -> IO Repository -> IO GlobalCache
IO (ErrorLogger ())
cleanPackage =
cleanPackage :: LogLevel -> IO (ErrorLogger ())
cleanPackage ll =
tryFindLocalPackageSpec "." |>= \specDir ->
loadPackageSpec specDir |>= \pkg ->
let dotcpm = specDir </> ".cpm"
......@@ -836,7 +840,7 @@ cleanPackage =
testdirs = maybe [] (\ (PackageTests tests) -> map fst tests)
(testSuite pkg)
rmdirs = dotcpm : map addCurrySubdir (srcdirs ++ testdirs)
in log Info ("Removing directories: " ++ unwords rmdirs) |>
in log ll ("Removing directories: " ++ unwords rmdirs) |>
(system (unwords (["rm", "-rf"] ++ rmdirs)) >> succeedIO ())
--- Creates a new package by asking some questions.
......
......@@ -221,7 +221,8 @@ installMissingDependencies cfg gc deps = if length missing > 0
else succeedIO ()
where
missing = filter (not . isPackageInstalled gc) deps
logMsg = "Installing missing dependencies " ++ (intercalate "," $ map packageId missing)
logMsg = "Installing missing dependencies " ++
intercalate "," (map packageId missing)
--- Filters a list of packages to the ones not installed in the global package
--- cache.
......
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