Permalink
Browse files

Update to Cabal-1.4 api

  • Loading branch information...
1 parent ace670a commit ffabce4ad7dca14f984b21dba2beaf9bc04ca9f3 Duncan Coutts committed Aug 23, 2008
Showing with 28 additions and 20 deletions.
  1. +11 −9 Cabal2Ebuild.hs
  2. +2 −2 Cache.hs
  3. +14 −8 Main.hs
  4. +1 −1 hackport.cabal
View
@@ -28,11 +28,13 @@ module Cabal2Ebuild
import qualified Distribution.PackageDescription as Cabal
(PackageDescription(..))
-import qualified Distribution.Package as Cabal (PackageIdentifier(..))
-import qualified Distribution.Version as Cabal (showVersion, Dependency(..),
- VersionRange(..))
+import qualified Distribution.Package as Cabal
+ ( PackageIdentifier(..), Dependency(..) )
+import qualified Distribution.Version as Cabal
+ ( VersionRange(..) )
import qualified Distribution.License as Cabal (License(..))
--import qualified Distribution.Compiler as Cabal (CompilerFlavor(..))
+import Distribution.Text (display)
import Data.Char (toLower,isUpper)
@@ -85,7 +87,7 @@ ebuildTemplate = EBuild {
cabal2ebuild :: Cabal.PackageDescription -> EBuild
cabal2ebuild pkg = ebuildTemplate {
name = map toLower cabalPkgName,
- version = Cabal.showVersion (Cabal.pkgVersion (Cabal.package pkg)),
+ version = display (Cabal.pkgVersion (Cabal.package pkg)),
description = if null (Cabal.synopsis pkg) then Cabal.description pkg
else Cabal.synopsis pkg,
homepage = Cabal.homepage pkg,
@@ -139,13 +141,13 @@ convertDependency (Cabal.Dependency pname versionRange)
convert :: Cabal.VersionRange -> Dependency
convert Cabal.AnyVersion = AnyVersionOf ebuildName
- convert (Cabal.ThisVersion v) = ThisVersionOf (Cabal.showVersion v) ebuildName
- convert (Cabal.LaterVersion v) = LaterVersionOf (Cabal.showVersion v) ebuildName
- convert (Cabal.EarlierVersion v) = EarlierVersionOf (Cabal.showVersion v) ebuildName
+ convert (Cabal.ThisVersion v) = ThisVersionOf (display v) ebuildName
+ convert (Cabal.LaterVersion v) = LaterVersionOf (display v) ebuildName
+ convert (Cabal.EarlierVersion v) = EarlierVersionOf (display v) ebuildName
convert (Cabal.UnionVersionRanges (Cabal.ThisVersion v1) (Cabal.LaterVersion v2))
- | v1 == v2 = OrLaterVersionOf (Cabal.showVersion v1) ebuildName
+ | v1 == v2 = OrLaterVersionOf (display v1) ebuildName
convert (Cabal.UnionVersionRanges (Cabal.ThisVersion v1) (Cabal.EarlierVersion v2))
- | v1 == v2 = OrEarlierVersionOf (Cabal.showVersion v1) ebuildName
+ | v1 == v2 = OrEarlierVersionOf (display v1) ebuildName
convert (Cabal.UnionVersionRanges r1 r2)
= DependEither (convert r1) (convert r2)
View
@@ -9,7 +9,7 @@ import P2
import Version
import Overlays
-import qualified Distribution.Version as Cabal ( readVersion )
+import Distribution.Text ( simpleParse )
import Control.Arrow
import Data.Char
@@ -73,7 +73,7 @@ indexToPortage index port = second nub . runWriter $ do
pkgs <- forM index $ \(pkg_h_name, pkg_h_ver, pkg_desc) -> do
let pkg_name = map toLower pkg_h_name
pkg_cat <- lookupCat pkg_name
- Just ver <- return . Cabal.readVersion $ pkg_h_ver
+ Just ver <- return . simpleParse $ pkg_h_ver
return $ Ebuild (P pkg_cat pkg_name)
(fromCabalVersion ver)
"<hackage>"
View
@@ -6,10 +6,13 @@ import Data.Maybe
import Data.List
import Data.Version
import Distribution.Package
-import Distribution.PackageDescription
- (finalizePackageDescription, package)
+import Distribution.Compiler (CompilerId(..), CompilerFlavor(GHC))
+import Distribution.PackageDescription.Configuration
+ ( finalizePackageDescription, flattenPackageDescription )
+import Distribution.Simple.PackageIndex (PackageIndex)
+import Distribution.Text (display)
import System.IO
-import System.Info (os, arch)
+import Distribution.System (buildOS, buildArch)
import qualified Data.Map as Map
import Text.ParserCombinators.Parsec
@@ -78,11 +81,14 @@ merge pstr = do
"hackage" -> return "dev-haskell"
c -> return c
let Just genericDesc = ePkgDesc pkg
- Right (desc, _) = finalizePackageDescription [] Nothing os arch
- ("ghc", Version [6,8,2] []) genericDesc
- ebuild <- fixSrc (package desc) (E.cabal2ebuild desc)
+ Right (desc, _) = finalizePackageDescription []
+ (Nothing :: Maybe (PackageIndex PackageIdentifier))
+ buildOS buildArch
+ (CompilerId GHC (Version [6,8,2] []))
+ [] genericDesc
+ ebuild <- fixSrc (packageId desc) (E.cabal2ebuild desc)
liftIO $ do
- putStrLn $ "Merging " ++ category ++ '/': pname ++ "-" ++ showVersion (pkgVersion (package desc))
+ putStrLn $ "Merging " ++ category ++ '/': pname ++ "-" ++ display (pkgVersion (packageId desc))
putStrLn $ "Destination: " ++ portdir
mergeEbuild portdir category ebuild
where
@@ -99,7 +105,7 @@ merge pstr = do
makeEbuild :: String -> HPAction ()
makeEbuild cabalFileName = liftIO $ do
pkg <- Cabal.readPackageDescription normal cabalFileName
- let ebuild = cabal2ebuild (Cabal.flattenPackageDescription pkg)
+ let ebuild = cabal2ebuild (flattenPackageDescription pkg)
let ebuildFileName = name ebuild ++ "-" ++ version ebuild ++ ".ebuild"
writeFile ebuildFileName (showEBuild ebuild)
View
@@ -21,7 +21,7 @@ Executable hackport
mtl,
network,
regex-compat,
- Cabal >= 1.2 && < 1.3,
+ Cabal >= 1.4 && < 1.5,
HTTP >= 3000 && < 3002,
zlib,
tar

0 comments on commit ffabce4

Please sign in to comment.