f79875ef3b
The tarball on hackage will include only the files needed for cabal install; it is NOT the full git-annex source tree. While it's totally obnoxious that cabal files need every file listed out when basic wildcard support could avoid hundreds of lines, and have to be maintained when files are added, this does get the tarball size back down to 1 mb. This also stops stack from complaining that it found modules not listed in the cabal file. debian/changelog, debian/NEWS, debian/copyright: Converted to symlinks to CHANGELOG, NEWS, and COPYRIGHT, which used to symlink to these instead. This avoids needing to include debian/ in the hackage tarball. Setup.hs: Build man pages at install time using make and mdwn2man. If it fails, which it probably will on windows, just skip installing them.
71 lines
2.5 KiB
Haskell
71 lines
2.5 KiB
Haskell
{-# LANGUAGE NamedFieldPuns #-}
|
|
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
|
|
|
{- cabal setup file -}
|
|
|
|
import Distribution.Simple
|
|
import Distribution.Simple.LocalBuildInfo
|
|
import Distribution.Simple.Setup
|
|
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
|
|
import Data.List
|
|
import Control.Exception
|
|
import qualified System.Info
|
|
|
|
import qualified Build.DesktopFile as DesktopFile
|
|
import qualified Build.Configure as Configure
|
|
import Utility.SafeCommand
|
|
|
|
main :: IO ()
|
|
main = defaultMainWithHooks simpleUserHooks
|
|
{ preConf = \_ _ -> do
|
|
Configure.run Configure.tests
|
|
return (Nothing, [])
|
|
, postCopy = myPostCopy
|
|
}
|
|
|
|
myPostCopy :: Args -> CopyFlags -> PackageDescription -> LocalBuildInfo -> IO ()
|
|
myPostCopy _ flags pkg lbi = when (System.Info.os /= "mingw32") $ do
|
|
installGitAnnexShell dest verbosity pkg lbi
|
|
installManpages dest verbosity pkg lbi
|
|
installDesktopFile dest verbosity pkg lbi
|
|
where
|
|
dest = fromFlag $ copyDest flags
|
|
verbosity = fromFlag $ copyVerbosity flags
|
|
|
|
installGitAnnexShell :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
|
|
installGitAnnexShell copyDest verbosity pkg lbi =
|
|
rawSystemExit verbosity "ln"
|
|
["-sf", "git-annex", dstBinDir </> "git-annex-shell"]
|
|
where
|
|
dstBinDir = bindir $ absoluteInstallDirs pkg lbi copyDest
|
|
|
|
{- See http://www.haskell.org/haskellwiki/Cabal/Developer-FAQ#Installing_manpages -}
|
|
installManpages :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
|
|
installManpages copyDest verbosity pkg lbi =
|
|
installOrdinaryFiles verbosity dstManDir =<< srcManpages
|
|
where
|
|
dstManDir = mandir (absoluteInstallDirs pkg lbi copyDest) </> "man1"
|
|
srcManpages = do
|
|
havemans <- boolSystem "make" [Param "mans"]
|
|
if havemans
|
|
then zip (repeat "man")
|
|
. filter (".1" `isSuffixOf`)
|
|
<$> getDirectoryContents "man"
|
|
else return []
|
|
|
|
installDesktopFile :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
|
|
installDesktopFile copyDest _verbosity pkg lbi
|
|
| progfile copyDest == progfile NoCopyDest =
|
|
DesktopFile.installUser (progfile copyDest)
|
|
`catch` installerror
|
|
| otherwise = return ()
|
|
where
|
|
progfile cd = bindir (absoluteInstallDirs pkg lbi cd) </> "git-annex"
|
|
installerror :: SomeException -> IO ()
|
|
installerror e = putStrLn ("Warning: Installation of desktop integration files did not succeed (" ++ show e ++ "); skipping.")
|