diff --git a/Build/Standalone.hs b/Build/Standalone.hs index f11d64993d..9bd5c1c0ee 100644 --- a/Build/Standalone.hs +++ b/Build/Standalone.hs @@ -1,6 +1,6 @@ {- Makes standalone bundle. - - - Copyright 2012 Joey Hess + - Copyright 2012-2019 Joey Hess - - Licensed under the GNU AGPL version 3 or higher. -} @@ -12,10 +12,12 @@ module Main where import Control.Monad.IfElse import System.Environment import System.FilePath +import System.Posix.Files import Control.Monad import Build.BundledPrograms import Utility.SafeCommand +import Utility.Process import Utility.Path import Utility.Directory @@ -39,6 +41,56 @@ installProg dir prog = searchPath prog >>= go error $ "install failed for " ++ prog return (dest, f) +installGitLibs :: FilePath -> IO () +installGitLibs topdir = do + -- install git-core programs; these are run by the git command + createDirectoryIfMissing True gitcoredestdir + execpath <- getgitpath "exec-path" + cfs <- dirContents execpath + forM_ cfs $ \f -> do + destf <- (gitcoredestdir ) + <$> relPathDirToFile execpath f + createDirectoryIfMissing True (takeDirectory destf) + issymlink <- isSymbolicLink <$> getFileStatus f + if issymlink + then do + -- many git-core files may symlink to eg + -- ../../git. The link targets are put + -- into a subdirectory so all links to + -- .../git get the same binary. + linktarget <- readSymbolicLink f + let linktarget' = gitcoredestdir "bin" takeFileName linktarget + createDirectoryIfMissing True (takeDirectory linktarget') + createSymbolicLink linktarget' destf + else cp f destf + + -- install git's template files + -- git does not have an option to get the path of these, + -- but they're architecture independent files, so are located + -- next to the --man-path, in eg /usr/share/git-core + manpath <- getgitpath "man-path" + let templatepath = manpath ".." "git-core" "templates" + tfs <- dirContents templatepath + forM_ tfs $ \f -> do + destf <- (templatedestdir ) + <$> relPathDirToFile templatepath f + createDirectoryIfMissing True (takeDirectory destf) + cp f destf + where + gitcoredestdir = topdir "git-core" + templatedestdir = topdir "templates" + + getgitpath v = do + let opt = "--" ++ v + ls <- lines <$> readProcess "git" [opt] + case ls of + [] -> error $ "git " ++ opt ++ "did not output a location" + (p:_) -> return p + + cp src dest = + unlessM (boolSystem "cp" [Param "-a", File src, File dest]) $ + error "cp failed" + main :: IO () main = getArgs >>= go where @@ -50,3 +102,4 @@ main = getArgs >>= go createDirectoryIfMissing True dir forM progs $ installProg dir writeFile "tmp/standalone-installed" (show (concat installed)) + installGitLibs topdir diff --git a/CHANGELOG b/CHANGELOG index 81d32398cd..9402d2bc55 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,8 @@ git-annex (7.20191011) UNRELEASED; urgency=medium of hard-coded key value to be used, so probably nothing will be affected. * forget --drop-dead: Remove several classes of git-annex log files when they become empty, further reducing the size of the git-annex branch. + * OSX: Deal with symbolic link problem that caused git to not be included in + the git-annex.dmg. -- Joey Hess Thu, 19 Sep 2019 11:11:19 -0400 diff --git a/Makefile b/Makefile index e07faa35a8..27e5184fb7 100644 --- a/Makefile +++ b/Makefile @@ -162,10 +162,6 @@ linuxstandalone: ./Build/Standalone "$(LINUXSTANDALONE_DEST)" - install -d "$(LINUXSTANDALONE_DEST)/git-core" - (cd "$(shell git --exec-path)" && tar c .) | (cd "$(LINUXSTANDALONE_DEST)"/git-core && tar x) - install -d "$(LINUXSTANDALONE_DEST)/templates" - (cd "$(shell git --man-path)"/../git-core/templates && tar c .) | (cd "$(LINUXSTANDALONE_DEST)"/templates && tar x) install -d "$(LINUXSTANDALONE_DEST)/magic" cp /usr/share/file/magic.mgc "$(LINUXSTANDALONE_DEST)/magic" cp /usr/share/i18n -a "$(LINUXSTANDALONE_DEST)" @@ -231,9 +227,6 @@ osxapp: ./Build/Standalone $(OSXAPP_BASE) - (cd "$(shell git --exec-path)" && tar c .) | (cd "$(OSXAPP_BASE)" && tar x) - install -d "$(OSXAPP_BASE)/templates" - (cd "$(shell git --man-path)"/../git-core/templates && tar c .) | (cd "$(OSXAPP_BASE)"/templates && tar x) install -d "$(OSXAPP_BASE)/magic" if [ -e "$(OSX_MAGIC_FILE)" ]; then \ cp "$(OSX_MAGIC_FILE)" "$(OSXAPP_BASE)/magic/magic.mgc"; \