Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added 'metadata.xml' autogeneration for packages where it does not ex…

…ist.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
  • Loading branch information...
commit 59858eb76adf14962ad2ad4deb8e3456083e6295 1 parent 3eb9093
@trofi trofi authored
View
2  Cabal2Ebuild.hs
@@ -48,6 +48,8 @@ cabal2ebuild pkg = Portage.ebuildTemplate {
E.version = display (Cabal.pkgVersion (Cabal.package pkg)),
E.description = if null (Cabal.synopsis pkg) then Cabal.description pkg
else Cabal.synopsis pkg,
+ E.long_desc = if null (Cabal.description pkg) then Cabal.synopsis pkg
+ else Cabal.description pkg,
E.homepage = thisHomepage,
E.license = Cabal.license pkg,
E.my_pn = if any isUpper cabalPkgName then Just cabalPkgName else Nothing,
View
15 Merge.hs
@@ -21,6 +21,7 @@ import Distribution.Text (display)
import System.Directory ( getCurrentDirectory
, setCurrentDirectory
, createDirectoryIfMissing
+ , doesFileExist
)
import System.Cmd (system)
import System.FilePath ((</>))
@@ -46,6 +47,7 @@ import Distribution.Client.Types
import qualified Portage.PackageId as Portage
import qualified Portage.Version as Portage
import qualified Portage.Host as Host
+import qualified Portage.Metadata as Portage
import qualified Portage.Overlay as Overlay
import qualified Portage.Resolve as Portage
@@ -235,6 +237,17 @@ mergeEbuild verbosity target cat ebuild = do
let edir = target </> cat </> E.name ebuild
elocal = E.name ebuild ++"-"++ E.version ebuild <.> "ebuild"
epath = edir </> elocal
+ emeta = "metadata.xml"
+ mpath = edir </> emeta
+ default_meta = Portage.makeDefaultMetadata (E.long_desc ebuild)
createDirectoryIfMissing True edir
- info verbosity $ "Writing " ++ elocal
+ notice verbosity $ "Writing " ++ elocal
writeFile epath (display ebuild)
+
+ yet_meta <- doesFileExist mpath
+ if (not yet_meta) -- TODO: add --force-meta-rewrite to opts
+ then do notice verbosity $ "Writing " ++ emeta
+ writeFile mpath default_meta
+ else do current_meta <- readFile mpath
+ when (current_meta /= default_meta) $
+ notice verbosity $ "Default and current " ++ emeta ++ " differ."
View
2  Portage/EBuild.hs
@@ -19,6 +19,7 @@ data EBuild = EBuild {
version :: String,
hackportVersion :: String,
description :: String,
+ long_desc :: String,
homepage :: String,
license :: Cabal.License,
slot :: String,
@@ -42,6 +43,7 @@ ebuildTemplate = EBuild {
version = "0.1",
hackportVersion = getHackportVersion Paths_hackport.version,
description = "",
+ long_desc = "",
homepage = "http://hackage.haskell.org/package/${PN}",
license = Cabal.UnknownLicense "xxx UNKNOWN xxx",
slot = "0",
View
26 Portage/Metadata.hs
@@ -1,6 +1,7 @@
module Portage.Metadata
( Metadata(..)
, metadataFromFile
+ , makeDefaultMetadata
) where
import qualified Data.ByteString as B
@@ -27,3 +28,28 @@ parseMetadata xml = do
{
metadataHerds = herds
}
+
+-- don't use Text.XML.Light as we like our own pretty printer
+makeDefaultMetadata :: String -> String
+makeDefaultMetadata long_description =
+ unlines [ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ , "<!DOCTYPE pkgmetadata SYSTEM \"http://www.gentoo.org/dtd/metadata.dtd\">"
+ , "<pkgmetadata>"
+ , "\t<herd>haskell</herd>"
+ , "\t<maintainer>"
+ , "\t\t<email>haskell@gentoo.org</email>"
+ , "\t</maintainer>"
+ , (init {- strip trailing newline-}
+ . unlines
+ . map (\l -> if l `elem` ["<longdescription>", "</longdescription>"]
+ then "\t" ++ l -- leading/trailing lines
+ else "\t\t" ++ l -- description itself
+ )
+ . lines
+ . showElement
+ . unode "longdescription"
+ . ("\n" ++) -- prepend newline to separate form <longdescription>
+ . (++ "\n") -- append newline
+ ) long_description
+ , "</pkgmetadata>"
+ ]
View
6 TODO
@@ -9,13 +9,13 @@ Easier
still are any missing. set good default values, and make sure we don't
get any 'fromFlag' errors due to missing defaults for all commands
-* catch baseconstraints and upgrade ghc requirement
+* catch base constraints and upgrade ghc requirement
(like in vty-4.0.0.1: base >= 4 leads to ghc >= 6.10)
Harder
======
-* translate the dev-db/libpq dependency into virtual/postgresql-base
+* translate the dev-db/libpq dependency into dev-db/postgresql-base
the cabal field to describe c libs should be translated if we know the
proper gentoo package name.
@@ -35,5 +35,3 @@ Harder
See http://code.haskell.org/gentoo/keyword-stat/
* Pick keywords from latest available ebuild
-
-* Autogenerate metadata.xml from .cabal file if does not present
Please sign in to comment.
Something went wrong with that request. Please try again.