From 50814e7454edb2157e17e3cedc0a6ed584415e0c Mon Sep 17 00:00:00 2001 From: Lubomír Sedlář Date: Aug 28 2018 13:13:28 +0000 Subject: Skip sources in compose diff Without this patch the SRPM paths are included in both dicts, for sources as well as binary packages. Signed-off-by: Lubomír Sedlář --- diff --git a/compose_utils/diff.py b/compose_utils/diff.py index bd0527d..512a07f 100644 --- a/compose_utils/diff.py +++ b/compose_utils/diff.py @@ -5,7 +5,6 @@ import argparse import copy import json import os -from collections import namedtuple import productmd from kobo.rpmlib import parse_nvra @@ -29,10 +28,10 @@ class ComposeRpmsDiff(object): result = {} for variant in rpmm.rpms: for arch in rpmm.rpms[variant]: - if arch == "src": - continue for srpm_nevra in rpmm.rpms[variant][arch]: for rpm_nevra, data in rpmm.rpms[variant][arch][srpm_nevra].items(): + if data["category"] == "source": + continue result[data["path"]] = ( variant, arch, @@ -77,15 +76,12 @@ class ComposeRpmsDiff(object): result["old_compose"] = old_rm.compose.id result["new_compose"] = new_rm.compose.id - for i in ( - list(srpms_old.keys()) - + list(srpms_new.keys()) - + list(rpms_old.keys()) - + list(rpms_new.keys()) - ): + for i in list(srpms_old.keys()) + list(srpms_new.keys()): if i in srpms_old and i in srpms_new: del srpms_old[i] del srpms_new[i] + + for i in list(rpms_old.keys()) + list(rpms_new.keys()): if i in rpms_old and i in rpms_new: del rpms_old[i] del rpms_new[i] @@ -97,7 +93,8 @@ class ComposeRpmsDiff(object): "dropped_rpms": len(rpms_old), } - # Build dicts of added/dropped rpms - rpm_manifest like format variant/arch/srpm_nvra/[rpm_nevra/]:data + # Build dicts of added/dropped rpms - rpm_manifest like format + # variant/arch/srpm_nvra/[rpm_nevra/]:data added_rpms = {} dropped_rpms = {} diff --git a/tests/test_diff.py b/tests/test_diff.py index 882345e..b5deaf3 100644 --- a/tests/test_diff.py +++ b/tests/test_diff.py @@ -18,12 +18,14 @@ EXPECTED_DIFF = { "dummy-elinks-debuginfo.i386", "dummy-elinks-debuginfo.x86_64", "dummy-elinks.i386", + "dummy-elinks.src", "dummy-elinks.x86_64", ], "dropped": [ "dummy-tftp-debuginfo.i386", "dummy-tftp-debuginfo.x86_64", "dummy-tftp.i386", + "dummy-tftp.src", "dummy-tftp.x86_64", ], }, @@ -32,12 +34,14 @@ EXPECTED_DIFF = { "dummy-elinks-debuginfo.s390x", "dummy-elinks-debuginfo.x86_64", "dummy-elinks.s390x", + "dummy-elinks.src", "dummy-elinks.x86_64", ], "dropped": [ "dummy-tftp-debuginfo.s390x", "dummy-tftp-debuginfo.x86_64", "dummy-tftp.s390x", + "dummy-tftp.src", "dummy-tftp.x86_64", ], },