diff --git a/cabal2ebuild.cabal b/cabal2ebuild.cabal
--- a/cabal2ebuild.cabal
+++ b/cabal2ebuild.cabal
@@ -1,5 +1,5 @@
 Name:                cabal2ebuild
-Version:             0.0.15.8
+Version:             0.0.15.9
 Stability:           Experimental
 Synopsis:            make gentoo's .ebuild file from .cabal file
 Description:
@@ -7,7 +7,11 @@
 	> hoge.cabal ...
 	> % cabal2ebuild
 	> % ls
-	> % hoge.cabal hoge-0.1.2.3.ebuild ...
+	> hoge.cabal hoge-0.1.2.3.ebuild ...
+	>
+	> % hackage2ebuild cabal2ebuild 0.0.15.8 -d ebuilds
+	> % ls ebuilds
+	> cabal2ebuild-0.0.15.8.ebuild
 Homepage:            yet
 License:             BSD3
 License-file:        LICENSE
@@ -17,7 +21,7 @@
 Category:            Distribution
 Build-type:          Simple
 -- Extra-source-files:  
-Cabal-version:       >=1.6
+Cabal-version:       >=1.8
 
 source-repository head
   type:		git
@@ -28,9 +32,21 @@
   location:	https://github.com/YoshikuniJujo/cabal2ebuild.git
   tag:		0.0.15.4
 
+library
+  hs-source-dirs:  src-lib
+  build-depends:   base > 3 && < 5, directory, Cabal, filepath
+  exposed-modules: Gentoo.Cabal2Ebuild
+  other-modules:   Gentoo.Depend
+
 executable cabal2ebuild
-  hs-source-dirs: src
+  hs-source-dirs: src-exec
   main-is:        cabal2ebuild.hs
-  other-modules:  Depend
-  build-depends:  base > 3 && < 5, directory, Cabal, filepath
+  other-modules:
+  build-depends:  base > 3 && < 5, cabal2ebuild, directory
   Ghc-options:    -Wall
