From 2ee6ce68feefa2a46051e6116e772f72d2ecfd91 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 8 Dec 2012 15:46:16 -0400 Subject: chmod libs so install_name_tool can modify them --- Build/OSXMkLibs.hs | 1 + 1 file changed, 1 insertion(+) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index 45a86000b..efe0cc1dd 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -43,6 +43,7 @@ installLibs appbase = do createDirectoryIfMissing True appbase putStrLn $ "installing " ++ lib _ <- boolSystem "cp" [File lib, File dest] + _ <- boolSystem "chmod" [Param "644", File dest] return $ Just appbase ) -- cgit v1.2.3 From bd94ced9e9d8ff1f4ef78d56f51d5c1b1694d5a0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 8 Dec 2012 17:14:45 -0400 Subject: fix library filenames in osx app --- Build/OSXMkLibs.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index efe0cc1dd..ef5ef0a84 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -77,7 +77,7 @@ install_name_tool binary lib = do ok <- boolSystem "install_name_tool" [ Param "-change" , File lib - , Param $ "@executable_path" ++ (dropFileName lib) + , Param $ "@executable_path" ++ (takeFileName lib) , File binary ] unless ok $ -- cgit v1.2.3 From bf990f23225c7f2eb114327c5ae6c4becd228175 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 8 Dec 2012 17:44:10 -0400 Subject: insane osx short library name hack Since I'm dealing with arbitrarily short fields in which to store the library name, and would have to rebuild a bunch of stuff like git to avoid that, and I have to prefix this obnoxiously long "@executable_path" to it, it's easy to run out of space. This makes it use 1 and 2 letter long filenames for libraries in the app. Fun fun fun fun fun. --- Build/OSXMkLibs.hs | 65 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 20 deletions(-) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index ef5ef0a84..f320ff585 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -23,19 +23,24 @@ import Utility.Monad import Utility.SafeCommand import Utility.Path +import qualified Data.Map as M +import qualified Data.Set as S + +type LibMap = M.Map FilePath String + {- Recursively find and install libs, until nothing new to install is found. -} -mklibs :: FilePath -> [FilePath] -> IO [FilePath] -mklibs appbase libdirs = do - new <- catMaybes <$> installLibs appbase +mklibs :: FilePath -> [FilePath] -> LibMap -> IO [FilePath] +mklibs appbase libdirs libmap = do + (new, libmap') <- installLibs appbase libmap if null new then return (libdirs++new) - else mklibs appbase (libdirs++new) + else mklibs appbase (libdirs++new) libmap' {- Returns directories into which new libs were installed. -} -installLibs :: FilePath -> IO [Maybe FilePath] -installLibs appbase = do - needlibs <- otool appbase - forM needlibs $ \lib -> do +installLibs :: FilePath -> LibMap -> IO ([FilePath], LibMap) +installLibs appbase libmap = do + (needlibs, libmap') <- otool appbase libmap + libs <- forM needlibs $ \lib -> do let dest = appbase takeFileName lib ifM (doesFileExist dest) ( return Nothing @@ -46,19 +51,21 @@ installLibs appbase = do _ <- boolSystem "chmod" [Param "644", File dest] return $ Just appbase ) + return (catMaybes libs, libmap') {- Returns libraries to install. -} -otool :: FilePath -> IO [FilePath] -otool appbase = do +otool :: FilePath -> LibMap -> IO ([FilePath], LibMap) +otool appbase libmap = do files <- filterM doesFileExist =<< dirContentsRecursive appbase - l <- forM files $ \file -> do - libs <- filter unprocessed . parseOtool - <$> readProcess "otool" ["-L", file] - forM_ libs $ \lib -> install_name_tool file lib - return libs - return $ nub $ concat l + process [] files libmap where unprocessed s = not ("@executable_path" `isInfixOf` s) + process c [] m = return (nub $ concat c, m) + process c (file:rest) m = do + libs <- filter unprocessed . parseOtool + <$> readProcess "otool" ["-L", file] + m' <- install_name_tool file libs m + process (libs:c) (file:rest) m' parseOtool :: String -> [FilePath] parseOtool = catMaybes . map parse . lines @@ -72,22 +79,40 @@ parseOtool = catMaybes . map parse . lines - Assumes all executables are installed into the same directory, and - the libraries will be installed in subdirectories that match their - absolute paths. -} -install_name_tool :: FilePath -> FilePath -> IO () -install_name_tool binary lib = do +install_name_tool :: FilePath -> [FilePath] -> LibMap -> IO LibMap +install_name_tool _ [] libmap = return libmap +install_name_tool binary (lib:rest) libmap = do + let (libname, libmap') = getLibName lib libmap ok <- boolSystem "install_name_tool" [ Param "-change" , File lib - , Param $ "@executable_path" ++ (takeFileName lib) + , Param $ "@executable_path/" ++ libname , File binary ] unless ok $ hPutStrLn stderr $ "install_name_tool failed for " ++ binary + install_name_tool binary rest libmap' + +{- Uses really short names for the library files it installs, because + - binaries have arbitrarily short RPATH field limits. -} +getLibName :: FilePath -> LibMap -> (FilePath, LibMap) +getLibName lib libmap = case M.lookup lib libmap of + Just n -> (n, libmap) + Nothing -> let n = nextfreename + in (n, M.insert lib n libmap) + where + names = map (\c -> [c]) letters ++ + [[l1, l2] | l1 <- letters, l2 <- letters] + letters = ['a' .. 'z'] ++ ['A' .. 'Z'] ++ ['0' .. '9'] + used = S.fromList $ M.elems libmap + nextfreename = fromMaybe (error "ran out of short library names!") $ + headMaybe $ dropWhile (`S.member` used) names main :: IO () main = getArgs >>= go where go [] = error "specify OSXAPP_BASE" go (appbase:_) = do - libdirs <- mklibs appbase [] + libdirs <- mklibs appbase [] M.empty writeFile (appbase "libdirs") $ unlines $ nub libdirs -- cgit v1.2.3 From ac66b7f6542b37ca1a7eab817a430c3db4235a1a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 9 Dec 2012 12:14:19 -0400 Subject: fix infinite loop --- Build/OSXMkLibs.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index f320ff585..a0df54a1b 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -65,7 +65,7 @@ otool appbase libmap = do libs <- filter unprocessed . parseOtool <$> readProcess "otool" ["-L", file] m' <- install_name_tool file libs m - process (libs:c) (file:rest) m' + process (libs:c) rest m' parseOtool :: String -> [FilePath] parseOtool = catMaybes . map parse . lines -- cgit v1.2.3 From 8b50290947148e9ae15bc46804bf1cd6614bd4d0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 9 Dec 2012 12:15:24 -0400 Subject: fix executable permissions sh at least does not default to having a write bit --- Build/OSXMkLibs.hs | 1 + 1 file changed, 1 insertion(+) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index a0df54a1b..20bf0bf69 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -62,6 +62,7 @@ otool appbase libmap = do unprocessed s = not ("@executable_path" `isInfixOf` s) process c [] m = return (nub $ concat c, m) process c (file:rest) m = do + _ <- boolSystem "chmod" [Param "755", File file] libs <- filter unprocessed . parseOtool <$> readProcess "otool" ["-L", file] m' <- install_name_tool file libs m -- cgit v1.2.3 From 9b9916db456f1f7f6322cd4cfdc25c27cdadb40a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 9 Dec 2012 12:20:00 -0400 Subject: install libs using short names, with symlinks to we can tell what libraries they are supposed to be --- Build/OSXMkLibs.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index 20bf0bf69..7c15e9451 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -41,14 +41,17 @@ installLibs :: FilePath -> LibMap -> IO ([FilePath], LibMap) installLibs appbase libmap = do (needlibs, libmap') <- otool appbase libmap libs <- forM needlibs $ \lib -> do - let dest = appbase takeFileName lib + let shortlib = fromMaybe (error "internal") (M.lookup lib libmap') + let dest = appbase shortlib + let symdest = appbase takeFileName lib ifM (doesFileExist dest) ( return Nothing , do createDirectoryIfMissing True appbase - putStrLn $ "installing " ++ lib + putStrLn $ "installing " ++ lib ++ " as " ++ dest _ <- boolSystem "cp" [File lib, File dest] _ <- boolSystem "chmod" [Param "644", File dest] + _ <- boolSystem "ln" [Param "-s", File shortlib, File symdest] return $ Just appbase ) return (catMaybes libs, libmap') -- cgit v1.2.3 From e30ac23d6895f8fb4320b58d855be74a778d2b87 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 9 Dec 2012 12:35:50 -0400 Subject: reverse symlinks --- Build/OSXMkLibs.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index 7c15e9451..ba4490f6d 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -42,16 +42,16 @@ installLibs appbase libmap = do (needlibs, libmap') <- otool appbase libmap libs <- forM needlibs $ \lib -> do let shortlib = fromMaybe (error "internal") (M.lookup lib libmap') - let dest = appbase shortlib - let symdest = appbase takeFileName lib + let dest = appbase takeFileName lib + let symdest = appbase shortlib ifM (doesFileExist dest) ( return Nothing , do createDirectoryIfMissing True appbase - putStrLn $ "installing " ++ lib ++ " as " ++ dest + putStrLn $ "installing " ++ lib ++ " as " ++ shortlib _ <- boolSystem "cp" [File lib, File dest] _ <- boolSystem "chmod" [Param "644", File dest] - _ <- boolSystem "ln" [Param "-s", File shortlib, File symdest] + _ <- boolSystem "ln" [Param "-s", File (takeFileName lib), File symdest] return $ Just appbase ) return (catMaybes libs, libmap') -- cgit v1.2.3 From ad0681321d5efc9e11210c8c675e920fa28a7c3a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 9 Dec 2012 12:44:02 -0400 Subject: tweak --- Build/OSXMkLibs.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index ba4490f6d..e6cac1850 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -102,8 +102,7 @@ install_name_tool binary (lib:rest) libmap = do getLibName :: FilePath -> LibMap -> (FilePath, LibMap) getLibName lib libmap = case M.lookup lib libmap of Just n -> (n, libmap) - Nothing -> let n = nextfreename - in (n, M.insert lib n libmap) + Nothing -> (nextfreename, M.insert lib nextfreename libmap) where names = map (\c -> [c]) letters ++ [[l1, l2] | l1 <- letters, l2 <- letters] -- cgit v1.2.3 From 0bffe4b2c81715bc9068d19cf408f642126774d2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 9 Dec 2012 12:54:19 -0400 Subject: oh yeah, OSX is case insensative --- Build/OSXMkLibs.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index e6cac1850..23a824ced 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -106,7 +106,7 @@ getLibName lib libmap = case M.lookup lib libmap of where names = map (\c -> [c]) letters ++ [[l1, l2] | l1 <- letters, l2 <- letters] - letters = ['a' .. 'z'] ++ ['A' .. 'Z'] ++ ['0' .. '9'] + letters = ['a' .. 'z'] ++ ['0' .. '9'] used = S.fromList $ M.elems libmap nextfreename = fromMaybe (error "ran out of short library names!") $ headMaybe $ dropWhile (`S.member` used) names -- cgit v1.2.3 From 10567a63ffdc61c023923da91dbd57f39935c080 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 9 Dec 2012 12:59:34 -0400 Subject: remove unused cruft --- Build/OSXMkLibs.hs | 12 ++++-------- standalone/osx/git-annex.app/Contents/MacOS/runshell | 18 ++---------------- 2 files changed, 6 insertions(+), 24 deletions(-) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index 23a824ced..ef3b6701a 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -29,12 +29,11 @@ import qualified Data.Set as S type LibMap = M.Map FilePath String {- Recursively find and install libs, until nothing new to install is found. -} -mklibs :: FilePath -> [FilePath] -> LibMap -> IO [FilePath] +mklibs :: FilePath -> [FilePath] -> LibMap -> IO () mklibs appbase libdirs libmap = do (new, libmap') <- installLibs appbase libmap - if null new - then return (libdirs++new) - else mklibs appbase (libdirs++new) libmap' + unless null new $ + mklibs appbase (libdirs++new) libmap' {- Returns directories into which new libs were installed. -} installLibs :: FilePath -> LibMap -> IO ([FilePath], LibMap) @@ -115,7 +114,4 @@ main :: IO () main = getArgs >>= go where go [] = error "specify OSXAPP_BASE" - go (appbase:_) = do - libdirs <- mklibs appbase [] M.empty - writeFile (appbase "libdirs") $ - unlines $ nub libdirs + go (appbase:_) = mklibs appbase [] M.empty diff --git a/standalone/osx/git-annex.app/Contents/MacOS/runshell b/standalone/osx/git-annex.app/Contents/MacOS/runshell index e972b777f..03b6befdf 100755 --- a/standalone/osx/git-annex.app/Contents/MacOS/runshell +++ b/standalone/osx/git-annex.app/Contents/MacOS/runshell @@ -1,6 +1,6 @@ #!/bin/sh -# Runs a shell command (or interactive shell) using the binaries and -# libraries bundled with this app. +# Runs a shell command (or interactive shell) using the binaries +# bundled with this app. set -e @@ -46,20 +46,6 @@ export ORIG_PATH PATH=$base/bin:$PATH export PATH -# This makes the linker first look in the library directories bundled -# in this app. Only if it fails to find a library there will a system -# library be used. -# -# This seems to work better than DYLD_LIBRARY_PATH, which can force -# the wrong version of a library to be used, if the app bundles two -# different versions of a single library. And it seems to work better -# than DYLD_FALLBACK_LIBRARY_PATH, which fails to override old system -# versions of libraries when a program in the app needs a newer version. -#ORIG_DYLD_ROOT_PATH="$DYLD_ROOT_PATH" -#export ORIG_DYLD_ROOT_PATH -#DYLD_ROOT_PATH=$base -#export DYLD_ROOT_PATH - ORIG_GIT_EXEC_PATH="$GIT_EXEC_PATH" export ORIG_GIT_EXEC_PATH GIT_EXEC_PATH=$base -- cgit v1.2.3 From 0f5b494133b7dcd99fbb7958ce1d8a30dd5e7063 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 9 Dec 2012 13:02:59 -0400 Subject: syntax --- Build/OSXMkLibs.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index ef3b6701a..4535073d7 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -32,7 +32,7 @@ type LibMap = M.Map FilePath String mklibs :: FilePath -> [FilePath] -> LibMap -> IO () mklibs appbase libdirs libmap = do (new, libmap') <- installLibs appbase libmap - unless null new $ + unless (null new) $ mklibs appbase (libdirs++new) libmap' {- Returns directories into which new libs were installed. -} -- cgit v1.2.3 From ecd7822e0a9b7bf19c2c5f1f6f88c3ff9ce28709 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 9 Dec 2012 13:06:59 -0400 Subject: avoid using short lib names that clash with unix command names --- Build/OSXMkLibs.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index 4535073d7..ab78e39bf 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -103,9 +103,8 @@ getLibName lib libmap = case M.lookup lib libmap of Just n -> (n, libmap) Nothing -> (nextfreename, M.insert lib nextfreename libmap) where - names = map (\c -> [c]) letters ++ - [[l1, l2] | l1 <- letters, l2 <- letters] - letters = ['a' .. 'z'] ++ ['0' .. '9'] + names = map (\c -> [c]) ['A' .. 'Z'] ++ + [[n, l] | n <- ['0' .. '9'], l <- ['A' .. 'Z'] used = S.fromList $ M.elems libmap nextfreename = fromMaybe (error "ran out of short library names!") $ headMaybe $ dropWhile (`S.member` used) names -- cgit v1.2.3 From 63b4d134a253acd21b148ce0be41701dc62a810d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 9 Dec 2012 13:08:57 -0400 Subject: typo --- Build/OSXMkLibs.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index ab78e39bf..c03fb81be 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -104,7 +104,7 @@ getLibName lib libmap = case M.lookup lib libmap of Nothing -> (nextfreename, M.insert lib nextfreename libmap) where names = map (\c -> [c]) ['A' .. 'Z'] ++ - [[n, l] | n <- ['0' .. '9'], l <- ['A' .. 'Z'] + [[n, l] | n <- ['0' .. '9'], l <- ['A' .. 'Z']] used = S.fromList $ M.elems libmap nextfreename = fromMaybe (error "ran out of short library names!") $ headMaybe $ dropWhile (`S.member` used) names -- cgit v1.2.3 From 8a92fbcc1b6da89082f54ca06b9f237c37633b9f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 9 Dec 2012 13:17:55 -0400 Subject: use full path name to generate library filename avoids overlaps --- Build/OSXMkLibs.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index c03fb81be..6462cb14e 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -15,6 +15,7 @@ import System.Directory import System.IO import Control.Monad import Data.List +import Data.String.Utils import Utility.PartialPrelude import Utility.Directory @@ -41,7 +42,8 @@ installLibs appbase libmap = do (needlibs, libmap') <- otool appbase libmap libs <- forM needlibs $ \lib -> do let shortlib = fromMaybe (error "internal") (M.lookup lib libmap') - let dest = appbase takeFileName lib + let fulllib = replace "/" "_" lib + let dest = appbase fulllib let symdest = appbase shortlib ifM (doesFileExist dest) ( return Nothing @@ -50,7 +52,7 @@ installLibs appbase libmap = do putStrLn $ "installing " ++ lib ++ " as " ++ shortlib _ <- boolSystem "cp" [File lib, File dest] _ <- boolSystem "chmod" [Param "644", File dest] - _ <- boolSystem "ln" [Param "-s", File (takeFileName lib), File symdest] + _ <- boolSystem "ln" [Param "-s", File fulllib, File symdest] return $ Just appbase ) return (catMaybes libs, libmap') -- cgit v1.2.3 From c3451715b90022e898f14bb5d45c8d7db9563929 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 9 Dec 2012 13:29:30 -0400 Subject: optimisation; only run install_name_tool once per binary --- Build/OSXMkLibs.hs | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index 6462cb14e..18c0e7c8d 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -79,24 +79,30 @@ parseOtool = catMaybes . map parse . lines | "\t" `isPrefixOf` l = headMaybe $ words l | otherwise = Nothing -{- Adjusts binaries to use libraries in paths relative to the executable. - - - - Assumes all executables are installed into the same directory, and - - the libraries will be installed in subdirectories that match their - - absolute paths. -} +{- Adjusts binaries to use libraries bundled with it, rather than the + - system libraries. -} install_name_tool :: FilePath -> [FilePath] -> LibMap -> IO LibMap -install_name_tool _ [] libmap = return libmap -install_name_tool binary (lib:rest) libmap = do - let (libname, libmap') = getLibName lib libmap - ok <- boolSystem "install_name_tool" +install_name_tool binary libs libmap = do + let (libnames, libmap') = getLibNames libs libmap + let params = concatMap change $ zip libs libnames + ok <- boolSystem "install_name_tool" $ params ++ [File binary] + unless ok $ + hPutStrLn stderr $ "install_name_tool failed for " ++ binary + return libmap' + where + change (lib, libname) = [ Param "-change" , File lib , Param $ "@executable_path/" ++ libname - , File binary ] - unless ok $ - hPutStrLn stderr $ "install_name_tool failed for " ++ binary - install_name_tool binary rest libmap' + +getLibNames :: [FilePath] -> LibMap -> ([FilePath], LibMap) +getLibNames libs libmap = go [] libs libmap + where + go c [] m = (reverse c, m) + go c (l:rest) m = + let (f, m') = getLibName l m + in go (f:c) rest m' {- Uses really short names for the library files it installs, because - binaries have arbitrarily short RPATH field limits. -} -- cgit v1.2.3 From 0f286ff189d0e8be29e9be17cb18ec290593a40d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 9 Dec 2012 13:38:08 -0400 Subject: install_name_tool fix --- Build/OSXMkLibs.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index 18c0e7c8d..b6e679d73 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -82,12 +82,13 @@ parseOtool = catMaybes . map parse . lines {- Adjusts binaries to use libraries bundled with it, rather than the - system libraries. -} install_name_tool :: FilePath -> [FilePath] -> LibMap -> IO LibMap +install_name_tool _ [] libmap = return libmap install_name_tool binary libs libmap = do let (libnames, libmap') = getLibNames libs libmap let params = concatMap change $ zip libs libnames ok <- boolSystem "install_name_tool" $ params ++ [File binary] unless ok $ - hPutStrLn stderr $ "install_name_tool failed for " ++ binary + error $ "install_name_tool failed for " ++ binary return libmap' where change (lib, libname) = -- cgit v1.2.3 From 0dab523220965b8740cf423a48751f4753153294 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 9 Dec 2012 13:42:30 -0400 Subject: install libs in subdirs again --- Build/OSXMkLibs.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index b6e679d73..23f5a8f78 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -15,7 +15,6 @@ import System.Directory import System.IO import Control.Monad import Data.List -import Data.String.Utils import Utility.PartialPrelude import Utility.Directory @@ -42,13 +41,13 @@ installLibs appbase libmap = do (needlibs, libmap') <- otool appbase libmap libs <- forM needlibs $ \lib -> do let shortlib = fromMaybe (error "internal") (M.lookup lib libmap') - let fulllib = replace "/" "_" lib + let fulllib = dropWhile (== '/') lib let dest = appbase fulllib let symdest = appbase shortlib ifM (doesFileExist dest) ( return Nothing , do - createDirectoryIfMissing True appbase + createDirectoryIfMissing True (parentDir fulllib) putStrLn $ "installing " ++ lib ++ " as " ++ shortlib _ <- boolSystem "cp" [File lib, File dest] _ <- boolSystem "chmod" [Param "644", File dest] -- cgit v1.2.3 From b10d1fe182a9fbe2f02938dc7eb5381795580edd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 9 Dec 2012 13:45:51 -0400 Subject: typo --- Build/OSXMkLibs.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Build/OSXMkLibs.hs') diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index 23f5a8f78..a3448b563 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -47,7 +47,7 @@ installLibs appbase libmap = do ifM (doesFileExist dest) ( return Nothing , do - createDirectoryIfMissing True (parentDir fulllib) + createDirectoryIfMissing True (parentDir dest) putStrLn $ "installing " ++ lib ++ " as " ++ shortlib _ <- boolSystem "cp" [File lib, File dest] _ <- boolSystem "chmod" [Param "644", File dest] -- cgit v1.2.3