You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.8 KiB

  1. From d7b6c04aaf416344332e73f49fe457013e3ccf36 Mon Sep 17 00:00:00 2001
  2. From: Alexander Couzens <lynxis@fe80.eu>
  3. Date: Sun, 10 Dec 2017 00:54:06 +0100
  4. Subject: [PATCH] CMakeLists: build reproducible by default
  5. Merged-upstream: yes
  6. Using the build user and build hostname as part of the git hash breaks
  7. reproducible builds. Make this part optional, but build reproducible by
  8. default.
  9. ---
  10. CMakeLists.txt | 47 +++++++++++++++++++++++++++--------------------
  11. 1 file changed, 27 insertions(+), 20 deletions(-)
  12. Index: libwebsockets-2.4.0/CMakeLists.txt
  13. ===================================================================
  14. --- libwebsockets-2.4.0.orig/CMakeLists.txt
  15. +++ libwebsockets-2.4.0/CMakeLists.txt
  16. @@ -39,26 +39,32 @@ message(STATUS "CMAKE_TOOLCHAIN_FILE='${
  17. find_package(Git)
  18. if(GIT_EXECUTABLE)
  19. execute_process(
  20. - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  21. - COMMAND "${GIT_EXECUTABLE}" describe
  22. - OUTPUT_VARIABLE GIT_HASH
  23. - OUTPUT_STRIP_TRAILING_WHITESPACE
  24. - )
  25. - execute_process(
  26. - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  27. - COMMAND "whoami"
  28. - OUTPUT_VARIABLE GIT_USER
  29. - OUTPUT_STRIP_TRAILING_WHITESPACE
  30. - )
  31. - execute_process(
  32. - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  33. - COMMAND "hostname"
  34. - OUTPUT_VARIABLE GIT_HOST
  35. - OUTPUT_STRIP_TRAILING_WHITESPACE
  36. - )
  37. - string(REGEX REPLACE "([^\\])[\\]([^\\])" "\\1\\\\\\\\\\2" GIT_USER ${GIT_USER})
  38. - set(LWS_BUILD_HASH ${GIT_USER}@${GIT_HOST}-${GIT_HASH})
  39. - message("Git commit hash: ${LWS_BUILD_HASH}")
  40. + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  41. + COMMAND "${GIT_EXECUTABLE}" describe
  42. + OUTPUT_VARIABLE GIT_HASH
  43. + OUTPUT_STRIP_TRAILING_WHITESPACE
  44. + )
  45. + set(LWS_BUILD_HASH ${GIT_HASH})
  46. +
  47. + # appen the build user and hostname
  48. + if(NOT LWS_REPRODUCIBLE)
  49. + execute_process(
  50. + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  51. + COMMAND "whoami"
  52. + OUTPUT_VARIABLE GIT_USER
  53. + OUTPUT_STRIP_TRAILING_WHITESPACE
  54. + )
  55. + execute_process(
  56. + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  57. + COMMAND "hostname"
  58. + OUTPUT_VARIABLE GIT_HOST
  59. + OUTPUT_STRIP_TRAILING_WHITESPACE
  60. + )
  61. + string(REGEX REPLACE "([^\\])[\\]([^\\])" "\\1\\\\\\\\\\2" GIT_USER ${GIT_USER})
  62. + set(LWS_BUILD_HASH ${GIT_USER}@${GIT_HOST}-${GIT_HASH})
  63. + endif()
  64. +
  65. + message("Git commit hash: ${LWS_BUILD_HASH}")
  66. endif()
  67. set(LWS_WITH_BUNDLED_ZLIB_DEFAULT OFF)
  68. @@ -121,6 +127,7 @@ option(LWS_AVOID_SIGPIPE_IGN "Android 7+
  69. option(LWS_WITH_STATS "Keep statistics of lws internal operations" OFF)
  70. option(LWS_WITH_SOCKS5 "Allow use of SOCKS5 proxy on client connections" OFF)
  71. option(LWS_WITH_PEER_LIMITS "Track peers and restrict resources a single peer can allocate" OFF)
  72. +option(LWS_REPRODUCIBLE "Build libwebsockets reproducible. It removes the build user and hostname from the build" ON)
  73. macro(confirm_command CMD NOCMD)
  74. find_program (HAVE_CMD_${CMD} ${CMD} )