From 15d4219d2a4d2506a6283a9c5ef7958cced7c8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Thu, 16 Feb 2023 22:30:34 +0000 Subject: [PATCH] [Git] Create `git` shell driver for macOS --- G/Git/build_tarballs.jl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/G/Git/build_tarballs.jl b/G/Git/build_tarballs.jl index 10357de33be..10476d705f8 100644 --- a/G/Git/build_tarballs.jl +++ b/G/Git/build_tarballs.jl @@ -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 +# . if [[ "${target}" == *-apple-* ]]; then for file in $(grep -l -r '^#!/bin/sh' "${prefix}"); do if [[ $(basename "${file}") == git* ]]; then @@ -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 """