Commit 420e7018 authored by Michael Hanus 's avatar Michael Hanus

Move file problems when installing package eliminated

parent 9d4d3c13
......@@ -42,9 +42,9 @@ data Config = Config {
--- or a new value for the option is not specified in the .cpmrc file.
defaultConfig :: Config
defaultConfig = Config
{ packageInstallDir = "$HOME/.cpm/packages"
, binInstallDir = "$HOME/.cpm/bin"
, repositoryDir = "$HOME/.cpm/index"
{ packageInstallDir = "$HOME/.cpm/packages"
, binInstallDir = "$HOME/.cpm/bin"
, repositoryDir = "$HOME/.cpm/index"
, packageIndexRepository = packageIndexURI }
--- Reads the .cpmrc file from the user's home directory (if present) and merges
......
......@@ -519,14 +519,17 @@ installExecutable cfg repo gc p =
log Info ("Compiling main module: " ++ mainmod) |>
let cmd = unwords [":set", if levelGte Debug lvl then "v1" else "v0",
":load", mainmod, ":save", ":quit"]
bindir = binInstallDir cfg
binexec = bindir </> name
bindir = binInstallDir cfg
binexec = bindir </> name
binexecbak = binexec ++ ".bak"
in compiler CompilerOptions { comCommand = cmd } cfg repo gc |>
log Info ("Installing executable '" ++ name ++ "' into '" ++
bindir ++ "'") |>
(doesFileExist binexec >>= \exbin ->
when exbin (renameFile binexec (binexec++".bak")) >>
renameFile mainmod binexec >>
when exbin (system ("rm -f " ++ binexecbak) >>
renameFile binexec binexecbak) >>
-- renaming might not work across file systems:
system (unwords ["mv", mainmod, binexec]) >>
checkPath path bindir))
(executableSpec p)
where
......
......@@ -312,7 +312,7 @@ showVersionConstraint (VCompatible v) = " ~> " ++ (showVersion v)
--- Renders the id of a package as a string. Package name and version separated
--- by a dash.
packageId :: Package -> String
packageId p = (name p) ++ "-" ++ (showVersion $ version p)
packageId p = name p ++ "-" ++ showVersion (version p)
--- Reads a package spec from a JSON string.
readPackageSpec :: String -> Either String Package
......
......@@ -239,8 +239,8 @@ checkoutPackage cfg _ _ pkg = do
then copyDirectory pkgDir pkgId >> log Info logMsg
else log Error $ "Package '" ++ pkgId ++ "' is not installed."
where
pkgDir = (packageInstallDir cfg) </> pkgId
pkgId = packageId pkg
pkgDir = packageInstallDir cfg </> pkgId
pkgId = packageId pkg
logMsg = "Package '" ++ pkgId ++ "' checked out into local directory."
--- Removes a package from 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