main :: IO ()
main = do args <- getArgs
case args of
- [package] ->
- doit package
+ [packagesFile, package] ->
+ doit packagesFile package
_ ->
- error "Syntax: ifBuildable <package>"
+ error "Syntax: ifBuildable <packages-file> <package>"
-doit :: String -> IO ()
-doit package
+doit :: FilePath -> String -> IO ()
+doit packagesFile package
= do setCurrentDirectory package
unbuildable <- doesFileExist "unbuildable"
if not unbuildable
then exitWith ExitSuccess
- else do mustBeBuildables <- getMustBeBuildablePackages
+ else do mustBeBuildables <- getMustBeBuildables packagesFile
if package `elem` mustBeBuildables
then exitWith ExitSuccess
else do hPutStrLn stderr "Warning: Package is unbuildable"
exitWith (ExitFailure 1)
-getMustBeBuildablePackages :: IO [String]
-getMustBeBuildablePackages
- = do xs <- readFile "../boot-packages"
- return $ filter ("readline" /=) $ lines xs
+getMustBeBuildables :: FilePath -> IO [String]
+getMustBeBuildables packagesFile
+ = do xs <- readFile packagesFile
+ let nonCommentLines = filter (("#" /=) . take 1) $ lines xs
+ requiredLines = filter ((2 == ) . length) $ map words nonCommentLines
+ requiredLibraries = [ x | 'l':'i':'b':'r':'a':'r':'i':'e':'s':'/':x
+ <- map head requiredLines ]
+ return $ filter ("editline" /=) requiredLibraries
+