Skip to content

Commit 2c1097a

Browse files
aschmolckzimbatm
authored andcommittedJul 11, 2017
git: add missing deps for filter-branch etc (#27221)
Several git commands are implemented as shell scripts that run awk, sed, grep and perl. There is some existing patching in the postinstall for perl to rewrite it to an absolute reference to pkgs.perl, but several other packages are both missing as a dependency and have no rewrite logic. In particular git filter-branch depends on sed and grep. Additionally, the perl logic also seds git-am, which is now a binary not a shell script anymore (see <github.com/git/git/blob/master/builtin/am.c>), so this part was obsolete. I tested this by grepping all shell scripts for the relevant commands and then comparing the diffs of the new version to what is produced in master. All changes in the scripts seem good to me.
1 parent c725924 commit 2c1097a

File tree

1 file changed

+20
-6
lines changed
  • pkgs/applications/version-management/git-and-tools/git

1 file changed

+20
-6
lines changed
 

‎pkgs/applications/version-management/git-and-tools/git/default.nix

+20-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{ fetchurl, stdenv, curl, openssl, zlib, expat, perl, python, gettext, cpio
2-
, gnugrep, gzip, openssh
2+
, gnugrep, gnused, gawk, coreutils # needed at runtime by git-filter-branch etc
3+
, gzip, openssh
34
, asciidoc, texinfo, xmlto, docbook2x, docbook_xsl, docbook_xml_dtd_45
45
, libxslt, tcl, tk, makeWrapper, libiconv
56
, svnSupport, subversionClient, perlLibs, smtpPerlLibs, gitwebPerlLibs
@@ -104,11 +105,24 @@ stdenv.mkDerivation {
104105
--replace ' grep' ' ${gnugrep}/bin/grep' \
105106
--replace ' egrep' ' ${gnugrep}/bin/egrep'
106107
107-
# Fix references to the perl binary. Note that the tab character
108-
# in the patterns is important.
109-
sed -i -e 's| perl -ne| ${perl}/bin/perl -ne|g' \
110-
-e 's| perl -e| ${perl}/bin/perl -e|g' \
111-
$out/libexec/git-core/{git-am,git-submodule}
108+
# Fix references to the perl, sed, awk and various coreutil binaries used by
109+
# shell scripts that git calls (e.g. filter-branch)
110+
SCRIPT="$(cat <<'EOS'
111+
BEGIN{
112+
@a=(
113+
'${perl}/bin/perl', '${gnugrep}/bin/grep', '${gnused}/bin/sed', '${gawk}/bin/awk',
114+
'${coreutils}/bin/cut', '${coreutils}/bin/basename', '${coreutils}/bin/dirname',
115+
'${coreutils}/bin/wc', '${coreutils}/bin/tr'
116+
);
117+
}
118+
foreach $c (@a) {
119+
$n=(split("/", $c))[-1];
120+
s|(?<=[^#][^/.-])\b''${n}(?=\s)|''${c}|g
121+
}
122+
EOS
123+
)"
124+
perl -0777 -i -pe "$SCRIPT" \
125+
$out/libexec/git-core/git-{sh-setup,filter-branch,merge-octopus,mergetool,quiltimport,request-pull,stash,submodule,subtree,web--browse}
112126
113127
# Fix references to gettext.
114128
substituteInPlace $out/libexec/git-core/git-sh-i18n \

0 commit comments

Comments
 (0)