Skip to content

Commit

Permalink
[Git] Create git shell driver for macOS
Browse files Browse the repository at this point in the history
Co-authored-by: Elliot Saba <[email protected]>
  • Loading branch information
giordano and staticfloat committed Feb 16, 2023
1 parent 33f854f commit aa64caa
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions G/Git/build_tarballs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ make install INSTALL_SYMLINKS="yes, please"
# environment variable `DYLD_FALLBACK_LIBRARY_PATH` is reset. We work around this
# limitation by re-exporting `DYLD_FALLBACK_LIBRARY_PATH` through another environment
# variable called `JLL_DYLD_FALLBACK_LIBRARY_PATH` which won't be reset by SIP.
# Read more about the issue and the hacks we apply here at
# <https://github.com/JuliaVersionControl/Git.jl/issues/40>.
if [[ "${target}" == *-apple-* ]]; then
for file in $(grep -l -r '^#!/bin/sh' "${prefix}"); do
if [[ $(basename "${file}") == git* ]]; then
Expand All @@ -70,6 +72,20 @@ if [[ "${target}" == *-apple-* ]]; then
sed -i -e 's?^#!/usr/bin/perl?#!/usr/bin/perl\n$ENV{'DYLD_FALLBACK_LIBRARY_PATH'} = $ENV{'JLL_DYLD_FALLBACK_LIBRARY_PATH'};?' "${file}"
fi
done
# Rename the `git` binary executable
mv "${bindir}/git" "${bindir}/_git"
# Create a shell driver called `git` which re-exports `DYLD_FALLBACK_LIBRARY_PATH` for us
cat > "${bindir}/git" << 'EOF'
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- $(readlink -f "${BASH_SOURCE[0]}") )" &> /dev/null && pwd )
export DYLD_FALLBACK_LIBRARY_PATH="${JLL_DYLD_FALLBACK_LIBRARY_PATH}"
exec -a "${BASH_SOURCE[0]}" "${SCRIPT_DIR}/_git" "$@"
EOF
chmod +x "${bindir}/git"
fi
"""

Expand Down

0 comments on commit aa64caa

Please sign in to comment.