From 6cb08876f056986fb0429c330f6ec9d8f8808438 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 10 Aug 2020 12:20:32 -0400 Subject: [PATCH] make /usr/lib consolidation more robust Directory enumeration could happen in either order, and also there could be some other directories so the two to combine are not adjacent. --- Build/LinuxMkLibs.hs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Build/LinuxMkLibs.hs b/Build/LinuxMkLibs.hs index a873d76ad3..7bb5c1de4b 100644 --- a/Build/LinuxMkLibs.hs +++ b/Build/LinuxMkLibs.hs @@ -68,24 +68,19 @@ mklibs top _installedbins = do - and improves startup time. -} consolidateUsrLib :: FilePath -> [FilePath] -> IO [FilePath] -consolidateUsrLib top libdirs = map reverse <$> go [] (map reverse libdirs) +consolidateUsrLib top libdirs = go [] libdirs where go c [] = return c - go c (x:[]) = return (x:c) - go c (x:y:rest) - | x == y ++ reverse ("/usr") = do - let x' = reverse x - let y' = reverse y - fs <- getDirectoryContents (inTop top x') + go c (x:rest) = case filter (\d -> ("/usr" ++ d) == x) libdirs of + (d:_) -> do + fs <- getDirectoryContents (inTop top x) forM_ fs $ \f -> unless (dirCruft f) $ renameFile - (inTop top (x' f)) - (inTop top (y' f)) - go (y:c) rest - | otherwise = do - print (x,y) - go (x:c) (y:rest) + (inTop top (x f)) + (inTop top (d f)) + go c rest + _ -> go (x:c) rest {- Installs a linker shim script around a binary. -