Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Less restrictive version requirements in output

  • Loading branch information...
commit c13b096f5f75e1f21e6a6f91d13c498e763c3cf9 1 parent b166d6a
Rémy Oudompheng authored

Showing 1 changed file with 19 additions and 12 deletions. Show diff stats Hide diff stats

  1. +19 12 Distribution/ArchLinux/PkgBuild.hs
31 Distribution/ArchLinux/PkgBuild.hs
@@ -180,29 +180,36 @@ instance Text ArchOptions where
180 180 -- the PKGBUILD version spec is less expressive than cabal, we can
181 181 -- only handle simple intervals like (0,v) or (v,+infty)
182 182 mydisp :: VersionInterval -> Doc
183   -mydisp (LowerBound v InclusiveBound, NoUpperBound) = if v==zeroVersion then empty else text ">=" <> disp v
184   -mydisp (LowerBound v ExclusiveBound, NoUpperBound) = text ">" <> disp v
185   -mydisp (_, UpperBound v boundType) = text symbol <> disp v
186   - where symbol = if boundType == InclusiveBound then "<=" else "<"
  183 +mydisp (LowerBound v t, NoUpperBound) =
  184 + case t of
  185 + InclusiveBound -> if v==zeroVersion then empty else text ">=" <> disp v
  186 + ExclusiveBound -> text ">" <> disp v
  187 +mydisp (LowerBound v1 t1, UpperBound v2 t2) = text symbol <> disp v2
  188 + where symbol | v1 == v2 = "="
  189 + | t2 == InclusiveBound = "<="
  190 + | t2 == ExclusiveBound = "<"
187 191
188 192 zeroVersion :: Version
189 193 zeroVersion = Version [0] []
190 194
191 195 instance Text ArchDep where
192 196 disp (ArchDep (Dependency name ver)) =
193   - disp name <> mydisp2 intervals
  197 + disp name <> mydisp (collapse intervals)
194 198 where
195 199 intervals = asVersionIntervals ver
196 200 strName = display name
197 201 -- >= (greater than or equal to), <= (less than or
198 202 -- equal to), = (equal to), > (greater than), or <
199   - mydisp2 l | l == [] = trace ("WARNING: version requirement for " ++
200   - strName ++ " is logically impossible.") empty
201   - | tail l == [] = mydisp $ head l
202   - -- If there are multiple possible ranges, take only latest versions
203   - | otherwise = trace ("WARNING: multiple version ranges specified for " ++
204   - strName ++ " using only the last one.") $ mydisp $ last l
205   -
  203 + --
  204 + -- Reduce intervals to a single one
  205 + collapse l | null l = trace ("WARNING: version requirement for " ++
  206 + strName ++ " is logically impossible.")
  207 + (head $ asVersionIntervals anyVersion)
  208 + | null $ tail l = head l
  209 + -- If there are multiple possible ranges, take the interval that contains all
  210 + | otherwise = trace ("WARNING: multiple version ranges specified for " ++
  211 + strName ++ " using only the last one.")
  212 + (fst $ head l, snd $ last l)
206 213 parse = undefined
207 214
208 215 --

0 comments on commit c13b096

Please sign in to comment.
Something went wrong with that request. Please try again.