2012-06-10 06:32:25 +00:00
|
|
|
{-# LANGUAGE NamedFieldPuns #-}
|
2012-06-12 15:38:16 +00:00
|
|
|
|
2011-06-30 18:55:03 +00:00
|
|
|
{- cabal setup file -}
|
|
|
|
|
|
|
|
import Distribution.Simple
|
2012-04-14 18:01:14 +00:00
|
|
|
import Distribution.Simple.LocalBuildInfo
|
|
|
|
import Distribution.Simple.Setup
|
2012-06-10 06:32:25 +00:00
|
|
|
import Distribution.Simple.Utils (installOrdinaryFiles, rawSystemExit)
|
2012-06-06 09:35:32 +00:00
|
|
|
import Distribution.PackageDescription (PackageDescription(..))
|
|
|
|
import Distribution.Verbosity (Verbosity)
|
2012-04-14 18:01:14 +00:00
|
|
|
import System.FilePath
|
2012-09-01 19:20:45 +00:00
|
|
|
import Control.Applicative
|
|
|
|
import Control.Monad
|
|
|
|
import System.Directory
|
2011-06-30 18:55:03 +00:00
|
|
|
|
2012-08-02 01:04:25 +00:00
|
|
|
import qualified Build.InstallDesktopFile as InstallDesktopFile
|
2012-03-10 18:00:26 +00:00
|
|
|
import qualified Build.Configure as Configure
|
2011-06-30 18:55:03 +00:00
|
|
|
|
2012-04-14 18:01:14 +00:00
|
|
|
main = defaultMainWithHooks simpleUserHooks
|
|
|
|
{ preConf = configure
|
2012-06-10 06:32:25 +00:00
|
|
|
, postInst = myPostInst
|
2012-04-14 18:01:14 +00:00
|
|
|
}
|
2011-06-30 18:55:03 +00:00
|
|
|
|
2012-03-10 18:00:26 +00:00
|
|
|
configure _ _ = do
|
2012-03-23 16:24:40 +00:00
|
|
|
Configure.run Configure.tests
|
2012-03-10 18:00:26 +00:00
|
|
|
return (Nothing, [])
|
2012-04-14 18:01:14 +00:00
|
|
|
|
2012-06-12 09:50:09 +00:00
|
|
|
myPostInst :: Args -> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO ()
|
2012-06-10 06:32:25 +00:00
|
|
|
myPostInst _ (InstallFlags { installVerbosity }) pkg lbi = do
|
2012-06-10 09:21:13 +00:00
|
|
|
installGitAnnexShell dest verbosity pkg lbi
|
|
|
|
installManpages dest verbosity pkg lbi
|
2012-08-02 01:04:25 +00:00
|
|
|
installDesktopFile dest verbosity pkg lbi
|
2012-06-10 09:21:13 +00:00
|
|
|
where
|
|
|
|
dest = NoCopyDest
|
|
|
|
verbosity = fromFlag installVerbosity
|
2012-06-10 06:32:25 +00:00
|
|
|
|
2012-06-12 09:50:09 +00:00
|
|
|
installGitAnnexShell :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
|
2012-06-10 06:32:25 +00:00
|
|
|
installGitAnnexShell copyDest verbosity pkg lbi =
|
2012-06-10 09:21:13 +00:00
|
|
|
rawSystemExit verbosity "ln"
|
|
|
|
["-sf", "git-annex", dstBinDir </> "git-annex-shell"]
|
|
|
|
where
|
|
|
|
dstBinDir = bindir $ absoluteInstallDirs pkg lbi copyDest
|
2012-06-06 09:35:32 +00:00
|
|
|
|
2012-09-01 19:20:45 +00:00
|
|
|
{- 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.
|
|
|
|
-}
|
2012-06-12 09:50:09 +00:00
|
|
|
installManpages :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
|
2012-06-10 06:32:25 +00:00
|
|
|
installManpages copyDest verbosity pkg lbi =
|
2012-09-01 19:20:45 +00:00
|
|
|
installOrdinaryFiles verbosity dstManDir =<< srcManpages
|
2012-06-10 09:21:13 +00:00
|
|
|
where
|
|
|
|
dstManDir = mandir (absoluteInstallDirs pkg lbi copyDest) </> "man1"
|
2012-09-01 19:20:45 +00:00
|
|
|
srcManpages = zip (repeat srcManDir)
|
|
|
|
<$> filterM doesFileExist manpages
|
2012-06-10 09:21:13 +00:00
|
|
|
srcManDir = ""
|
|
|
|
manpages = ["git-annex.1", "git-annex-shell.1"]
|
2012-08-02 01:04:25 +00:00
|
|
|
|
|
|
|
installDesktopFile :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
|
|
|
|
installDesktopFile copyDest verbosity pkg lbi =
|
2012-08-02 03:31:53 +00:00
|
|
|
InstallDesktopFile.writeDesktop $ dstBinDir </> "git-annex"
|
2012-08-02 01:04:25 +00:00
|
|
|
where
|
|
|
|
dstBinDir = bindir $ absoluteInstallDirs pkg lbi copyDest
|