Permalink
Browse files

hackport-cabal2ebuild.patch

added subcommand `make-ebuild' (from cabal2ebuild.hs)
  • Loading branch information...
1 parent 2f85f14 commit 32a344ce009fa507a2b78b3fdc822672d84d2935 @trofi trofi committed Aug 23, 2008
Showing with 18 additions and 0 deletions.
  1. +6 −0 Config.hs
  2. +12 −0 Main.hs
View
6 Config.hs
@@ -20,6 +20,7 @@ data OperationMode
| Update
| ShowHelp
| Status String
+ | MakeEbuild String
data DiffMode
= ShowAll
@@ -93,6 +94,10 @@ parseConfig opts = let
"status":[] -> Right (Status "")
"status":"toportage":[] -> Right (Status "toportage")
"status":xs-> Left ("invalid argument(s) to 'status': " ++ show xs)
+ "make-ebuild":[] -> Left "Need .cabal file to make ebuild."
+ "make-ebuild":package:[] -> Right (MakeEbuild package)
+ "make-ebuild":_:rest -> Left ("'make-ebuild' takes 1 argument("++show ((length rest)+1)++" given).\n")
+
[] -> Right ShowHelp
_ -> Left "Unknown opertation mode\n"
in case mode of
@@ -108,6 +113,7 @@ hackageUsage = putStr $ flip usageInfo hackageOptions $ unlines
, "\t\"hackport [OPTION] diff\" prints the difference between the portage-tree and the server's packages"
, "\t\"hackport [OPTION] update\" updates the local cache"
, "\t\"hackport [OPTION] status\" compares the overlay with the portage tree"
+ , "\t\"hackport [OPTION] make-ebuild\" creates standalone ebuild from given .cabal file"
, "Options:"
]
View
12 Main.hs
@@ -26,6 +26,10 @@ import Package
import Overlays
import P2
+import qualified Distribution.PackageDescription as Cabal
+import Distribution.Verbosity (normal)
+import Cabal2Ebuild
+
list :: String -> HPAction ()
list name = do
index <- readCache =<< getOverlayPath
@@ -92,6 +96,13 @@ merge pstr = do
eof
return (mc, p, mv)
+makeEbuild :: String -> HPAction ()
+makeEbuild cabalFileName = liftIO $ do
+ pkg <- Cabal.readPackageDescription normal cabalFileName
+ let ebuild = cabal2ebuild (Cabal.flattenPackageDescription pkg)
+ let ebuildFileName = name ebuild ++ "-" ++ version ebuild ++ ".ebuild"
+ writeFile ebuildFileName (showEBuild ebuild)
+
hpmain :: HPAction ()
hpmain = do
mode <- loadConfig
@@ -107,6 +118,7 @@ hpmain = do
DiffTree dtmode -> diffAction dtmode
Update -> updateCache
Status action -> statusAction action
+ MakeEbuild cabalFileName -> makeEbuild cabalFileName
main :: IO ()
main = do

0 comments on commit 32a344c

Please sign in to comment.