From 7ca5fd445ca559bf2bf9f8434329539aa54f146b Mon Sep 17 00:00:00 2001 From: Chris Lamb Date: Mon, 20 Nov 2023 09:53:01 +0000 Subject: [PATCH] Make the Requires.private line in generated .pkgconfig files reproducible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 . Signed-off-by: Chris Lamb --- mesonbuild/modules/pkgconfig.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index ee12293cd..fa543fdb5 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/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)