The version number is now derived from git, unless built with VERSION_FROM_CHANGELOG.
This commit is contained in:
parent
c149c678ad
commit
59f616684d
4 changed files with 35 additions and 5 deletions
|
@ -8,9 +8,12 @@ import System.Process
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
import System.Environment
|
import System.Environment
|
||||||
|
import Data.Maybe
|
||||||
|
|
||||||
import Build.TestConfig
|
import Build.TestConfig
|
||||||
import Utility.SafeCommand
|
import Utility.SafeCommand
|
||||||
|
import Utility.Monad
|
||||||
|
import Utility.Exception
|
||||||
|
|
||||||
tests :: [TestCase]
|
tests :: [TestCase]
|
||||||
tests =
|
tests =
|
||||||
|
@ -70,14 +73,34 @@ testCp k option = TestCase cmd $ testCmd k cmdline
|
||||||
cmd = "cp " ++ option
|
cmd = "cp " ++ option
|
||||||
cmdline = cmd ++ " " ++ testFile ++ " " ++ testFile ++ ".new"
|
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 :: Test
|
||||||
getVersion = do
|
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)
|
return $ Config "packageversion" (StringConfig version)
|
||||||
|
|
||||||
getVersionString :: IO String
|
getChangelogVersion :: IO String
|
||||||
getVersionString = do
|
getChangelogVersion = do
|
||||||
changelog <- readFile "CHANGELOG"
|
changelog <- readFile "CHANGELOG"
|
||||||
let verline = head $ lines changelog
|
let verline = head $ lines changelog
|
||||||
return $ middle (words verline !! 1)
|
return $ middle (words verline !! 1)
|
||||||
|
@ -97,7 +120,7 @@ getSshConnectionCaching = Config "sshconnectioncaching" . BoolConfig <$>
|
||||||
{- Set up cabal file with version. -}
|
{- Set up cabal file with version. -}
|
||||||
cabalSetup :: IO ()
|
cabalSetup :: IO ()
|
||||||
cabalSetup = do
|
cabalSetup = do
|
||||||
version <- getVersionString
|
version <- getChangelogVersion
|
||||||
cabal <- readFile cabalfile
|
cabal <- readFile cabalfile
|
||||||
writeFile tmpcabalfile $ unlines $
|
writeFile tmpcabalfile $ unlines $
|
||||||
map (setfield "Version" version) $
|
map (setfield "Version" version) $
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -14,6 +14,8 @@ git-annex (4.20130406) UNRELEASED; urgency=low
|
||||||
and connecting to it from another. (Note: Does not yet use HTTPS.)
|
and connecting to it from another. (Note: Does not yet use HTTPS.)
|
||||||
* webapp: When a repository's group is changed, rescan for transfers.
|
* webapp: When a repository's group is changed, rescan for transfers.
|
||||||
* Added annex.web-download-command setting.
|
* 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
|
-- Joey Hess <joeyh@debian.org> Sat, 06 Apr 2013 15:24:15 -0400
|
||||||
|
|
||||||
|
|
3
debian/rules
vendored
3
debian/rules
vendored
|
@ -3,6 +3,9 @@
|
||||||
# Avoid using cabal, as it writes to $HOME
|
# Avoid using cabal, as it writes to $HOME
|
||||||
export CABAL=./Setup
|
export CABAL=./Setup
|
||||||
|
|
||||||
|
# Do use the changelog's version number, rather than making one up.
|
||||||
|
export VERSION_FROM_CHANGELOG=1
|
||||||
|
|
||||||
%:
|
%:
|
||||||
dh $@
|
dh $@
|
||||||
|
|
||||||
|
|
|
@ -7,3 +7,5 @@
|
||||||
Shouldn't that be `4.20130405`?
|
Shouldn't that be `4.20130405`?
|
||||||
|
|
||||||
The md5sum of the build I downloaded is `aabbb3aa2397be206cae86f33db9eef4`.
|
The md5sum of the build I downloaded is `aabbb3aa2397be206cae86f33db9eef4`.
|
||||||
|
|
||||||
|
> [[done]]; new version will look like eg `4.20130410-gc149c67` --[[Joey]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue