From c3a4b2b91f64d3af208dc5cd8c8ef25c81b327ca Mon Sep 17 00:00:00 2001 From: mprahl Date: Dec 12 2018 21:14:07 +0000 Subject: Force the epoch on SRPM artifacts in the modulemd files uploaded to the CG build --- diff --git a/module_build_service/builder/KojiContentGenerator.py b/module_build_service/builder/KojiContentGenerator.py index 8678c07..dd095d9 100644 --- a/module_build_service/builder/KojiContentGenerator.py +++ b/module_build_service/builder/KojiContentGenerator.py @@ -263,6 +263,12 @@ class KojiContentGenerator(object): # Temporary dict with build_id as a key to find builds easily. builds = {build['build_id']: build for build in builds} + # Create a mapping of build IDs to SRPM NEVRAs so that the for loop below can directly + # access these values when adding the `srpm_nevra` key to the returned RPMs + build_id_to_srpm_nevra = { + srpm["build_id"]: kobo.rpmlib.make_nvra(srpm, force_epoch=True) + for srpm in src_rpms.values() + } # Handle the multicall result. For each build associated with the source RPM, # store the exclusivearch and excludearch lists. For each RPM, store the 'license' and # also other useful data from the Build associated with the RPM. @@ -274,7 +280,7 @@ class KojiContentGenerator(object): rpm["license"] = headers["license"] rpm['srpm_name'] = build['name'] - rpm['srpm_nevra'] = build['nvr'] + rpm['srpm_nevra'] = build_id_to_srpm_nevra[rpm["build_id"]] rpm['exclusivearch'] = build['exclusivearch'] rpm['excludearch'] = build['excludearch'] diff --git a/tests/test_content_generator.py b/tests/test_content_generator.py index a6a2f08..e87b244 100644 --- a/tests/test_content_generator.py +++ b/tests/test_content_generator.py @@ -342,6 +342,7 @@ class TestBuild: { 'id': 1, 'arch': 'src', + 'epoch': None, 'build_id': 875991, 'name': 'module-build-macros', 'release': '1.module_92011fe6', @@ -350,6 +351,7 @@ class TestBuild: { 'id': 2, 'arch': 'noarch', + 'epoch': None, 'build_id': 875991, 'name': 'module-build-macros', 'release': '1.module_92011fe6', @@ -358,6 +360,7 @@ class TestBuild: { 'id': 3, 'arch': 'src', + 'epoch': 3, 'build_id': 875636, 'name': 'ed', 'release': '2.module_bd6e0eb1', @@ -366,6 +369,7 @@ class TestBuild: { 'id': 4, 'arch': 'x86_64', + 'epoch': 3, 'build_id': 875636, 'name': 'ed', 'release': '2.module_bd6e0eb1', @@ -376,6 +380,7 @@ class TestBuild: builds = [ { 'build_id': 875636, + 'epoch': 3, 'name': 'ed', 'release': '2.module_bd6e0eb1', 'version': '1.14.1', @@ -383,6 +388,7 @@ class TestBuild: }, { 'build_id': 875991, + 'epoch': None, 'name': 'module-build-macros', 'release': '1.module_92011fe6', 'version': '0.1', @@ -403,9 +409,11 @@ class TestBuild: for rpm in rpms: # We want to mainly check the excludearch and exclusivearch code. if rpm["name"] == "module-build-macros": + assert rpm["srpm_nevra"] == "module-build-macros-0:0.1-1.module_92011fe6.src" assert rpm["excludearch"] == ["x86_64"] assert rpm["license"] == "MIT" else: + assert rpm["srpm_nevra"] == "ed-3:1.14.1-2.module_bd6e0eb1.src" assert rpm["exclusivearch"] == ["x86_64"] assert rpm["license"] == "GPL"