Skip to content

Commit b11c0b1

Browse files
committed
Fixed fatal error: sys/random.h: No such file or directory
When building git dependency on redhat 7 with git v2.50 we get a compilation error due to the include of a missing file. ``` 15:05:27 + make CURL_LDFLAGS=-lcurl 15:05:28 GIT_VERSION=2.50.0 15:05:28 * new build flags 15:05:28 CC daemon.o 15:05:28 In file included from git-compat-util.h:26:0, 15:05:28 from daemon.c:3: 15:05:28 compat/posix.h:159:24: fatal error: sys/random.h: No such file or directory 15:05:28 #include <sys/random.h> 15:05:28 ^ 15:05:28 compilation terminated. ``` Signed-off-by: Lars Erik Wik <[email protected]>
1 parent f6917dc commit b11c0b1

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

deps-packaging/git/cfbuild-git.spec

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ mkdir -p %{_builddir}
2222

2323
%build
2424

25+
case "$OS" in
26+
rhel|centos)
27+
if [ $(echo $OS_VERSION | cut -d. -f1) = 7 ]
28+
then
29+
# Fixes the following compilation error on rhel 7:
30+
# 15:05:28 compat/posix.h:159:24: fatal error: sys/random.h: No such file or directory
31+
# 15:05:28 #include <sys/random.h>
32+
# 15:05:28 ^
33+
# 15:05:28 compilation terminated.
34+
patch -p1 < %{_topdir}/SOURCES/fix_git_on_rhel7.patch
35+
fi
36+
;;
37+
esac
38+
2539
make CURL_LDFLAGS="-lcurl"
2640

2741
%install
@@ -67,7 +81,3 @@ CFEngine Build Automation -- git
6781
%{prefix}/lib/git-core
6882

6983
%changelog
70-
71-
72-
73-
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff -ruN git-2.50.0/compat/posix.h git-2.50.0-modified/compat/posix.h
2+
--- git-2.50.0/compat/posix.h 2025-06-16 07:42:57.000000000 +0200
3+
+++ git-2.50.0-modified/compat/posix.h 2025-06-24 13:40:42.044059021 +0200
4+
@@ -155,9 +155,9 @@
5+
#ifdef HAVE_ARC4RANDOM_LIBBSD
6+
#include <bsd/stdlib.h>
7+
#endif
8+
-#ifdef HAVE_GETRANDOM
9+
-#include <sys/random.h>
10+
-#endif
11+
+// #ifdef HAVE_GETRANDOM
12+
+// #include <sys/random.h>
13+
+// #endif
14+
#ifdef NO_INTPTR_T
15+
/*
16+
* On I16LP32, ILP32 and LP64 "long" is the safe bet, however

0 commit comments

Comments
 (0)