git-annex/Setup.hs

69 lines
2.3 KiB
Haskell
Raw Normal View History

Combine post install commands in 'postInst' and add 'postCopy' hook. The creation of the 'git-annex-shell' symlink was in 'postInst' hook. I combined it with the man-page installation in a 'postInst' hook and a 'postCopy' hook. I don't understand how to use the `cabal copy` command, but the examples I looked at defined both hooks. Relevant comments from the source: * man-page installation: See http://www.haskell.org/haskellwiki/Cabal/Developer-FAQ#Installing_manpages. Based on pandoc's and lhs2tex's 'Setup.installManpages' and 'postInst' hooks. 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. * the `cabal copy` command: ???: Not sure how you're supposed to use this. E.g., when I do 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.
2012-06-10 06:32:25 +00:00
{-# LANGUAGE NamedFieldPuns #-}
2015-05-10 20:40:24 +00:00
{-# OPTIONS_GHC -fno-warn-tabs #-}
2012-06-12 15:38:16 +00:00
{- cabal setup file -}
import Distribution.Simple
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Setup
Combine post install commands in 'postInst' and add 'postCopy' hook. The creation of the 'git-annex-shell' symlink was in 'postInst' hook. I combined it with the man-page installation in a 'postInst' hook and a 'postCopy' hook. I don't understand how to use the `cabal copy` command, but the examples I looked at defined both hooks. Relevant comments from the source: * man-page installation: See http://www.haskell.org/haskellwiki/Cabal/Developer-FAQ#Installing_manpages. Based on pandoc's and lhs2tex's 'Setup.installManpages' and 'postInst' hooks. 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. * the `cabal copy` command: ???: Not sure how you're supposed to use this. E.g., when I do 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.
2012-06-10 06:32:25 +00:00
import Distribution.Simple.Utils (installOrdinaryFiles, rawSystemExit)
import Distribution.PackageDescription (PackageDescription(..))
import Distribution.Verbosity (Verbosity)
import System.FilePath
import Control.Applicative
import Control.Monad
import System.Directory
2015-07-31 15:34:09 +00:00
import Data.List
2013-04-17 16:02:44 +00:00
import qualified Build.DesktopFile as DesktopFile
import qualified Build.Configure as Configure
2014-03-10 20:59:38 +00:00
main :: IO ()
main = defaultMainWithHooks simpleUserHooks
2014-03-10 20:59:38 +00:00
{ preConf = \_ _ -> do
Configure.run Configure.tests
return (Nothing, [])
, postCopy = myPostCopy
}
myPostCopy :: Args -> CopyFlags -> PackageDescription -> LocalBuildInfo -> IO ()
myPostCopy _ (CopyFlags { copyVerbosity }) pkg lbi = do
installGitAnnexShell dest verbosity pkg lbi
installManpages dest verbosity pkg lbi
installDesktopFile dest verbosity pkg lbi
2012-11-11 04:51:07 +00:00
where
dest = NoCopyDest
verbosity = fromFlag copyVerbosity
Combine post install commands in 'postInst' and add 'postCopy' hook. The creation of the 'git-annex-shell' symlink was in 'postInst' hook. I combined it with the man-page installation in a 'postInst' hook and a 'postCopy' hook. I don't understand how to use the `cabal copy` command, but the examples I looked at defined both hooks. Relevant comments from the source: * man-page installation: See http://www.haskell.org/haskellwiki/Cabal/Developer-FAQ#Installing_manpages. Based on pandoc's and lhs2tex's 'Setup.installManpages' and 'postInst' hooks. 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. * the `cabal copy` command: ???: Not sure how you're supposed to use this. E.g., when I do 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.
2012-06-10 06:32:25 +00:00
installGitAnnexShell :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
Combine post install commands in 'postInst' and add 'postCopy' hook. The creation of the 'git-annex-shell' symlink was in 'postInst' hook. I combined it with the man-page installation in a 'postInst' hook and a 'postCopy' hook. I don't understand how to use the `cabal copy` command, but the examples I looked at defined both hooks. Relevant comments from the source: * man-page installation: See http://www.haskell.org/haskellwiki/Cabal/Developer-FAQ#Installing_manpages. Based on pandoc's and lhs2tex's 'Setup.installManpages' and 'postInst' hooks. 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. * the `cabal copy` command: ???: Not sure how you're supposed to use this. E.g., when I do 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.
2012-06-10 06:32:25 +00:00
installGitAnnexShell copyDest verbosity pkg lbi =
rawSystemExit verbosity "ln"
["-sf", "git-annex", dstBinDir </> "git-annex-shell"]
2012-11-11 04:51:07 +00:00
where
dstBinDir = bindir $ absoluteInstallDirs pkg lbi copyDest
{- See http://www.haskell.org/haskellwiki/Cabal/Developer-FAQ#Installing_manpages
-
- Man pages are provided prebuilt in the tarball in cabal,
- but may not be available otherwise, in which case, skip installing them.
-}
installManpages :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
Combine post install commands in 'postInst' and add 'postCopy' hook. The creation of the 'git-annex-shell' symlink was in 'postInst' hook. I combined it with the man-page installation in a 'postInst' hook and a 'postCopy' hook. I don't understand how to use the `cabal copy` command, but the examples I looked at defined both hooks. Relevant comments from the source: * man-page installation: See http://www.haskell.org/haskellwiki/Cabal/Developer-FAQ#Installing_manpages. Based on pandoc's and lhs2tex's 'Setup.installManpages' and 'postInst' hooks. 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. * the `cabal copy` command: ???: Not sure how you're supposed to use this. E.g., when I do 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.
2012-06-10 06:32:25 +00:00
installManpages copyDest verbosity pkg lbi =
installOrdinaryFiles verbosity dstManDir =<< srcManpages
2012-11-11 04:51:07 +00:00
where
dstManDir = mandir (absoluteInstallDirs pkg lbi copyDest) </> "man1"
2015-07-31 15:34:09 +00:00
srcManpages = do
havemans <- doesDirectoryExist srcManDir
if havemans
then zip (repeat srcManDir)
. filter (".1" `isSuffixOf`)
<$> getDirectoryContents srcManDir
else return []
srcManDir = "man"
installDesktopFile :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
2014-03-10 20:59:38 +00:00
installDesktopFile copyDest _verbosity pkg lbi =
2013-04-17 16:02:44 +00:00
DesktopFile.install $ dstBinDir </> "git-annex"
2012-11-11 04:51:07 +00:00
where
dstBinDir = bindir $ absoluteInstallDirs pkg lbi copyDest