Commit b1b0d849 authored by Chris Lamb's avatar Chris Lamb 👀
Browse files

Don't rely on zipdetails' --walk being available, and only add that argument...

Don't rely on zipdetails' --walk being available, and only add that argument on newer versions. (Closes: #408)
parent 47591178
Loading
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -32,7 +32,11 @@ from diffoscope.tempfiles import get_named_temporary_file
from .utils.file import File
from .directory import Directory
from .utils.archive import Archive, ArchiveMember
from .utils.command import Command
from .utils.command import Command, our_check_output


def zipdetails_version():
    return our_check_output(["zipdetails", "--version"]).decode("UTF-8")


class Zipinfo(Command):
@@ -159,6 +163,16 @@ class Zipdetails(Command):
    def cmdline(self):
        # See <https://salsa.debian.org/reproducible-builds/diffoscope/-/issues/406>
        # for discussion of zipdetails command line arguments.
        #
        # Older zipdetails does not support --walk; added in Debian
        # 5.40.0~rc1-1, but "zipdetails --version" shipped in, say, perl
        # 5.36.0-7+deb12u1 returns "2.104".
        #
        # See <https://salsa.debian.org/reproducible-builds/diffoscope/-/issues/408>
        #
        if float(zipdetails_version()) < 4.0:
            return ["zipdetails", "--redact", "--utc", self.path]

        return ["zipdetails", "--redact", "--walk", "--utc", self.path]


+1 −4
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ from diffoscope.comparators.zip import (
    MozillaZipFile,
    NuGetPackageFile,
    JmodJavaModule,
    zipdetails_version,
)

from ..utils.data import load_fixture, assert_diff
@@ -47,10 +48,6 @@ test_comment1 = load_fixture("test_comment1.zip")
test_comment2 = load_fixture("test_comment2.zip")


def zipdetails_version():
    return subprocess.check_output(["zipdetails", "--version"]).decode("UTF-8")


def io_compress_zip_version():
    try:
        return subprocess.check_output(