% Package manipulation
%
\begin{code}
-{-# OPTIONS_GHC -w #-}
+{-# OPTIONS -w #-}
-- The above warning supression flag is a temporary kludge.
-- While working on this module you are encouraged to remove it and fix
-- any warnings in the module. See
--- http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings
+-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
-- for details
module Packages (
import ErrUtils ( debugTraceMsg, putMsg, Message )
import System.Directory
+import System.FilePath
import Data.Maybe
import Control.Monad
import Data.List
-- to maintain the package database on systems with a package
-- management system, or systems that don't want to run ghc-pkg
-- to register or unregister packages. Undocumented feature for now.
- let system_pkgconf_dir = system_pkgconf ++ ".d"
+ let system_pkgconf_dir = system_pkgconf <.> "d"
system_pkgconf_dir_exists <- doesDirectoryExist system_pkgconf_dir
system_pkgconfs <-
if system_pkgconf_dir_exists
then do files <- getDirectoryContents system_pkgconf_dir
- return [ system_pkgconf_dir ++ '/' : file
+ return [ system_pkgconf_dir </> file
| file <- files
- , isSuffixOf ".conf" file]
+ , takeExtension file == ".conf" ]
else return []
-- Read user's package conf (eg. ~/.ghc/i386-linux-6.3/package.conf)
appdir <- getAppUserDataDirectory "ghc"
let
pkgconf = appdir
- `joinFileName` (TARGET_ARCH ++ '-':TARGET_OS ++ '-':cProjectVersion)
- `joinFileName` "package.conf"
+ </> (TARGET_ARCH ++ '-':TARGET_OS ++ '-':cProjectVersion)
+ </> "package.conf"
flg <- doesFileExist pkgconf
if (flg && dopt Opt_ReadUserPackageConf dflags)
then return [pkgconf]
munge_paths = map munge_path
munge_path p
- | Just p' <- maybePrefixMatch "$topdir" p = top_dir ++ p'
+ | Just p' <- maybePrefixMatch "$topdir" p = top_dir ++ p'
+ | Just p' <- maybePrefixMatch "$httptopdir" p = toHttpPath top_dir ++ p'
| otherwise = p
+ toHttpPath p = "file:///" ++ p
+
-- -----------------------------------------------------------------------------
-- Modify our copy of the package database based on a package flag
-- add base & rts to the preload packages
basicLinkedPackages = filter (flip elemUFM pkg_db)
[basePackageId,rtsPackageId]
- preload2 = nub (basicLinkedPackages ++ map mkPackageId preload1)
+ -- but in any case remove the current package from the set of
+ -- preloaded packages so that base/rts does not end up in the
+ -- set up preloaded package when we are just building it
+ preload2 = nub (filter (/= new_this_pkg)
+ (basicLinkedPackages ++ map mkPackageId preload1))
-- Close the preload packages with their dependencies
dep_preload <- closeDeps pkg_db (zip preload2 (repeat Nothing))
extend_modmap pkgid modmap =
addListToUFM_C (++) modmap
- [(m, [(pkg, m `elem` exposed_mods)]) | m <- all_mods]
+ ([(m, [(pkg, True)]) | m <- exposed_mods] ++
+ [(m, [(pkg, False)]) | m <- hidden_mods])
where
pkg = expectJust "mkModuleMap" (lookupPackage pkg_db pkgid)
- exposed_mods = map mkModuleName (exposedModules pkg)
- hidden_mods = map mkModuleName (hiddenModules pkg)
- all_mods = exposed_mods ++ hidden_mods
+ exposed_mods = exposedModules pkg
+ hidden_mods = hiddenModules pkg
pprPkg :: PackageConfig -> SDoc
pprPkg p = text (showPackageId (package p))
dumpPackages dflags
= do let pkg_map = pkgIdMap (pkgState dflags)
putMsg dflags $
- vcat (map (text.showInstalledPackageInfo) (eltsUFM pkg_map))
+ vcat (map (text.showInstalledPackageInfo.to_ipi) (eltsUFM pkg_map))
+ where
+ to_ipi pkgconf@InstalledPackageInfo_{ exposedModules = e,
+ hiddenModules = h } =
+ pkgconf{ exposedModules = map moduleNameString e,
+ hiddenModules = map moduleNameString h }
\end{code}