2014-12-16 18:04:40 +00:00
|
|
|
{- dotted versions, such as 1.0.1
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2011-2014 Joey Hess <id@joeyh.name>
|
2014-12-16 18:04:40 +00:00
|
|
|
-
|
|
|
|
- License: BSD-2-clause
|
|
|
|
-}
|
|
|
|
|
2015-05-10 20:38:49 +00:00
|
|
|
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
|
|
|
|
2019-11-21 19:38:06 +00:00
|
|
|
module Utility.DottedVersion (
|
|
|
|
DottedVersion,
|
|
|
|
fromDottedVersion,
|
|
|
|
normalize,
|
|
|
|
) where
|
2014-12-16 18:04:40 +00:00
|
|
|
|
2020-10-29 16:02:46 +00:00
|
|
|
import Utility.Split
|
2014-12-16 18:04:40 +00:00
|
|
|
|
|
|
|
data DottedVersion = DottedVersion String Integer
|
|
|
|
deriving (Eq)
|
|
|
|
|
|
|
|
instance Ord DottedVersion where
|
|
|
|
compare (DottedVersion _ x) (DottedVersion _ y) = compare x y
|
|
|
|
|
|
|
|
instance Show DottedVersion where
|
Refuse to upgrade direct mode repositories when git is older than 2.22
That git fixed a memory leak that could cause an OOM during the upgrade.
Most git-annex builds have a new enough git already.
OSX git was upgraded with brew.
Linux i386ancient build's git was too old. Upgrading it to a fixed
git didn't work (due to the newer git not working with the old ssh,
https://bugs.chromium.org/p/git/issues/detail?id=7 )
Choices to deal with that were:
* Somehow make direct mode upgrade work with the old git, avoiding its
OOM problem. One way would be to switch the repo to indirect mode
first, and so upgrade to a repo with locked files. Not good when
the filesystem does not support symlinks.
* backport the OOM fix from git 2.22
(And do what about the version number so git-annex knows it's fixed?)
* backport openssh (and possibly more stuff)
* move the i386ancient build to at least Debian stretch (still backporting git)
But this will make it no longer work with some of the ancient kernels it
targets.
Of those, backporting the OOM fix seemed the best approach. Put "oomfix"
in the git version number to indicate it.
I have not automated building the git backport, so here's the patch I
used:
diff -ur orig/git-2.1.4/convert.c git-2.1.4/convert.c
--- orig/git-2.1.4/convert.c 2014-12-18 18:42:18.000000000 +0000
+++ git-2.1.4/convert.c 2019-08-29 20:05:04.371872338 +0100
@@ -404,7 +404,7 @@
if (start_async(&async))
return 0; /* error was already reported */
- if (strbuf_read(&nbuf, async.out, len) < 0) {
+ if (strbuf_read(&nbuf, async.out, 0) < 0) {
error("read from external filter %s failed", cmd);
ret = 0;
}
diff -ur orig/git-2.1.4/GIT-VERSION-GEN git-2.1.4/GIT-VERSION-GEN
--- orig/git-2.1.4/GIT-VERSION-GEN 2014-12-18 18:42:18.000000000 +0000
+++ git-2.1.4/GIT-VERSION-GEN 2019-08-29 20:06:39.132743228 +0100
@@ -1,7 +1,7 @@
#!/bin/sh
GVF=GIT-VERSION-FILE
-DEF_VER=v2.1.4
+DEF_VER=v2.1.4.oomfix
LF='
'
diff -ur orig/git-2.1.4/configure git-2.1.4/configure
--- orig/git-2.1.4/configure 2014-12-18 18:42:19.000000000 +0000
+++ git-2.1.4/configure 2019-08-29 20:27:45.896380015 +0100
@@ -580,8 +580,8 @@
# Identity of this package.
PACKAGE_NAME='git'
PACKAGE_TARNAME='git'
-PACKAGE_VERSION='2.1.4'
-PACKAGE_STRING='git 2.1.4'
+PACKAGE_VERSION='2.1.4.oomfix'
+PACKAGE_STRING='git 2.1.4.oomfix'
PACKAGE_BUGREPORT='git@vger.kernel.org'
PACKAGE_URL=''
diff -ur orig/git-2.1.4/version git-2.1.4/version
--- orig/git-2.1.4/version 2014-12-18 18:42:19.000000000 +0000
+++ git-2.1.4/version 2019-08-29 20:06:17.572545210 +0100
@@ -1 +1 @@
-2.1.4
+2.1.4.oomfix
2019-08-29 18:12:45 +00:00
|
|
|
show = fromDottedVersion
|
|
|
|
|
|
|
|
fromDottedVersion :: DottedVersion -> String
|
|
|
|
fromDottedVersion (DottedVersion s _) = s
|
2014-12-16 18:04:40 +00:00
|
|
|
|
|
|
|
{- To compare dotted versions like 1.7.7 and 1.8, they are normalized to
|
|
|
|
- a somewhat arbitrary integer representation. -}
|
|
|
|
normalize :: String -> DottedVersion
|
|
|
|
normalize v = DottedVersion v $
|
|
|
|
sum $ mult 1 $ reverse $ extend precision $ take precision $
|
2017-01-31 22:40:42 +00:00
|
|
|
map readi $ splitc '.' v
|
2014-12-16 18:04:40 +00:00
|
|
|
where
|
|
|
|
extend n l = l ++ replicate (n - length l) 0
|
|
|
|
mult _ [] = []
|
|
|
|
mult n (x:xs) = (n*x) : mult (n*10^width) xs
|
|
|
|
readi :: String -> Integer
|
|
|
|
readi s = case reads s of
|
|
|
|
((x,_):_) -> x
|
|
|
|
_ -> 0
|
|
|
|
precision = 10 -- number of segments of the version to compare
|
|
|
|
width = length "yyyymmddhhmmss" -- maximum width of a segment
|