X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=libraries%2FinstallPackage.hs;h=4f5b5baee8b1d82e050e2b4be0cb661abaa4aa31;hp=d1ca8fa4c2ac5016f59d39857e952f6a6775f08f;hb=d8ca7c9ed01c99475367520dcd4906571355a4a1;hpb=5fccc8561f788bc94246a62f1fae63d29085ea63 diff --git a/libraries/installPackage.hs b/libraries/installPackage.hs index d1ca8fa..4f5b5ba 100644 --- a/libraries/installPackage.hs +++ b/libraries/installPackage.hs @@ -13,7 +13,10 @@ main :: IO () main = do args <- getArgs case args of - destdir : pref : idatadir : idocdir : ghcpkg : ghcpkgconf : args' -> + ghcpkg : ghcpkgconf : destdir : topdir : + iprefix : ibindir : ilibdir : ilibexecdir : + idatadir : idocdir : ihtmldir : iinterfacedir : + args' -> let verbosity = case args' of [] -> normal ['-':'v':v] -> @@ -22,22 +25,26 @@ main _ -> Just v in flagToVerbosity m _ -> error ("Bad arguments: " ++ show args) - in doit destdir pref idatadir idocdir ghcpkg ghcpkgconf - verbosity + in doit verbosity ghcpkg ghcpkgconf destdir topdir + iprefix ibindir ilibdir ilibexecdir idatadir + idocdir ihtmldir iinterfacedir _ -> error "Missing arguments" -doit :: FilePath -> FilePath -> FilePath -> FilePath -> FilePath -> FilePath - -> Verbosity +doit :: Verbosity -> FilePath -> FilePath -> FilePath -> FilePath + -> FilePath -> FilePath -> FilePath -> FilePath -> FilePath + -> FilePath -> FilePath -> FilePath -> IO () -doit destdir pref idatadir idocdir ghcpkg ghcpkgconf verbosity = +doit verbosity ghcpkg ghcpkgconf destdir topdir + iprefix ibindir ilibdir ilibexecdir idatadir + idocdir ihtmldir iinterfacedir = do let userHooks = simpleUserHooks copyto = if null destdir then NoCopyDest else CopyTo destdir copyFlags = (emptyCopyFlags copyto) { copyVerbose = verbosity } registerFlags = emptyRegisterFlags { - regUser = MaybeUserGlobal, + regPackageDB = Just GlobalPackageDB, regVerbose = verbosity, regGenScript = False, regInPlace = False @@ -61,9 +68,15 @@ doit destdir pref idatadir idocdir ghcpkg ghcpkgconf verbosity = pd_reg = pd { library = Just (mkLib (const True)) } -- When coying, we need to actually give a concrete -- directory to copy to rather than "$topdir" - i_copy = i { prefixDirTemplate = toPathTemplate pref, - dataDirTemplate = toPathTemplate idatadir, - docDirTemplate = toPathTemplate idocdir + toPathTemplate' = toPathTemplate . replaceTopdir topdir + i_copy = i { prefixDirTemplate = toPathTemplate' iprefix, + binDirTemplate = toPathTemplate' ibindir, + libDirTemplate = toPathTemplate' ilibdir, + libexecDirTemplate = toPathTemplate' ilibexecdir, + dataDirTemplate = toPathTemplate' idatadir, + docDirTemplate = toPathTemplate' idocdir, + htmlDirTemplate = toPathTemplate' ihtmldir, + interfaceDirTemplate = toPathTemplate' iinterfacedir } lbi_copy = lbi { installDirTemplates = i_copy } -- When we run GHC we give it a $topdir that includes the @@ -74,17 +87,31 @@ doit destdir pref idatadir idocdir ghcpkg ghcpkgconf verbosity = prog = ConfiguredProgram { programId = programName ghcPkgProgram, programVersion = Nothing, - programArgs = ["--global-conf", ghcpkgconf], + programArgs = ["--force", "--global-conf", ghcpkgconf], programLocation = UserSpecified ghcpkg } progs' = updateProgram prog progs - i_reg = i { libSubdirTemplate = toPathTemplate "$pkgid" } + i_reg = i { prefixDirTemplate = toPathTemplate iprefix, + binDirTemplate = toPathTemplate ibindir, + libDirTemplate = toPathTemplate ilibdir, + libexecDirTemplate = toPathTemplate ilibexecdir, + dataDirTemplate = toPathTemplate idatadir, + docDirTemplate = toPathTemplate idocdir, + htmlDirTemplate = toPathTemplate ihtmldir, + interfaceDirTemplate = toPathTemplate iinterfacedir + } lbi_reg = lbi { installDirTemplates = i_reg, withPrograms = progs' } (copyHook simpleUserHooks) pd_copy lbi_copy userHooks copyFlags (regHook simpleUserHooks) pd_reg lbi_reg userHooks registerFlags return () +replaceTopdir :: FilePath -> FilePath -> FilePath +replaceTopdir topdir ('$':'t':'o':'p':'d':'i':'r':p) = topdir ++ p +replaceTopdir topdir ('$':'h':'t':'t':'p':'t':'o':'p':'d':'i':'r':p) + = topdir ++ p +replaceTopdir _ p = p + -- Get the build info, merging the setup-config and buildinfo files. getConfig :: Verbosity -> IO LocalBuildInfo getConfig verbosity = do