-
Notifications
You must be signed in to change notification settings - Fork 0
/
ifBuildable.hs
36 lines (30 loc) · 1.15 KB
/
ifBuildable.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
-- Returns exitcode 0 if the given package is buildable or is a boot package,
-- and 1 otherwise.
module Main (main) where
import Control.Monad
import System.Directory
import System.Environment
import System.Exit
import System.IO
main :: IO ()
main = do args <- getArgs
case args of
[bootPackagesFile, package] ->
doit bootPackagesFile package
_ ->
error "Syntax: ifBuildable <boot-packages-file> <package>"
doit :: FilePath -> String -> IO ()
doit bootPackagesFile package
= do setCurrentDirectory package
unbuildable <- doesFileExist "unbuildable"
if not unbuildable
then exitWith ExitSuccess
else do mustBeBuildables <- getMustBeBuildables bootPackagesFile
if package `elem` mustBeBuildables
then exitWith ExitSuccess
else do hPutStrLn stderr "Warning: Package is unbuildable"
exitWith (ExitFailure 1)
getMustBeBuildables :: FilePath -> IO [String]
getMustBeBuildables bootPackagesFile
= do xs <- readFile bootPackagesFile
return $ filter ("editline" /=) $ lines xs