Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 98 lines (90 sloc) 5.017 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 module Cabal2Ebuild
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
20 (cabal2ebuild
cb4a7bb @kolmodin Start on translating extra-libraries into ebuild deps
kolmodin authored
21 ,convertDependencies
4f6ec6f @kolmodin guess-ghc-version: Integrate GHC guessing into 'hackport merge'
kolmodin authored
22 ,convertDependency) where
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
23
24 import qualified Distribution.PackageDescription as Cabal
87d875b @kolmodin Wall police
kolmodin authored
25 (PackageDescription(..))
8273e68 @kolmodin Update the CLI and start using cabal-install features
kolmodin authored
26 import qualified Distribution.Package as Cabal (PackageIdentifier(..)
97f2ecb @trofi Portage/GHCCore.hs: drop coreLibs logic
trofi authored
27 , Dependency(..))
2d84418 @jkarlson Remove useless imports and variables.
jkarlson authored
28 import qualified Distribution.Version as Cabal (VersionRange, foldVersionRange')
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
29 import Distribution.Text (display)
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
30
52a92a7 @trofi Merge.hs: move existing metadata reading out before ebuild generation
trofi authored
31 import Data.Char (isUpper)
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
32
6956e2f @kolmodin Tiny cleanup about different Version structures. Add rdepend to ebuild.
kolmodin authored
33 import Portage.Dependency
28670d8 @trofi Portage/Cabal.hs: move cabal->portage license converter to 'Portage.C…
trofi authored
34 import qualified Portage.Cabal as Portage
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
35 import qualified Portage.PackageId as Portage
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
36 import qualified Portage.EBuild as Portage
caf3f8f @trofi merge: search DEPENDS in according categories instead of hardcoding d…
trofi authored
37 import qualified Portage.Resolve as Portage
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
38 import qualified Portage.EBuild as E
caf3f8f @trofi merge: search DEPENDS in according categories instead of hardcoding d…
trofi authored
39 import qualified Portage.Overlay as O
6956e2f @kolmodin Tiny cleanup about different Version structures. Add rdepend to ebuild.
kolmodin authored
40 import Portage.Version
41
1bf9719 @hasufell Add package category to EBuild data type
hasufell authored
42 cabal2ebuild :: Portage.Category -> Cabal.PackageDescription -> Portage.EBuild
43 cabal2ebuild cat pkg = Portage.ebuildTemplate {
52a92a7 @trofi Merge.hs: move existing metadata reading out before ebuild generation
trofi authored
44 E.name = Portage.cabal_pn_to_PN cabal_pn,
1bf9719 @hasufell Add package category to EBuild data type
hasufell authored
45 E.category = display cat,
18b7fbc @trofi caba2ebuild: don't mangle package name as hackage is case sensitive
trofi authored
46 E.hackage_name= cabalPkgName,
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
47 E.version = display (Cabal.pkgVersion (Cabal.package pkg)),
48 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
49 else Cabal.synopsis pkg,
59858eb @trofi Added 'metadata.xml' autogeneration for packages where it does not ex…
trofi authored
50 E.long_desc = if null (Cabal.description pkg) then Cabal.synopsis pkg
51 else Cabal.description pkg,
8bc201b @jkarlson Add silly default homepage and src_uri.
jkarlson authored
52 E.homepage = thisHomepage,
28670d8 @trofi Portage/Cabal.hs: move cabal->portage license converter to 'Portage.C…
trofi authored
53 E.license = Portage.convertLicense $ Cabal.license pkg,
b04d5eb @trofi Switch to EAPI=5 by default, use subslots for libraries use build-tim…
trofi authored
54 E.slot = (E.slot E.ebuildTemplate) ++ maybe [] (const "/${PV}") (Cabal.library pkg),
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
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
bacaeb6 @trofi Cabal2Ebuild: move 'test-suite' to the end of features
trofi authored
61 ++ (if hasTests then ["test-suite"] else [])
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
62 } where
52a92a7 @trofi Merge.hs: move existing metadata reading out before ebuild generation
trofi authored
63 cabal_pn = Cabal.pkgName $ Cabal.package pkg
64 cabalPkgName = display cabal_pn
755d028 @trofi Cabal2Ebuild.hs: cleanup whitespace
trofi authored
65 hasExe = (not . null) (Cabal.executables pkg)
c1c12ae @renegat96 Add test-suite support
renegat96 authored
66 hasTests = (not . null) (Cabal.testSuites pkg)
8bc201b @jkarlson Add silly default homepage and src_uri.
jkarlson authored
67 thisHomepage = if (null $ Cabal.homepage pkg)
68 then E.homepage E.ebuildTemplate
69 else Cabal.homepage pkg
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
70
caf3f8f @trofi merge: search DEPENDS in according categories instead of hardcoding d…
trofi authored
71 convertDependencies :: O.Overlay -> Portage.Category -> [Cabal.Dependency] -> [Dependency]
8deac8c @trofi cleanup: convert 'convertDependency' return type from '[Dependency]' …
trofi authored
72 convertDependencies overlay category = map (convertDependency overlay category)
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
73
8deac8c @trofi cleanup: convert 'convertDependency' return type from '[Dependency]' …
trofi authored
74 convertDependency :: O.Overlay -> Portage.Category -> Cabal.Dependency -> Dependency
caf3f8f @trofi merge: search DEPENDS in according categories instead of hardcoding d…
trofi authored
75 convertDependency overlay category (Cabal.Dependency pname versionRange)
1585cc6 @trofi Cabal2Ebuild.hs: migrated to foldVersionRange
trofi authored
76 = convert versionRange
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
77 where
caf3f8f @trofi merge: search DEPENDS in according categories instead of hardcoding d…
trofi authored
78 pn = case Portage.resolveFullPortageName overlay pname of
79 Just r -> r
80 Nothing -> Portage.PackageName category (Portage.normalizeCabalPackageName pname)
29553c8 @trofi Portage/Dependency.hs: simplify datastructure holding dependency ranges
trofi authored
81 mk_p :: DRange -> Dependency
38dd085 @qnikst Change Dependency type to make builder simpler.
qnikst authored
82 mk_p dr = DependAtom (Atom pn dr (DAttr AnySlot []))
29553c8 @trofi Portage/Dependency.hs: simplify datastructure holding dependency ranges
trofi authored
83 p_v v = fromCabalVersion v
84
8deac8c @trofi cleanup: convert 'convertDependency' return type from '[Dependency]' …
trofi authored
85 convert :: Cabal.VersionRange -> Dependency
1585cc6 @trofi Cabal2Ebuild.hs: migrated to foldVersionRange
trofi authored
86 convert = Cabal.foldVersionRange'
8deac8c @trofi cleanup: convert 'convertDependency' return type from '[Dependency]' …
trofi authored
87 ( mk_p (DRange ZeroB InfinityB) -- ^ @\"-any\"@ version
88 )(\v -> mk_p (DExact (p_v v)) -- ^ @\"== v\"@
89 )(\v -> mk_p (DRange (StrictLB (p_v v)) InfinityB) -- ^ @\"> v\"@
90 )(\v -> mk_p (DRange ZeroB (StrictUB (p_v v))) -- ^ @\"< v\"@
91 )(\v -> mk_p (DRange (NonstrictLB (p_v v)) InfinityB) -- ^ @\">= v\"@
824dde3 @trofi Cabal2Ebuild.hs: fix cabal to portage version conversion '<=' bug
trofi authored
92 )(\v -> mk_p (DRange ZeroB (NonstrictUB (p_v v))) -- ^ @\"<= v\"@
8deac8c @trofi cleanup: convert 'convertDependency' return type from '[Dependency]' …
trofi authored
93 )(\v1 v2 -> mk_p (DRange (NonstrictLB (p_v v1)) (StrictUB (p_v v2))) -- ^ @\"== v.*\"@ wildcard. (incl lower, excl upper)
94 )(\g1 g2 -> DependAnyOf [g1, g2] -- ^ @\"_ || _\"@ union
95 )(\r1 r2 -> DependAllOf [r1, r2] -- ^ @\"_ && _\"@ intersection
96 )(\dp -> dp -- ^ @\"(_)\"@ parentheses
1585cc6 @trofi Cabal2Ebuild.hs: migrated to foldVersionRange
trofi authored
97 )
Something went wrong with that request. Please try again.