Skip to content

Commit

Permalink
Use VersionIntervals to print PKGBUILDs (clears deprecation warnings
Browse files Browse the repository at this point in the history
and improves dependency checking at the level of makepkg).
  • Loading branch information
Rémy Oudompheng committed Oct 23, 2010
1 parent be8c9b2 commit 4c9a0e3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 46 deletions.
49 changes: 21 additions & 28 deletions Distribution/ArchLinux/PkgBuild.hs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -178,39 +178,32 @@ instance Text ArchOptions where
disp Strip = text "strip" disp Strip = text "strip"
parse = undefined parse = undefined


-- the PKGBUILD version spec is less expressive than cabal, we can't -- the PKGBUILD version spec is less expressive than cabal, we can
-- really handle unions or intersections well yet. -- only handle simple intervals like (0,v) or (v,+infty)
mydisp :: VersionInterval -> Doc
mydisp (LowerBound v InclusiveBound, NoUpperBound) = if v==zeroVersion then empty else text ">=" <> disp v
mydisp (LowerBound v ExclusiveBound, NoUpperBound) = text ">" <> disp v
mydisp x@(lower, UpperBound v boundType) = maybeWarn (text symbol <> disp v)
where maybeWarn = if lower == LowerBound zeroVersion InclusiveBound then id
else trace ("WARNING: arbitrary version interval requirements are unsupported, using <" ++ display v ++ " instead.")
symbol = if boundType == InclusiveBound then "<=" else "<"

zeroVersion = Version [0] []


instance Text ArchDep where instance Text ArchDep where
disp (ArchDep (Dependency name ver)) = disp (ArchDep (Dependency name ver)) =
text (display name) <> mydisp (simplifyVersionRange ver) disp name <> mydisp2 intervals
where where
intervals = asVersionIntervals ver
strName = display name
-- >= (greater than or equal to), <= (less than or -- >= (greater than or equal to), <= (less than or
-- equal to), = (equal to), > (greater than), or < -- equal to), = (equal to), > (greater than), or <
mydisp AnyVersion = empty mydisp2 l | l == [] = trace ("WARNING: version requirement for " ++

strName ++ " is logically impossible.") empty
mydisp (ThisVersion v) = text "=" <> disp v | tail l == [] = mydisp $ head l
mydisp (LaterVersion v) = char '>' <> disp v -- If there are multiple possible ranges, take only latest versions
mydisp (EarlierVersion v) = char '<' <> disp v | otherwise = trace ("WARNING: multiple version ranges specified for " ++

strName ++ " using only the last one.") $ mydisp $ last l
mydisp (UnionVersionRanges (ThisVersion v1) (LaterVersion v2))
| v1 == v2 = text ">=" <> disp v1
mydisp (UnionVersionRanges (LaterVersion v2) (ThisVersion v1))
| v1 == v2 = text ">=" <> disp v1
mydisp (UnionVersionRanges (ThisVersion v1) (EarlierVersion v2))
| v1 == v2 = text "<=" <> disp v1
mydisp (UnionVersionRanges (EarlierVersion v2) (ThisVersion v1))
| v1 == v2 = text "<=" <> disp v1

{-
mydisp (UnionVersionRanges r1 r2)
= disp r1 <+> text "||" <+> disp r2
mydisp (IntersectVersionRanges r1 r2)
= disp r1 <+> text "&&" <+> disp r2
-}

mydisp x = trace ("WARNING: Can't handle this version format yet: " ++ show x ++ "\ncheck the dependencies by hand.")$ empty


parse = undefined parse = undefined


Expand Down Expand Up @@ -432,7 +425,7 @@ readDepends s =
-- TODO : read version spec -- TODO : read version spec
str2archdep :: String -> ArchDep str2archdep :: String -> ArchDep
str2archdep s = case v of str2archdep s = case v of
Nothing -> ArchDep (Dependency (PackageName name) AnyVersion) Nothing -> ArchDep (Dependency (PackageName name) anyVersion)
Just w -> ArchDep (Dependency (PackageName name) w) Just w -> ArchDep (Dependency (PackageName name) w)
where name = takeWhile (\x -> x `notElem` "<=>") s where name = takeWhile (\x -> x `notElem` "<=>") s
vspec = dropWhile (\x -> x `notElem` "<=>") s vspec = dropWhile (\x -> x `notElem` "<=>") s
Expand Down
36 changes: 18 additions & 18 deletions data/ghc-provides.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ integer-gmp
ghc-binary ghc-binary


## Official Provides: http://repos.archlinux.org/wsvn/packages/ghc/repos/extra-x86_64/PKGBUILD ## Official Provides: http://repos.archlinux.org/wsvn/packages/ghc/repos/extra-x86_64/PKGBUILD
# array==0.3.0.0 array==0.3.0.0
# bytestring==0.9.1.5 bytestring==0.9.1.5
# Cabal==1.8.0.2 Cabal==1.8.0.2
# containers==0.3.0.0 containers==0.3.0.0
# directory==1.0.1.0 directory==1.0.1.0
# extensible-exceptions extensible-exceptions
# filepath==1.1.0.3 filepath==1.1.0.3
# haskell98==1.0.1.1 haskell98==1.0.1.1
# hpc==0.5.0.4 hpc==0.5.0.4
# old-locale==1.0.0.2 old-locale==1.0.0.2
# old-time==1.0.0.1 old-time==1.0.0.1
# pretty==1.0.1.1 pretty==1.0.1.1
# process==1.0.1.2 process==1.0.1.2
# random==1.0.0.2 random==1.0.0.2
# syb==0.1.0.2 syb==0.1.0.2
# template-haskell==2.4.0.0 template-haskell==2.4.0.0
# time==1.1.4 time==1.1.4
# unix==2.4.0.0 unix==2.4.0.0
## utf8-string ## utf8-string
# #
# #
Expand Down

0 comments on commit 4c9a0e3

Please sign in to comment.