Clean up Setup.hs.

Remove post-copy hook 'myPostCopy': it's easy to write one based on
'myPostInst', so just wait until someone complains that it's missing.

Remove most comments.

Put long type sigs on one line like in the other source files.
This commit is contained in:
Nathan Collins 2012-06-12 02:50:09 -07:00
parent 2e0965eba9
commit 000bbba3c0

View file

@ -14,15 +14,13 @@ import qualified Build.Configure as Configure
main = defaultMainWithHooks simpleUserHooks main = defaultMainWithHooks simpleUserHooks
{ preConf = configure { preConf = configure
, postInst = myPostInst , postInst = myPostInst
, postCopy = myPostCopy
} }
configure _ _ = do configure _ _ = do
Configure.run Configure.tests Configure.run Configure.tests
return (Nothing, []) return (Nothing, [])
myPostInst :: Args -> InstallFlags -> PackageDescription myPostInst :: Args -> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO ()
-> LocalBuildInfo -> IO ()
myPostInst _ (InstallFlags { installVerbosity }) pkg lbi = do myPostInst _ (InstallFlags { installVerbosity }) pkg lbi = do
installGitAnnexShell dest verbosity pkg lbi installGitAnnexShell dest verbosity pkg lbi
installManpages dest verbosity pkg lbi installManpages dest verbosity pkg lbi
@ -30,27 +28,7 @@ myPostInst _ (InstallFlags { installVerbosity }) pkg lbi = do
dest = NoCopyDest dest = NoCopyDest
verbosity = fromFlag installVerbosity verbosity = fromFlag installVerbosity
-- ???: Not sure how you're supposed to use this. E.g., when I do installGitAnnexShell :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
--
-- cabal install --prefix=/tmp/git-annex-install
-- cabal copy --deistdir=/tmp/git-annex-copy
--
-- I get the copy under
--
-- /tmp/git-annex-copy/tmp/git-annex-install
--
-- Also, `cabal install` fails when given a relative --prefix.
myPostCopy :: Args -> CopyFlags -> PackageDescription
-> LocalBuildInfo -> IO ()
myPostCopy _ (CopyFlags { copyDest, copyVerbosity }) pkg lbi = do
installGitAnnexShell dest verbosity pkg lbi
installManpages dest verbosity pkg lbi
where
dest = fromFlag copyDest
verbosity = fromFlag copyVerbosity
installGitAnnexShell :: CopyDest -> Verbosity -> PackageDescription
-> LocalBuildInfo -> IO ()
installGitAnnexShell copyDest verbosity pkg lbi = installGitAnnexShell copyDest verbosity pkg lbi =
rawSystemExit verbosity "ln" rawSystemExit verbosity "ln"
["-sf", "git-annex", dstBinDir </> "git-annex-shell"] ["-sf", "git-annex", dstBinDir </> "git-annex-shell"]
@ -59,28 +37,8 @@ installGitAnnexShell copyDest verbosity pkg lbi =
-- See http://www.haskell.org/haskellwiki/Cabal/Developer-FAQ#Installing_manpages. -- See http://www.haskell.org/haskellwiki/Cabal/Developer-FAQ#Installing_manpages.
-- --
-- Based on pandoc's and lhs2tex's 'Setup.installManpages' and -- Based on pandoc's Setup.hs.
-- 'postInst' hooks. installManpages :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
--
-- My understanding: 'postCopy' is run for `cabal copy`, 'postInst' is
-- run for `cabal inst`, and copy is not a generalized install, so you
-- have to write two nearly identical hooks.
--
-- Summary of hooks:
-- http://www.haskell.org/cabal/release/cabal-latest/doc/API/Cabal/Distribution-Simple-UserHooks.htm--
-- Other people are also confused:
--
-- * Bug: 'postCopy' and 'postInst' are confusing:
-- http://hackage.haskell.org/trac/hackage/ticket/718
--
-- * A cabal maintainer suggests using 'postCopy' instead of
-- 'postInst', because `cabal install` is `cabal copy` followed by
-- `cabal register`:
-- http://www.haskell.org/pipermail/libraries/2008-March/009416.html
-- Although that sounds desirable, it's not true, as the reply and
-- experiments indicate.
installManpages :: CopyDest -> Verbosity -> PackageDescription
-> LocalBuildInfo -> IO ()
installManpages copyDest verbosity pkg lbi = installManpages copyDest verbosity pkg lbi =
installOrdinaryFiles verbosity dstManDir srcManpages installOrdinaryFiles verbosity dstManDir srcManpages
where where