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
|
|
|
|
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
|
2016-04-28 19:18:11 +00:00
|
|
|
import System.Directory
|
2015-07-31 15:34:09 +00:00
|
|
|
import Data.List
|
2016-05-31 17:58:13 +00:00
|
|
|
import Data.Maybe
|
2015-11-03 14:45:33 +00:00
|
|
|
import Control.Exception
|
2016-05-05 20:05:27 +00:00
|
|
|
import qualified System.Info
|
2011-06-30 18:55:03 +00:00
|
|
|
|
2013-04-17 16:02:44 +00:00
|
|
|
import qualified Build.DesktopFile as DesktopFile
|
2012-03-10 18:00:26 +00:00
|
|
|
import qualified Build.Configure as Configure
|
2016-05-31 17:58:13 +00:00
|
|
|
import Build.Mans (buildMans)
|
2016-05-24 05:00:06 +00:00
|
|
|
import Utility.SafeCommand
|
2011-06-30 18:55:03 +00:00
|
|
|
|
2014-03-10 20:59:38 +00:00
|
|
|
main :: IO ()
|
2012-04-14 18:01:14 +00:00
|
|
|
main = defaultMainWithHooks simpleUserHooks
|
2014-03-10 20:59:38 +00:00
|
|
|
{ preConf = \_ _ -> do
|
|
|
|
Configure.run Configure.tests
|
|
|
|
return (Nothing, [])
|
2015-07-31 16:03:19 +00:00
|
|
|
, postCopy = myPostCopy
|
2012-04-14 18:01:14 +00:00
|
|
|
}
|
2011-06-30 18:55:03 +00:00
|
|
|
|
2015-07-31 16:03:19 +00:00
|
|
|
myPostCopy :: Args -> CopyFlags -> PackageDescription -> LocalBuildInfo -> IO ()
|
2016-05-05 20:05:27 +00:00
|
|
|
myPostCopy _ flags pkg lbi = when (System.Info.os /= "mingw32") $ do
|
2016-11-21 21:27:38 +00:00
|
|
|
installGitAnnexLinks dest verbosity pkg lbi
|
2012-06-10 09:21:13 +00:00
|
|
|
installManpages dest verbosity pkg lbi
|
2012-08-02 01:04:25 +00:00
|
|
|
installDesktopFile dest verbosity pkg lbi
|
2012-11-11 04:51:07 +00:00
|
|
|
where
|
2015-08-09 14:30:35 +00:00
|
|
|
dest = fromFlag $ copyDest flags
|
|
|
|
verbosity = fromFlag $ copyVerbosity flags
|
2012-06-10 06:32:25 +00:00
|
|
|
|
2016-11-21 21:27:38 +00:00
|
|
|
installGitAnnexLinks :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
|
|
|
|
installGitAnnexLinks copyDest verbosity pkg lbi = do
|
2012-06-10 09:21:13 +00:00
|
|
|
rawSystemExit verbosity "ln"
|
|
|
|
["-sf", "git-annex", dstBinDir </> "git-annex-shell"]
|
2016-11-21 21:27:38 +00:00
|
|
|
rawSystemExit verbosity "ln"
|
|
|
|
["-sf", "git-annex", dstBinDir </> "git-remote-tor-annex"]
|
2012-11-11 04:51:07 +00:00
|
|
|
where
|
|
|
|
dstBinDir = bindir $ absoluteInstallDirs pkg lbi copyDest
|
2012-06-06 09:35:32 +00:00
|
|
|
|
2016-05-24 05:00:06 +00:00
|
|
|
{- See http://www.haskell.org/haskellwiki/Cabal/Developer-FAQ#Installing_manpages -}
|
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-11-11 04:51:07 +00:00
|
|
|
where
|
|
|
|
dstManDir = mandir (absoluteInstallDirs pkg lbi copyDest) </> "man1"
|
2016-05-31 17:58:13 +00:00
|
|
|
-- If mdwn2man fails, perhaps because perl is not available,
|
|
|
|
-- we just skip installing man pages.
|
|
|
|
srcManpages = zip (repeat "man") . map takeFileName . catMaybes
|
|
|
|
<$> buildMans
|
2012-08-02 01:04:25 +00:00
|
|
|
|
|
|
|
installDesktopFile :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
|
2015-08-09 14:30:35 +00:00
|
|
|
installDesktopFile copyDest _verbosity pkg lbi
|
|
|
|
| progfile copyDest == progfile NoCopyDest =
|
2015-11-03 15:06:33 +00:00
|
|
|
DesktopFile.installUser (progfile copyDest)
|
|
|
|
`catch` installerror
|
2015-08-09 14:30:35 +00:00
|
|
|
| otherwise = return ()
|
2012-11-11 04:51:07 +00:00
|
|
|
where
|
2015-08-09 14:30:35 +00:00
|
|
|
progfile cd = bindir (absoluteInstallDirs pkg lbi cd) </> "git-annex"
|
2015-11-03 15:06:33 +00:00
|
|
|
installerror :: SomeException -> IO ()
|
|
|
|
installerror e = putStrLn ("Warning: Installation of desktop integration files did not succeed (" ++ show e ++ "); skipping.")
|