OSX: Deal with symbolic link problem that caused git to not be included in the git-annex.dmg
Homebrew now has eg: datalads-imac:~ joey$ ls -l /Users/joey/homebrew/Cellar/git/2.23.0/libexec/git-core total 36776 lrwxr-xr-x 1 joey staff 13 Aug 29 13:38 git -> ../../bin/git lrwxr-xr-x 1 joey staff 13 Aug 29 13:38 git-add -> ../../bin/git So the target of the symlink also needs to be installed now. Doing it in shell code was too hairy for my dentistry-addled brain, so reimplemented in haskell. Also using it for building linuxstandalone.
This commit is contained in:
parent
bf7a22b812
commit
5463f97ca2
3 changed files with 56 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
|||
{- Makes standalone bundle.
|
||||
-
|
||||
- Copyright 2012 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2012-2019 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- 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
|
||||
|
|
|
@ -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 <id@joeyh.name> Thu, 19 Sep 2019 11:11:19 -0400
|
||||
|
||||
|
|
7
Makefile
7
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"; \
|
||||
|
|
Loading…
Reference in a new issue