+
+executable hackage2ebuild
+  hs-source-dirs: src-exec
+  main-is:        hackage2ebuild.hs
+  build-depends:  base > 3 && < 5, cabal2ebuild, curl
+  ghc-options:    -Wall
diff --git a/src-exec/cabal2ebuild.hs b/src-exec/cabal2ebuild.hs
new file mode 100644
--- /dev/null
+++ b/src-exec/cabal2ebuild.hs
@@ -0,0 +1,11 @@
+import Gentoo.Cabal2Ebuild (cabal2ebuild)
+
+import Data.List
+import Control.Applicative
+import System.Directory
+
+main :: IO ()
+main = do
+  cabal <- head . filter (isSuffixOf ".cabal") <$> getDirectoryContents "."
+  maybe (putStrLn "parse error") (uncurry writeFile)
+  	=<< cabal2ebuild <$> readFile cabal
diff --git a/src-exec/hackage2ebuild.hs b/src-exec/hackage2ebuild.hs
new file mode 100644
--- /dev/null
+++ b/src-exec/hackage2ebuild.hs
@@ -0,0 +1,52 @@
+import Gentoo.Cabal2Ebuild
+import Network.Curl
+import System.Environment
+import System.Console.GetOpt
+import System.Exit
+
+main :: IO ()
+main = do
+	args <- getArgs
+	let	(os, as, errs) = getOpt Permute descrs args
+	(pn, pv) <- case (as, errs) of
+			([n, v], []) -> return (n, readV v)
+			_ -> do	putStrLn "Usage: hackage2ebuild [package name] [package version]"
+				mapM_ putStr errs
+				exitFailure
+	(rsp, cnt) <- withCurlDo $ curlGetString (mkURL pn pv) []
+	case cabal2ebuild cnt of
+		Just (fn, eb) -> writeFile (getDir os ++ "/" ++ fn) eb
+		_ -> putStrLn "cabal2ebuild: error"
+	putStrLn $ mkURL pn pv
+	print rsp
+	print os
+
+mkURL :: String -> Version -> URLString
+mkURL pn pv =
+	"http://hackage.haskell.org/package/" ++ pn ++ "-" ++ showV pv ++ "/" ++
+	pn ++ ".cabal"
+
+type Version = [Int]
+
+readV :: String -> [Int]
+readV str = case span (/= '.') str of
+	(n, "") -> [read n]
+	(n, '.' : ns) -> read n : readV ns
+	_ -> error "never occur"
+
+showV :: [Int] -> String
+showV [n] = show n
+showV (n : ns) = show n ++ "." ++ showV ns
+showV _ = error "bad version"
+
+descrs :: [OptDescr Option]
+descrs = [
+	Option "d" [] (ReqArg Directory "directory") "directory"
+ ] 
+
+data Option = Directory FilePath deriving Show
+
+getDir :: [Option] -> FilePath
+getDir [] = "."
+getDir (Directory fp : _) = fp
+-- getDir (_ : os) = getDir os
diff --git a/src-lib/Gentoo/Cabal2Ebuild.hs b/src-lib/Gentoo/Cabal2Ebuild.hs
new file mode 100644
--- /dev/null
+++ b/src-lib/Gentoo/Cabal2Ebuild.hs
@@ -0,0 +1,159 @@
+module Gentoo.Cabal2Ebuild (cabal2ebuild) where
+
+import Distribution.Package
+-- import Distribution.Version
+import Distribution.PackageDescription
+import Distribution.PackageDescription.Parse
+import Distribution.Verbosity
+import Data.Maybe
+import Data.Version
+import Distribution.License
+-- import System.Directory
+import Data.List
+
+import Gentoo.Depend
+
+import System.IO.Unsafe
+import System.Directory
+import System.FilePath
+import Control.Applicative
+
+test :: IO ()
+test = do
+  gpd <- readPackageDescription normal "cabal2ebuild.cabal"
+  print $ getName gpd ++ ".ebuild"
+  print $ getName gpd ++ ".tar.gz"
+  print $ getLicense gpd
+  print $ hasLib gpd
+  print $ hasEx gpd
+  putStrLn $ makeCabalFeatures ( hasLib gpd ) ( hasEx gpd )
+  putStrLn $ makeSrcURI $ getName gpd
+  putStrLn ""
+--  putStrLn $ makeEbuild gpd
+  print $ condTreeData $ snd $ head $ condExecutables gpd
+  mapM_ print $ condTreeConstraints $ snd $ head $ condExecutables gpd
+  print $ synopsis $ packageDescription gpd
+  putStrLn ""
+  putStr $ ebuildToFile $ gpdToEbuild gpd
+  print $ condLibrary gpd
+  print $ ebDepends gpd
+  
+
+cabal2ebuild :: String -> Maybe (FilePath, String)
+cabal2ebuild cnt = case parsePackageDescription cnt of
+	ParseOk _ gpd -> Just (makeFileName gpd, ebuildToFile $ gpdToEbuild gpd)
+	_ -> Nothing
+
+makeFileName :: GenericPackageDescription -> String
+makeFileName gpd = getName gpd ++ ".ebuild"
+
+-- data EbLicense = BSD3 | GPL | LGPL deriving Show
+
+data EbKWords = X86 | BX86 | AMD64 deriving Show
+
+showEKW :: EbKWords -> String
+showEKW X86  = "x86"
+showEKW BX86 = "~x86"
+showEKW AMD64 = "amd64"
+
+data Ebuild = Ebuild {
+ 
+  ebCabalFt :: [ String ] ,
+  ebInherit :: String ,
+  ebAPI     :: Int ,
+  ebDsc     :: String ,
+  ebHmpg    :: String ,
+  srcURI    :: String ,
+  ebLicense :: License ,
+  ebSlot    :: Int ,
+  ebKWords  :: [ EbKWords ] ,
+  ebDepend  :: [ String ]
+
+ } deriving Show
+
+gpdToEbuild :: GenericPackageDescription -> Ebuild
+gpdToEbuild gpd = Ebuild {
+
+  ebCabalFt = ft ,
+  ebInherit = "haskell-cabal",
+  ebAPI     = 3 ,
+  ebDsc     = synopsis $ packageDescription gpd ,
+  ebHmpg    = homepage $ packageDescription gpd ,
+  srcURI    = makeSrcURI ( getName gpd ) ,
+  ebLicense = getLicense gpd ,
+  ebSlot    = 0 ,
+  ebKWords  = [ X86, AMD64 ] ,
+  ebDepend  = ">=dev-lang/ghc-6.10" : "dev-haskell/cabal" : ebDepends gpd
+
+ }
+  where
+  ft :: [ String ]
+  ft = concatMap snd $ filter fst
+    [ ( hasLib gpd , [ "lib", "haddock", "profile", "hscolour" ] ),
+      ( hasEx gpd  , [ "bin" ] ) ] 
+  
+ebuildToFile :: Ebuild -> String
+ebuildToFile eb =
+  "EAPI=" ++ show ( ebAPI eb ) ++ "\n\n" ++
+  "CABAL_FEATURES=\"" ++ unwords ( ebCabalFt eb ) ++ "\"\n" ++
+  "inherit " ++ ebInherit eb ++ "\n\n" ++
+  "DESCRIPTION=" ++ show ( ebDsc eb ) ++ "\n" ++
+  "HOMEPAGE=" ++ show ( ebHmpg eb ) ++ "\n" ++
+  "SRC_URI=" ++ srcURI eb ++ "\n\n" ++
+  "LICENSE=\"" ++ show ( ebLicense eb ) ++ "\"\n" ++
+  "SLOT=\"" ++ show ( ebSlot eb ) ++ "\"\n" ++
+  "KEYWORDS=\"" ++ unwords ( map showEKW $ ebKWords eb ) ++ "\"\n\n" ++
+  "DEPEND=\"" ++ unlines ( ebDepend eb ) ++ "\"\n"
+
+makeEbuild :: GenericPackageDescription -> String
+makeEbuild gpd =
+  makeCabalFeatures ( hasLib gpd ) ( hasEx gpd ) ++ "\n" ++
+  "inherit haskell-cabal\n\n" ++
+  "EAPI=3\n\n" ++
+  "SRC_URI=" ++ makeSrcURI ( getName gpd ) ++ "\n\n" ++
+  makeLicense ( getLicense gpd ) ++ "\n" ++
+  "SLOT=\"0\"\n" ++ "KEYWORDS=\"x86\"\n"
+
+makeCabalFeatures :: Bool -> Bool -> String
+makeCabalFeatures lb ex
+  = let ls = if lb then "lib " else ""
+        xs = if ex then "bin " else ""
+     in "CABAL_FEATURES=" ++ show ( xs ++ ls ++ "haddock profile hscolour" )
+
+myGentooRepo :: Maybe String
+myGentooRepo = unsafePerformIO $ do
+	hd <- getHomeDirectory
+	let confFile = hd </> ".cabal2ebuild" </> "gentoo_repo.txt"
+	fe <- doesFileExist confFile
+	if not fe then return Nothing else
+		fromConfigFile <$> readFile confFile
+
+fromConfigFile :: String -> Maybe String
+fromConfigFile cnt = case lines cnt of
+	["local", repo] -> Just repo
+	_ -> Nothing
+
+makeSrcURI :: String -> String
+-- makeSrcURI nam = show ( "http://homepage3.nifty.com/salamander/second/portage/distfiles/" ++ nam ++ ".tar.gz" )
+makeSrcURI nam = case myGentooRepo of
+	Just r -> show $ r ++ nam ++ ".tar.gz"
+	_ -> show $ "http://hackage.haskell.org/package/" ++ nam ++ "/" ++
+		nam ++ ".tar.gz"
+
+makeLicense :: License -> String
+makeLicense l = "LICENSE=" ++ show ( show l )
+
+getName :: GenericPackageDescription -> String
+getName gpd = let pd = packageDescription gpd
+                  PackageName pn = pkgName $ package pd
+                  vn = showVersion $ pkgVersion $ package pd
+               in pn ++ "-" ++ vn
+
+getLicense :: GenericPackageDescription -> License
+getLicense = license . packageDescription
+
+hasLib :: GenericPackageDescription -> Bool
+hasLib = isJust . condLibrary
+
+hasEx :: GenericPackageDescription -> Bool
+hasEx = not . null . condExecutables
diff --git a/src-lib/Gentoo/Depend.hs b/src-lib/Gentoo/Depend.hs
new file mode 100644
--- /dev/null
+++ b/src-lib/Gentoo/Depend.hs
@@ -0,0 +1,93 @@
+module Gentoo.Depend (
+
+  ebDepends
+
+  , testEbDepend
+
+) where
+
+import Distribution.Package
+import Distribution.PackageDescription
+import Distribution.Version
+import Data.Version
+import Data.Maybe
+
+pkgCabEbList :: [ ( String, Maybe String ) ]
+pkgCabEbList = [
+
+  ( "ghc"       , Just "dev-lang/ghc"        ) ,
+  ( "Cabal"     , Just "dev-haskell/cabal"   ) ,
+  ( "X11"       , Just "dev-haskell/x11"     ) ,
+  ( "directory" , Nothing                    ) ,
+  ( "base"      , Nothing                    ) ,
+  ( "time"	, Nothing                    ) ,
+  ( "bytestring", Nothing                    ) ,
+  ( "containers", Nothing                    ) ,
+  ( "array"     , Nothing                    ) ,
+  ( "unix"      , Nothing                    ) ,
+  ( "ghc-prim"  , Nothing                    ) ,
+  ( "filepath"  , Nothing                    ) ,
+  ( "old-locale", Nothing                    ) ,
+  ( "random"    , Nothing                    ) ,
+  ( "X11-xft"   , Just "dev-haskell/x11-xft" ) ,
+  ( "process"   , Nothing                    ) ,
+  ( "HUnit"     , Just "dev-haskell/hunit"   ) ,
+  ( "old-time"  , Nothing                    ) ,
+  ( "HaXml"	, Just "dev-haskell/haxml"   ) ,
+  ( "Imlib"	, Just "dev-haskell/imlib"   ) ,
+  ( "ListLike"	, Just "dev-haskell/listlike") ,
+  ( "pretty"	, Nothing                    ) ,
+  ( "template-haskell"	, Nothing            ) ,
+  ( "GLUT"      , Just "dev-haskell/glut"    ) ,
+  ( "HsSyck"	, Just "dev-haskell/hssyck"  ) ,
+  ( "HTTP"      , Just "dev-haskell/http"    )
+ ]
+
+testEbDepend = ebDepend
+
+ebDepend :: Dependency -> Maybe String
+ebDepend dp
+  = let ( b, a ) = ebPkgVersion dp
+     in fmap ( \n -> b ++ n ++ (if null a then "" else "-") ++ a ) $ ebPkgName dp
+             
+
+ebPkgName :: Dependency -> Maybe String
+ebPkgName = getPkgName . getDepPkgName
+
+getPkgName :: String -> Maybe String
+getPkgName cbpkg = case lookup cbpkg pkgCabEbList of
+                        Just ebpkg -> ebpkg
+                        Nothing    -> Just $ "dev-haskell/" ++ cbpkg
+
+getDepPkgName :: Dependency -> String
+getDepPkgName ( Dependency ( PackageName nam ) _ ) = nam
+
+ebPkgVersion :: Dependency -> ( String, String )
+ebPkgVersion = getPkgVersion . getDepPkgVersion
+
+getPkgVersion :: VersionRange -> ( String, String )
+getPkgVersion AnyVersion = ( "", "" )
+getPkgVersion ( UnionVersionRanges vr1 vr2 )
+  = let ( b1, a1 ) = getPkgVersion vr1
+        ( b2, a2 ) = getPkgVersion vr2
+     in ( b2 ++ b1, a1 )
+getPkgVersion ( ThisVersion v ) = ( "=", showVersion v )
+getPkgVersion ( LaterVersion v ) = ( ">", showVersion v )
+getPkgVersion ( EarlierVersion v ) = ( "<", showVersion v )
+getPkgVersion ( IntersectVersionRanges v1 v2 ) = getPkgVersion v1
+getPkgVersion ( WildcardVersion v@Version{versionBranch = vb} ) =
+	( "<", showVersion v{versionBranch = init vb ++ [last vb + 1]} )
+
+getDepPkgVersion :: Dependency -> VersionRange
+getDepPkgVersion ( Dependency _ vr ) = vr
+
+
+--  print $ catMaybes $ map ebDepend $ concatMap condTreeConstraints $ map snd $ condExecutables gpd
+ebDepends :: GenericPackageDescription -> [ String ]
+ebDepends gpd =
+  let exdep = catMaybes $ map ebDepend $ concatMap condTreeConstraints $ map snd $ condExecutables gpd
+      libdep = concat $ maybeToList $
+	fmap ( catMaybes . map ebDepend . condTreeConstraints ) $ condLibrary gpd
+--  print $ map snd $ condExecutables gpd
+--  print $ fmap ( map ebDepend . condTreeConstraints ) $ condLibrary gpd
+   in exdep ++ libdep
diff --git a/src/Depend.hs b/src/Depend.hs
deleted file mode 100644
--- a/src/Depend.hs
+++ /dev/null
@@ -1,93 +0,0 @@
-module Depend (
-
-  ebDepends
-
-  , testEbDepend
-
-) where
-
-import Distribution.Package
-import Distribution.PackageDescription
-import Distribution.Version
-import Data.Version
-import Data.Maybe
-
-pkgCabEbList :: [ ( String, Maybe String ) ]
-pkgCabEbList = [
-
-  ( "ghc"       , Just "dev-lang/ghc"        ) ,
-  ( "Cabal"     , Just "dev-haskell/cabal"   ) ,
-  ( "X11"       , Just "dev-haskell/x11"     ) ,
-  ( "directory" , Nothing                    ) ,
-  ( "base"      , Nothing                    ) ,
-  ( "time"	, Nothing                    ) ,
-  ( "bytestring", Nothing                    ) ,
-  ( "containers", Nothing                    ) ,
-  ( "array"     , Nothing                    ) ,
-  ( "unix"      , Nothing                    ) ,
-  ( "ghc-prim"  , Nothing                    ) ,
-  ( "filepath"  , Nothing                    ) ,
-  ( "old-locale", Nothing                    ) ,
-  ( "random"    , Nothing                    ) ,
-  ( "X11-xft"   , Just "dev-haskell/x11-xft" ) ,
-  ( "process"   , Nothing                    ) ,
-  ( "HUnit"     , Just "dev-haskell/hunit"   ) ,
-  ( "old-time"  , Nothing                    ) ,
-  ( "HaXml"	, Just "dev-haskell/haxml"   ) ,
-  ( "Imlib"	, Just "dev-haskell/imlib"   ) ,
-  ( "ListLike"	, Just "dev-haskell/listlike") ,
-  ( "pretty"	, Nothing                    ) ,
-  ( "template-haskell"	, Nothing            ) ,
-  ( "GLUT"      , Just "dev-haskell/glut"    ) ,
-  ( "HsSyck"	, Just "dev-haskell/hssyck"  ) ,
-  ( "HTTP"      , Just "dev-haskell/http"    )
- ]
-
-testEbDepend = ebDepend
-
-ebDepend :: Dependency -> Maybe String
-ebDepend dp
-  = let ( b, a ) = ebPkgVersion dp
-     in fmap ( \n -> b ++ n ++ (if null a then "" else "-") ++ a ) $ ebPkgName dp
-             
-
-ebPkgName :: Dependency -> Maybe String
-ebPkgName = getPkgName . getDepPkgName
-
-getPkgName :: String -> Maybe String
-getPkgName cbpkg = case lookup cbpkg pkgCabEbList of
-                        Just ebpkg -> ebpkg
-                        Nothing    -> Just $ "dev-haskell/" ++ cbpkg
-
-getDepPkgName :: Dependency -> String
-getDepPkgName ( Dependency ( PackageName nam ) _ ) = nam
-
-ebPkgVersion :: Dependency -> ( String, String )
-ebPkgVersion = getPkgVersion . getDepPkgVersion
-
-getPkgVersion :: VersionRange -> ( String, String )
-getPkgVersion AnyVersion = ( "", "" )
-getPkgVersion ( UnionVersionRanges vr1 vr2 )
-  = let ( b1, a1 ) = getPkgVersion vr1
-        ( b2, a2 ) = getPkgVersion vr2
-     in ( b2 ++ b1, a1 )
-getPkgVersion ( ThisVersion v ) = ( "=", showVersion v )
-getPkgVersion ( LaterVersion v ) = ( ">", showVersion v )
-getPkgVersion ( EarlierVersion v ) = ( "<", showVersion v )
-getPkgVersion ( IntersectVersionRanges v1 v2 ) = getPkgVersion v1
-getPkgVersion ( WildcardVersion v@Version{versionBranch = vb} ) =
-	( "<", showVersion v{versionBranch = init vb ++ [last vb + 1]} )
-
-getDepPkgVersion :: Dependency -> VersionRange
-getDepPkgVersion ( Dependency _ vr ) = vr
-
-
---  print $ catMaybes $ map ebDepend $ concatMap condTreeConstraints $ map snd $ condExecutables gpd
-ebDepends :: GenericPackageDescription -> [ String ]
-ebDepends gpd =
-  let exdep = catMaybes $ map ebDepend $ concatMap condTreeConstraints $ map snd $ condExecutables gpd
-      libdep = concat $ maybeToList $
-	fmap ( catMaybes . map ebDepend . condTreeConstraints ) $ condLibrary gpd
---  print $ map snd $ condExecutables gpd
---  print $ fmap ( map ebDepend . condTreeConstraints ) $ condLibrary gpd
-   in exdep ++ libdep
diff --git a/src/cabal2ebuild.hs b/src/cabal2ebuild.hs
deleted file mode 100644
--- a/src/cabal2ebuild.hs
+++ /dev/null
@@ -1,158 +0,0 @@
-import Distribution.Package
--- import Distribution.Version
-import Distribution.PackageDescription
-import Distribution.PackageDescription.Parse
-import Distribution.Verbosity
-import Data.Maybe
-import Data.Version
-import Distribution.License
--- import System.Directory
-import Data.List
-import Depend
-
-import System.IO.Unsafe
-import System.Directory
-import System.FilePath
-import Control.Applicative
-
-test :: IO ()
-test = do
-  gpd <- readPackageDescription normal "cabal2ebuild.cabal"
-  print $ getName gpd ++ ".ebuild"
-  print $ getName gpd ++ ".tar.gz"
-  print $ getLicense gpd
-  print $ hasLib gpd
-  print $ hasEx gpd
-  putStrLn $ makeCabalFeatures ( hasLib gpd ) ( hasEx gpd )
-  putStrLn $ makeSrcURI $ getName gpd
-  putStrLn ""
---  putStrLn $ makeEbuild gpd
-  print $ condTreeData $ snd $ head $ condExecutables gpd
-  mapM_ print $ condTreeConstraints $ snd $ head $ condExecutables gpd
-  print $ synopsis $ packageDescription gpd
-  putStrLn ""
-  putStr $ ebuildToFile $ gpdToEbuild gpd
-  print $ condLibrary gpd
-  print $ ebDepends gpd
-  
-
-main :: IO ()
-main = do
-  cabal <- fmap ( head . filter ( isSuffixOf ".cabal" ) ) $ getDirectoryContents "."
-  gpd <- readPackageDescription normal cabal
-  writeFile ( makeFileName gpd ) -- $ makeEbuild gpd
-                                 $ ebuildToFile $ gpdToEbuild gpd
-
-makeFileName :: GenericPackageDescription -> String
-makeFileName gpd = getName gpd ++ ".ebuild"
-
--- data EbLicense = BSD3 | GPL | LGPL deriving Show
-
-data EbKWords = X86 | BX86 | AMD64 deriving Show
-
-showEKW :: EbKWords -> String
-showEKW X86  = "x86"
-showEKW BX86 = "~x86"
-showEKW AMD64 = "amd64"
-
-data Ebuild = Ebuild {
- 
-  ebCabalFt :: [ String ] ,
-  ebInherit :: String ,
-  ebAPI     :: Int ,
-  ebDsc     :: String ,
-  ebHmpg    :: String ,
-  srcURI    :: String ,
-  ebLicense :: License ,
-  ebSlot    :: Int ,
-  ebKWords  :: [ EbKWords ] ,
-  ebDepend  :: [ String ]
-
- } deriving Show
-
-gpdToEbuild :: GenericPackageDescription -> Ebuild
-gpdToEbuild gpd = Ebuild {
-
-  ebCabalFt = ft ,
-  ebInherit = "haskell-cabal",
-  ebAPI     = 3 ,
-  ebDsc     = synopsis $ packageDescription gpd ,
-  ebHmpg    = homepage $ packageDescription gpd ,
-  srcURI    = makeSrcURI ( getName gpd ) ,
-  ebLicense = getLicense gpd ,
-  ebSlot    = 0 ,
-  ebKWords  = [ X86, AMD64 ] ,
-  ebDepend  = ">=dev-lang/ghc-6.10" : "dev-haskell/cabal" : ebDepends gpd
-
- }
-  where
-  ft :: [ String ]
-  ft = concatMap snd $ filter fst
-    [ ( hasLib gpd , [ "lib", "haddock", "profile", "hscolour" ] ),
-      ( hasEx gpd  , [ "bin" ] ) ] 
-  
-ebuildToFile :: Ebuild -> String
-ebuildToFile eb =
-  "EAPI=" ++ show ( ebAPI eb ) ++ "\n\n" ++
-  "CABAL_FEATURES=\"" ++ unwords ( ebCabalFt eb ) ++ "\"\n" ++
-  "inherit " ++ ebInherit eb ++ "\n\n" ++
-  "DESCRIPTION=" ++ show ( ebDsc eb ) ++ "\n" ++
-  "HOMEPAGE=" ++ show ( ebHmpg eb ) ++ "\n" ++
-  "SRC_URI=" ++ srcURI eb ++ "\n\n" ++
-  "LICENSE=\"" ++ show ( ebLicense eb ) ++ "\"\n" ++
-  "SLOT=\"" ++ show ( ebSlot eb ) ++ "\"\n" ++
-  "KEYWORDS=\"" ++ unwords ( map showEKW $ ebKWords eb ) ++ "\"\n\n" ++
-  "DEPEND=\"" ++ unlines ( ebDepend eb ) ++ "\"\n"
-
-makeEbuild :: GenericPackageDescription -> String
-makeEbuild gpd =
-  makeCabalFeatures ( hasLib gpd ) ( hasEx gpd ) ++ "\n" ++
-  "inherit haskell-cabal\n\n" ++
-  "EAPI=3\n\n" ++
-  "SRC_URI=" ++ makeSrcURI ( getName gpd ) ++ "\n\n" ++
-  makeLicense ( getLicense gpd ) ++ "\n" ++
-  "SLOT=\"0\"\n" ++ "KEYWORDS=\"x86\"\n"
-
-makeCabalFeatures :: Bool -> Bool -> String
-makeCabalFeatures lb ex
-  = let ls = if lb then "lib " else ""
-        xs = if ex then "bin " else ""
-     in "CABAL_FEATURES=" ++ show ( xs ++ ls ++ "haddock profile hscolour" )
-
-myGentooRepo :: Maybe String
-myGentooRepo = unsafePerformIO $ do
-	hd <- getHomeDirectory
-	let confFile = hd </> ".cabal2ebuild" </> "gentoo_repo.txt"
-	fe <- doesFileExist confFile
-	if not fe then return Nothing else
-		fromConfigFile <$> readFile confFile
-
-fromConfigFile :: String -> Maybe String
-fromConfigFile cnt = case lines cnt of
-	["local", repo] -> Just repo
-	_ -> Nothing
-
-makeSrcURI :: String -> String
--- makeSrcURI nam = show ( "http://homepage3.nifty.com/salamander/second/portage/distfiles/" ++ nam ++ ".tar.gz" )
-makeSrcURI nam = case myGentooRepo of
-	Just r -> show $ r ++ nam ++ ".tar.gz"
-	_ -> show $ "http://hackage.haskell.org/package/" ++ nam ++ "/" ++
-		nam ++ ".tar.gz"
-
-makeLicense :: License -> String
-makeLicense l = "LICENSE=" ++ show ( show l )
-
-getName :: GenericPackageDescription -> String
-getName gpd = let pd = packageDescription gpd
-                  PackageName pn = pkgName $ package pd
-                  vn = showVersion $ pkgVersion $ package pd
-               in pn ++ "-" ++ vn
-
-getLicense :: GenericPackageDescription -> License
-getLicense = license . packageDescription
-
-hasLib :: GenericPackageDescription -> Bool
-hasLib = isJust . condLibrary
-
-hasEx :: GenericPackageDescription -> Bool
-hasEx = not . null . condExecutables
