-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSetup.hs
27 lines (24 loc) · 1.46 KB
/
Setup.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import Distribution.PackageDescription ( PackageDescription(..) )
import Distribution.Simple
import Distribution.Simple.InstallDirs ( docdir, mandir, CopyDest (NoCopyDest) )
import Distribution.Simple.LocalBuildInfo ( LocalBuildInfo(..), absoluteInstallDirs )
import Distribution.Simple.Program.Run ( runProgramInvocation, programInvocation, progInvokeCwd )
import Distribution.Simple.Program.Types ( ConfiguredProgram, simpleProgram )
import Distribution.Simple.Setup ( copyDest, copyVerbosity, fromFlag, installVerbosity, haddockVerbosity )
import Distribution.Simple.Utils
import Distribution.Verbosity ( Verbosity, moreVerbose )
import System.Exit ( exitSuccess )
import System.FilePath ( splitDirectories, joinPath, takeExtension, replaceExtension, (</>) )
main :: IO ()
main = do
defaultMainWithHooks $ simpleUserHooks
{ postCopy = \ _ flags pkg lbi ->
installManpages pkg lbi (fromFlag $ copyVerbosity flags) (fromFlag $ copyDest flags)
, postInst = \ _ flags pkg lbi ->
installManpages pkg lbi (fromFlag $ installVerbosity flags) NoCopyDest
}
exitSuccess
installManpages :: PackageDescription -> LocalBuildInfo -> Verbosity -> CopyDest -> IO ()
installManpages pkg lbi verbosity copy = do
installOrdinaryFiles verbosity (mandir (absoluteInstallDirs pkg lbi copy))
[ ("man", joinPath mp) | ("man":mp) <- map splitDirectories $ extraSrcFiles pkg ]