[libvirt] [libvirt-python 0/3] reproducible builds

Debian tries to make builds reporducible[0] therefore we need predictable output (i.e. no timestamps, predictable iteration over hashes, etc.). This patch (mostly by Chris Lamb) to libvirt-python makes the necessary changes. [0] https://wiki.debian.org/ReproducibleBuilds Guido Günther (3): Sort dictionary keys Simplify sorting Sort tuples on both items generator.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) -- 2.1.4

In order to achive reproducible builds[0] we want functions and enums always generated in the same order. [0] https://wiki.debian.org/ReproducibleBuilds/About --- generator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generator.py b/generator.py index 78082e8..c14b0d4 100755 --- a/generator.py +++ b/generator.py @@ -1940,7 +1940,7 @@ def qemuBuildWrappers(module): # # Generate functions directly, no classes # - for name in list(qemu_functions.keys()): + for name in sorted(qemu_functions.keys()): func = nameFixup(name, 'None', None, None) (desc, ret, args, file, mod, cond) = qemu_functions[name] fd.write("def %s(" % func) @@ -1990,7 +1990,7 @@ def qemuBuildWrappers(module): # # Generate enum constants # - for type,enum in list(qemu_enums.items()): + for type,enum in sorted(qemu_enums.items()): fd.write("# %s\n" % type) items = list(enum.items()) items.sort(key=lambda i: int(i[1])) @@ -2053,7 +2053,7 @@ def lxcBuildWrappers(module): # # Generate functions directly, no classes # - for name in list(lxc_functions.keys()): + for name in sorted(lxc_functions.keys()): func = nameFixup(name, 'None', None, None) (desc, ret, args, file, mod, cond) = lxc_functions[name] fd.write("def %s(" % func) @@ -2103,7 +2103,7 @@ def lxcBuildWrappers(module): # # Generate enum constants # - for type,enum in list(lxc_enums.items()): + for type,enum in sorted(lxc_enums.items()): fd.write("# %s\n" % type) items = list(enum.items()) items.sort(key=lambda i: int(i[1])) -- 2.1.4

On Tue, May 19, 2015 at 12:53:12AM +0200, Guido Günther wrote:
In order to achive reproducible builds[0] we want functions and enums always generated in the same order.
[0] https://wiki.debian.org/ReproducibleBuilds/About --- generator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
ACK Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

funcs.keys() can't be None, only the empty array --- generator.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/generator.py b/generator.py index c14b0d4..861f166 100755 --- a/generator.py +++ b/generator.py @@ -931,10 +931,7 @@ def buildStubs(module, api_xml): wrapper.write("#include \"typewrappers.h\"\n") wrapper.write("#include \"build/" + module + ".h\"\n\n") - funcnames = list(funcs.keys()) - if funcnames is not None: - funcnames.sort() - for function in funcnames: + for function in sorted(funcs.keys()): # Skip the functions which are not for the module ret = print_function_wrapper(module, function, wrapper, export, include) if ret < 0: -- 2.1.4

On Tue, May 19, 2015 at 12:53:13AM +0200, Guido Günther wrote:
funcs.keys() can't be None, only the empty array --- generator.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
ACK Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

In order to achieve reproducible builds[0] we want the items within enums always generated in the same order so sort on both items in the tuple. [0] https://wiki.debian.org/ReproducibleBuilds/About --- generator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generator.py b/generator.py index 861f166..676243c 100755 --- a/generator.py +++ b/generator.py @@ -1852,7 +1852,7 @@ def buildWrappers(module): value = int(value) except ValueError: value = float('inf') - return value + return value, data[0] # Resolve only one level of reference def resolveEnum(enum, data): @@ -1990,7 +1990,7 @@ def qemuBuildWrappers(module): for type,enum in sorted(qemu_enums.items()): fd.write("# %s\n" % type) items = list(enum.items()) - items.sort(key=lambda i: int(i[1])) + items.sort(key=lambda i: (int(i[1]), i[0])) for name,value in items: fd.write("%s = %s\n" % (name,value)) fd.write("\n") @@ -2103,7 +2103,7 @@ def lxcBuildWrappers(module): for type,enum in sorted(lxc_enums.items()): fd.write("# %s\n" % type) items = list(enum.items()) - items.sort(key=lambda i: int(i[1])) + items.sort(key=lambda i: (int(i[1]), i[0])) for name,value in items: fd.write("%s = %s\n" % (name,value)) fd.write("\n") -- 2.1.4

On Tue, May 19, 2015 at 12:53:14AM +0200, Guido Günther wrote:
In order to achieve reproducible builds[0] we want the items within enums always generated in the same order so sort on both items in the tuple.
[0] https://wiki.debian.org/ReproducibleBuilds/About --- generator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
ACK Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Wed, May 20, 2015 at 01:23:32PM +0100, Daniel P. Berrange wrote:
On Tue, May 19, 2015 at 12:53:14AM +0200, Guido Günther wrote:
In order to achieve reproducible builds[0] we want the items within enums always generated in the same order so sort on both items in the tuple.
[0] https://wiki.debian.org/ReproducibleBuilds/About --- generator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
ACK
Pushed the whole series. Thanks! -- Guido
participants (2)
-
Daniel P. Berrange
-
Guido Günther