Commit 53fc7ec4 authored by bjorn@bringert.net's avatar bjorn@bringert.net
Browse files

Set prefix to .cabal by default.

parent 03783edd
......@@ -14,13 +14,12 @@ module Network.Hackage.CabalInstall.Clean
( clean
) where
import Network.Hackage.CabalInstall.Types (ConfigFlags)
import Network.Hackage.CabalInstall.Config (packagesDirectory)
import Network.Hackage.CabalInstall.Types (ConfigFlags(..))
import System.Directory (removeDirectoryRecursive)
-- | 'clean' removes all downloaded packages from the {config-dir}\/packages\/ directory.
clean :: ConfigFlags -> IO ()
clean cfg
= removeDirectoryRecursive (packagesDirectory cfg)
= removeDirectoryRecursive (configCacheDir cfg)
......@@ -11,8 +11,7 @@
-- Utilities for handling saved state such as known packages, known servers and downloaded packages.
-----------------------------------------------------------------------------
module Network.Hackage.CabalInstall.Config
( packagesDirectory
, repoCacheDir
( repoCacheDir
, packageFile
, packageDir
, getKnownPackages
......@@ -46,7 +45,7 @@ import Distribution.PackageDescription (GenericPackageDescription(..)
import Distribution.ParseUtils (FieldDescr, simpleField, listField, liftField, field)
import Distribution.Simple.Compiler (Compiler)
import qualified Distribution.Simple.Configure as Configure (configCompiler)
import Distribution.Simple.InstallDirs (InstallDirTemplates(..), PathTemplate, defaultInstallDirs)
import Distribution.Simple.InstallDirs (InstallDirTemplates(..), PathTemplate, toPathTemplate, defaultInstallDirs)
import Distribution.Simple.Program (ProgramConfiguration, defaultProgramConfiguration)
import Distribution.Version (Dependency, showVersion)
import Distribution.Verbosity (Verbosity, normal)
......@@ -56,13 +55,9 @@ import Network.Hackage.CabalInstall.Types (ConfigFlags (..), PkgInfo (..), Repo(
import Network.Hackage.CabalInstall.Utils
-- | Full path to the packages directory.
packagesDirectory :: ConfigFlags -> FilePath
packagesDirectory cfg = configCacheDir cfg </> "packages"
-- | Full path to the local cache directory for a repository.
repoCacheDir :: ConfigFlags -> Repo -> FilePath
repoCacheDir cfg repo = packagesDirectory cfg </> repoName repo
repoCacheDir cfg repo = configCacheDir cfg </> repoName repo
-- |Generate the full path to the locally cached copy of
-- the tarball for a given @PackageIdentifer@.
......@@ -130,26 +125,28 @@ findCompiler cfg = Configure.configCompiler
-- * Default config
--
defaultConfigDir :: IO FilePath
defaultConfigDir = getAppUserDataDirectory "cabal"
defaultCabalDir :: IO FilePath
defaultCabalDir = getAppUserDataDirectory "cabal"
defaultConfigFile :: IO FilePath
defaultConfigFile = do dir <- defaultConfigDir
defaultConfigFile = do dir <- defaultCabalDir
return $ dir </> "config"
defaultCacheDir :: IO FilePath
defaultCacheDir = defaultConfigDir
defaultCacheDir = do dir <- defaultCabalDir
return $ dir </> "packages"
defaultCompiler :: CompilerFlavor
defaultCompiler = fromMaybe GHC defaultCompilerFlavor
defaultConfigFlags :: IO ConfigFlags
defaultConfigFlags =
do installDirs <- defaultInstallDirs defaultCompiler True
do defaultPrefix <- defaultCabalDir
installDirs <- defaultInstallDirs defaultCompiler True
cacheDir <- defaultCacheDir
return $ ConfigFlags
{ configCompiler = defaultCompiler
, configInstallDirs = installDirs
, configInstallDirs = installDirs { prefixDirTemplate = toPathTemplate defaultPrefix }
, configCacheDir = cacheDir
, configRepos = [Repo "hackage.haskell.org" "http://hackage.haskell.org/packages/archive"]
, configVerbose = normal
......
......@@ -32,7 +32,7 @@ import Text.Printf (printf)
import System.Directory (doesFileExist, createDirectoryIfMissing)
import Network.Hackage.CabalInstall.Types (ConfigFlags (..), UnresolvedDependency (..), Repo(..))
import Network.Hackage.CabalInstall.Config (packagesDirectory, repoCacheDir, packageFile, packageDir, pkgURL, message, findCompiler)
import Network.Hackage.CabalInstall.Config (repoCacheDir, packageFile, packageDir, pkgURL, message, findCompiler)
import Network.Hackage.CabalInstall.Dependency (filterFetchables, resolveDependencies)
import Distribution.Package (PackageIdentifier(..), showPackageId)
......
......@@ -19,7 +19,7 @@ module Network.Hackage.CabalInstall.Setup
import Control.Monad (when)
import Distribution.ParseUtils (parseDependency)
import Distribution.Compiler (CompilerFlavor(..))
import Distribution.Simple.InstallDirs (InstallDirTemplates(..))
import Distribution.Simple.InstallDirs (InstallDirTemplates(..), toPathTemplate)
import Distribution.Verbosity
import Data.List (find)
import System.Console.GetOpt (ArgDescr (..), ArgOrder (..), OptDescr (..), usageInfo, getOpt')
......@@ -97,7 +97,7 @@ configFromOptions = foldr f
OptUserInstall u -> cfg { configUserInstall = u }
OptHelp -> error "Got to setFlagsFromOptions OptHelp"
OptVerbose v -> cfg { configVerbose = v }
where lib g d = cfg { configInstallDirs = g (configInstallDirs cfg) (read $ show d) } -- FIXME: Read PathTemplate seems to require quotes
where lib g d = cfg { configInstallDirs = g (configInstallDirs cfg) (toPathTemplate d) }
data Cmd = Cmd {
cmdName :: String,
......
Supports Markdown
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