Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 130 lines (123 sloc) 5.832 kb
aff37c25 » der_eq@freenet.de
2005-09-05 First release of HackPort, the Hackage tool for Portage
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
b44fb9d4 » kolmodin
2010-06-20 Move datatype EBuild to Portage.EBuild
25 (cabal2ebuild
cb4a7bb9 » kolmodin
2009-03-01 Start on translating extra-libraries into ebuild deps
26 ,convertDependencies
4f6ec6f5 » kolmodin
2010-07-28 guess-ghc-version: Integrate GHC guessing into 'hackport merge'
27 ,convertDependency) where
aff37c25 » der_eq@freenet.de
2005-09-05 First release of HackPort, the Hackage tool for Portage
28
29 import qualified Distribution.PackageDescription as Cabal
87d875b3 » kolmodin
2008-03-15 Wall police
30 (PackageDescription(..))
8273e68c » kolmodin
2009-02-07 Update the CLI and start using cabal-install features
31 import qualified Distribution.Package as Cabal (PackageIdentifier(..)
32 , Dependency(..)
33 , PackageName(..))
2d84418a » jkarlson
2010-07-09 Remove useless imports and variables.
34 import qualified Distribution.Version as Cabal (VersionRange, foldVersionRange')
9e6e1bc1 » kolmodin
2010-06-19 Make Portage.Dependency use PackageName instead of just a String
35 import Distribution.Text (display)
aff37c25 » der_eq@freenet.de
2005-09-05 First release of HackPort, the Hackage tool for Portage
36
8022ddcf » der_eq@freenet.de
2005-09-21 Adding support for variable substitution in generated ebuilds
37 import Data.Char (toLower,isUpper)
aff37c25 » der_eq@freenet.de
2005-09-05 First release of HackPort, the Hackage tool for Portage
38
6956e2f0 » kolmodin
2009-08-03 Tiny cleanup about different Version structures. Add rdepend to ebuild.
39 import Portage.Dependency
0a5a285c » qnikst
2012-02-27 UseFlag handling
40 import Portage.Use
9e6e1bc1 » kolmodin
2010-06-19 Make Portage.Dependency use PackageName instead of just a String
41 import qualified Portage.PackageId as Portage
b44fb9d4 » kolmodin
2010-06-20 Move datatype EBuild to Portage.EBuild
42 import qualified Portage.EBuild as Portage
caf3f8fa » trofi
2012-02-28 merge: search DEPENDS in according categories instead of hardcoding d…
43 import qualified Portage.Resolve as Portage
b44fb9d4 » kolmodin
2010-06-20 Move datatype EBuild to Portage.EBuild
44 import qualified Portage.EBuild as E
caf3f8fa » trofi
2012-02-28 merge: search DEPENDS in according categories instead of hardcoding d…
45 import qualified Portage.Overlay as O
6956e2f0 » kolmodin
2009-08-03 Tiny cleanup about different Version structures. Add rdepend to ebuild.
46 import Portage.Version
47
b44fb9d4 » kolmodin
2010-06-20 Move datatype EBuild to Portage.EBuild
48 cabal2ebuild :: Cabal.PackageDescription -> Portage.EBuild
49 cabal2ebuild pkg = Portage.ebuildTemplate {
50 E.name = map toLower cabalPkgName,
18b7fbca » trofi
2012-02-15 caba2ebuild: don't mangle package name as hackage is case sensitive
51 E.hackage_name= cabalPkgName,
b44fb9d4 » kolmodin
2010-06-20 Move datatype EBuild to Portage.EBuild
52 E.version = display (Cabal.pkgVersion (Cabal.package pkg)),
53 E.description = if null (Cabal.synopsis pkg) then Cabal.description pkg
aff37c25 » der_eq@freenet.de
2005-09-05 First release of HackPort, the Hackage tool for Portage
54 else Cabal.synopsis pkg,
59858eb7 » trofi
2011-11-27 Added 'metadata.xml' autogeneration for packages where it does not ex…
55 E.long_desc = if null (Cabal.description pkg) then Cabal.synopsis pkg
56 else Cabal.description pkg,
8bc201b1 » jkarlson
2010-07-10 Add silly default homepage and src_uri.
57 E.homepage = thisHomepage,
b44fb9d4 » kolmodin
2010-06-20 Move datatype EBuild to Portage.EBuild
58 E.license = Cabal.license pkg,
59 E.my_pn = if any isUpper cabalPkgName then Just cabalPkgName else Nothing,
60 E.features = E.features E.ebuildTemplate
bd75ad03 » kolmodin
2009-12-22 first stab at DEPEND / RDEPEND tracking
61 ++ (if hasExe then ["bin"] else [])
2ed012c2 » trofi
2011-11-20 cabal2ebuild: adding USE=hoogle by default
62 ++ maybe [] (const (["lib","profile","haddock","hoogle"]
9d28e5bc » Stephan Friedrichs
2009-03-04 make sure hscolour does not get the hscolour feature
63 ++ if cabalPkgName == "hscolour" then [] else ["hscolour"])
64 ) (Cabal.library pkg) -- hscolour can't colour its own sources
bacaeb6a » trofi
2012-04-19 Cabal2Ebuild: move 'test-suite' to the end of features
65 ++ (if hasTests then ["test-suite"] else [])
8022ddcf » der_eq@freenet.de
2005-09-21 Adding support for variable substitution in generated ebuilds
66 } where
9e6e1bc1 » kolmodin
2010-06-19 Make Portage.Dependency use PackageName instead of just a String
67 cabalPkgName = display $ Cabal.pkgName (Cabal.package pkg)
bd75ad03 » kolmodin
2009-12-22 first stab at DEPEND / RDEPEND tracking
68 hasExe = (not . null) (Cabal.executables pkg)
c1c12aef » renegat96
2012-04-16 Add test-suite support
69 hasTests = (not . null) (Cabal.testSuites pkg)
8bc201b1 » jkarlson
2010-07-10 Add silly default homepage and src_uri.
70 thisHomepage = if (null $ Cabal.homepage pkg)
71 then E.homepage E.ebuildTemplate
72 else Cabal.homepage pkg
aff37c25 » der_eq@freenet.de
2005-09-05 First release of HackPort, the Hackage tool for Portage
73
caf3f8fa » trofi
2012-02-28 merge: search DEPENDS in according categories instead of hardcoding d…
74 convertDependencies :: O.Overlay -> Portage.Category -> [Cabal.Dependency] -> [Dependency]
75 convertDependencies overlay category = concatMap (convertDependency overlay category)
aff37c25 » der_eq@freenet.de
2005-09-05 First release of HackPort, the Hackage tool for Portage
76
caf3f8fa » trofi
2012-02-28 merge: search DEPENDS in according categories instead of hardcoding d…
77 convertDependency :: O.Overlay -> Portage.Category -> Cabal.Dependency -> [Dependency]
78 convertDependency overlay _category (Cabal.Dependency pname@(Cabal.PackageName _name) _)
8273e68c » kolmodin
2009-02-07 Update the CLI and start using cabal-install features
79 | pname `elem` coreLibs = [] -- no explicit dep on core libs
caf3f8fa » trofi
2012-02-28 merge: search DEPENDS in according categories instead of hardcoding d…
80 convertDependency overlay category (Cabal.Dependency pname versionRange)
1585cc6e » trofi
2009-12-20 Cabal2Ebuild.hs: migrated to foldVersionRange
81 = convert versionRange
aff37c25 » der_eq@freenet.de
2005-09-05 First release of HackPort, the Hackage tool for Portage
82 where
caf3f8fa » trofi
2012-02-28 merge: search DEPENDS in according categories instead of hardcoding d…
83 pn = case Portage.resolveFullPortageName overlay pname of
84 Just r -> r
85 Nothing -> Portage.PackageName category (Portage.normalizeCabalPackageName pname)
1585cc6e » trofi
2009-12-20 Cabal2Ebuild.hs: migrated to foldVersionRange
86 convert :: Cabal.VersionRange -> [Dependency]
87 convert = Cabal.foldVersionRange'
0a5a285c » qnikst
2012-02-27 UseFlag handling
88 ( [AnyVersionOf pn []] -- ^ @\"-any\"@ version
89 )(\v -> [ThisVersionOf (fromCabalVersion v) pn []] -- ^ @\"== v\"@
90 )(\v -> [LaterVersionOf (fromCabalVersion v) pn []] -- ^ @\"> v\"@
91 )(\v -> [EarlierVersionOf (fromCabalVersion v) pn []] -- ^ @\"< v\"@
92 )(\v -> [OrLaterVersionOf (fromCabalVersion v) pn []] -- ^ @\">= v\"@
93 )(\v -> [OrEarlierVersionOf (fromCabalVersion v) pn []] -- ^ @\"<= v\"@
94 )(\v _ -> [ThisMajorOf (fromCabalVersion v) pn []] -- ^ @\"== v.*\"@ wildcard. (incl lower, excl upper)
fbf5eb0a » kolmodin
2010-06-20 Properly handle portage's "||" operator, it takes multiple arguments
95 )(\g1 g2 -> [DependEither (flatten g1 ++ flatten g2) ] -- ^ @\"_ || _\"@ union
33ecc291 » kolmodin
2010-12-26 Support cabal's new (_) dependency, with parantheses
96 )(\r1 r2 -> r1 ++ r2 -- ^ @\"_ && _\"@ intersection
97 )(\dp -> [AllOf dp ] -- ^ @\"(_)\"@ parentheses
1585cc6e » trofi
2009-12-20 Cabal2Ebuild.hs: migrated to foldVersionRange
98 )
fbf5eb0a » kolmodin
2010-06-20 Properly handle portage's "||" operator, it takes multiple arguments
99 where
100 flatten :: [Dependency] -> [[Dependency]]
101 flatten [DependEither ds] = concatMap flatten ds
102 flatten other = [other]
103
8273e68c » kolmodin
2009-02-07 Update the CLI and start using cabal-install features
104 coreLibs :: [Cabal.PackageName]
105 coreLibs = map Cabal.PackageName
61f04b0b » Duncan Coutts
2008-01-14 Update list of core libs
106 ["array"
8022ddcf » der_eq@freenet.de
2005-09-21 Adding support for variable substitution in generated ebuilds
107 ,"base"
eb77d89b » trofi
2009-10-23 wipe bytestring as a explicit dependency once again
108 ,"bytestring" -- intentionally no ebuild. use ghc's version
109 -- to avoid dreaded 'diamond dependency' problem
61f04b0b » Duncan Coutts
2008-01-14 Update list of core libs
110 ,"containers"
111 ,"directory"
136cbd45 » kolmodin
2009-04-17 We do need editline dependencies
112 --,"editline"
fe190252 » trofi
2009-12-23 ban one more core package: filepath this time
113 ,"filepath" -- intentionally no ebuild. use ghc's version
61f04b0b » Duncan Coutts
2008-01-14 Update list of core libs
114 ,"ghc"
285f6b19 » kolmodin
2009-03-14 Add missing core libs to list
115 ,"ghc-prim"
8022ddcf » der_eq@freenet.de
2005-09-21 Adding support for variable substitution in generated ebuilds
116 ,"haskell98"
2f85f14c » kolmodin
2008-07-08 Write comments about core packages
117 ,"hpc" --has ebuild, but only in the overlay
ed7c596e » trofi
2011-12-11 core libraries: add 'integer-gmp' to list of core ones
118 ,"integer" -- up to ghc-6.10
119 ,"integer-gmp" -- ghc-6.12+
61f04b0b » Duncan Coutts
2008-01-14 Update list of core libs
120 ,"old-locale"
121 ,"old-time"
122 ,"packedstring"
123 ,"pretty"
124 ,"process"
b45538ac » trofi
2012-01-02 Cabal2Ebuild: don't hide 'random' and 'readline' depends
125 -- ,"random" -- not a core package since ghc-7.2
61f04b0b » Duncan Coutts
2008-01-14 Update list of core libs
126 ,"rts"
5a4179b8 » trofi
2011-04-23 depends: treat syb as external depend again
127 -- ,"syb" -- was splitted off from ghc again
aff37c25 » der_eq@freenet.de
2005-09-05 First release of HackPort, the Hackage tool for Portage
128 ,"template-haskell"
b45538ac » trofi
2012-01-02 Cabal2Ebuild: don't hide 'random' and 'readline' depends
129 ,"unix" -- unsafe to upgrade
61f04b0b » Duncan Coutts
2008-01-14 Update list of core libs
130 ]
Something went wrong with that request. Please try again.