Permalink
Browse files

when confronted with several overlays, pick one with a HackPort cache

It ignores the verbosity levels, always prints messages on stdout.
  • Loading branch information...
1 parent acf9f02 commit 6655a42fe1891568029a0cd95789cb1e63442d34 @kolmodin kolmodin committed Oct 1, 2005
Showing with 17 additions and 2 deletions.
  1. +16 −1 HackPort/Bash.hs
  2. +1 −1 HackPort/Main.hs
View
@@ -13,7 +13,22 @@ getOverlay = do
case overlays of
[] -> throwDyn NoOverlay
[x] -> return x
- mul -> throwDyn $ MultipleOverlays mul
+ mul -> search mul
+ where
+ search mul = do
+ let loop [] = throwDyn $ MultipleOverlays mul
+ loop (x:xs) = do
+ found <- doesFileExist (x ++ "/.hackagecache.xml")
+ if found
+ then return x
+ else loop xs
+ putStrLn "There are several overlays in your /etc/make.conf"
+ putStr $ unlines $ map (" * " ++) mul
+ putStrLn "Looking for one with a HackPort cache..."
+ overlay <- loop mul
+ putStrLn ("I choose " ++ overlay ++
+ "\nOverride my decision with hackport -p /my/overlay")
+ return overlay
getOverlays :: IO [String]
getOverlays = runBash "source /etc/make.conf;echo -n $PORTDIR_OVERLAY" >>= (return.words)
View
@@ -29,7 +29,7 @@ readCache' cfg portDir = let target=portDir++"/.hackagecache.xml" in readCache (
getPortageTree :: Config -> IO String
getPortageTree cfg = case portageTree cfg of
- Nothing -> getOverlay `sayDebug` ("Guessing overlay from /etc/make.conf... ",\tree->"Found '"++tree++"'\n")
+ Nothing -> getOverlay `sayDebug` ("Guessing overlay from /etc/make.conf... \n",\tree->"Found '"++tree++"'\n")
Just tree -> return tree
where
sayDebug=verboseDebug (verbosity cfg)

0 comments on commit 6655a42

Please sign in to comment.