Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 126 lines (117 sloc) 5.489 kb
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
1 -- A program for generating a Gentoo ebuild from a .cabal file
2 --
3 -- Author : Duncan Coutts <dcoutts@gentoo.org>
4 --
5 -- Created: 21 July 2005
6 --
7 -- Copyright (C) 2005 Duncan Coutts
8 --
9 -- This library is free software; you can redistribute it and/or
10 -- modify it under the terms of the GNU General Public License
11 -- as published by the Free Software Foundation; either version 2
12 -- of the License, or (at your option) any later version.
13 --
14 -- This library is distributed in the hope that it will be useful,
15 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
16 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 -- General Public License for more details.
18 --
19 -- |
20 -- Maintainer : haskell@gentoo.org
21 --
22 -- cabal2ebuild - a program for generating a Gentoo ebuild from a .cabal file
23 --
24 module Cabal2Ebuild
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
25 (cabal2ebuild
cb4a7bb @kolmodin Start on translating extra-libraries into ebuild deps
kolmodin authored
26 ,convertDependencies
4f6ec6f @kolmodin guess-ghc-version: Integrate GHC guessing into 'hackport merge'
kolmodin authored
27 ,convertDependency) where
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
28
29 import qualified Distribution.PackageDescription as Cabal
87d875b @kolmodin Wall police
kolmodin authored
30 (PackageDescription(..))
8273e68 @kolmodin Update the CLI and start using cabal-install features
kolmodin authored
31 import qualified Distribution.Package as Cabal (PackageIdentifier(..)
32 , Dependency(..)
33 , PackageName(..))
2d84418 @jkarlson Remove useless imports and variables.
jkarlson authored
34 import qualified Distribution.Version as Cabal (VersionRange, foldVersionRange')
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
35 import Distribution.Text (display)
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
36
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
37 import Data.Char (toLower,isUpper)
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
38
6956e2f @kolmodin Tiny cleanup about different Version structures. Add rdepend to ebuild.
kolmodin authored
39 import Portage.Dependency
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
40 import qualified Portage.PackageId as Portage
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
41 import qualified Portage.EBuild as Portage
42 import qualified Portage.EBuild as E
6956e2f @kolmodin Tiny cleanup about different Version structures. Add rdepend to ebuild.
kolmodin authored
43 import Portage.Version
44
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
45 cabal2ebuild :: Cabal.PackageDescription -> Portage.EBuild
46 cabal2ebuild pkg = Portage.ebuildTemplate {
47 E.name = map toLower cabalPkgName,
48 E.version = display (Cabal.pkgVersion (Cabal.package pkg)),
49 E.description = if null (Cabal.synopsis pkg) then Cabal.description pkg
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
50 else Cabal.synopsis pkg,
59858eb @trofi Added 'metadata.xml' autogeneration for packages where it does not ex…
trofi authored
51 E.long_desc = if null (Cabal.description pkg) then Cabal.synopsis pkg
52 else Cabal.description pkg,
8bc201b @jkarlson Add silly default homepage and src_uri.
jkarlson authored
53 E.homepage = thisHomepage,
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
54 E.license = Cabal.license pkg,
55 E.my_pn = if any isUpper cabalPkgName then Just cabalPkgName else Nothing,
56 E.features = E.features E.ebuildTemplate
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
57 ++ (if hasExe then ["bin"] else [])
2ed012c @trofi cabal2ebuild: adding USE=hoogle by default
trofi authored
58 ++ maybe [] (const (["lib","profile","haddock","hoogle"]
9d28e5b make sure hscolour does not get the hscolour feature
Stephan Friedrichs authored
59 ++ if cabalPkgName == "hscolour" then [] else ["hscolour"])
60 ) (Cabal.library pkg) -- hscolour can't colour its own sources
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
61 } where
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
62 cabalPkgName = display $ Cabal.pkgName (Cabal.package pkg)
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
63 hasExe = (not . null) (Cabal.executables pkg)
8bc201b @jkarlson Add silly default homepage and src_uri.
jkarlson authored
64 thisHomepage = if (null $ Cabal.homepage pkg)
65 then E.homepage E.ebuildTemplate
66 else Cabal.homepage pkg
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
67
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
68 convertDependencies :: Portage.Category -> [Cabal.Dependency] -> [Dependency]
23fbd30 @kolmodin allow deps to not be in the dev-haskell/ category
kolmodin authored
69 convertDependencies category = concatMap (convertDependency category)
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
70
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
71 convertDependency :: Portage.Category -> Cabal.Dependency -> [Dependency]
23fbd30 @kolmodin allow deps to not be in the dev-haskell/ category
kolmodin authored
72 convertDependency _category (Cabal.Dependency pname@(Cabal.PackageName _name) _)
8273e68 @kolmodin Update the CLI and start using cabal-install features
kolmodin authored
73 | pname `elem` coreLibs = [] -- no explicit dep on core libs
23fbd30 @kolmodin allow deps to not be in the dev-haskell/ category
kolmodin authored
74 convertDependency category (Cabal.Dependency pname versionRange)
1585cc6 @trofi Cabal2Ebuild.hs: migrated to foldVersionRange
trofi authored
75 = convert versionRange
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
76 where
decf164 @kolmodin Bump Copyright header
kolmodin authored
77 -- XXX: not always true, we should look properly for deps in the overlay
78 -- to find the correct category
fbf5eb0 @kolmodin Properly handle portage's "||" operator, it takes multiple arguments
kolmodin authored
79 pn = Portage.PackageName category (Portage.normalizeCabalPackageName pname)
1585cc6 @trofi Cabal2Ebuild.hs: migrated to foldVersionRange
trofi authored
80 convert :: Cabal.VersionRange -> [Dependency]
81 convert = Cabal.foldVersionRange'
fbf5eb0 @kolmodin Properly handle portage's "||" operator, it takes multiple arguments
kolmodin authored
82 ( [AnyVersionOf pn] -- ^ @\"-any\"@ version
83 )(\v -> [ThisVersionOf (fromCabalVersion v) pn] -- ^ @\"== v\"@
84 )(\v -> [LaterVersionOf (fromCabalVersion v) pn] -- ^ @\"> v\"@
85 )(\v -> [EarlierVersionOf (fromCabalVersion v) pn] -- ^ @\"< v\"@
86 )(\v -> [OrLaterVersionOf (fromCabalVersion v) pn] -- ^ @\">= v\"@
87 )(\v -> [OrEarlierVersionOf (fromCabalVersion v) pn] -- ^ @\"<= v\"@
88 )(\v _ -> [ThisMajorOf (fromCabalVersion v) pn] -- ^ @\"== v.*\"@ wildcard. (incl lower, excl upper)
89 )(\g1 g2 -> [DependEither (flatten g1 ++ flatten g2) ] -- ^ @\"_ || _\"@ union
33ecc29 @kolmodin Support cabal's new (_) dependency, with parantheses
kolmodin authored
90 )(\r1 r2 -> r1 ++ r2 -- ^ @\"_ && _\"@ intersection
91 )(\dp -> [AllOf dp ] -- ^ @\"(_)\"@ parentheses
1585cc6 @trofi Cabal2Ebuild.hs: migrated to foldVersionRange
trofi authored
92 )
fbf5eb0 @kolmodin Properly handle portage's "||" operator, it takes multiple arguments
kolmodin authored
93 where
94 flatten :: [Dependency] -> [[Dependency]]
95 flatten [DependEither ds] = concatMap flatten ds
96 flatten other = [other]
97
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
98
8273e68 @kolmodin Update the CLI and start using cabal-install features
kolmodin authored
99 coreLibs :: [Cabal.PackageName]
100 coreLibs = map Cabal.PackageName
61f04b0 Update list of core libs
Duncan Coutts authored
101 ["array"
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
102 ,"base"
eb77d89 @trofi wipe bytestring as a explicit dependency once again
trofi authored
103 ,"bytestring" -- intentionally no ebuild. use ghc's version
104 -- to avoid dreaded 'diamond dependency' problem
61f04b0 Update list of core libs
Duncan Coutts authored
105 ,"containers"
106 ,"directory"
136cbd4 @kolmodin We do need editline dependencies
kolmodin authored
107 --,"editline"
fe19025 @trofi ban one more core package: filepath this time
trofi authored
108 ,"filepath" -- intentionally no ebuild. use ghc's version
61f04b0 Update list of core libs
Duncan Coutts authored
109 ,"ghc"
285f6b1 @kolmodin Add missing core libs to list
kolmodin authored
110 ,"ghc-prim"
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
111 ,"haskell98"
2f85f14 @kolmodin Write comments about core packages
kolmodin authored
112 ,"hpc" --has ebuild, but only in the overlay
285f6b1 @kolmodin Add missing core libs to list
kolmodin authored
113 ,"integer"
61f04b0 Update list of core libs
Duncan Coutts authored
114 ,"old-locale"
115 ,"old-time"
116 ,"packedstring"
117 ,"pretty"
118 ,"process"
119 ,"random"
2f85f14 @kolmodin Write comments about core packages
kolmodin authored
120 ,"readline" --has ebuild, but only in the overlay
61f04b0 Update list of core libs
Duncan Coutts authored
121 ,"rts"
5a4179b @trofi depends: treat syb as external depend again
trofi authored
122 -- ,"syb" -- was splitted off from ghc again
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
123 ,"template-haskell"
2f85f14 @kolmodin Write comments about core packages
kolmodin authored
124 ,"unix" --has ebuild, but only in the overlay
61f04b0 Update list of core libs
Duncan Coutts authored
125 ]
Something went wrong with that request. Please try again.