-
Notifications
You must be signed in to change notification settings - Fork 21
/
Portage.hs
38 lines (32 loc) · 1008 Bytes
/
Portage.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module Portage where
import Control.Monad.Trans
import Distribution.Package
import System.Directory
import Text.Regex
import Data.Maybe
import Data.Version
import Bash
import MaybeRead
import Action
import Config
ebuildVersionRegex name = mkRegex ("^"++name++"-(.*)\\.ebuild$")
filterPackages :: String -> [String] -> IO [String]
filterPackages _ [] = return []
filterPackages base (x:xs) = do
ak <- case x of
"." -> return Nothing
".." -> return Nothing
dir -> do
exists <- doesDirectoryExist (base++dir)
return (if exists then Just dir else Nothing)
rest <- filterPackages base xs
return (maybe rest (:rest) ak)
getOverlayPath :: HPAction String
getOverlayPath = do
cfg <- getCfg
case overlayPath cfg of
Nothing -> do
tree <- getOverlay `sayDebug` ("Guessing overlay from /etc/make.conf...\n",\tree->"Found '"++tree++"'")
setOverlayPath $ Just tree
return tree
Just tree -> return tree