Make the Requires.private line in generated .pkgconfig files reproducible

Whilst working on the Reproducible Builds effort, we noticed that
meson was generates .pkgconfig files that are not reproducible.

For example, here is neatvnc's pkgconfig file when built with HEAD^1:

   Name: neatvnc
   Description: A Neat VNC server library
   Version: 0.7.0
  -Requires.private: pixman-1, aml < 0.4.0, aml >= 0.3.0, zlib, libdrm, libturbojpeg, gnutls, nettle, hogweed, gmp, gbm, libavcodec, libavfilter, libavutil
  +Requires.private: pixman-1, aml >= 0.3.0, aml < 0.4.0, zlib, libdrm, libturbojpeg, gnutls, nettle, hogweed, gmp, gbm, libavcodec, libavfilter, libavutil
   Libs: -L${libdir} -lneatvnc
   Libs.private: -lm
   Cflags: -I${includedir}

This is, ultimately, due to iterating over the contents of a set within a
DefaultDict and can thus be fixed by sorting the output immediately prior to
generating the Requires.private string.

An alternative solution would be to place the sorted(…) call a few lines
down:

    return ', '.join(sorted(result))

However, this changes the expected ordering of the entire line, and many users
may be unhappy with that (alternative) change as a result. By contrast, this
commit will only enforce an ordering when there are multiple version
requirements (eg. a lower and a higher version requirement, ie. a version
range). It will, additionally, order them with the lower part of the range
first.

This was originally filed (with a slightly different patch) by myself in
the the Debian bug tracker <https://bugs.debian.org/1056117>.

Signed-off-by: Chris Lamb <lamby@debian.org>
pull/12408/head
Chris Lamb 1 year ago committed by Jussi Pakkanen
parent dfd8cfbd8d
commit 2ed94ccb47
  1. 2
      mesonbuild/modules/pkgconfig.py

@ -307,7 +307,7 @@ class DependenciesHelper:
for name in reqs:
vreqs = self.version_reqs.get(name, None)
if vreqs:
result += [name + ' ' + self.format_vreq(vreq) for vreq in vreqs]
result += [name + ' ' + self.format_vreq(vreq) for vreq in sorted(vreqs)]
else:
result += [name]
return ', '.join(result)

Loading…
Cancel
Save