[Git][reproducible-builds/diffoscope][master] Add support for printing the signatures via apksigner(1). (Closes:...

Chris Lamb gitlab at salsa.debian.org
Sat May 16 15:08:02 UTC 2020



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
c5f03d53 by Chris Lamb at 2020-05-16T16:04:28+01:00
Add support for printing the signatures via apksigner(1). (Closes: reproducible-builds/diffoscope#121)

- - - - -


4 changed files:

- debian/control
- debian/tests/control
- diffoscope/comparators/apk.py
- diffoscope/external_tools.py


Changes:

=====================================
debian/control
=====================================
@@ -9,6 +9,7 @@ Uploaders:
 Build-Depends:
  abootimg <!nocheck>,
  apktool [!ppc64el !s390x] <!nocheck>,
+ apksigner <!nocheck>,
  bash-completion,
  binutils-multiarch <!nocheck>,
  black <!nocheck>,


=====================================
debian/tests/control
=====================================
@@ -7,7 +7,7 @@
 #   $ mv debian/tests/control.tmp debian/tests/control
 
 Tests: pytest-with-recommends
-Depends: python3-all, diffoscope, black, python3-pytest, python3-h5py, file, linux-image-amd64 [amd64] | linux-image-generic [amd64], abootimg, acl, apktool [!ppc64el !s390x], binutils-multiarch, bzip2, caca-utils, colord, db-util, default-jdk-headless | default-jdk | java-sdk, device-tree-compiler, docx2txt, e2fsprogs, enjarify, ffmpeg, fontforge-extras, fp-utils [!ppc64el !s390x], genisoimage, gettext, ghc, ghostscript, giflib-tools, gnumeric, gnupg, gnupg-utils, hdf5-tools, imagemagick, jsbeautifier, libarchive-tools, llvm, lz4 | liblz4-tool, mono-utils, ocaml-nox, odt2txt, oggvideotools [!s390x], openssh-client, openssl, pgpdump, poppler-utils, procyon-decompiler, python3-pdfminer, r-base-core, rpm2cpio, sng, sqlite3, squashfs-tools, tcpdump, unzip, wabt, xmlbeans, xxd | vim-common, xz-utils, zip, zstd, python3-argcomplete, python3-binwalk, python3-defusedxml, python3-distro, python3-guestfs, python3-jsondiff, python3-progressbar, python3-pypdf2, python3-debian, python3-pyxattr, python3-rpm, python3-tlsh
+Depends: python3-all, diffoscope, black, python3-pytest, python3-h5py, file, linux-image-amd64 [amd64] | linux-image-generic [amd64], abootimg, acl, apksigner, apktool [!ppc64el !s390x], binutils-multiarch, bzip2, caca-utils, colord, db-util, default-jdk-headless | default-jdk | java-sdk, device-tree-compiler, docx2txt, e2fsprogs, enjarify, ffmpeg, fontforge-extras, fp-utils [!ppc64el !s390x], genisoimage, gettext, ghc, ghostscript, giflib-tools, gnumeric, gnupg, gnupg-utils, hdf5-tools, imagemagick, jsbeautifier, libarchive-tools, llvm, lz4 | liblz4-tool, mono-utils, ocaml-nox, odt2txt, oggvideotools [!s390x], openssh-client, openssl, pgpdump, poppler-utils, procyon-decompiler, python3-pdfminer, r-base-core, rpm2cpio, sng, sqlite3, squashfs-tools, tcpdump, unzip, wabt, xmlbeans, xxd | vim-common, xz-utils, zip, zstd, python3-argcomplete, python3-binwalk, python3-defusedxml, python3-distro, python3-guestfs, python3-jsondiff, python3-progressbar, python3-pypdf2, python3-debian, python3-pyxattr, python3-rpm, python3-tlsh
 
 Tests: pytest
 Depends: python3-all, diffoscope, python3-pytest, python3-h5py, file, python3-tlsh


=====================================
diffoscope/comparators/apk.py
=====================================
@@ -24,11 +24,13 @@ import logging
 import itertools
 import subprocess
 
+from diffoscope.difference import Difference
 from diffoscope.tools import tool_required
 from diffoscope.tempfiles import get_temporary_directory
 
 from .utils.file import File
 from .utils.archive import Archive
+from .utils.command import Command
 from .utils.compare import compare_files
 from .zip import ZipContainer, zipinfo_differences
 from .missing_file import MissingFile
@@ -186,6 +188,14 @@ class ApkContainer(Archive):
         return differences
 
 
+class Apksigner(Command):
+    VALID_RETURNCODES = {0, 1}
+
+    @tool_required('apksigner')
+    def cmdline(self):
+        return ["apksigner", "verify", "--verbose", "--print-certs", self.path]
+
+
 class ApkFile(File):
     DESCRIPTION = "Android APK files"
     FILE_TYPE_HEADER_PREFIX = b"PK\x03\x04"
@@ -194,7 +204,13 @@ class ApkFile(File):
     CONTAINER_CLASSES = [ApkContainer, ZipContainer]
 
     def compare_details(self, other, source=None):
-        return zipinfo_differences(self, other)
+        differences = zipinfo_differences(self, other)
+
+        x = Difference.from_command(Apksigner, self.path, other.path)
+        if x is not None:
+            difference.insert(0, x)
+
+        return differences
 
 
 def filter_apk_metadata(filepath, archive_name):


=====================================
diffoscope/external_tools.py
=====================================
@@ -20,6 +20,7 @@
 EXTERNAL_TOOLS = {
     'abootimg': {'debian': 'abootimg', 'guix': 'abootimg'},
     'apktool': {'debian': 'apktool'},
+    'apksigner': {'debian': 'apksigner'},
     'db_dump': {'debian': 'db-util', 'guix': 'bdb'},
     'bsdtar': {
         'debian': 'libarchive-tools',



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/c5f03d5365300513f28ec54840da7c70f9789d0c

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/c5f03d5365300513f28ec54840da7c70f9789d0c
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20200516/19d42445/attachment.htm>


More information about the rb-commits mailing list