Commit babef8d0 authored by ijones's avatar ijones
Browse files

respects --user flag

** made register command respect --user flag
** changed install to put the sources in the place that register
   expects it, though I'm not sure if it's exactly right.
parent 01c060d0
...@@ -49,7 +49,7 @@ module Distribution.Simple.Install ( ...@@ -49,7 +49,7 @@ module Distribution.Simple.Install (
import Distribution.Package (PackageDescription(..), showPackageId) import Distribution.Package (PackageDescription(..), showPackageId)
import Distribution.Simple.Configure(LocalBuildInfo(..)) import Distribution.Simple.Configure(LocalBuildInfo(..))
import Distribution.Simple.Utils(setupMessage, moveSources) import Distribution.Simple.Utils(setupMessage, moveSources, pathSeperatorStr)
import System.Cmd(system) import System.Cmd(system)
import System.Directory(doesDirectoryExist, createDirectory, doesFileExist) import System.Directory(doesDirectoryExist, createDirectory, doesFileExist)
...@@ -62,7 +62,8 @@ install :: PackageDescription -> LocalBuildInfo ...@@ -62,7 +62,8 @@ install :: PackageDescription -> LocalBuildInfo
-> Maybe FilePath -- ^install-prefix -> Maybe FilePath -- ^install-prefix
-> IO () -> IO ()
install pkg_descr lbi install_prefixM = do install pkg_descr lbi install_prefixM = do
let pref = maybe (prefix lbi) id install_prefixM let pref = (maybe (prefix lbi) id install_prefixM) ++
pathSeperatorStr ++ "lib" ++ pathSeperatorStr ++ (showPackageId $ package pkg_descr)
setupMessage "Installing" pkg_descr setupMessage "Installing" pkg_descr
moveSources pref (allModules pkg_descr) (mainModules pkg_descr) moveSources pref (allModules pkg_descr) (mainModules pkg_descr)
-- installation step should be performed by caller. -- installation step should be performed by caller.
......
...@@ -52,6 +52,8 @@ import Distribution.Package (PackageDescription, package, showPackageId) ...@@ -52,6 +52,8 @@ import Distribution.Package (PackageDescription, package, showPackageId)
import Distribution.Simple.Utils (setupMessage, rawSystemExit, die) import Distribution.Simple.Utils (setupMessage, rawSystemExit, die)
import Distribution.Simple.GHCPackageConfig (mkGHCPackageConfig, showGHCPackageConfig) import Distribution.Simple.GHCPackageConfig (mkGHCPackageConfig, showGHCPackageConfig)
import System(getEnv)
import Control.Monad (when) import Control.Monad (when)
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
...@@ -62,13 +64,14 @@ register :: PackageDescription -> LocalBuildInfo ...@@ -62,13 +64,14 @@ register :: PackageDescription -> LocalBuildInfo
-> IO () -> IO ()
register pkg_descr lbi userInst = do register pkg_descr lbi userInst = do
setupMessage "Registering" pkg_descr setupMessage "Registering" pkg_descr
when userInst (putStrLn "Would install for --user, but not implemented")
case compilerFlavor (compiler lbi) of case compilerFlavor (compiler lbi) of
GHC -> do let pkg_config = mkGHCPackageConfig pkg_descr lbi GHC -> do let pkg_config = mkGHCPackageConfig pkg_descr lbi
writeFile installedPkgConfigFile (showGHCPackageConfig pkg_config) writeFile installedPkgConfigFile (showGHCPackageConfig pkg_config)
home <- getEnv "HOME"
rawSystemExit (compilerPkgTool (compiler lbi)) rawSystemExit (compilerPkgTool (compiler lbi))
["--add-package", "--input-file="++installedPkgConfigFile] (["--add-package", "--input-file="++installedPkgConfigFile]
++ (if userInst then ["--config-file=" ++ home ++ "/.ghc-packages"] else []))
_ -> die ("only registering with GHC is implemented") _ -> die ("only registering with GHC is implemented")
installedPkgConfigFile :: String installedPkgConfigFile :: String
......
* Code * Code
** Write top-level Setup test cases (like "make check" under the test directory)
** Extensions -> flags interface ** Extensions -> flags interface
** parse pkg.desc ** parse Setup.description
** build (for NHC and Hugs) ** build (for NHC and Hugs)
** install (for GHC and NHC) - look for .o and .hi, register, etc ** install (for GHC and NHC) - look for .o and .hi, register, etc
...@@ -20,8 +22,8 @@ ...@@ -20,8 +22,8 @@
** clean up Setup parsing code. ** clean up Setup parsing code.
** register ** register
** generate InstalledPackageInfo *** for hugs & nhc
** read & write config-droppings
** configure: check for presence of build dependencies ** configure: check for presence of build dependencies
** ./Setup test ** ./Setup test
......
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