summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-04-10 16:53:04 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-04-10 16:53:38 -0400
commit2badf04eeb1898d5b77c171a28a1b263cca16313 (patch)
tree87fb49ea99b69b609480e5f1436a3b9cea5b6759
parente0aebe9cf31c3fd1e4e5b490f78c37deda857b3a (diff)
The version number is now derived from git, unless built with VERSION_FROM_CHANGELOG.
-rw-r--r--Build/Configure.hs33
-rw-r--r--debian/changelog2
-rwxr-xr-xdebian/rules3
-rw-r--r--doc/bugs/Incorrect_version_on_64_Standalone_Build.mdwn2
4 files changed, 35 insertions, 5 deletions
diff --git a/Build/Configure.hs b/Build/Configure.hs
index b6f2b773d..ae51e2f9e 100644
--- a/Build/Configure.hs
+++ b/Build/Configure.hs
@@ -8,9 +8,12 @@ import System.Process
import Control.Applicative
import System.FilePath
import System.Environment
+import Data.Maybe
import Build.TestConfig
import Utility.SafeCommand
+import Utility.Monad
+import Utility.Exception
tests :: [TestCase]
tests =
@@ -70,14 +73,34 @@ testCp k option = TestCase cmd $ testCmd k cmdline
cmd = "cp " ++ option
cmdline = cmd ++ " " ++ testFile ++ " " ++ testFile ++ ".new"
-{- Pulls package version out of the changelog. -}
+{- 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.
+ - This works for autobuilds, ad-hoc builds, etc.
+ -
+ - For official builds, VERSION_FROM_CHANGELOG makes it use just the most
+ - recent version from the changelog.
+ -
+ - If git or a git repo is not available, or something goes wrong,
+ - just use the version from the changelog. -}
getVersion :: Test
getVersion = do
- version <- getVersionString
+ changelogversion <- getChangelogVersion
+ version <- ifM (isJust <$> catchMaybeIO (getEnv "VERSION_FROM_CHANGELOG"))
+ ( return changelogversion
+ , catchDefaultIO changelogversion $ do
+ let major = takeWhile (/= '.') changelogversion
+ autoversion <- readProcess "sh"
+ [ "-c"
+ , "git log -n 1 --format=format:'%ci %h'| sed -e 's/-//g' -e 's/ .* /-g/'"
+ ] ""
+ if null autoversion
+ then return changelogversion
+ else return $ concat [ major, ".", autoversion ]
+ )
return $ Config "packageversion" (StringConfig version)
-getVersionString :: IO String
-getVersionString = do
+getChangelogVersion :: IO String
+getChangelogVersion = do
changelog <- readFile "CHANGELOG"
let verline = head $ lines changelog
return $ middle (words verline !! 1)
@@ -97,7 +120,7 @@ getSshConnectionCaching = Config "sshconnectioncaching" . BoolConfig <$>
{- Set up cabal file with version. -}
cabalSetup :: IO ()
cabalSetup = do
- version <- getVersionString
+ version <- getChangelogVersion
cabal <- readFile cabalfile
writeFile tmpcabalfile $ unlines $
map (setfield "Version" version) $
diff --git a/debian/changelog b/debian/changelog
index 1549a12ed..a1c12388e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -14,6 +14,8 @@ git-annex (4.20130406) UNRELEASED; urgency=low
and connecting to it from another. (Note: Does not yet use HTTPS.)
* webapp: When a repository's group is changed, rescan for transfers.
* Added annex.web-download-command setting.
+ * The version number is now derived from git, unless built with
+ VERSION_FROM_CHANGELOG.
-- Joey Hess <joeyh@debian.org> Sat, 06 Apr 2013 15:24:15 -0400
diff --git a/debian/rules b/debian/rules
index a0231eb60..da5596871 100755
--- a/debian/rules
+++ b/debian/rules
@@ -3,6 +3,9 @@
# Avoid using cabal, as it writes to $HOME
export CABAL=./Setup
+# Do use the changelog's version number, rather than making one up.
+export VERSION_FROM_CHANGELOG=1
+
%:
dh $@
diff --git a/doc/bugs/Incorrect_version_on_64_Standalone_Build.mdwn b/doc/bugs/Incorrect_version_on_64_Standalone_Build.mdwn
index 38288b8f1..a7384b327 100644
--- a/doc/bugs/Incorrect_version_on_64_Standalone_Build.mdwn
+++ b/doc/bugs/Incorrect_version_on_64_Standalone_Build.mdwn
@@ -7,3 +7,5 @@
Shouldn't that be `4.20130405`?
The md5sum of the build I downloaded is `aabbb3aa2397be206cae86f33db9eef4`.
+
+> [[done]]; new version will look like eg `4.20130410-gc149c67` --[[Joey]]