Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

hackport-cabal2ebuild.patch

added subcommand `make-ebuild' (from cabal2ebuild.hs)
  • Loading branch information...
commit 32a344ce009fa507a2b78b3fdc822672d84d2935 1 parent 2f85f14
Sergei Trofimovich trofi authored

Showing 2 changed files with 18 additions and 0 deletions. Show diff stats Hide diff stats

  1. +6 0 Config.hs
  2. +12 0 Main.hs
6 Config.hs
@@ -20,6 +20,7 @@ data OperationMode
20 20 | Update
21 21 | ShowHelp
22 22 | Status String
  23 + | MakeEbuild String
23 24
24 25 data DiffMode
25 26 = ShowAll
@@ -93,6 +94,10 @@ parseConfig opts = let
93 94 "status":[] -> Right (Status "")
94 95 "status":"toportage":[] -> Right (Status "toportage")
95 96 "status":xs-> Left ("invalid argument(s) to 'status': " ++ show xs)
  97 + "make-ebuild":[] -> Left "Need .cabal file to make ebuild."
  98 + "make-ebuild":package:[] -> Right (MakeEbuild package)
  99 + "make-ebuild":_:rest -> Left ("'make-ebuild' takes 1 argument("++show ((length rest)+1)++" given).\n")
  100 +
96 101 [] -> Right ShowHelp
97 102 _ -> Left "Unknown opertation mode\n"
98 103 in case mode of
@@ -108,6 +113,7 @@ hackageUsage = putStr $ flip usageInfo hackageOptions $ unlines
108 113 , "\t\"hackport [OPTION] diff\" prints the difference between the portage-tree and the server's packages"
109 114 , "\t\"hackport [OPTION] update\" updates the local cache"
110 115 , "\t\"hackport [OPTION] status\" compares the overlay with the portage tree"
  116 + , "\t\"hackport [OPTION] make-ebuild\" creates standalone ebuild from given .cabal file"
111 117 , "Options:"
112 118 ]
113 119
12 Main.hs
@@ -26,6 +26,10 @@ import Package
26 26 import Overlays
27 27 import P2
28 28
  29 +import qualified Distribution.PackageDescription as Cabal
  30 +import Distribution.Verbosity (normal)
  31 +import Cabal2Ebuild
  32 +
29 33 list :: String -> HPAction ()
30 34 list name = do
31 35 index <- readCache =<< getOverlayPath
@@ -92,6 +96,13 @@ merge pstr = do
92 96 eof
93 97 return (mc, p, mv)
94 98
  99 +makeEbuild :: String -> HPAction ()
  100 +makeEbuild cabalFileName = liftIO $ do
  101 + pkg <- Cabal.readPackageDescription normal cabalFileName
  102 + let ebuild = cabal2ebuild (Cabal.flattenPackageDescription pkg)
  103 + let ebuildFileName = name ebuild ++ "-" ++ version ebuild ++ ".ebuild"
  104 + writeFile ebuildFileName (showEBuild ebuild)
  105 +
95 106 hpmain :: HPAction ()
96 107 hpmain = do
97 108 mode <- loadConfig
@@ -107,6 +118,7 @@ hpmain = do
107 118 DiffTree dtmode -> diffAction dtmode
108 119 Update -> updateCache
109 120 Status action -> statusAction action
  121 + MakeEbuild cabalFileName -> makeEbuild cabalFileName
110 122
111 123 main :: IO ()
112 124 main = do

0 comments on commit 32a344c

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