summaryrefslogtreecommitdiff
path: root/distrib/compare/FilenameDescr.hs
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2011-03-16 21:47:08 +0000
committerIan Lynagh <igloo@earth.li>2011-03-16 21:47:08 +0000
commit42b40db07ce70b89f867247809c4e930fd82a6f6 (patch)
tree6e2c870065190b8982fc895dfef90443b0f7a498 /distrib/compare/FilenameDescr.hs
parent3ce328c715c8ae97325d21216a4dd51050876c62 (diff)
downloadhaskell-42b40db07ce70b89f867247809c4e930fd82a6f6.tar.gz
Bindist comparison tool: Handle differences in the library ways nicely
In particular, this makes it possible to compare release bindists (with profiling files) and validate bindists (without them).
Diffstat (limited to 'distrib/compare/FilenameDescr.hs')
-rw-r--r--distrib/compare/FilenameDescr.hs33
1 files changed, 12 insertions, 21 deletions
diff --git a/distrib/compare/FilenameDescr.hs b/distrib/compare/FilenameDescr.hs
index 5952058639..4b5898e990 100644
--- a/distrib/compare/FilenameDescr.hs
+++ b/distrib/compare/FilenameDescr.hs
@@ -2,7 +2,9 @@
module FilenameDescr where
import Data.Either
+import Data.List
+import BuildInfo
import Utils
import Tar
@@ -12,6 +14,7 @@ import Tar
type FilenameDescr = [FilenameDescrBit]
data FilenameDescrBit = VersionOf String
| FP String
+ | Ways
deriving (Show, Eq, Ord)
normalise :: FilenameDescr -> FilenameDescr
@@ -20,24 +23,11 @@ normalise [x] = [x]
normalise (FP x1 : FP x2 : xs) = normalise (FP (x1 ++ x2) : xs)
normalise (x : xs) = x : normalise xs
--- Mapping from thing (e.g. "Cabal") to version (e.g. "1.10.0.0")
-type ThingVersionMap = [(String, String)]
-
-addThingVersion :: ThingVersionMap -> String -> String -> Maybe ThingVersionMap
-addThingVersion mapping thing version
- = case lookup thing mapping of
- Just version' ->
- if version == version'
- then Just mapping
- else Nothing
- Nothing ->
- Just ((thing, version) : mapping)
-
-- Sanity check that the FilenameDescr matches the filename in the tar line
-checkContent :: ThingVersionMap -> (FilenameDescr, TarLine) -> Errors
-checkContent mapping (fd, tl)
+checkContent :: BuildInfo -> (FilenameDescr, TarLine) -> Errors
+checkContent buildInfo (fd, tl)
= let fn = tlFileName tl
- in case flattenFilenameDescr mapping fd of
+ in case flattenFilenameDescr buildInfo fd of
Right fn' ->
if fn' == fn
then []
@@ -45,14 +35,15 @@ checkContent mapping (fd, tl)
Left errs ->
errs
-flattenFilenameDescr :: ThingVersionMap -> FilenameDescr
+flattenFilenameDescr :: BuildInfo -> FilenameDescr
-> Either Errors FilePath
-flattenFilenameDescr mapping fd = case partitionEithers (map f fd) of
- ([], strs) -> Right (concat strs)
- (errs, _) -> Left (concat errs)
+flattenFilenameDescr buildInfo fd = case partitionEithers (map f fd) of
+ ([], strs) -> Right (concat strs)
+ (errs, _) -> Left (concat errs)
where f (FP fp) = Right fp
f (VersionOf thing)
- = case lookup thing mapping of
+ = case lookup thing (biThingVersionMap buildInfo) of
Just v -> Right v
Nothing -> Left ["Can't happen: thing has no version in mapping"]
+ f Ways = Right $ intercalate "-" $ biWays buildInfo