use install_name_tool to adjust library paths in osx app
Have not yet been able to test this.
This commit is contained in:
parent
1108430c45
commit
1dd386903b
3 changed files with 34 additions and 15 deletions
|
@ -47,11 +47,15 @@ installLibs appbase = do
|
||||||
return $ Just libdir
|
return $ Just libdir
|
||||||
)
|
)
|
||||||
|
|
||||||
|
{- Returns libraries to install. -}
|
||||||
otool :: FilePath -> IO [FilePath]
|
otool :: FilePath -> IO [FilePath]
|
||||||
otool appbase = do
|
otool appbase = do
|
||||||
files <- filterM doesFileExist =<< dirContentsRecursive appbase
|
files <- filterM doesFileExist =<< dirContentsRecursive appbase
|
||||||
s <- readProcess "otool" ("-L" : files)
|
l <- forM files $ \file -> do
|
||||||
return $ nub $ parseOtool s
|
libs <- parseOtool <$> readProcess "otool" ["-L", file]
|
||||||
|
forM_ libs $ \lib -> install_name_tool file lib
|
||||||
|
return libs
|
||||||
|
return $ nub $ concat l
|
||||||
|
|
||||||
parseOtool :: String -> [FilePath]
|
parseOtool :: String -> [FilePath]
|
||||||
parseOtool = catMaybes . map parse . lines
|
parseOtool = catMaybes . map parse . lines
|
||||||
|
@ -60,6 +64,22 @@ parseOtool = catMaybes . map parse . lines
|
||||||
| "\t" `isPrefixOf` l = headMaybe $ words l
|
| "\t" `isPrefixOf` l = headMaybe $ words l
|
||||||
| otherwise = Nothing
|
| 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. -}
|
||||||
|
install_name_tool :: FilePath -> FilePath -> IO ()
|
||||||
|
install_name_tool binary lib = do
|
||||||
|
ok <- boolSystem "install_name_tool"
|
||||||
|
[ Param "-change"
|
||||||
|
, File lib
|
||||||
|
, Param $ "@executable_path" ++ lib
|
||||||
|
, File binary
|
||||||
|
]
|
||||||
|
unless ok $
|
||||||
|
hPutStrLn stderr $ "install_name_tool failed for " ++ binary
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = getArgs >>= go
|
main = getArgs >>= go
|
||||||
where
|
where
|
||||||
|
|
13
Makefile
13
Makefile
|
@ -192,19 +192,18 @@ osxapp:
|
||||||
install -d $(GIT_ANNEX_TMP_BUILD_DIR)/build-dmg
|
install -d $(GIT_ANNEX_TMP_BUILD_DIR)/build-dmg
|
||||||
cp -R standalone/osx/git-annex.app "$(OSXAPP_DEST)"
|
cp -R standalone/osx/git-annex.app "$(OSXAPP_DEST)"
|
||||||
|
|
||||||
install -d "$(OSXAPP_BASE)/bin"
|
install -d "$(OSXAPP_BASE)"
|
||||||
cp git-annex "$(OSXAPP_BASE)/bin/"
|
cp git-annex "$(OSXAPP_BASE)"
|
||||||
strip "$(OSXAPP_BASE)/bin/git-annex"
|
strip "$(OSXAPP_BASE)/git-annex"
|
||||||
ln -sf git-annex "$(OSXAPP_BASE)/bin/git-annex-shell"
|
ln -sf git-annex "$(OSXAPP_BASE)/git-annex-shell"
|
||||||
gzcat standalone/licences.gz > $(OSXAPP_BASE)/LICENSE
|
gzcat standalone/licences.gz > $(OSXAPP_BASE)/LICENSE
|
||||||
cp $(OSXAPP_BASE)/LICENSE $(GIT_ANNEX_TMP_BUILD_DIR)/build-dmg/LICENSE.txt
|
cp $(OSXAPP_BASE)/LICENSE $(GIT_ANNEX_TMP_BUILD_DIR)/build-dmg/LICENSE.txt
|
||||||
|
|
||||||
for bin in $(THIRDPARTY_BINS); do \
|
for bin in $(THIRDPARTY_BINS); do \
|
||||||
cp "$$(which "$$bin")" "$(OSXAPP_BASE)/bin/"; \
|
cp "$$(which "$$bin")" "$(OSXAPP_BASE)"; \
|
||||||
done
|
done
|
||||||
|
|
||||||
install -d "$(OSXAPP_BASE)/git-core"
|
(cd "$(shell git --exec-path)" && tar c .) | (cd "$(OSXAPP_BASE)" && tar x)
|
||||||
(cd "$(shell git --exec-path)" && tar c .) | (cd "$(OSXAPP_BASE)"/git-core && tar x)
|
|
||||||
|
|
||||||
runghc Build/OSXMkLibs.hs $(OSXAPP_BASE)
|
runghc Build/OSXMkLibs.hs $(OSXAPP_BASE)
|
||||||
rm -f tmp/git-annex.dmg
|
rm -f tmp/git-annex.dmg
|
||||||
|
|
|
@ -55,18 +55,18 @@ export PATH
|
||||||
# different versions of a single library. And it seems to work better
|
# different versions of a single library. And it seems to work better
|
||||||
# than DYLD_FALLBACK_LIBRARY_PATH, which fails to override old system
|
# than DYLD_FALLBACK_LIBRARY_PATH, which fails to override old system
|
||||||
# versions of libraries when a program in the app needs a newer version.
|
# versions of libraries when a program in the app needs a newer version.
|
||||||
ORIG_DYLD_ROOT_PATH="$DYLD_ROOT_PATH"
|
#ORIG_DYLD_ROOT_PATH="$DYLD_ROOT_PATH"
|
||||||
export ORIG_DYLD_ROOT_PATH
|
#export ORIG_DYLD_ROOT_PATH
|
||||||
DYLD_ROOT_PATH=$base
|
#DYLD_ROOT_PATH=$base
|
||||||
export DYLD_ROOT_PATH
|
#export DYLD_ROOT_PATH
|
||||||
|
|
||||||
ORIG_GIT_EXEC_PATH="$GIT_EXEC_PATH"
|
ORIG_GIT_EXEC_PATH="$GIT_EXEC_PATH"
|
||||||
export ORIG_GIT_EXEC_PATH
|
export ORIG_GIT_EXEC_PATH
|
||||||
GIT_EXEC_PATH=$base/git-core
|
GIT_EXEC_PATH=$base
|
||||||
export GIT_EXEC_PATH
|
export GIT_EXEC_PATH
|
||||||
|
|
||||||
# Indicate which variables were exported above.
|
# Indicate which variables were exported above.
|
||||||
GIT_ANNEX_STANDLONE_ENV="PATH DYLD_ROOT_PATH GIT_EXEC_PATH"
|
GIT_ANNEX_STANDLONE_ENV="PATH GIT_EXEC_PATH"
|
||||||
export GIT_ANNEX_STANDLONE_ENV
|
export GIT_ANNEX_STANDLONE_ENV
|
||||||
|
|
||||||
if [ "$1" ]; then
|
if [ "$1" ]; then
|
||||||
|
|
Loading…
Reference in a new issue