Bug#1000327: meson: please make the generated cmake files reproducible

Chris Lamb lamby at debian.org
Sun Nov 21 17:41:35 GMT 2021


Source: meson
Version: 0.60.1-1
Severity: wishlist
Tags: patch
User: reproducible-builds at lists.alioth.debian.org
Usertags: timestamps toolchain
X-Debbugs-Cc: reproducible-bugs at lists.alioth.debian.org

Hi,

Whilst working on the Reproducible Builds effort we noticed that
meson is not generating reproducible .cmake files.

For example:

│ │ │ ├── ./usr/lib/x86_64-linux-gnu/cmake/xbyak/xbyakConfig.cmake
│ │ │ │ @@ -1,11 +1,11 @@
│ │ │ │  
│ │ │ │  ####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
│ │ │ │  ####### Any changes to this file will be overwritten by the next CMake run ####
│ │ │ │ -####### The input file was /build/1st/xbyak-6.00/cmake/meson-config.cmake.in ########
│ │ │ │ +####### The input file was /build/2/xbyak-6.00/2nd/cmake/meson-config.cmake.in ########

(This is from src:xbyak version 6.00-2.)

A patch is attached that uses os.path.basename to only include
"meson-config.cmake.in" instead of the full path. This not only makes
the build reproducible, but it also matches CMake's own behaviour.
Specifically, CMakePackageConfigHelpers.cmake does the equivalent
transformation using:

  get_filename_component(inputFileName "${_inputFile}" NAME)


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      lamby at debian.org / chris-lamb.co.uk
       `-
-------------- next part --------------
diff --git a/mesonbuild/modules/cmake.py b/mesonbuild/modules/cmake.py
index 51ee9ee..37838d0 100644
--- a/mesonbuild/modules/cmake.py
+++ b/mesonbuild/modules/cmake.py
@@ -299,7 +299,7 @@ class CmakeModule(ExtensionModule):
 
     def create_package_file(self, infile, outfile, PACKAGE_RELATIVE_PATH, extra, confdata):
         package_init = PACKAGE_INIT_BASE.replace('@PACKAGE_RELATIVE_PATH@', PACKAGE_RELATIVE_PATH)
-        package_init = package_init.replace('@inputFileName@', infile)
+        package_init = package_init.replace('@inputFileName@', os.path.basename(infile))
         package_init += extra
         package_init += PACKAGE_INIT_SET_AND_CHECK
 


More information about the Reproducible-bugs mailing list