summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
Diffstat (limited to 'Build')
-rw-r--r--Build/Configure.hs10
-rw-r--r--Build/TestConfig.hs21
-rw-r--r--Build/Version.hs12
-rwxr-xr-xBuild/make-sdist.sh21
4 files changed, 18 insertions, 46 deletions
diff --git a/Build/Configure.hs b/Build/Configure.hs
index e488ee1..1a3527f 100644
--- a/Build/Configure.hs
+++ b/Build/Configure.hs
@@ -1,10 +1,13 @@
-{- Checks system configuration and generates SysConfig.hs. -}
+{- Checks system configuration and generates SysConfig. -}
+
+{-# OPTIONS_GHC -fno-warn-tabs #-}
module Build.Configure where
import System.Environment
-import Control.Applicative
import Control.Monad.IfElse
+import Control.Applicative
+import Prelude
import Build.TestConfig
import Build.Version
@@ -13,7 +16,7 @@ import Git.Version
tests :: [TestCase]
tests =
[ TestCase "version" (Config "packageversion" . StringConfig <$> getVersion)
- , TestCase "git" $ requireCmd "git" "git --version >/dev/null"
+ , TestCase "git" $ testCmd "git" "git --version >/dev/null"
, TestCase "git version" getGitVersion
]
@@ -23,7 +26,6 @@ getGitVersion = Config "gitversion" . StringConfig . show
run :: [TestCase] -> IO ()
run ts = do
- args <- getArgs
config <- runTests ts
writeSysConfig config
whenM (isReleaseBuild) $
diff --git a/Build/TestConfig.hs b/Build/TestConfig.hs
index e55641f..2f7213f 100644
--- a/Build/TestConfig.hs
+++ b/Build/TestConfig.hs
@@ -1,14 +1,16 @@
-{- Tests the system and generates Build.SysConfig.hs. -}
+{- Tests the system and generates SysConfig. -}
+
+{-# OPTIONS_GHC -fno-warn-tabs #-}
module Build.TestConfig where
import Utility.Path
import Utility.Monad
import Utility.SafeCommand
+import Utility.Directory
import System.IO
import System.FilePath
-import System.Directory
type ConfigKey = String
data ConfigValue =
@@ -40,12 +42,11 @@ instance Show Config where
valuetype (MaybeBoolConfig _) = "Maybe Bool"
writeSysConfig :: [Config] -> IO ()
-writeSysConfig config = writeFile "Build/SysConfig.hs" body
+writeSysConfig config = writeFile "Build/SysConfig" body
where
body = unlines $ header ++ map show config ++ footer
header = [
"{- Automatically generated. -}"
- , "module Build.SysConfig where"
, ""
]
footer = []
@@ -59,18 +60,6 @@ runTests (TestCase tname t : ts) = do
rest <- runTests ts
return $ c:rest
-{- Tests that a command is available, aborting if not. -}
-requireCmd :: ConfigKey -> String -> Test
-requireCmd k cmdline = do
- ret <- testCmd k cmdline
- handle ret
- where
- handle r@(Config _ (BoolConfig True)) = return r
- handle r = do
- testEnd r
- error $ "** the " ++ c ++ " command is required"
- c = head $ words cmdline
-
{- Checks if a command is available by running a command line. -}
testCmd :: ConfigKey -> String -> Test
testCmd k cmdline = do
diff --git a/Build/Version.hs b/Build/Version.hs
index da9d1bb..d39a0fe 100644
--- a/Build/Version.hs
+++ b/Build/Version.hs
@@ -1,24 +1,26 @@
{- Package version determination, for configure script. -}
+{-# OPTIONS_GHC -fno-warn-tabs #-}
+
module Build.Version where
-import Data.Maybe
-import Control.Applicative
import Data.List
import System.Environment
-import System.Directory
import Data.Char
import System.Process
+import Control.Applicative
+import Prelude
import Utility.Monad
import Utility.Exception
+import Utility.Directory
type Version = String
{- Set when making an official release. (Distribution vendors should set
- this too.) -}
isReleaseBuild :: IO Bool
-isReleaseBuild = isJust <$> catchMaybeIO (getEnv "RELEASE_BUILD")
+isReleaseBuild = (== Just "1") <$> catchMaybeIO (getEnv "RELEASE_BUILD")
{- Version is usually based on the major version from the changelog,
- plus the date of the last commit, plus the git rev of that commit.
@@ -44,7 +46,7 @@ getVersion = do
getChangelogVersion :: IO Version
getChangelogVersion = do
- changelog <- readFile "debian/changelog"
+ changelog <- readFile "CHANGELOG"
let verline = takeWhile (/= '\n') changelog
return $ middle (words verline !! 1)
where
diff --git a/Build/make-sdist.sh b/Build/make-sdist.sh
deleted file mode 100755
index d4dbdb9..0000000
--- a/Build/make-sdist.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-#
-# Workaround for `cabal sdist` requiring all included files to be listed
-# in .cabal.
-
-# Create target directory
-sdist_dir=git-repair-$(grep '^Version:' git-repair.cabal | sed -re 's/Version: *//')
-mkdir --parents dist/$sdist_dir
-
-find . \( -name .git -or -name dist -or -name cabal-dev \) -prune \
- -or -not -name \\*.orig -not -type d -print \
-| perl -ne "print unless length >= 100 - length q{$sdist_dir}" \
-| xargs cp --parents --target-directory dist/$sdist_dir
-
-cd dist
-tar --format=ustar -caf $sdist_dir.tar.gz $sdist_dir
-
-# Check that tarball can be unpacked by cabal.
-# It's picky about tar longlinks etc.
-rm -rf $sdist_dir
-cabal unpack $sdist_dir.tar.gz