PageRenderTime 32ms CodeModel.GetById 19ms app.highlight 6ms RepoModel.GetById 3ms app.codeStats 0ms

/Setup.hs

http://github.com/Eelis/geordi
Haskell | 26 lines | 22 code | 3 blank | 1 comment | 0 complexity | 86528a2fb5dbf5f9d3a2cc6f87de6930 MD5 | raw file
 1#! /usr/bin/env runhaskell
 2
 3import Distribution.Simple
 4import Distribution.Simple.Setup (ConfigFlags, InstallFlags)
 5import Distribution.PackageDescription (PackageDescription(..))
 6import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..))
 7import Distribution.Simple.InstallDirs (initialPathTemplateEnv, prefix, bindir, datadir, datasubdir, fromPathTemplate, installDirsTemplateEnv, packageTemplateEnv, substPathTemplate)
 8import System.Posix.Files (setFileMode, ownerModes)
 9
10main :: IO ()
11main = defaultMainWithHooks $ autoconfUserHooks { postInst = myPostInst }
12
13myPostInst :: Args -> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO ()
14myPostInst args flags pkg_descr lbi = do
15  (pre, _:post) <- fmap (span (/= "DATA=\"\"") . lines) $ readFile "scripts/compile-prelude"
16  let
17    idt = installDirTemplates lbi
18    env = installDirsTemplateEnv idt
19    idt' = fmap (fromPathTemplate
20      . substPathTemplate env
21      . substPathTemplate (packageTemplateEnv (package pkg_descr))) idt
22      -- This makes little sense to me, but it works...
23    to = bindir idt' ++ "/geordi-compile-prelude"
24  writeFile to $ unlines $ pre ++ ["DATA=\"" ++ datadir idt' ++ "/" ++ datasubdir idt' ++ "/\""] ++ post
25  setFileMode to ownerModes
26  postInst autoconfUserHooks args flags pkg_descr lbi