summaryrefslogtreecommitdiff
path: root/Setup.hs
diff options
context:
space:
mode:
authorGravatar Nathan Collins <nathan.collins@gmail.com>2012-06-06 02:35:32 -0700
committerGravatar Nathan Collins <nathan.collins@gmail.com>2012-06-06 02:35:32 -0700
commit6f17b2fb39f389b01accee420548b54e22f41e0a (patch)
tree0329dc20074366fb6e09fe4dac72667ddce989e4 /Setup.hs
parent1cfd2e1c0572acf13f75897af3f5921cf0950e75 (diff)
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.
Diffstat (limited to 'Setup.hs')
-rw-r--r--Setup.hs24
1 files changed, 24 insertions, 0 deletions
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