filter out non-cygwin libs

This commit is contained in:
Joey Hess 2015-04-21 16:38:49 -04:00
parent 0cf8af6d8a
commit dc6949b509

View file

@ -27,7 +27,7 @@ import Control.Applicative
import Data.String import Data.String
import Data.Maybe import Data.Maybe
import Data.Char import Data.Char
import Data.List (nub) import Data.List (nub, isPrefixOf)
import Utility.Tmp import Utility.Tmp
import Utility.Path import Utility.Path
@ -47,7 +47,7 @@ main = do
when (isNothing p) $ when (isNothing p) $
print ("unable to find in PATH", f) print ("unable to find in PATH", f)
return p return p
dlls <- forM (catMaybes extrabins) findLibs dlls <- forM (catMaybes extrabins) findCygLibs
dllpaths <- mapM searchPath (nub (concat dlls)) dllpaths <- mapM searchPath (nub (concat dlls))
webappscript <- vbsLauncher tmpdir "git-annex-webapp" "git-annex webapp" webappscript <- vbsLauncher tmpdir "git-annex-webapp" "git-annex webapp"
autostartscript <- vbsLauncher tmpdir "git-annex-autostart" "git annex assistant --autostart" autostartscript <- vbsLauncher tmpdir "git-annex-autostart" "git annex assistant --autostart"
@ -189,9 +189,11 @@ htmlHelpText = unlines
, "</html" , "</html"
] ]
findLibs :: FilePath -> IO [FilePath] -- Find cygwin libraries used by the specified executable.
findLibs p = mapMaybe parse . lines <$> readProcess "ldd" [p] findCygLibs :: FilePath -> IO [FilePath]
findCygLibs p = filter iscyg . mapMaybe parse . lines <$> readProcess "ldd" [p]
where where
parse l = case words (dropWhile isSpace l) of parse l = case words (dropWhile isSpace l) of
(dll:"=>":_dllpath:_offset:[]) -> Just dll (dll:"=>":_dllpath:_offset:[]) -> Just dll
_ -> Nothing _ -> Nothing
iscyg f = "cyg" `isPrefixOf` f || "lib" `isPrefixOf` f