Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 125 lines (115 sloc) 5.244 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
02aa2fc @kolmodin Stop using HASKELL_DEPS, BUILD_TOOLS, EXTRA_LIBS variables in ebuilds
kolmodin authored
27 ,convertDependency
28 ,default_ghc_dependency) where
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
29
30 import qualified Distribution.PackageDescription as Cabal
87d875b @kolmodin Wall police
kolmodin authored
31 (PackageDescription(..))
8273e68 @kolmodin Update the CLI and start using cabal-install features
kolmodin authored
32 import qualified Distribution.Package as Cabal (PackageIdentifier(..)
33 , Dependency(..)
34 , PackageName(..))
2d84418 @jkarlson Remove useless imports and variables.
jkarlson authored
35 import qualified Distribution.Version as Cabal (VersionRange, foldVersionRange')
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
36 import Distribution.Text (display)
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
37
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
38 import Data.Char (toLower,isUpper)
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
39
6956e2f @kolmodin Tiny cleanup about different Version structures. Add rdepend to ebuild.
kolmodin authored
40 import Portage.Dependency
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
41 import qualified Portage.PackageId as Portage
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
42 import qualified Portage.EBuild as Portage
43 import qualified Portage.EBuild as E
6956e2f @kolmodin Tiny cleanup about different Version structures. Add rdepend to ebuild.
kolmodin authored
44 import Portage.Version
45
02aa2fc @kolmodin Stop using HASKELL_DEPS, BUILD_TOOLS, EXTRA_LIBS variables in ebuilds
kolmodin authored
46 default_ghc_dependency :: Dependency
47 default_ghc_dependency = OrLaterVersionOf (Version [6,8,1] Nothing [] 0) (Portage.mkPackageName "dev-lang" "ghc")
48
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
49 cabal2ebuild :: Cabal.PackageDescription -> Portage.EBuild
50 cabal2ebuild pkg = Portage.ebuildTemplate {
51 E.name = map toLower cabalPkgName,
52 E.version = display (Cabal.pkgVersion (Cabal.package pkg)),
53 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
54 else Cabal.synopsis pkg,
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
55 E.homepage = Cabal.homepage pkg,
56 E.src_uri = Cabal.pkgUrl pkg,
57 E.license = Cabal.license pkg,
58 E.my_pn = if any isUpper cabalPkgName then Just cabalPkgName else Nothing,
59 E.features = E.features E.ebuildTemplate
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
60 ++ (if hasExe then ["bin"] else [])
9d28e5b make sure hscolour does not get the hscolour feature
Stephan Friedrichs authored
61 ++ maybe [] (const (["lib","profile","haddock"]
62 ++ if cabalPkgName == "hscolour" then [] else ["hscolour"])
63 ) (Cabal.library pkg) -- hscolour can't colour its own sources
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
64 } where
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
65 cabalPkgName = display $ Cabal.pkgName (Cabal.package pkg)
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
66 hasExe = (not . null) (Cabal.executables 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
1585cc6 @trofi Cabal2Ebuild.hs: migrated to foldVersionRange
trofi authored
90 )(\r1 r2 -> r1 ++ r2
91 )
fbf5eb0 @kolmodin Properly handle portage's "||" operator, it takes multiple arguments
kolmodin authored
92 where
93 flatten :: [Dependency] -> [[Dependency]]
94 flatten [DependEither ds] = concatMap flatten ds
95 flatten other = [other]
96
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
97
8273e68 @kolmodin Update the CLI and start using cabal-install features
kolmodin authored
98 coreLibs :: [Cabal.PackageName]
99 coreLibs = map Cabal.PackageName
61f04b0 Update list of core libs
Duncan Coutts authored
100 ["array"
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
101 ,"base"
eb77d89 @trofi wipe bytestring as a explicit dependency once again
trofi authored
102 ,"bytestring" -- intentionally no ebuild. use ghc's version
103 -- to avoid dreaded 'diamond dependency' problem
61f04b0 Update list of core libs
Duncan Coutts authored
104 ,"containers"
105 ,"directory"
136cbd4 @kolmodin We do need editline dependencies
kolmodin authored
106 --,"editline"
fe19025 @trofi ban one more core package: filepath this time
trofi authored
107 ,"filepath" -- intentionally no ebuild. use ghc's version
61f04b0 Update list of core libs
Duncan Coutts authored
108 ,"ghc"
285f6b1 @kolmodin Add missing core libs to list
kolmodin authored
109 ,"ghc-prim"
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
110 ,"haskell98"
2f85f14 @kolmodin Write comments about core packages
kolmodin authored
111 ,"hpc" --has ebuild, but only in the overlay
285f6b1 @kolmodin Add missing core libs to list
kolmodin authored
112 ,"integer"
61f04b0 Update list of core libs
Duncan Coutts authored
113 ,"old-locale"
114 ,"old-time"
115 ,"packedstring"
116 ,"pretty"
117 ,"process"
118 ,"random"
2f85f14 @kolmodin Write comments about core packages
kolmodin authored
119 ,"readline" --has ebuild, but only in the overlay
61f04b0 Update list of core libs
Duncan Coutts authored
120 ,"rts"
cd68bad @trofi wipe syb as a explicit dependency from generated ebuilds
trofi authored
121 ,"syb" -- intentionally no ebuild. use ghc's version
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
122 ,"template-haskell"
2f85f14 @kolmodin Write comments about core packages
kolmodin authored
123 ,"unix" --has ebuild, but only in the overlay
61f04b0 Update list of core libs
Duncan Coutts authored
124 ]
Something went wrong with that request. Please try again.