Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 382 lines (325 sloc) 14.149 kb
deff889 @trofi Some fixes for -Wall (name colisions, redundant imports)
trofi authored
1 {-# OPTIONS -XPatternGuards #-}
6956e2f @kolmodin Tiny cleanup about different Version structures. Add rdepend to ebuild.
kolmodin authored
2 {- | Merge a package from hackage to an ebuild.
3
4 Merging a library
5 =================
6
7 Compile time:
8 ghc
9 cabal
10 build tools
62a881a @kolmodin Update docs about what needs to be merged wrt DEPEND/RDEPEND
kolmodin authored
11 deps (haskell dependencies)
6956e2f @kolmodin Tiny cleanup about different Version structures. Add rdepend to ebuild.
kolmodin authored
12 extra-libs (c-libs)
13
14 Run time:
62a881a @kolmodin Update docs about what needs to be merged wrt DEPEND/RDEPEND
kolmodin authored
15 ghc
16 deps (haskell dependencies)
6956e2f @kolmodin Tiny cleanup about different Version structures. Add rdepend to ebuild.
kolmodin authored
17 extra-libs (c-libs)
18
62a881a @kolmodin Update docs about what needs to be merged wrt DEPEND/RDEPEND
kolmodin authored
19 RDEPEND="ghc ${DEPS} ${EXTRALIBS}"
20 DEPEND="${RDEPEND} cabal ${BUILDTOOLS}"
6956e2f @kolmodin Tiny cleanup about different Version structures. Add rdepend to ebuild.
kolmodin authored
21
22 Merging an executable
23 =====================
24 Packages with both executable and library must be treated as libraries, as it will impose a stricter DEPEND.
25
26 Compile time:
27 ghc
28 cabal
29 build tools
30 deps
31 extra-libs (c-libs)
32
33 Run time:
34 extra-libs (c-libs)
35
36 RDEPEND="${EXTRALIBS}"
4475bd7 @kolmodin Add deps to docs about building an executable
kolmodin authored
37 DEPEND="${RDEPEND} ghc cabal ${DEPS} ${BUILDTOOLS}"
6956e2f @kolmodin Tiny cleanup about different Version structures. Add rdepend to ebuild.
kolmodin authored
38
39 -}
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
40 module Merge
41 ( merge ) where
a1730ad @kolmodin Switch to using Cabal's CLI API
kolmodin authored
42
43 import Control.Monad.Error
8135c0c @kolmodin Implement fetching and creation of digests for new ebuilds
kolmodin authored
44 import Control.Exception
a1730ad @kolmodin Switch to using Cabal's CLI API
kolmodin authored
45 import Data.Maybe
46 import Data.List
47 import Distribution.Package
48 import Distribution.Compiler (CompilerId(..), CompilerFlavor(GHC))
cb4a7bb @kolmodin Start on translating extra-libraries into ebuild deps
kolmodin authored
49 import Distribution.PackageDescription ( PackageDescription(..)
34e7842 @kolmodin Set --flags=-cocoa when finalizing a PackageDescription
kolmodin authored
50 , FlagName(..)
cb4a7bb @kolmodin Start on translating extra-libraries into ebuild deps
kolmodin authored
51 , libBuildInfo
52 , buildInfo
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
53 , buildable
1de8047 @kolmodin Add build-tools deps as well, using a static table
kolmodin authored
54 , extraLibs
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
55 , buildTools
56 , hasLibs )
a1730ad @kolmodin Switch to using Cabal's CLI API
kolmodin authored
57 import Distribution.PackageDescription.Configuration
58 ( finalizePackageDescription )
59 import Distribution.Text (display)
60
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
61 import System.Directory ( getCurrentDirectory
62 , setCurrentDirectory
63 , createDirectoryIfMissing
64 )
8135c0c @kolmodin Implement fetching and creation of digests for new ebuilds
kolmodin authored
65 import System.Cmd (system)
deff889 @trofi Some fixes for -Wall (name colisions, redundant imports)
trofi authored
66 import System.FilePath ((</>))
a1730ad @kolmodin Switch to using Cabal's CLI API
kolmodin authored
67
68 import qualified Cabal2Ebuild as E
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
69 import Cabal2Ebuild
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
70 import Error as E
71
72 import qualified Distribution.Package as Cabal
73 import qualified Distribution.Version as Cabal
a1730ad @kolmodin Switch to using Cabal's CLI API
kolmodin authored
74
60d04de @kolmodin adapt to cabal-1.8 and cabal-install-0.7.5 (HEADs)
kolmodin authored
75 import Distribution.System (buildPlatform)
a1730ad @kolmodin Switch to using Cabal's CLI API
kolmodin authored
76 import Distribution.Verbosity
77 import Distribution.Simple.Utils
78
79 import Network.URI
80
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
81 import Distribution.Client.IndexUtils ( getAvailablePackages )
4b2a1d2 @kolmodin Upgrade bundled cabal-install from 0.8.0 to 0.8.2
kolmodin authored
82 import Distribution.Client.HttpUtils ( downloadURI )
60d04de @kolmodin adapt to cabal-1.8 and cabal-install-0.7.5 (HEADs)
kolmodin authored
83 import qualified Distribution.Client.PackageIndex as Index
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
84 import Distribution.Client.Types
85
86 import qualified Portage.PackageId as Portage
87 import qualified Portage.Version as Portage
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
88 import qualified Portage.Dependency as Portage
27f08f3 @kolmodin Move host information code into Portage.Host
kolmodin authored
89 import qualified Portage.Host as Host
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
90 import qualified Portage.Overlay as Overlay
033ff9b @kolmodin move package resolving functions to Portage.Resolve
kolmodin authored
91 import qualified Portage.Resolve as Portage
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
92
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
93 import Debug.Trace ( trace )
94
deff889 @trofi Some fixes for -Wall (name colisions, redundant imports)
trofi authored
95 (<->) :: String -> String -> String
f56d508 @kolmodin Cleanup in merge
kolmodin authored
96 a <-> b = a ++ '-':b
deff889 @trofi Some fixes for -Wall (name colisions, redundant imports)
trofi authored
97
98 (<.>) :: String -> String -> String
f56d508 @kolmodin Cleanup in merge
kolmodin authored
99 a <.> b = a ++ '.':b
100
22e0fbc @kolmodin Add requests for 'hackport merge'
kolmodin authored
101 {-
102 Requested features:
c2b8367 @kolmodin Update TODOs
kolmodin authored
103 * Copy the old keywords and ~arch them
22e0fbc @kolmodin Add requests for 'hackport merge'
kolmodin authored
104 * Add files to darcs?
105 * Print diff with the next latest version?
96a6477 @kolmodin Add some todos
kolmodin authored
106 BUGS:
107 * Dependencies are always expected to be in dev-haskell
22e0fbc @kolmodin Add requests for 'hackport merge'
kolmodin authored
108 -}
109
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
110 readPackageString :: [String]
111 -> Either HackPortError ( Maybe Portage.Category
112 , Cabal.PackageName
113 , Maybe Portage.Version
114 )
115 readPackageString args = do
116 packageString <-
117 case args of
7ab62d5 @kolmodin Tried hlint, nice.
kolmodin authored
118 [] -> Left (ArgumentError "Need an argument, [category/]package[-version]")
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
119 [pkg] -> return pkg
120 _ -> Left (ArgumentError ("Too many arguments: " ++ unwords args))
121 case Portage.parseFriendlyPackage packageString of
122 Just v@(_,_,Nothing) -> return v
123 -- we only allow versions we can convert into cabal versions
124 Just v@(_,_,Just (Portage.Version _ Nothing [] 0)) -> return v
125 _ -> Left (ArgumentError ("Could not parse [category/]package[-version]: " ++ packageString))
126
823b6ef @kolmodin Look into portage dir when resolving extra-libraries
kolmodin authored
127
128
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
129 -- | Given a list of available packages, and maybe a preferred version,
130 -- return the available package with that version. Latest version is chosen
131 -- if no preference.
132 resolveVersion :: [AvailablePackage] -> Maybe Cabal.Version -> Maybe AvailablePackage
133 resolveVersion avails Nothing = Just $ maximumBy (comparing packageInfoId) avails
134 resolveVersion avails (Just ver) = listToMaybe (filter match avails)
135 where
7ab62d5 @kolmodin Tried hlint, nice.
kolmodin authored
136 match avail = ver == pkgVersion (packageInfoId avail)
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
137
df59c13 @trofi resurrected support of global '-p' (aka --overlay-path' flag
trofi authored
138 merge :: Verbosity -> Repo -> URI -> [String] -> FilePath -> IO ()
139 merge verbosity repo serverURI args overlayPath = do
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
140 (m_category, user_pName, m_version) <-
141 case readPackageString args of
142 Left err -> throwEx err
143 Right (c,p,m_v) ->
144 case m_v of
145 Nothing -> return (c,p,Nothing)
146 Just v -> case Portage.toCabalVersion v of
147 Nothing -> throwEx (ArgumentError "illegal version")
148 Just ver -> return (c,p,Just ver)
149
150 debug verbosity $ "Category: " ++ show m_category
151 debug verbosity $ "Package: " ++ show user_pName
152 debug verbosity $ "Version: " ++ show m_version
153
154 let (Cabal.PackageName user_pname_str) = user_pName
155
156 overlay <- Overlay.loadLazy overlayPath
27f08f3 @kolmodin Move host information code into Portage.Host
kolmodin authored
157 portage_path <- Host.portage_dir `fmap` Host.getInfo
e203713 @trofi added support for nonstandard PORTDIR(emerge) location::gentoo(paludis)
trofi authored
158 portage <- Overlay.loadLazy portage_path
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
159 index <- fmap packageIndex $ getAvailablePackages verbosity [ repo ]
160
161 -- find all packages that maches the user specified package name
162 availablePkgs <-
163 case Index.searchByName index user_pname_str of
164 Index.None -> throwEx (PackageNotFound user_pname_str)
165 Index.Ambiguous pkgs -> throwEx (ArgumentError ("Ambiguous name: " ++ unwords (map show pkgs)))
166 Index.Unambiguous pkg -> return pkg
167
168 -- select a single package taking into account the user specified version
169 selectedPkg <-
170 case resolveVersion availablePkgs m_version of
171 Nothing -> do
172 putStrLn "No such version for that package, available versions:"
7ab62d5 @kolmodin Tried hlint, nice.
kolmodin authored
173 forM_ availablePkgs $ \ avail ->
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
174 putStrLn (display . packageInfoId $ avail)
175 throwEx (ArgumentError "no such version for that package")
176 Just avail -> return avail
177
178 -- print some info
179 info verbosity "Selecting package:"
180 forM_ availablePkgs $ \ avail -> do
181 let match_text | packageInfoId avail == packageInfoId selectedPkg = "* "
182 | otherwise = "- "
183 info verbosity $ match_text ++ (display . packageInfoId $ avail)
184
185 let cabal_pkgId = packageInfoId selectedPkg
186 norm_pkgId = Portage.normalizeCabalPackageId cabal_pkgId
187 norm_pkgName = packageName norm_pkgId
2d91ca9 @kolmodin bugfix: allow the syntax "hackport merge foo/bar"
kolmodin authored
188 cat <- maybe (Portage.resolveCategory verbosity overlay norm_pkgName) return m_category
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
189
190 let pkgGenericDesc = packageDescription selectedPkg
191 Right (pkgDesc0, flags) =
192 finalizePackageDescription
193 [ -- XXX: common things we should enable/disable?
194 -- (FlagName "small_base", True) -- try to use small base
34e7842 @kolmodin Set --flags=-cocoa when finalizing a PackageDescription
kolmodin authored
195 (FlagName "cocoa", False)
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
196 ]
2775da0 @trofi -Wall cleanups
trofi authored
197 (\dep -> trace ("accepting dep(?): " ++ display dep) True)
60d04de @kolmodin adapt to cabal-1.8 and cabal-install-0.7.5 (HEADs)
kolmodin authored
198 -- (Nothing :: Maybe (Index.PackageIndex PackageIdentifier))
199 buildPlatform
6956e2f @kolmodin Tiny cleanup about different Version structures. Add rdepend to ebuild.
kolmodin authored
200 (CompilerId GHC (Cabal.Version [6,10,4] []))
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
201 [] pkgGenericDesc
60d04de @kolmodin adapt to cabal-1.8 and cabal-install-0.7.5 (HEADs)
kolmodin authored
202 pkgDesc = let deps = [ Dependency pn (Cabal.simplifyVersionRange vr)
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
203 | Dependency pn vr <- buildDepends pkgDesc0
204 ]
205 in pkgDesc0 { buildDepends = deps }
1de8047 @kolmodin Add build-tools deps as well, using a static table
kolmodin authored
206
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
207 hasBuildableExes p =
208 any (buildable . buildInfo)
209 . executables $ p
210 treatAsLibrary = (not . hasBuildableExes) pkgDesc && hasLibs pkgDesc
211
212 -- calculate build tools
213 bt = [ pkg' -- TODO: currently ignoring version range
2775da0 @trofi -Wall cleanups
trofi authored
214 | Cabal.Dependency (Cabal.PackageName pkg ) _range <- buildToolsDeps pkgDesc
1de8047 @kolmodin Add build-tools deps as well, using a static table
kolmodin authored
215 , Just pkg' <- return (lookup pkg buildToolsTable)
216 ]
217
823b6ef @kolmodin Look into portage dir when resolving extra-libraries
kolmodin authored
218 packageNameResolver s = do
deff889 @trofi Some fixes for -Wall (name colisions, redundant imports)
trofi authored
219 (Portage.PackageName (Portage.Category p_cat) (Cabal.PackageName pn))
033ff9b @kolmodin move package resolving functions to Portage.Resolve
kolmodin authored
220 <- Portage.resolveFullPortageName portage (Cabal.PackageName s)
deff889 @trofi Some fixes for -Wall (name colisions, redundant imports)
trofi authored
221 return $ E.AnyVersionOf (p_cat </> pn)
823b6ef @kolmodin Look into portage dir when resolving extra-libraries
kolmodin authored
222
60d04de @kolmodin adapt to cabal-1.8 and cabal-install-0.7.5 (HEADs)
kolmodin authored
223 -- calculate extra-libs
823b6ef @kolmodin Look into portage dir when resolving extra-libraries
kolmodin authored
224 extra <- findCLibs verbosity packageNameResolver pkgDesc
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
225
226 debug verbosity ("Selected flags: " ++ show flags)
cb4a7bb @kolmodin Start on translating extra-libraries into ebuild deps
kolmodin authored
227 debug verbosity ("extra-libs: ")
228 mapM_ (debug verbosity . show) extra
1de8047 @kolmodin Add build-tools deps as well, using a static table
kolmodin authored
229
230 debug verbosity ("build-tools:")
231 mapM_ (debug verbosity . show) bt
232
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
233 -- debug verbosity ("Finalized package:\n" ++ showPackageDescription pkgDesc)
234
235 -- TODO: more fixes
96a6477 @kolmodin Add some todos
kolmodin authored
236 -- * inherit keywords from previous ebuilds
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
237 let d e = if treatAsLibrary
238 then Portage.showDepend (cabal_dep e)
239 : "${RDEPEND}"
240 : [ "${BUILDTOOLS}" | not . null $ build_tools e ]
241 else Portage.showDepend (cabal_dep e)
242 : Portage.showDepend (ghc_dep e)
243 : "${RDEPEND}"
244 : [ "${BUILDTOOLS}" | not . null $ build_tools e ]
245 ++ [ "${HASKELLDEPS}" | not . null $ haskell_deps e ]
246 rd e = if treatAsLibrary
247 then Portage.showDepend (ghc_dep e)
248 : [ "${HASKELLDEPS}" | not . null $ haskell_deps e ]
249 ++ [ "${EXTRALIBS}" | not . null $ extra_libs e ]
250 else [ "${EXTRALIBS}" | not . null $ extra_libs e ]
cb4a7bb @kolmodin Start on translating extra-libraries into ebuild deps
kolmodin authored
251 let ebuild = fixSrc serverURI (packageId pkgDesc)
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
252 . (\e -> e { depend = d e } )
253 . (\e -> e { rdepend = rd e } )
5e4d73e @kolmodin Ugly simplifyer when we have multiple exact same deps
kolmodin authored
254 . (\e -> e { extra_libs = nub (extra_libs e ++ extra) } )
255 . (\e -> e { build_tools = nub (build_tools e ++ bt) } )
cb4a7bb @kolmodin Start on translating extra-libraries into ebuild deps
kolmodin authored
256 $ E.cabal2ebuild pkgDesc
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
257
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
258 debug verbosity ("Treat as library: " ++ show treatAsLibrary)
deff889 @trofi Some fixes for -Wall (name colisions, redundant imports)
trofi authored
259 mergeEbuild verbosity overlayPath (Portage.unCategory cat) ebuild
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
260 fetchAndDigest
261 verbosity
deff889 @trofi Some fixes for -Wall (name colisions, redundant imports)
trofi authored
262 (overlayPath </> display cat </> display norm_pkgName)
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
263 (display cabal_pkgId <.> "tar.gz")
264 (mkUri cabal_pkgId)
265
36431fe @kolmodin Further cleanup
kolmodin authored
266 findCLibs :: Verbosity -> (String -> Maybe E.Dependency) -> PackageDescription -> IO [E.Dependency]
267 findCLibs verbosity portageResolver (PackageDescription { library = lib, executables = exes }) = do
823b6ef @kolmodin Look into portage dir when resolving extra-libraries
kolmodin authored
268 debug verbosity "Mapping extra-libraries into portage packages..."
cb4a7bb @kolmodin Start on translating extra-libraries into ebuild deps
kolmodin authored
269 -- for extra libs we don't find, maybe look into into installed packages?
823b6ef @kolmodin Look into portage dir when resolving extra-libraries
kolmodin authored
270 when (not . null $ notFound) $
87489f1 @kolmodin Clean up the extra-libraries resolving a bit
kolmodin authored
271 warn verbosity ("Could not find portage packages for extra-libraries: " ++ unwords notFound)
823b6ef @kolmodin Look into portage dir when resolving extra-libraries
kolmodin authored
272 when (not . null $ found) $
273 debug verbosity ("Found c-libraries deps: " ++ show found)
274 return found
cb4a7bb @kolmodin Start on translating extra-libraries into ebuild deps
kolmodin authored
275 where
87489f1 @kolmodin Clean up the extra-libraries resolving a bit
kolmodin authored
276 resolvers = [ staticTranslateExtraLib, portageResolver ]
277
278 resolved = [ chain p resolvers
279 | p <- libE ++ exeE
280 ] :: [Either String E.Dependency]
281
282 notFound = [ p | Left p <- resolved ]
283 found = [ p | Right p <- resolved ]
284
285 chain v [] = Left v
286 chain v (f:fs) = case f v of
287 Nothing -> chain v fs
288 Just x -> Right x
289
cb4a7bb @kolmodin Start on translating extra-libraries into ebuild deps
kolmodin authored
290 libE = maybe [] (extraLibs.libBuildInfo) lib
291 exeE = concatMap (extraLibs.buildInfo) exes
292
87489f1 @kolmodin Clean up the extra-libraries resolving a bit
kolmodin authored
293 staticTranslateExtraLib :: String -> Maybe E.Dependency
294 staticTranslateExtraLib lib = lookup lib m
cb4a7bb @kolmodin Start on translating extra-libraries into ebuild deps
kolmodin authored
295 where
296 m = [ ("z", E.AnyVersionOf "sys-libs/zlib")
297 , ("bz2", E.AnyVersionOf "sys-libs/bzlib")
6956e2f @kolmodin Tiny cleanup about different Version structures. Add rdepend to ebuild.
kolmodin authored
298 , ("mysqlclient", E.LaterVersionOf (Portage.Version [4,0] Nothing [] 0) "virtual/mysql")
299 , ("pq", E.LaterVersionOf (Portage.Version [7] Nothing [] 0) "virtual/postgresql-base")
9f81ec9 @kolmodin Map extra-dependency "ev" to gentoo package "dev-libs/libev"
kolmodin authored
300 , ("ev", E.AnyVersionOf "dev-libs/libev")
cb4a7bb @kolmodin Start on translating extra-libraries into ebuild deps
kolmodin authored
301 ]
302
1de8047 @kolmodin Add build-tools deps as well, using a static table
kolmodin authored
303 buildToolsDeps :: PackageDescription -> [Cabal.Dependency]
304 buildToolsDeps (PackageDescription { library = lib, executables = exes }) = cabalDeps
305 where
306 cabalDeps = depL ++ depE
307 depL = maybe [] (buildTools.libBuildInfo) lib
308 depE = concatMap (buildTools.buildInfo) exes
309
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
310 buildToolsTable :: [(String, E.Dependency)]
1de8047 @kolmodin Add build-tools deps as well, using a static table
kolmodin authored
311 buildToolsTable =
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
312 [ ("happy", E.AnyVersionOf "dev-haskell/happy")
313 , ("alex", E.AnyVersionOf "dev-haskell/alex")
314 , ("c2hs", E.AnyVersionOf "dev-haskell/c2hs")
52d6d83 @kolmodin build-tools: add the tools gkt2hs-buildtools has
kolmodin authored
315 , ("gtk2hsTypeGen", E.AnyVersionOf "dev-haskell/gtk2hs-buildtools")
316 , ("gtk2hsHookGenerator", E.AnyVersionOf "dev-haskell/gtk2hs-buildtools")
317 , ("gtk2hsC2hs", E.AnyVersionOf "dev-haskell/gtk2hs-buildtools")
1de8047 @kolmodin Add build-tools deps as well, using a static table
kolmodin authored
318 ]
319
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
320 mkUri :: Cabal.PackageIdentifier -> URI
321 mkUri pid =
322 -- example:
323 -- http://hackage.haskell.org/packages/archive/Cabal/1.4.0.2/Cabal-1.4.0.2.tar.gz
324 fromJust $ parseURI $
325 "http://hackage.haskell.org/packages/archive/"
deff889 @trofi Some fixes for -Wall (name colisions, redundant imports)
trofi authored
326 </> p_name </> p_ver </> p_name <-> p_ver <.> "tar.gz"
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
327 where
deff889 @trofi Some fixes for -Wall (name colisions, redundant imports)
trofi authored
328 p_ver = display (packageVersion pid)
329 p_name = display (packageName pid)
8135c0c @kolmodin Implement fetching and creation of digests for new ebuilds
kolmodin authored
330
331 fetchAndDigest :: Verbosity
332 -> FilePath -- ^ directory of ebuild
333 -> String -- ^ tarball name
334 -> URI -- ^ tarball uri
6ec3592 Hackport now uses Cabal-1.6
Ivan.Miljenovic@gmail.com authored
335 -> IO ()
7ab62d5 @kolmodin Tried hlint, nice.
kolmodin authored
336 fetchAndDigest verbosity ebuildDir tarballName tarballURI =
8135c0c @kolmodin Implement fetching and creation of digests for new ebuilds
kolmodin authored
337 withWorkingDirectory ebuildDir $ do
821330f @kolmodin use cabal package tarball downloading code from cabal-install
kolmodin authored
338 repo_info <- Host.getInfo
339 let tarDestination = (Host.distfiles_dir repo_info) </> tarballName
4b2a1d2 @kolmodin Upgrade bundled cabal-install from 0.8.0 to 0.8.2
kolmodin authored
340 downloadURI verbosity tarballURI tarDestination
341 -- Just err -> throwEx (E.DownloadFailed (show tarballURI) (show err))
342 -- TODO: downloadURI will throw a non-hackport exception if the
343 -- download fails
344 notice verbosity $ "Saved to " ++ tarDestination
345 notice verbosity "Recalculating digests..."
346 _ <- system "repoman manifest"
347 return ()
8135c0c @kolmodin Implement fetching and creation of digests for new ebuilds
kolmodin authored
348
349 withWorkingDirectory :: FilePath -> IO a -> IO a
350 withWorkingDirectory newDir action = do
351 oldDir <- getCurrentDirectory
352 bracket
353 (setCurrentDirectory newDir)
354 (\_ -> setCurrentDirectory oldDir)
355 (\_ -> action)
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
356
357 mergeEbuild :: Verbosity -> FilePath -> String -> EBuild -> IO ()
deff889 @trofi Some fixes for -Wall (name colisions, redundant imports)
trofi authored
358 mergeEbuild verbosity target cat ebuild = do
359 let edir = target </> cat </> name ebuild
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
360 elocal = name ebuild ++"-"++ version ebuild <.> "ebuild"
361 epath = edir </> elocal
362 createDirectoryIfMissing True edir
363 info verbosity $ "Writing " ++ elocal
364 writeFile epath (showEBuild ebuild)
365
366 fixSrc :: URI -> PackageIdentifier -> EBuild -> EBuild
367 fixSrc serverURI p ebuild =
368 ebuild {
369 src_uri = show $ serverURI {
370 uriPath =
7ab62d5 @kolmodin Tried hlint, nice.
kolmodin authored
371 uriPath serverURI
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
372 </> display (pkgName p)
373 </> display (pkgVersion p)
374 </> display (pkgName p) ++ "-" ++ display (pkgVersion p)
375 <.> "tar.gz"
175e753 @kolmodin Set a default homepage to hackport if none is set
kolmodin authored
376 },
377 E.homepage = case E.homepage ebuild of
4b232ba @kolmodin Use modern hackage URLs when linking to a package's homepage
kolmodin authored
378 "" -> "http://hackage.haskell.org/package/"
175e753 @kolmodin Set a default homepage to hackport if none is set
kolmodin authored
379 ++ display (pkgName p)
380 x -> x
f309365 @kolmodin Reimplement 'hackport merge'
kolmodin authored
381 }
Something went wrong with that request. Please try again.