•  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
r2 vs r3
1
나무위키 파서 개발하다 빡쳐서 쓴 내용들
2
13
{{{#!syntax diff
24
diff --git a/builtin/commit.c b/builtin/commit.c
35
index 2f45968222..25e26a2f70 100644
......
4951
error: 1 dependencies of derivation '/nix/store/hx9d5rydwzi4inqhbfi33azafafv7071-home-manager-path.drv' failed to build
5052
error: 1 dependencies of derivation '/nix/store/whrrhjd3lwjv6kj6j7smd3xx1h3b1d3l-home-manager-generation.drv' failed to build}}}
5153
54
근데 make test를 돌리려고 하는데 perl shebang이 hardcode되어있다.
55
56
{{{
57
{
58
fetchurl,
59
fetchpatch,
60
lib,
61
stdenv,
62
buildPackages,
63
curl,
64
openssl,
65
zlib,
66
expat,
67
perlPackages,
68
python3,
69
gettext,
70
cpio,
71
gnugrep,
72
gnused,
73
gawk,
74
coreutils, # needed at runtime by git-filter-branch etc
75
openssh,
76
pcre2,
77
bash,
78
asciidoc,
79
texinfo,
80
xmlto,
81
docbook2x,
82
docbook_xsl,
83
docbook_xml_dtd_45,
84
libxslt,
85
tcl,
86
tk,
87
makeWrapper,
88
libiconv,
89
libiconvReal,
90
svnSupport ? false,
91
subversionClient,
92
perlLibs,
93
smtpPerlLibs,
94
perlSupport ? stdenv.buildPlatform == stdenv.hostPlatform,
95
nlsSupport ? true,
96
osxkeychainSupport ? stdenv.hostPlatform.isDarwin,
97
guiSupport ? false,
98
withManual ? true,
99
pythonSupport ? true,
100
withpcre2 ? true,
101
sendEmailSupport ? perlSupport,
102
Security,
103
CoreServices,
104
nixosTests,
105
withLibsecret ? false,
106
pkg-config,
107
glib,
108
libsecret,
109
gzip, # needed at runtime by gitweb.cgi
110
withSsh ? false,
111
sysctl,
112
deterministic-host-uname, # trick Makefile into targeting the host platform when cross-compiling
113
doInstallCheck ? !stdenv.hostPlatform.isDarwin, # extremely slow on darwin
114
tests,
115
}:
116
117
assert osxkeychainSupport -> stdenv.hostPlatform.isDarwin;
118
assert sendEmailSupport -> perlSupport;
119
assert svnSupport -> perlSupport;
120
121
let
122
version = "2.47.2";
123
svn = subversionClient.override { perlBindings = perlSupport; };
124
gitwebPerlLibs = with perlPackages; [
125
CGI
126
HTMLParser
127
CGIFast
128
FCGI
129
FCGIProcManager
130
HTMLTagCloud
131
];
132
in
133
134
stdenv.mkDerivation (finalAttrs: {
135
pname =
136
"git"
137
+ lib.optionalString svnSupport "-with-svn"
138
+ lib.optionalString (
139
!svnSupport && !guiSupport && !sendEmailSupport && !withManual && !pythonSupport && !withpcre2
140
) "-minimal";
141
inherit version;
142
143
src = fetchurl {
144
url = "https://www.kernel.org/pub/software/scm/git/git-${version}.tar.xz";
145
hash = "sha256-sZJovmtvFVa0ep3YNCcuFn06dXQM3NKDzzgS7f/jkw8=";
146
};
147
148
outputs = [ "out" ] ++ lib.optional withManual "doc";
149
separateDebugInfo = true;
150
151
hardeningDisable = [ "format" ];
152
153
enableParallelBuilding = true;
154
155
patches =
156
[
157
./docbook2texi.patch
158
./git-sh-i18n.patch
159
./git-send-email-honor-PATH.patch
160
./installCheck-path.patch
161
]
162
++ lib.optionals withSsh [
163
./ssh-path.patch
164
]
165
++ lib.optionals (guiSupport && stdenv.hostPlatform.isDarwin) [
166
# Needed to workaround an issue in macOS where gitk shows a empty window
167
# https://github.com/Homebrew/homebrew-core/issues/68798
168
# https://github.com/git/git/pull/944
169
(fetchpatch {
170
name = "gitk_check_main_window_visibility_before_waiting_for_it_to_show.patch";
171
url = "https://github.com/git/git/commit/1db62e44b7ec93b6654271ef34065b31496cd02e.patch";
172
hash = "sha256-ntvnrYFFsJ1Ebzc6vM9/AMFLHMS1THts73PIOG5DkQo=";
173
})
174
];
175
176
postPatch =
177
''
178
# Fix references to gettext introduced by ./git-sh-i18n.patch
179
substituteInPlace git-sh-i18n.sh \
180
--subst-var-by gettext ${gettext}
181
182
# ensure we are using the correct shell when executing the test scripts
183
patchShebangs t/*.sh
184
''
185
+ lib.optionalString withSsh ''
186
for x in connect.c git-gui/lib/remote_add.tcl ; do
187
substituteInPlace "$x" \
188
--subst-var-by ssh "${openssh}/bin/ssh"
189
done
190
'';
191
192
nativeBuildInputs =
193
[
194
deterministic-host-uname
195
gettext
196
perlPackages.perl
197
makeWrapper
198
pkg-config
199
]
200
++ lib.optionals withManual [
201
asciidoc
202
texinfo
203
xmlto
204
docbook2x
205
docbook_xsl
206
docbook_xml_dtd_45
207
libxslt
208
];
209
buildInputs =
210
[
211
curl
212
openssl
213
zlib
214
expat
215
cpio
216
(if stdenv.hostPlatform.isFreeBSD then libiconvReal else libiconv)
217
bash
218
]
219
++ lib.optionals perlSupport [ perlPackages.perl ]
220
++ lib.optionals guiSupport [
221
tcl
222
tk
223
]
224
++ lib.optionals withpcre2 [ pcre2 ]
225
++ lib.optionals stdenv.hostPlatform.isDarwin [
226
Security
227
CoreServices
228
]
229
++ lib.optionals withLibsecret [
230
glib
231
libsecret
232
];
233
234
# required to support pthread_cancel()
235
NIX_LDFLAGS =
236
lib.optionalString (stdenv.cc.isGNU && stdenv.hostPlatform.libc == "glibc") "-lgcc_s"
237
+ lib.optionalString (stdenv.hostPlatform.isFreeBSD) "-lthr";
238
239
configureFlags =
240
[
241
"ac_cv_prog_CURL_CONFIG=${lib.getDev curl}/bin/curl-config"
242
]
243
++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
244
"ac_cv_fread_reads_directories=yes"
245
"ac_cv_snprintf_returns_bogus=no"
246
"ac_cv_iconv_omits_bom=no"
247
];
248
249
preBuild = ''
250
makeFlagsArray+=( perllibdir=$out/$(perl -MConfig -wle 'print substr $Config{installsitelib}, 1 + length $Config{siteprefixexp}') )
251
'';
252
253
makeFlags =
254
[
255
"prefix=\${out}"
256
]
257
# Git does not allow setting a shell separately for building and run-time.
258
# Therefore lets leave it at the default /bin/sh when cross-compiling
259
++ lib.optional (stdenv.buildPlatform == stdenv.hostPlatform) "SHELL_PATH=${stdenv.shell}"
260
++ (if perlSupport then [ "PERL_PATH=${perlPackages.perl}/bin/perl" ] else [ "NO_PERL=1" ])
261
++ (if pythonSupport then [ "PYTHON_PATH=${python3}/bin/python" ] else [ "NO_PYTHON=1" ])
262
++ lib.optionals stdenv.hostPlatform.isSunOS [
263
"INSTALL=install"
264
"NO_INET_NTOP="
265
"NO_INET_PTON="
266
]
267
++ (if stdenv.hostPlatform.isDarwin then [ "NO_APPLE_COMMON_CRYPTO=1" ] else [ "sysconfdir=/etc" ])
268
++ lib.optionals stdenv.hostPlatform.isMusl [
269
"NO_SYS_POLL_H=1"
270
"NO_GETTEXT=YesPlease"
271
]
272
++ lib.optional withpcre2 "USE_LIBPCRE2=1"
273
++ lib.optional (!nlsSupport) "NO_GETTEXT=1"
274
# git-gui refuses to start with the version of tk distributed with
275
# macOS Catalina. We can prevent git from building the .app bundle
276
# by specifying an invalid tk framework. The postInstall step will
277
# then ensure that git-gui uses tcl/tk from nixpkgs, which is an
278
# acceptable version.
279
#
280
# See https://github.com/Homebrew/homebrew-core/commit/dfa3ccf1e7d3901e371b5140b935839ba9d8b706
281
++ lib.optional stdenv.hostPlatform.isDarwin "TKFRAMEWORK=/nonexistent";
282
283
disallowedReferences = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
284
stdenv.shellPackage
285
];
286
287
postBuild =
288
''
289
make -C contrib/subtree
290
''
291
+ (lib.optionalString perlSupport ''
292
make -C contrib/diff-highlight
293
'')
294
+ (lib.optionalString osxkeychainSupport ''
295
make -C contrib/credential/osxkeychain
296
'')
297
+ (lib.optionalString withLibsecret ''
298
make -C contrib/credential/libsecret
299
'');
300
301
## Install
302
303
# WARNING: Do not `rm` or `mv` files from the source tree; use `cp` instead.
304
# We need many of these files during the installCheckPhase.
305
306
installFlags = [ "NO_INSTALL_HARDLINKS=1" ];
307
308
preInstall =
309
(lib.optionalString osxkeychainSupport ''
310
mkdir -p $out/bin
311
ln -s $out/share/git/contrib/credential/osxkeychain/git-credential-osxkeychain $out/bin/
312
rm -f $PWD/contrib/credential/osxkeychain/git-credential-osxkeychain.o
313
'')
314
+ (lib.optionalString withLibsecret ''
315
mkdir -p $out/bin
316
ln -s $out/share/git/contrib/credential/libsecret/git-credential-libsecret $out/bin/
317
rm -f $PWD/contrib/credential/libsecret/git-credential-libsecret.o
318
'');
319
320
postInstall =
321
''
322
notSupported() {
323
unlink $1 || true
324
}
325
326
# Install git-subtree.
327
make -C contrib/subtree install ${lib.optionalString withManual "install-doc"}
328
rm -rf contrib/subtree
329
330
# Install contrib stuff.
331
mkdir -p $out/share/git
332
cp -a contrib $out/share/git/
333
mkdir -p $out/share/bash-completion/completions
334
ln -s $out/share/git/contrib/completion/git-completion.bash $out/share/bash-completion/completions/git
335
ln -s $out/share/git/contrib/completion/git-prompt.sh $out/share/bash-completion/completions/
336
# only readme, developed in another repo
337
rm -r contrib/hooks/multimail
338
mkdir -p $out/share/git-core/contrib
339
cp -a contrib/hooks/ $out/share/git-core/contrib/
340
substituteInPlace $out/share/git-core/contrib/hooks/pre-auto-gc-battery \
341
--replace ' grep' ' ${gnugrep}/bin/grep' \
342
343
# grep is a runtime dependency, need to patch so that it's found
344
substituteInPlace $out/libexec/git-core/git-sh-setup \
345
--replace ' grep' ' ${gnugrep}/bin/grep' \
346
--replace ' egrep' ' ${gnugrep}/bin/egrep'
347
348
# Fix references to the perl, sed, awk and various coreutil binaries used by
349
# shell scripts that git calls (e.g. filter-branch)
350
SCRIPT="$(cat <<'EOS'
351
BEGIN{
352
@a=(
353
'${gnugrep}/bin/grep', '${gnused}/bin/sed', '${gawk}/bin/awk',
354
'${coreutils}/bin/cut', '${coreutils}/bin/basename', '${coreutils}/bin/dirname',
355
'${coreutils}/bin/wc', '${coreutils}/bin/tr'
356
${lib.optionalString perlSupport ", '${perlPackages.perl}/bin/perl'"}
357
);
358
}
359
foreach $c (@a) {
360
$n=(split("/", $c))[-1];
361
s|(?<=[^#][^/.-])\b''${n}(?=\s)|''${c}|g
362
}
363
EOS
364
)"
365
perl -0777 -i -pe "$SCRIPT" \
366
$out/libexec/git-core/git-{sh-setup,filter-branch,merge-octopus,mergetool,quiltimport,request-pull,submodule,subtree,web--browse}
367
368
369
# Also put git-http-backend into $PATH, so that we can use smart
370
# HTTP(s) transports for pushing
371
ln -s $out/libexec/git-core/git-http-backend $out/bin/git-http-backend
372
ln -s $out/share/git/contrib/git-jump/git-jump $out/bin/git-jump
373
''
374
+ lib.optionalString perlSupport ''
375
# wrap perl commands
376
makeWrapper "$out/share/git/contrib/credential/netrc/git-credential-netrc.perl" $out/bin/git-credential-netrc \
377
--set PERL5LIB "$out/${perlPackages.perl.libPrefix}:${perlPackages.makePerlPath perlLibs}"
378
wrapProgram $out/libexec/git-core/git-cvsimport \
379
--set GITPERLLIB "$out/${perlPackages.perl.libPrefix}:${perlPackages.makePerlPath perlLibs}"
380
wrapProgram $out/libexec/git-core/git-archimport \
381
--set GITPERLLIB "$out/${perlPackages.perl.libPrefix}:${perlPackages.makePerlPath perlLibs}"
382
wrapProgram $out/libexec/git-core/git-instaweb \
383
--set GITPERLLIB "$out/${perlPackages.perl.libPrefix}:${perlPackages.makePerlPath perlLibs}"
384
wrapProgram $out/libexec/git-core/git-cvsexportcommit \
385
--set GITPERLLIB "$out/${perlPackages.perl.libPrefix}:${perlPackages.makePerlPath perlLibs}"
386
387
# gzip (and optionally bzip2, xz, zip) are runtime dependencies for
388
# gitweb.cgi, need to patch so that it's found
389
sed -i -e "s|'compressor' => \['gzip'|'compressor' => ['${gzip}/bin/gzip'|" \
390
$out/share/gitweb/gitweb.cgi
391
# Give access to CGI.pm and friends (was removed from perl core in 5.22)
392
for p in ${lib.concatStringsSep " " gitwebPerlLibs}; do
393
sed -i -e "/use CGI /i use lib \"$p/${perlPackages.perl.libPrefix}\";" \
394
"$out/share/gitweb/gitweb.cgi"
395
done
396
''
397
398
+ (
399
if svnSupport then
400
''
401
# wrap git-svn
402
wrapProgram $out/libexec/git-core/git-svn \
403
--set GITPERLLIB "$out/${perlPackages.perl.libPrefix}:${
404
perlPackages.makePerlPath (perlLibs ++ [ svn.out ])
405
}" \
406
--prefix PATH : "${svn.out}/bin"
407
''
408
else
409
''
410
# replace git-svn by notification script
411
notSupported $out/libexec/git-core/git-svn
412
''
413
)
414
415
+ (
416
if sendEmailSupport then
417
''
418
# wrap git-send-email
419
wrapProgram $out/libexec/git-core/git-send-email \
420
--set GITPERLLIB "$out/${perlPackages.perl.libPrefix}:${perlPackages.makePerlPath smtpPerlLibs}"
421
''
422
else
423
''
424
# replace git-send-email by notification script
425
notSupported $out/libexec/git-core/git-send-email
426
''
427
)
428
429
+ lib.optionalString withManual ''
430
# Install man pages
431
make -j $NIX_BUILD_CORES PERL_PATH="${buildPackages.perl}/bin/perl" cmd-list.made install install-html \
432
-C Documentation
433
''
434
435
+ (
436
if guiSupport then
437
''
438
# Wrap Tcl/Tk programs
439
for prog in bin/gitk libexec/git-core/{git-gui,git-citool,git-gui--askpass}; do
440
sed -i -e "s|exec 'wish'|exec '${tk}/bin/wish'|g" \
441
-e "s|exec wish|exec '${tk}/bin/wish'|g" \
442
"$out/$prog"
443
done
444
ln -s $out/share/git/contrib/completion/git-completion.bash $out/share/bash-completion/completions/gitk
445
''
446
else
447
''
448
# Don't wrap Tcl/Tk, replace them by notification scripts
449
for prog in bin/gitk libexec/git-core/git-gui; do
450
notSupported "$out/$prog"
451
done
452
''
453
)
454
+ lib.optionalString osxkeychainSupport ''
455
# enable git-credential-osxkeychain on darwin if desired (default)
456
mkdir -p $out/etc
457
cat > $out/etc/gitconfig << EOF
458
[credential]
459
helper = osxkeychain
460
EOF
461
'';
462
463
## InstallCheck
464
465
doCheck = false;
466
inherit doInstallCheck;
467
468
installCheckTarget = "test";
469
470
# see also installCheckFlagsArray
471
installCheckFlags = [
472
"DEFAULT_TEST_TARGET=prove"
473
"PERL_PATH=${buildPackages.perl}/bin/perl"
474
];
475
476
nativeInstallCheckInputs = lib.optional (
477
stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isFreeBSD
478
) sysctl;
479
480
preInstallCheck =
481
''
482
installCheckFlagsArray+=(
483
GIT_PROVE_OPTS="--jobs $NIX_BUILD_CORES --failures --state=failed,save"
484
GIT_TEST_INSTALLED=$out/bin
485
${lib.optionalString (!svnSupport) "NO_SVN_TESTS=y"}
486
)
487
488
function disable_test {
489
local test=$1 pattern=$2
490
if [ $# -eq 1 ]; then
491
mv t/{,skip-}$test.sh || true
492
else
493
sed -i t/$test.sh \
494
-e "/^\s*test_expect_.*$pattern/,/^\s*' *\$/{s/^/: #/}"
495
fi
496
}
497
498
# Shared permissions are forbidden in sandbox builds:
499
substituteInPlace t/test-lib.sh \
500
--replace "test_set_prereq POSIXPERM" ""
501
# TODO: Investigate while these still fail (without POSIXPERM):
502
# Tested to fail: 2.46.0
503
disable_test t0001-init 'shared overrides system'
504
# Tested to fail: 2.46.0
505
disable_test t0001-init 'init honors global core.sharedRepository'
506
# Tested to fail: 2.46.0
507
disable_test t1301-shared-repo
508
# /build/git-2.44.0/contrib/completion/git-completion.bash: line 452: compgen: command not found
509
disable_test t9902-completion
510
511
# Our patched gettext never fallbacks
512
disable_test t0201-gettext-fallbacks
513
''
514
+ lib.optionalString (!sendEmailSupport) ''
515
# Disable sendmail tests
516
disable_test t9001-send-email
517
''
518
+ ''
519
# Flaky tests:
520
disable_test t6421-merge-partial-clone
521
522
# Fails reproducibly on ZFS on Linux with formD normalization
523
disable_test t0021-conversion
524
disable_test t3910-mac-os-precompose
525
''
526
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
527
# XXX: Some tests added in 2.24.0 fail.
528
# Please try to re-enable on the next release.
529
disable_test t7816-grep-binary-pattern
530
# fail (as of 2.33.0)
531
#===( 18623;1208 8/? 224/? 2/? )= =fatal: Not a valid object name refs/tags/signed-empty
532
disable_test t6300-for-each-ref
533
# not ok 1 - populate workdir (with 2.33.1 on x86_64-darwin)
534
disable_test t5003-archive-zip
535
''
536
+ lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) ''
537
disable_test t7527-builtin-fsmonitor
538
''
539
+ lib.optionalString stdenv.hostPlatform.isMusl ''
540
# Test fails (as of 2.17.0, musl 1.1.19)
541
disable_test t3900-i18n-commit
542
# Fails largely due to assumptions about BOM
543
# Tested to fail: 2.18.0
544
disable_test t0028-working-tree-encoding
545
'';
546
547
stripDebugList = [
548
"lib"
549
"libexec"
550
"bin"
551
"share/git/contrib/credential/libsecret"
552
];
553
554
passthru = {
555
shellPath = "/bin/git-shell";
556
tests = {
557
withInstallCheck = finalAttrs.finalPackage.overrideAttrs (_: {
558
doInstallCheck = true;
559
});
560
buildbot-integration = nixosTests.buildbot;
561
} // tests.fetchgit;
562
updateScript = ./update.sh;
563
};
564
565
meta = {
566
homepage = "https://git-scm.com/";
567
description = "Distributed version control system";
568
license = lib.licenses.gpl2;
569
changelog = "https://github.com/git/git/blob/v${version}/Documentation/RelNotes/${version}.txt";
570
571
longDescription = ''
572
Git, a popular distributed version control system designed to
573
handle very large projects with speed and efficiency.
574
'';
575
576
platforms = lib.platforms.all;
577
maintainers = with lib.maintainers; [
578
primeos
579
wmertens
580
globin
581
kashw2
582
];
583
mainProgram = "git";
584
};
585
})
586
}}}
587
588
pkgs 원본 소스를 까봤는데 perlSupport 설정이 정신나갈 거 같다. 일단 그냥 symlink 강제로 박아서 해결할 듯.
589
52590
{{{#!syntax cpp
53591
struct delta_index {
54592
unsigned long memsize;
......