Skip to content
Browse files

Fix the broken 'hackport make-ebuild'

Now it mostly uses the same code-path as 'hackport merge'
  • Loading branch information...
1 parent 85f4f4e commit 6b6ca6bfe2a44729415cbf8651a955eeec4e9129 @kolmodin kolmodin committed
Showing with 31 additions and 31 deletions.
  1. +12 −14 Main.hs
  2. +19 −17 Merge.hs
View
26 Main.hs
@@ -14,15 +14,13 @@ import Distribution.Simple.Setup
, flagToList
, optionVerbosity
)
-import Distribution.PackageDescription.Configuration
- ( flattenPackageDescription )
import Distribution.ReadE ( succeedReadE )
import Distribution.Simple.Command -- commandsRun
import Distribution.Simple.Utils ( die, cabalVersion, warn )
import qualified Distribution.PackageDescription.Parse as Cabal
import qualified Distribution.Package as Cabal
import Distribution.Verbosity (Verbosity, normal)
-import Distribution.Text (display)
+import Distribution.Text (display, simpleParse)
import Distribution.Client.Types
import Distribution.Client.Update
@@ -40,9 +38,6 @@ import System.Directory ( doesDirectoryExist )
import System.Exit ( exitFailure )
import System.FilePath ( (</>) )
-import qualified Cabal2Ebuild as C2E
-import qualified Portage.EBuild as E
-
import Diff
import Error
import Status
@@ -145,15 +140,18 @@ defaultMakeEbuildFlags = MakeEbuildFlags {
}
makeEbuildAction :: MakeEbuildFlags -> [String] -> GlobalFlags -> IO ()
-makeEbuildAction flags args _globalFlags = do
- when (null args) $
- die "make-ebuild needs at least one argument"
- let _verbosity = fromFlag (makeEbuildVerbosity flags)
- forM_ args $ \cabalFileName -> do
+makeEbuildAction flags args globalFlags = do
+ (catstr,cabals) <- case args of
+ (category:cabal1:cabaln) -> return (category, cabal1:cabaln)
+ _ -> throwEx (ArgumentError "make-ebuild needs at least two arguments. <category> <cabal-1> <cabal-n>")
+ cat <- case simpleParse catstr of
+ Just c -> return c
+ Nothing -> throwEx (ArgumentError ("could not parse category: " ++ catstr))
+ let verbosity = fromFlag (makeEbuildVerbosity flags)
+ overlayPath <- getOverlayPath verbosity (fromFlag $ globalPathToOverlay globalFlags)
+ forM_ cabals $ \cabalFileName -> do
pkg <- Cabal.readPackageDescription normal cabalFileName
- let ebuild = C2E.cabal2ebuild (flattenPackageDescription pkg)
- let ebuildFileName = E.name ebuild ++ "-" ++ E.version ebuild ++ ".ebuild"
- writeFile ebuildFileName (display ebuild)
+ mergeGenericPackageDescription verbosity overlayPath cat pkg False
makeEbuildCommand :: CommandUI MakeEbuildFlags
makeEbuildCommand = CommandUI {
View
36 Merge.hs
@@ -1,6 +1,8 @@
{-# OPTIONS -XPatternGuards #-}
module Merge
- ( merge ) where
+ ( merge
+ , mergeGenericPackageDescription
+ ) where
import Control.Monad.Error
import Control.Exception
@@ -10,6 +12,7 @@ import Distribution.Package
-- import Distribution.Compiler (CompilerId(..), CompilerFlavor(GHC))
import Distribution.PackageDescription ( PackageDescription(..)
, FlagName(..)
+ , GenericPackageDescription
)
import Distribution.PackageDescription.Configuration
( finalizePackageDescription )
@@ -143,12 +146,13 @@ merge verbosity repo serverURI args overlayPath = do
info verbosity $ match_text ++ (display . packageInfoId $ avail)
let cabal_pkgId = packageInfoId selectedPkg
- norm_pkgId = Portage.normalizeCabalPackageId cabal_pkgId
- norm_pkgName = packageName norm_pkgId
+ norm_pkgName = packageName (Portage.normalizeCabalPackageId cabal_pkgId)
cat <- maybe (Portage.resolveCategory verbosity overlay norm_pkgName) return m_category
+ mergeGenericPackageDescription verbosity overlayPath cat (packageDescription selectedPkg) True
- let pkgGenericDesc = packageDescription selectedPkg
- Right (pkgDesc0, flags) =
+mergeGenericPackageDescription :: Verbosity -> FilePath -> Portage.Category -> GenericPackageDescription -> Bool -> IO ()
+mergeGenericPackageDescription verbosity overlayPath cat pkgGenericDesc fetch = do
+ let Right (pkgDesc0, flags) =
finalizePackageDescription
[ -- XXX: common things we should enable/disable?
-- (FlagName "small_base", True) -- try to use small base
@@ -173,19 +177,21 @@ merge verbosity repo serverURI args overlayPath = do
debug verbosity ("Selected flags: " ++ show flags)
info verbosity ("Guessing GHC version: " ++ maybe "could not guess" (display.fst) mminimumGHC)
- let ebuild = fixSrc serverURI (packageId pkgDesc)
- . (\e -> e { E.depend = Merge.dep edeps } )
+ let ebuild = (\e -> e { E.depend = Merge.dep edeps } )
. (\e -> e { E.depend_extra = Merge.dep_e edeps } )
. (\e -> e { E.rdepend = Merge.rdep edeps } )
. (\e -> e { E.rdepend_extra = Merge.rdep_e edeps } )
$ C2E.cabal2ebuild pkgDesc
mergeEbuild verbosity overlayPath (Portage.unCategory cat) ebuild
- fetchAndDigest
- verbosity
- (overlayPath </> display cat </> display norm_pkgName)
- (display cabal_pkgId <.> "tar.gz")
- (mkUri cabal_pkgId)
+ when fetch $ do
+ let cabal_pkgId = packageId pkgDesc
+ norm_pkgName = packageName (Portage.normalizeCabalPackageId cabal_pkgId)
+ fetchAndDigest
+ verbosity
+ (overlayPath </> display cat </> display norm_pkgName)
+ (display cabal_pkgId <.> "tar.gz")
+ (mkUri cabal_pkgId)
mkUri :: Cabal.PackageIdentifier -> URI
mkUri pid =
@@ -243,9 +249,5 @@ fixSrc serverURI p ebuild =
</> display (pkgVersion p)
</> display (pkgName p) ++ "-" ++ display (pkgVersion p)
<.> "tar.gz"
- },
- E.homepage = case E.homepage ebuild of
- "" -> "http://hackage.haskell.org/package/"
- ++ display (pkgName p)
- x -> x
+ }
}

0 comments on commit 6b6ca6b

Please sign in to comment.
Something went wrong with that request. Please try again.