Permalink
Browse files

added support sor searching overlays in paludis configuration

This patch changes semantics of overlay list:
Was:
search in nub $ local_dir ++ emerge_ovlays ++ paludis_ovlays {- unimpl == [] -}
Is:
search in nub $ local_dir ++ paludis_ovlays R emerge_ovlays(in case of no working paludis)
  • Loading branch information...
1 parent 3d054de commit 2ea4ac53a527a745dfaf837518bfee0d58a44075 @trofi trofi committed Mar 17, 2009
Showing with 60 additions and 25 deletions.
  1. +4 −13 Overlays.hs
  2. +55 −11 Portage/Overlay.hs
  3. +1 −1 Util.hs
View
@@ -6,9 +6,9 @@ import Data.Maybe (maybeToList, listToMaybe)
import System.Directory
import System.FilePath ((</>), splitPath, joinPath)
-import Bash
import Error
import CacheFile
+import Portage.Overlay
-- cabal
import Distribution.Verbosity
@@ -45,25 +45,16 @@ getOverlayPath verbosity = do
getOverlays :: IO [String]
getOverlays = do
- local <- getLocalOverlay
- portage <- getGlobalPortageOverlays
- paludis <- getGlobalPaludisOverlays
+ local <- getLocalOverlay
+ overlays <- overlay_list `fmap` getInfo
return $ nub $ map clean $
maybeToList local
- ++ portage
- ++ paludis
+ ++ overlays
where
clean path = case reverse path of
'/':p -> reverse p
_ -> path
-getGlobalPortageOverlays :: IO [String]
-getGlobalPortageOverlays =
- fmap words (runBash "source /etc/make.conf;echo -n $PORTDIR_OVERLAY")
-
-getGlobalPaludisOverlays :: IO [String]
-getGlobalPaludisOverlays = return [] -- TODO: fix
-
getLocalOverlay :: IO (Maybe FilePath)
getLocalOverlay = do
curDir <- getCurrentDirectory
View
@@ -178,34 +178,78 @@ getDirectoryTree = dirEntries
data LocalInfo =
LocalInfo { distfiles_dir :: String
+ , overlay_list :: [FilePath]
}
- deriving (Show)
defaultInfo :: LocalInfo
-defaultInfo = LocalInfo { distfiles_dir = "/usr/portage/distfiles" }
+defaultInfo = LocalInfo { distfiles_dir = "/usr/portage/distfiles"
+ , overlay_list = []
+ }
-- query paludis and then emerge
getInfo :: IO LocalInfo
getInfo = do paludis_info <- (fmap . fmap) parse_paludis_output (run_cmd "paludis --info")
emerge_info <- (fmap . fmap) parse_emerge_output (run_cmd "emerge --info")
return $ fromJust $ paludis_info `mplus` emerge_info `mplus` (Just defaultInfo)
+data LocalPaludisOverlay =
+ LocalPaludisOverlay { repo_name :: String
+ , format :: String
+ , location :: FilePath
+ , distdir :: FilePath
+ }
+
+bad_paludis_overlay :: LocalPaludisOverlay
+bad_paludis_overlay =
+ LocalPaludisOverlay { repo_name = undefined
+ , format = undefined
+ , location = undefined
+ , distdir = undefined
+ }
+
parse_paludis_output :: String -> LocalInfo
parse_paludis_output raw_data =
- foldl updateInfo defaultInfo $ lines raw_data
- where updateInfo info str =
- case (break (== ':') (refine str)) of
- -- TODO: not quite true. shoud parse info on 'by repo' basis
- -- TODO: we are interested in 'Repository gentoo:' actually
- ("distdir", ':':value) -> info{distfiles_dir = refine value}
- _ -> info
+ foldl updateInfo defaultInfo $ parse_paludis_overlays raw_data
+ where updateInfo info po =
+ case (format po) of
+ "ebuild" | (repo_name po) /= "gentoo" -- hack, skip main repo
+ -> info{ distfiles_dir = distdir po -- ew override last distdir here (FIXME?)
+ , overlay_list = (location po) : overlay_list info
+ }
+ _ -> info
+
+parse_paludis_overlays :: String -> [LocalPaludisOverlay]
+parse_paludis_overlays raw_data =
+ parse_paludis_overlays' (reverse $ lines raw_data) bad_paludis_overlay
+
+-- parse in reverse order :]
+parse_paludis_overlays' :: [String] -> LocalPaludisOverlay -> [LocalPaludisOverlay]
+parse_paludis_overlays' [] _ = []
+parse_paludis_overlays' (l:ls) info =
+ case (words l) of
+ -- look for "Repository <repo-name>:"
+ ["Repository", r_name] -> info{repo_name = init r_name} :
+ go bad_paludis_overlay
+ -- else - parse attributes
+ _ -> case (break (== ':') (refine l)) of
+ ("location", ':':value)
+ -> go info{location = refine value}
+ ("distdir", ':':value)
+ -> go info{distdir = refine value}
+ ("format", ':':value)
+ -> go info{format = refine value}
+ _ -> go info
+ where go = parse_paludis_overlays' ls
refine = dropWhile isSpace
parse_emerge_output :: String -> LocalInfo
parse_emerge_output raw_data =
foldl updateInfo defaultInfo $ lines raw_data
where updateInfo info str =
case (break (== '=') str) of
- ("DISTDIR", '=':value) -> info{distfiles_dir = unquote value}
- _ -> info
+ ("DISTDIR", '=':value)
+ -> info{distfiles_dir = unquote value}
+ ("PORTDIR_OVERLAY", '=':value)
+ -> info{overlay_list = words $ unquote value}
+ _ -> info
unquote = init . tail
View
@@ -12,7 +12,7 @@ module Util
import System.IO
import System.Process
-import System.Exit
+import System.Exit ()
-- 'run_cmd' executes command and returns it's standard output
-- as 'String'.

0 comments on commit 2ea4ac5

Please sign in to comment.