[Git][reproducible-builds/diffoscope][master] 6 commits: Clarify "Command [..] failed with exit code" to remove duplicate "exited with...
Chris Lamb
gitlab at salsa.debian.org
Fri May 22 10:00:14 UTC 2020
Chris Lamb pushed to branch master at Reproducible Builds / diffoscope
Commits:
ed8be4ad by Chris Lamb at 2020-05-22T10:15:15+01:00
Clarify "Command [..] failed with exit code" to remove duplicate "exited with exit" but also to note that diffoscope is intepreting this as an error.
- - - - -
151b2260 by Chris Lamb at 2020-05-22T10:15:51+01:00
Don't leak the full path of the temporary directory in "Command [..] exited with 1". (Closes: reproducible-builds/diffoscope#126)
We retain it in the Python log/debug messages.
- - - - -
1e25a087 by Chris Lamb at 2020-05-22T10:22:50+01:00
Rname "in_dsc_path" to "dsc_in_same_dir" to clarify the usage of this variable.
- - - - -
6b2f2e49 by Chris Lamb at 2020-05-22T10:32:31+01:00
Rename the --debugger command-line argument to --pdb.
- - - - -
8f63a6fd by Chris Lamb at 2020-05-22T10:36:50+01:00
Add matching comments to tie up a slightly abstraction-breaking bit of code in diffoscope.comparators.mising_file and the .dsc/.buildinfo file handling.
- - - - -
ca8861d5 by Chris Lamb at 2020-05-22T10:51:31+01:00
Inline MissingFile's special handling of deb822 to prevent leaking through abstract layers.
- - - - -
5 changed files:
- diffoscope/comparators/debian.py
- diffoscope/comparators/missing_file.py
- diffoscope/comparators/utils/file.py
- diffoscope/main.py
- diffoscope/utils.py
Changes:
=====================================
diffoscope/comparators/debian.py
=====================================
@@ -72,7 +72,7 @@ class DebControlContainer(Container):
@staticmethod
def get_version_trimming_re(dcc):
- version = dcc.source.deb822.get('Version')
+ version = dcc.source._deb822.get('Version')
# Remove the epoch as it's not in the filename
version = re.sub(r'^\d+:', '', version)
@@ -90,7 +90,7 @@ class DebControlContainer(Container):
yield self._trim_version_number(name), self.get_member(name)
def get_member_names(self):
- field = self.source.deb822.get('Files') or self.source.deb822.get(
+ field = self.source._deb822.get('Files') or self.source._deb822.get(
'Checksums-Sha256'
)
@@ -112,26 +112,37 @@ class DebControlContainer(Container):
class DebControlFile(File):
CONTAINER_CLASSES = [DebControlContainer]
- @property
- def deb822(self):
- return self._deb822
+ @staticmethod
+ def _get_deb822(file):
+ # Be nice to .changes and .dsc comparison in the MissingFile case
+
+ if isinstance(file, DebControlFile):
+ return file._deb822
+
+ class DummyChanges(dict):
+ def get_as_string(self, _):
+ return ""
+
+ return DummyChanges(Files=[], Version='')
def compare_details(self, other, source=None):
differences = []
+ other_deb822 = self._get_deb822(other)
+
for field in sorted(
- set(self.deb822.keys()).union(set(other.deb822.keys()))
+ set(self._deb822.keys()).union(set(other_deb822.keys()))
):
if field.startswith('Checksums-') or field == 'Files':
continue
my_value = ""
- if field in self.deb822:
- my_value = self.deb822.get_as_string(field).lstrip()
+ if field in self._deb822:
+ my_value = self._deb822.get_as_string(field).lstrip()
other_value = ""
- if field in other.deb822:
- other_value = other.deb822.get_as_string(field).lstrip()
+ if field in other_deb822:
+ other_value = other_deb822.get_as_string(field).lstrip()
differences.append(
Difference.from_text(
@@ -140,11 +151,11 @@ class DebControlFile(File):
)
# Compare Files as string
- if self.deb822.get('Files'):
+ if self._deb822.get('Files'):
differences.append(
Difference.from_text(
- self.deb822.get_as_string('Files'),
- other.deb822.get_as_string('Files'),
+ self._deb822.get_as_string('Files'),
+ other_deb822.get_as_string('Files'),
self.path,
other.path,
source='Files',
@@ -153,8 +164,8 @@ class DebControlFile(File):
else:
differences.append(
Difference.from_text(
- self.deb822.get_as_string('Checksums-Sha256'),
- other.deb822.get_as_string('Checksums-Sha256'),
+ self._deb822.get_as_string('Checksums-Sha256'),
+ other_deb822.get_as_string('Checksums-Sha256'),
self.path,
other.path,
source='Checksums-Sha256',
@@ -191,7 +202,9 @@ class DotChangesFile(DebControlFile):
if differences is None:
return None
- files = zip(self.deb822.get('Files'), other.deb822.get('Files'))
+ other_deb822 = self._get_deb822(other)
+
+ files = zip(self._deb822.get('Files'), other_deb822.get('Files'))
files_identical = all(
x == y for x, y in files if not x['name'].endswith('.buildinfo')
@@ -224,13 +237,13 @@ class DotDscFile(DebControlFile):
md5 = hashlib.md5()
# XXX: this will not work for containers
- in_dsc_path = os.path.join(
+ dsc_in_same_dir = os.path.join(
os.path.dirname(file.path), d['Name']
)
- if not os.path.exists(in_dsc_path):
+ if not os.path.exists(dsc_in_same_dir):
return False
- with open(in_dsc_path, 'rb') as f:
+ with open(dsc_in_same_dir, 'rb') as f:
for buf in iter(functools.partial(f.read, 32768), b''):
md5.update(buf)
if md5.hexdigest() != d['md5sum']:
@@ -282,13 +295,13 @@ class DotBuildinfoFile(DebControlFile):
sha256 = hashlib.sha256()
# XXX: this will not work for containers
- in_buildinfo_path = os.path.join(
+ dsc_in_same_dir = os.path.join(
os.path.dirname(file.path), d['Name']
)
- if not os.path.exists(in_buildinfo_path):
+ if not os.path.exists(dsc_in_same_dir):
return False
- with open(in_buildinfo_path, 'rb') as f:
+ with open(dsc_in_same_dir, 'rb') as f:
for buf in iter(functools.partial(f.read, 32768), b''):
sha256.update(buf)
if sha256.hexdigest() != d['sha256']:
=====================================
diffoscope/comparators/missing_file.py
=====================================
@@ -2,7 +2,7 @@
#
# diffoscope: in-depth comparison of files, archives, and directories
#
-# Copyright © 2016-2017, 2019 Chris Lamb <lamby at debian.org>
+# Copyright © 2016-2017, 2019-2020 Chris Lamb <lamby at debian.org>
#
# diffoscope is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -103,12 +103,3 @@ class MissingFile(File):
@property
def magic_file_type(self):
return self._other_file.magic_file_type
-
- # Be nice to .changes and .dsc comparisons
- @property
- def deb822(self):
- class DummyChanges(dict):
- def get_as_string(self, _):
- return ''
-
- return DummyChanges(Files=[], Version='')
=====================================
diffoscope/comparators/utils/file.py
=====================================
@@ -500,7 +500,7 @@ class File(metaclass=abc.ABCMeta):
suffix = '{} [...]'.format(suffix[:max_len])
difference.add_comment(
- "Command `{}` exited with exit code {}.{}".format(
+ "Command `{}` failed with exit code {}.{}".format(
format_cmdline(e.cmd),
e.returncode,
suffix or " (No output)",
=====================================
diffoscope/main.py
=====================================
@@ -109,9 +109,9 @@ def create_parser():
help='Display debug messages',
)
parser.add_argument(
- '--debugger',
+ '--pdb',
action='store_true',
- help='Open the Python debugger in case of crashes',
+ help='Open the Python pdb debugger in case of crashes',
)
parser.add_argument(
'--status-fd',
@@ -756,7 +756,7 @@ def main(args=None):
except Exception:
sys.stderr.buffer.write(line_eraser())
traceback.print_exc()
- if parsed_args and parsed_args.debugger:
+ if parsed_args and parsed_args.pdb:
import pdb
pdb.post_mortem()
=====================================
diffoscope/utils.py
=====================================
@@ -19,12 +19,18 @@
import os
import sys
+import tempfile
def format_cmdline(cmd, replace=(), truncate=None):
+ prefix = tempfile.gettempdir()
+
def fn(x):
if x in replace:
return '{}'
+ # Don't expose the full path name of the temporary directory
+ if x.startswith(prefix):
+ x = os.path.join('«TEMP»', x[len(prefix) + 1 :])
x = repr(x)
if ' ' not in x:
x = x[1:-1]
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/179109275914dc8856f16119db00633983e3df52...ca8861d5e499354e970d2099157d6f383dd236c7
--
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/179109275914dc8856f16119db00633983e3df52...ca8861d5e499354e970d2099157d6f383dd236c7
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/20200522/ac663cb0/attachment.htm>
More information about the rb-commits
mailing list