Commit 23540461 authored by Michael Hanus 's avatar Michael Hanus
Browse files

CPM updated

parent 4c36b254
...@@ -309,7 +309,7 @@ one can use the command ...@@ -309,7 +309,7 @@ one can use the command
cypm install <package> cypm install <package>
\end{lstlisting} \end{lstlisting}
This command checks out the package in some internal directory This command checks out the package in some internal directory
(default: \code{\$HOME/.cpm/app_packages}, see (default: \code{\$HOME/.cpm/apps_$Curry system$}, see
Section~\ref{sec:config}) Section~\ref{sec:config})
and installs the binary of the application provided by the package and installs the binary of the application provided by the package
in \code{\$HOME/.cpm/bin} (see also Section~\ref{sec:checkout}). in \code{\$HOME/.cpm/bin} (see also Section~\ref{sec:checkout}).
...@@ -685,7 +685,7 @@ Default value: \code{\$HOME/.cpm/bin} ...@@ -685,7 +685,7 @@ Default value: \code{\$HOME/.cpm/bin}
\item[\fbox{\code{APP_PACKAGE_PATH}}] \item[\fbox{\code{APP_PACKAGE_PATH}}]
The path to the package cache where packages are checked out if only The path to the package cache where packages are checked out if only
their binaries are installed (see Section~\ref{sec:installapp}). their binaries are installed (see Section~\ref{sec:installapp}).
Default value: \code{\$HOME/.cpm/app_packages}. Default value: \code{\$HOME/.cpm/apps_$Curry system$}.
\item[\fbox{\code{HOME_PACKAGE_PATH}}] \item[\fbox{\code{HOME_PACKAGE_PATH}}]
The path to the meta-package which is used if you are outside another The path to the meta-package which is used if you are outside another
......
...@@ -65,7 +65,7 @@ defaultConfig = Config ...@@ -65,7 +65,7 @@ defaultConfig = Config
{ packageInstallDir = "$HOME/.cpm/packages" { packageInstallDir = "$HOME/.cpm/packages"
, binInstallDir = "$HOME/.cpm/bin" , binInstallDir = "$HOME/.cpm/bin"
, repositoryDir = "$HOME/.cpm/index" , repositoryDir = "$HOME/.cpm/index"
, appPackageDir = "$HOME/.cpm/app_packages" , appPackageDir = ""
, packageIndexURL = packageIndexDefaultURL , packageIndexURL = packageIndexDefaultURL
, homePackageDir = "" , homePackageDir = ""
, curryExec = Dist.installDir </> "bin" </> Dist.curryCompiler , curryExec = Dist.installDir </> "bin" </> Dist.curryCompiler
...@@ -113,6 +113,17 @@ setCompilerExecutable cfg = do ...@@ -113,6 +113,17 @@ setCompilerExecutable cfg = do
maybe (error $ "Executable '" ++ exec ++ "' not found in path!") maybe (error $ "Executable '" ++ exec ++ "' not found in path!")
(\absexec -> return cfg { curryExec = absexec }) (\absexec -> return cfg { curryExec = absexec })
--- Sets the `appPackageDir` depending on the compiler version.
setAppPackageDir :: Config -> IO Config
setAppPackageDir cfg
| null (appPackageDir cfg)
= do homedir <- getHomeDirectory
let cpmdir = homedir </> ".cpm"
(cname,cmaj,cmin) = compilerVersion cfg
cmpname = cname ++ "_" ++ show cmaj ++ "." ++ show cmin
return cfg { appPackageDir = cpmdir </> "apps_" ++ cmpname }
| otherwise = return cfg
--- Sets the `homePackageDir` depending on the compiler version. --- Sets the `homePackageDir` depending on the compiler version.
setHomePackageDir :: Config -> IO Config setHomePackageDir :: Config -> IO Config
setHomePackageDir cfg setHomePackageDir cfg
...@@ -190,10 +201,11 @@ readConfigurationWith defsettings = do ...@@ -190,10 +201,11 @@ readConfigurationWith defsettings = do
case mergedSettings of case mergedSettings of
Left e -> return $ Left e Left e -> return $ Left e
Right s0 -> do s1 <- replaceHome s0 Right s0 -> do s1 <- replaceHome s0
createDirectories s1
s2 <- setCompilerVersion s1 s2 <- setCompilerVersion s1
s3 <- setHomePackageDir s2 s3 <- setAppPackageDir s2
return $ Right s3 s4 <- setHomePackageDir s3
createDirectories s4
return $ Right s4
replaceHome :: Config -> IO Config replaceHome :: Config -> IO Config
replaceHome cfg = do replaceHome cfg = do
......
...@@ -56,7 +56,7 @@ cpmBanner :: String ...@@ -56,7 +56,7 @@ cpmBanner :: String
cpmBanner = unlines [bannerLine,bannerText,bannerLine] cpmBanner = unlines [bannerLine,bannerText,bannerLine]
where where
bannerText = bannerText =
"Curry Package Manager <curry-language.org/tools/cpm> (version of 05/10/2018)" "Curry Package Manager <curry-language.org/tools/cpm> (version of 15/11/2018)"
bannerLine = take (length bannerText) (repeat '-') bannerLine = take (length bannerText) (repeat '-')
main :: IO () main :: IO ()
......
...@@ -10,7 +10,7 @@ module CPM.PackageCache.Runtime ...@@ -10,7 +10,7 @@ module CPM.PackageCache.Runtime
, writePackageConfig , writePackageConfig
) where ) where
import FilePath ( (</>), (<.>) ) import FilePath ( (</>), (<.>), takeDirectory )
import FileGoodies ( baseName ) import FileGoodies ( baseName )
import Directory ( createDirectoryIfMissing, copyFile, getDirectoryContents import Directory ( createDirectoryIfMissing, copyFile, getDirectoryContents
, getAbsolutePath, doesDirectoryExist, doesFileExist ) , getAbsolutePath, doesDirectoryExist, doesFileExist )
...@@ -70,7 +70,7 @@ ensureCacheDirectory :: String -> IO String ...@@ -70,7 +70,7 @@ ensureCacheDirectory :: String -> IO String
ensureCacheDirectory dir = do ensureCacheDirectory dir = do
createDirectoryIfMissing True packagesDir createDirectoryIfMissing True packagesDir
return packagesDir return packagesDir
where packagesDir = dir </> ".cpm" </> "packages" where packagesDir = dir </> ".cpm" </> "packages"
--- Writes the package configuration module (if specified) into the --- Writes the package configuration module (if specified) into the
...@@ -91,6 +91,7 @@ writePackageConfig cfg pkgdir pkg loadpath = ...@@ -91,6 +91,7 @@ writePackageConfig cfg pkgdir pkg loadpath =
writeConfigFile configmod binname = do writeConfigFile configmod binname = do
let configfile = pkgdir </> "src" </> foldr1 (</>) (split (=='.') configmod) let configfile = pkgdir </> "src" </> foldr1 (</>) (split (=='.') configmod)
<.> ".curry" <.> ".curry"
createDirectoryIfMissing True (takeDirectory configfile)
abspkgdir <- getAbsolutePath pkgdir abspkgdir <- getAbsolutePath pkgdir
writeFile configfile $ unlines $ writeFile configfile $ unlines $
[ "module " ++ configmod ++ " where" [ "module " ++ configmod ++ " where"
......
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