From c3b9e3d64ae4082b627ffa50996ee403b09759d5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 27 Oct 2014 11:09:55 -0400 Subject: Merge Build/ from git-annex, including removing a use of deprecated System.Cmd. --- Build/Configure.hs | 2 +- Build/TestConfig.hs | 2 -- Build/Version.hs | 12 ++++++------ 3 files changed, 7 insertions(+), 9 deletions(-) (limited to 'Build') diff --git a/Build/Configure.hs b/Build/Configure.hs index 4912122..e488ee1 100644 --- a/Build/Configure.hs +++ b/Build/Configure.hs @@ -12,7 +12,7 @@ import Git.Version tests :: [TestCase] tests = - [ TestCase "version" getVersion + [ TestCase "version" (Config "packageversion" . StringConfig <$> getVersion) , TestCase "git" $ requireCmd "git" "git --version >/dev/null" , TestCase "git version" getGitVersion ] diff --git a/Build/TestConfig.hs b/Build/TestConfig.hs index 8628ebe..e55641f 100644 --- a/Build/TestConfig.hs +++ b/Build/TestConfig.hs @@ -7,8 +7,6 @@ import Utility.Monad import Utility.SafeCommand import System.IO -import System.Cmd -import System.Exit import System.FilePath import System.Directory diff --git a/Build/Version.hs b/Build/Version.hs index 98e0dbf..da9d1bb 100644 --- a/Build/Version.hs +++ b/Build/Version.hs @@ -10,10 +10,11 @@ import System.Directory import Data.Char import System.Process -import Build.TestConfig import Utility.Monad import Utility.Exception +type Version = String + {- Set when making an official release. (Distribution vendors should set - this too.) -} isReleaseBuild :: IO Bool @@ -25,14 +26,14 @@ isReleaseBuild = isJust <$> catchMaybeIO (getEnv "RELEASE_BUILD") - - If git or a git repo is not available, or something goes wrong, - or this is a release build, just use the version from the changelog. -} -getVersion :: Test +getVersion :: IO Version getVersion = do changelogversion <- getChangelogVersion - version <- ifM (isReleaseBuild) + ifM (isReleaseBuild) ( return changelogversion , catchDefaultIO changelogversion $ do let major = takeWhile (/= '.') changelogversion - autoversion <- readProcess "sh" + autoversion <- takeWhile (\c -> isAlphaNum c || c == '-') <$> readProcess "sh" [ "-c" , "git log -n 1 --format=format:'%ci %h'| sed -e 's/-//g' -e 's/ .* /-g/'" ] "" @@ -40,9 +41,8 @@ getVersion = do then return changelogversion else return $ concat [ major, ".", autoversion ] ) - return $ Config "packageversion" (StringConfig version) -getChangelogVersion :: IO String +getChangelogVersion :: IO Version getChangelogVersion = do changelog <- readFile "debian/changelog" let verline = takeWhile (/= '\n') changelog -- cgit v1.2.3