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
|
|
|
|
import System.Directory
|
2015-07-31 15:34:09 +00:00
|
|
|
import Data.List
|
2015-11-03 14:45:33 +00:00
|
|
|
import Control.Exception
|
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
|
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 ()
|
2015-08-09 14:30:35 +00:00
|
|
|
myPostCopy _ flags 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-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
|
|
|
|
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"]
|
2012-11-11 04:51:07 +00:00
|
|
|
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-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"
|
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.")
|