From 6f17b2fb39f389b01accee420548b54e22f41e0a Mon Sep 17 00:00:00 2001 From: Nathan Collins Date: Wed, 6 Jun 2012 02:35:32 -0700 Subject: WIP: Add man page installation to Setup.hs This works with `cabal-dev install .`, but `cabal sdist` does not yet include the man pages (tried adding a `make $(mans)` before `cabal sdist` in `make sdist`, but no luck). XXX: Need to go back and replace spaces with tabs. --- Setup.hs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Setup.hs') diff --git a/Setup.hs b/Setup.hs index c36d6e4fe..c722077eb 100644 --- a/Setup.hs +++ b/Setup.hs @@ -3,6 +3,9 @@ import Distribution.Simple import Distribution.Simple.LocalBuildInfo import Distribution.Simple.Setup +import Distribution.Simple.Utils (installOrdinaryFiles) +import Distribution.PackageDescription (PackageDescription(..)) +import Distribution.Verbosity (Verbosity) import System.Cmd import System.FilePath @@ -11,6 +14,7 @@ import qualified Build.Configure as Configure main = defaultMainWithHooks simpleUserHooks { preConf = configure , instHook = install + , postInst = const installManpages } configure _ _ = do @@ -25,3 +29,23 @@ install pkg_descr lbi userhooks flags = do where installDirs = absoluteInstallDirs pkg_descr lbi $ fromFlag (copyDest defaultCopyFlags) + +-- See http://www.haskell.org/haskellwiki/Cabal/Developer-FAQ#Installing_manpages. +-- +-- Based on pandoc's 'Setup.installManpages' and 'postInst' hook. +-- Would be easier to just use 'rawSystem' as above. +-- +-- XXX: fix tabs! +installManpages :: InstallFlags -> PackageDescription -> LocalBuildInfo -> IO () +installManpages flags pkg lbi = + installOrdinaryFiles verbosity dstManDir manpages + where + srcManDir = "" + -- The 'NoCopyDest' means "don't add an additional path prefix". + -- The pandoc Setup.hs uses 'NoCopyDest' in the post install hook + -- and the 'CopyDest' from the copy flags in the post copy hook. + dstManDir = mandir (absoluteInstallDirs pkg lbi NoCopyDest) "man1" + manpages = zip (repeat srcManDir) + [ "git-annex.1" + , "git-annex-shell.1" ] + verbosity = fromFlag $ installVerbosity flags -- cgit v1.2.3