@@ -423,12 +423,13 @@ def process_build(self, build_id, rpmmod):
423423 cdx_root_component = None
424424 cdx_pedigrees = []
425425 for rpm in rpms :
426- (name , version , release , nvr , arch ) = (
426+ (name , version , release , nvr , arch , epoch ) = (
427427 rpm ["name" ],
428428 rpm ["version" ],
429429 rpm ["release" ],
430430 rpm ["nvr" ],
431431 rpm ["arch" ],
432+ rpm ["epoch" ],
432433 )
433434 filename = f"{ downloaddir } /{ name } -{ version } -{ release } .{ arch } .rpm"
434435 if arch == "src" :
@@ -441,6 +442,8 @@ def process_build(self, build_id, rpmmod):
441442 sha256header = self .get_rpm_sha256header (filename )
442443 sigmd5 = self .get_rpm_sigmd5 (filename )
443444 purl = f"pkg:rpm/redhat/{ name } @{ version } -{ release } ?arch={ arch } "
445+ if epoch :
446+ purl = f"{ purl } &epoch={ epoch } "
444447 if rpmmod :
445448 purl = f"{ purl } &rpmmod={ rpmmod } "
446449 package = {
@@ -526,6 +529,8 @@ def process_build(self, build_id, rpmmod):
526529 "relationships" : self .spdx_relationships ,
527530 }
528531
532+ copy_of_cdx_root = deepcopy (cdx_root_component )
533+ cdx_root_component .pop ("bom-ref" )
529534 cdx = {
530535 "bomFormat" : "CycloneDX" ,
531536 "specVersion" : "1.6" ,
@@ -546,19 +551,18 @@ def process_build(self, build_id, rpmmod):
546551 },
547552 }
548553
549- copy_of_cdx_root = deepcopy (cdx_root_component )
550554 copy_of_cdx_root ["pedigree" ] = {"ancestors" : cdx_pedigrees }
551555 self .cdx_components .append (copy_of_cdx_root )
552556 cdx ["components" ] = sorted (self .cdx_components , key = lambda c : c ["purl" ])
553557
554558 binary_rpm_purls = set ()
555559 for cdx_component in self .cdx_components :
556- if cdx_component ["bom-ref" ] == cdx_root_component ["bom-ref" ]:
560+ if cdx_component ["bom-ref" ] == copy_of_cdx_root ["bom-ref" ]:
557561 continue
558562 binary_rpm_purls .add (cdx_component ["purl" ])
559563
560564 cdx ["dependencies" ] = [
561- {"ref" : cdx_root_component ["bom-ref" ], "provides" : sorted (list (binary_rpm_purls ))}
565+ {"ref" : copy_of_cdx_root ["bom-ref" ], "provides" : sorted (list (binary_rpm_purls ))}
562566 ]
563567
564568 with open (f"{ build_id } .spdx.json" , "w" ) as fp :
@@ -624,7 +628,7 @@ def create_cdx_from_spdx(spdx_data):
624628build_ids = []
625629rpmmod = ""
626630if is_module :
627- module_tag , module_nsvc = get_modulemd_data ()
631+ module_tag , module_nsvc = get_modulemd_data ()
628632 rpmmod = module_nsvc
629633 module_builds = SESSION .listTagged (module_tag )
630634 for module_build in module_builds :
0 commit comments