diff --git a/src/packagedcode/rpm.py b/src/packagedcode/rpm.py index 01ae1ab850e..7fb1d95763c 100644 --- a/src/packagedcode/rpm.py +++ b/src/packagedcode/rpm.py @@ -96,6 +96,9 @@ def __new__(self, version, release=None, epoch=None): note: the sort order of the named tuple is the sort order. But for creation we put the rarely used epoch last with a default to None. """ + + epoch = str(epoch) if epoch else "" + if epoch and epoch.strip() and not epoch.isdigit(): raise ValueError('Invalid epoch: must be a number or empty.') if not version: diff --git a/tests/packagedcode/data/rpm/header/apache-commons-io-2.4-12.el7.noarch.rpm b/tests/packagedcode/data/rpm/header/apache-commons-io-2.4-12.el7.noarch.rpm new file mode 100644 index 00000000000..6fcf7c754b2 Binary files /dev/null and b/tests/packagedcode/data/rpm/header/apache-commons-io-2.4-12.el7.noarch.rpm differ diff --git a/tests/packagedcode/data/rpm/header/apache-commons-io-2.4-12.el7.noarch.rpm-expected.json b/tests/packagedcode/data/rpm/header/apache-commons-io-2.4-12.el7.noarch.rpm-expected.json new file mode 100644 index 00000000000..9d1e87ee975 --- /dev/null +++ b/tests/packagedcode/data/rpm/header/apache-commons-io-2.4-12.el7.noarch.rpm-expected.json @@ -0,0 +1,19 @@ +{ + "name": "apache-commons-io", + "epoch": "1", + "version": "2.4", + "release": "12.el7", + "arch": "noarch", + "os": "linux", + "summary": "Utilities to assist with developing IO functionality", + "description": null, + "distribution": null, + "vendor": "CentOS", + "license": "ASL 2.0", + "packager": "CentOS BuildSystem ", + "group": "Unspecified", + "url": "http://commons.apache.org/io", + "source_rpm": "apache-commons-io-2.4-12.el7.src.rpm", + "dist_url": null, + "is_binary": true +} diff --git a/tests/packagedcode/test_rpm.py b/tests/packagedcode/test_rpm.py index 0a726969384..56f4bfc5022 100644 --- a/tests/packagedcode/test_rpm.py +++ b/tests/packagedcode/test_rpm.py @@ -391,3 +391,7 @@ def test_rpm_tags_xsetup_0_28_b1_src_rpm(self): def test_rpm_tags_zziplib_0_11_15_3sf_i586_rpm(self): test_file = self.get_test_loc('rpm/header/zziplib-0.11.15-3sf.i586.rpm') self.check_rpm_tags(test_file) + + def test_rpm_tags_apache_commons_io_2_4_12_el7_noarch_rpm(self): + test_file = self.get_test_loc('rpm/header/apache-commons-io-2.4-12.el7.noarch.rpm') + self.check_rpm_tags(test_file) \ No newline at end of file