diff --git a/swh/loader/package/debian/loader.py b/swh/loader/package/debian/loader.py --- a/swh/loader/package/debian/loader.py +++ b/swh/loader/package/debian/loader.py @@ -41,7 +41,6 @@ @attr.s class DebianFileMetadata: - md5sum = attr.ib(type=str) name = attr.ib(type=str) """Filename""" sha256 = attr.ib(type=str) @@ -49,6 +48,9 @@ uri = attr.ib(type=str) """URL of this specific file""" + # md5sum is not always available, make it optional + md5sum = attr.ib(type=str, default="") + # Some of the DSC files imported in swh apparently had a Checksums-SHA512 # field which got recorded in the archive. Current versions of dpkg-source # don't seem to generate them, but keep the field available for diff --git a/swh/loader/package/debian/tests/test_debian.py b/swh/loader/package/debian/tests/test_debian.py --- a/swh/loader/package/debian/tests/test_debian.py +++ b/swh/loader/package/debian/tests/test_debian.py @@ -3,6 +3,7 @@ # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information +from copy import deepcopy import logging from os import path @@ -303,6 +304,18 @@ assert dsc_name is None +def test_debian_dsc_information_missing_md5sum(): + package_files = deepcopy(PACKAGE_FILES) + + for package_metadata in package_files["files"].values(): + del package_metadata["md5sum"] + + p_info = DebianPackageInfo.from_metadata(package_files, url=URL) + + for debian_file_metadata in p_info.files.values(): + assert not debian_file_metadata.md5sum + + def test_debian_dsc_information_too_many_dsc_entries(): # craft an extra dsc file fname = "cicero_0.7.2-3.dsc"