aboutsummaryrefslogtreecommitdiff
path: root/src/CabalHelper/Compiletime
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2020-04-10 23:18:46 +0200
committerDaniel Gröber <dxld@darkboxed.org>2020-04-18 07:49:11 +0200
commit8c35c5b6cf8f490301b2bad7c0ea48a4de5e0635 (patch)
tree79b08a4d1fccc0e01140c3dd89195022ab6a0f6e /src/CabalHelper/Compiletime
parenta18bbb2af92e9b4337e7f930cb80754f2408bcfd (diff)
Fix datestamp Cabal HEAD version being too long
Cabal's versionDigitParser limits the version nuber to nine digits, this used to not be checked for and used to just overflow the resulting Word. See 7d4eee68fcb3 ("Limit version number parts to be 9 digits")
Diffstat (limited to 'src/CabalHelper/Compiletime')
-rw-r--r--src/CabalHelper/Compiletime/Cabal.hs17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/CabalHelper/Compiletime/Cabal.hs b/src/CabalHelper/Compiletime/Cabal.hs
index b565152..1c4efa5 100644
--- a/src/CabalHelper/Compiletime/Cabal.hs
+++ b/src/CabalHelper/Compiletime/Cabal.hs
@@ -30,7 +30,6 @@ import Data.Version
import System.Directory
import System.FilePath
import System.IO
-import Text.Printf
import Distribution.Verbosity (Verbosity, silent, normal, verbose, deafening)
@@ -196,24 +195,14 @@ unpackCabalHEAD tmpdir = do
{ cwd = Just dir } ""
let ut = posixSecondsToUTCTime $ fromInteger (read ts)
(y,m,d) = toGregorian $ utctDay ut
- sec = round $ utctDayTime ut
- datecode =
- read $ show y ++ printf "%02d" m ++ printf "%02d" d ++ printf "%05d" sec
- sec :: Int; datecode :: Int
+ sec = round $ utctDayTime ut; sec :: Int
+ datecode = makeVersion [1000, fromInteger y, m, d, sec]
let cabal_file = tmpdir </> "Cabal/Cabal.cabal"
cf0 <- readFile cabal_file
- let Just cf1 = replaceVersionDecl (setVersion datecode) cf0
+ let Just cf1 = replaceVersionDecl (const (Just datecode)) cf0
writeFile (cabal_file<.>"tmp") cf1
renameFile (cabal_file<.>"tmp") cabal_file
return (CommitId commit, CabalSourceDir $ tmpdir </> "Cabal")
- where
- -- If the released version of cabal has 4 components but we use only three
- -- theirs will always be larger than this one here. That's not really
- -- critical though.
- setVersion i (versionBranch -> mj:mi:_:_:[]) =
- Just $ makeVersion $ mj:mi:[i]
- setVersion _ v =
- error $ "unpackCabalHEAD.setVersion: Wrong version format" ++ show v
-- | Replace the version declaration in a cabal file
replaceVersionDecl :: (Version -> Maybe Version) -> String -> Maybe String