The version number is now derived from git, unless built with VERSION_FROM_CHANGELOG.

This commit is contained in:
Joey Hess 2013-04-10 16:53:04 -04:00
parent c149c678ad
commit 59f616684d
4 changed files with 35 additions and 5 deletions

View file

@ -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) $

2
debian/changelog vendored
View file

@ -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

3
debian/rules vendored
View file

@ -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 $@

View file

@ -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]]