Skip to content
Browse files

Merge changes

  • Loading branch information...
1 parent 1cec758 commit c3c84207e3a0cee16887e818f8b967a7db6354e1 @kolmodin kolmodin committed Mar 7, 2009
Showing with 8 additions and 164 deletions.
  1. +0 −96 Cache.hs
  2. +0 −62 Index.hs
  3. +0 −1 Main.hs
  4. +2 −2 Overlays.hs
  5. +1 −1 Portage/PackageId.hs
  6. +5 −2 hackport.cabal
View
96 Cache.hs
@@ -1,96 +0,0 @@
-module Cache where
-
-{-
-import CacheFile
-import Error
-import Index
-import P2
-import qualified Portage.Version as Portage
-import Overlays
-
-import Distribution.Text ( simpleParse )
-
-import Control.Arrow
-import Data.Char
-import Data.List
-import Network.URI (URI, uriPath)
-import Network.HTTP (Request(..), RequestMethod(GET), simpleHTTP, rspBody)
-import qualified Data.ByteString.Lazy as L
-import System.Time
-import System.FilePath
-import Control.Monad.Writer
-import System.Directory (createDirectoryIfMissing, doesFileExist)
-
-import qualified Data.Map as Map
-
--- cabal
-import Distribution.Verbosity
-import Distribution.Simple.Utils
-
-
--- | A long time
-alarmingLongTime :: TimeDiff
-alarmingLongTime = TimeDiff
- { tdYear = 0
- , tdMonth = 0
- , tdDay = 7
- , tdHour = 0
- , tdMin = 0
- , tdSec = 0
- , tdPicosec = 0
- }
-
-updateCache :: Verbosity -> URI -> IO ()
-updateCache verbosity uri = do
- path <- getOverlayPath verbosity
- let cache = cacheURI uri
- notice verbosity $
- "Fetching cache from " ++ show cache ++ "..."
- res <- simpleHTTP (Request cache GET [] "")
- notice verbosity $
- "done."
- case res of
- Left err -> throwEx (ConnectionFailed (show cache) (show err))
- Right resp -> do
- createDirectoryIfMissing False (path </> hackportDir)
- Prelude.writeFile (cacheFile path) (rspBody resp)
- where
- cacheURI :: URI -> URI
- cacheURI uri = uri {uriPath = uriPath uri </> indexFile}
-
-
-readCache :: Verbosity -> FilePath -> URI -> IO Index
-readCache verbosity portdir uri = do
- let cachePath = cacheFile portdir
- exists <- doesFileExist cachePath
- unless exists $ do
- notice verbosity "No cache file present, attempting to update..."
- updateCache verbosity uri
- str <- L.readFile cachePath
- return (readIndex str)
-
-indexToPortage :: Index -> Portage -> (Portage, [String])
-indexToPortage index port = second nub . runWriter $ do
- pkgs <- forM index $ \(pkg_h_name, pkg_h_ver, pkg_desc) -> do
- let pkg_name = map toLower pkg_h_name
- pkg_cat <- lookupCat pkg_name
- Just ver <- return . simpleParse $ pkg_h_ver
- return $ Ebuild (P pkg_cat pkg_name)
- (Portage.fromCabalVersion ver)
- "<hackage>"
- (Just pkg_desc)
- return $ Map.map sort $ Map.fromListWith (++) [ (ePackage e, [e]) | e <- pkgs ]
- where
- catMap = Map.fromListWith (++) [ (p, [c]) | P c p <- Map.keys port ]
- lookupCat :: String -> Writer [String] String
- lookupCat p = do
- case Map.lookup p catMap of
- Nothing -> return "hackage"
- Just [x] -> return x
- Just xs -> do
- let c | elem "dev-haskell" xs = "dev-haskell"
- | otherwise = head xs
- tell ["WARNING: Category clash for package " ++ p ++ ", defaulting to " ++ c ++ ". Other categories: " ++ unwords (delete c xs)]
- return c
-
--}
View
62 Index.hs
@@ -1,62 +0,0 @@
-module Index where
-
-{-
-import qualified Data.Set as Set
-import qualified Data.Map as Map
-import Data.Version (Version,parseVersion)
-import Data.ByteString.Lazy.Char8(ByteString,unpack)
-import Codec.Archive.Tar
-import Distribution.PackageDescription
-import Distribution.PackageDescription.Parse
-^ ^ ^ ^ ^ ^ ^
-import Distribution.Package
-import Distribution.Text
-import System.FilePath.Posix
-import MaybeRead (readPMaybe)
-
-type Index = [(Cabal.PackageName, Version, GenericPackageDescription)]
-type IndexMap = Map.Map Cabal.PackageName (Set.Set Version)
-
-readIndex :: ByteString -> Index
-readIndex str = do
- let unziped = decompress str
- untared = readTarArchive unziped
- entr <- archiveEntries untared
- case splitDirectories (tarFileName (entryHeader entr)) of
- [".",pkgname,vers,file] -> do
- let descr = case parsePackageDescription (unpack (entryData entr)) of
- ParseOk _ pkg_desc -> pkg_desc
- _ -> error $ "Couldn't read cabal file "++show file
- return (pkgname,vers,descr)
- _ -> fail "doesn't look like the proper path"
-
-filterIndexByPV :: (String -> String -> Bool) -> Index -> Index
-filterIndexByPV cond index = [ x | x@(p,v,_d) <- index, cond (display p) (display v)]
-
-indexMapFromList :: [PackageIdentifier] -> IndexMap
-indexMapFromList pids = Map.unionsWith Set.union $
- [ Map.singleton (pName name) (Set.singleton vers)
- | (PackageIdentifier {pkgName = name,pkgVersion = vers}) <- pids ]
-
-pName :: PackageName -> String
-pName (PackageName name) = name
-
-mkPackage :: String -> PackageName
-mkPackage = PackageName
-
-indexToPackageIdentifier :: Index -> [PackageIdentifier]
-indexToPackageIdentifier index = do
-v v v v v v v
- (name,vers,_) <- index
- return $ PackageIdentifier {pkgName = name, pkgVersion = vers}
-*************
- (name,vers_str,_) <- index
- Just vers <- return $ readPMaybe parseVersion vers_str
- return $ PackageIdentifier {pkgName = PackageName name,pkgVersion = vers}
-^ ^ ^ ^ ^ ^ ^
-
-bestVersions :: IndexMap -> Map.Map Cabal.PackageName Version
-bestVersions = Map.map Set.findMax
-
-
--}
View
1 Main.hs
@@ -44,7 +44,6 @@ import Bash
import qualified Cabal2Ebuild as E
import Diff
import Error
-import Index
import Status
import Overlays
import Merge
View
4 Overlays.hs
@@ -2,7 +2,7 @@ module Overlays where
import Control.Monad
import Data.List (nub, inits)
-import Data.Maybe (maybeToList, listToMaybe, catMaybes)
+import Data.Maybe (maybeToList, listToMaybe)
import System.Directory
import System.FilePath ((</>), splitPath, joinPath)
@@ -33,7 +33,7 @@ getOverlayPath verbosity = do
info verbosity "OK!"
return x
else do
- info verbosity "Not ok."
+ info verbosity "Not ok."
loop xs
info verbosity "There are several overlays in your configuration."
mapM (info verbosity . (" * " ++)) mul
View
2 Portage/PackageId.hs
@@ -13,7 +13,7 @@ module Portage.PackageId (
) where
import qualified Distribution.Package as Cabal
-import Distribution.Text (Text(..),display)
+import Distribution.Text (Text(..))
import qualified Distribution.Compat.ReadP as Parse
View
7 hackport.cabal
@@ -26,7 +26,11 @@ Executable hackport
Cabal >= 1.6 && < 1.7,
HTTP >= 4000.0.3,
zlib,
- tar
+ tar,
+ array
+ -- array is inherited from cabal-install
+
+ -- tar >= 0.3.0.0 && < 0.4
if flag(split-base)
Build-Depends:
@@ -49,7 +53,6 @@ Executable hackport
CacheFile
Diff
Error
- Index
Main
MaybeRead
Overlays

0 comments on commit c3c8420

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