]> git.proxmox.com Git - libgit2.git/blob - debian/patches/reprotest.patch
Refresh d/patches
[libgit2.git] / debian / patches / reprotest.patch
1 From b85eefb4604d3ca6983bf80e7dc9d1cedde072fd Mon Sep 17 00:00:00 2001
2 From: Patrick Steinhardt <ps@pks.im>
3 Date: Fri, 15 May 2020 19:52:40 +0200
4 Subject: [PATCH] cmake: Sort source files for reproducible builds
5
6 We currently use `FILE(GLOB ...)` in most places to find source and
7 header files. This is problematic in that the order of files returned
8 depends on the operating system's directory iteration order and may thus
9 not be deterministic. As a result, we link object files in unspecified
10 order, which may cause the linker to emit different code across runs.
11
12 Fix this issue by sorting all code used as input to the libgit2 library
13 to improve the reliability of reproducible builds.
14
15 --- a/cmake/Modules/SelectHashes.cmake
16 +++ b/cmake/Modules/SelectHashes.cmake
17 @@ -66,4 +66,6 @@
18 MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend: ${SHA1_BACKEND}")
19 ENDIF()
20
21 +list(SORT SRC_SHA1)
22 +
23 ADD_FEATURE_INFO(SHA ON "using ${SHA1_BACKEND}")
24 --- a/src/CMakeLists.txt
25 +++ b/src/CMakeLists.txt
26 @@ -76,12 +76,13 @@
27 ADD_FEATURE_INFO(threadsafe THREADSAFE "threadsafe support")
28
29
30 -IF (WIN32 AND EMBED_SSH_PATH)
31 - FILE(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c")
32 - LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${EMBED_SSH_PATH}/include")
33 - FILE(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"")
34 - SET(GIT_SSH 1)
35 -ENDIF()
36 +if(WIN32 AND EMBED_SSH_PATH)
37 + file(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c")
38 + list(SORT SRC_SSH)
39 + list(APPEND LIBGIT2_SYSTEM_INCLUDES "${EMBED_SSH_PATH}/include")
40 + file(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"")
41 + set(GIT_SSH 1)
42 +endif()
43
44 IF (WIN32 AND WINHTTP)
45 SET(GIT_WINHTTP 1)
46 @@ -267,33 +268,38 @@
47 ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64)
48
49 # Collect sourcefiles
50 -FILE(GLOB SRC_H
51 +file(GLOB SRC_H
52 "${libgit2_SOURCE_DIR}/include/git2.h"
53 "${libgit2_SOURCE_DIR}/include/git2/*.h"
54 "${libgit2_SOURCE_DIR}/include/git2/sys/*.h")
55 +list(SORT SRC_H)
56
57 # On Windows use specific platform sources
58 -IF (WIN32 AND NOT CYGWIN)
59 - IF(MSVC)
60 +if (WIN32 AND NOT CYGWIN)
61 + if(MSVC)
62 SET(WIN_RC "win32/git2.rc")
63 - ENDIF()
64 + endif()
65
66 - FILE(GLOB SRC_OS win32/*.c win32/*.h)
67 -ELSEIF (AMIGA)
68 - ADD_DEFINITIONS(-DNO_ADDRINFO -DNO_READDIR_R -DNO_MMAP)
69 -ELSE()
70 - FILE(GLOB SRC_OS unix/*.c unix/*.h)
71 -ENDIF()
72 + file(GLOB SRC_OS win32/*.c win32/*.h)
73 + list(SORT SRC_OS)
74 +elseif(AMIGA)
75 + add_definitions(-DNO_ADDRINFO -DNO_READDIR_R -DNO_MMAP)
76 +else()
77 + file(GLOB SRC_OS unix/*.c unix/*.h)
78 + list(SORT SRC_OS)
79 +endif()
80
81 IF (USE_LEAK_CHECKER STREQUAL "valgrind")
82 ADD_DEFINITIONS(-DVALGRIND)
83 ENDIF()
84
85 -FILE(GLOB SRC_GIT2 *.c *.h
86 +file(GLOB SRC_GIT2 *.c *.h
87 allocators/*.c allocators/*.h
88 streams/*.c streams/*.h
89 transports/*.c transports/*.h
90 xdiff/*.c xdiff/*.h)
91 +list(SORT SRC_GIT2)
92 +
93 IF(APPLE)
94 # The old Secure Transport API has been deprecated in macOS 10.15.
95 SET_SOURCE_FILES_PROPERTIES(streams/stransport.c PROPERTIES COMPILE_FLAGS -Wno-deprecated)