Skip to content

Commit

Permalink
include RPMTAG_MODULARITYLABEL for rpms as 'module' in metadata.json
Browse files Browse the repository at this point in the history
* STONEBLD-258

Signed-off-by: Robert Cerven <rcerven@redhat.com>
  • Loading branch information
rcerven committed Mar 26, 2024
1 parent dd6417a commit 68b952b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
2 changes: 2 additions & 0 deletions atomic_reactor/utils/rpm.py
Expand Up @@ -20,6 +20,7 @@
'SIZE',
'SIGMD5',
'BUILDTIME',
'RPMTAG_MODULARITYLABEL',
'SIGPGP:pgpsig',
'SIGGPG:pgpsig',
'DSAHEADER:pgpsig',
Expand Down Expand Up @@ -107,6 +108,7 @@ def field(tag):
'arch': field('ARCH'),
'sigmd5': field('SIGMD5'),
'signature': signature,
'module': field('RPMTAG_MODULARITYLABEL'),
}

# Special handling for epoch as it must be an integer or None
Expand Down
22 changes: 11 additions & 11 deletions tests/plugins/test_rpmqa.py
Expand Up @@ -21,27 +21,27 @@

TEST_IMAGE = "fedora:latest"

PACKAGE_LIST = ['python-docker-py;1.3.1;1.fc24;noarch;(none);'
'191456;7c1f60d8cde73e97a45e0c489f4a3b26;1438058212;(none);(none);(none);(none)',
'fedora-repos-rawhide;24;0.1;noarch;(none);'
'2149;d41df1e059544d906363605d47477e60;1436940126;(none);(none);(none);(none)',
'gpg-pubkey-doc;1.0;1;noarch;(none);'
'1000;00000000000000000000000000000000;1436940126;(none);(none);(none);(none)']
PACKAGE_LIST = ['python-docker-py;1.3.1;1.fc24;noarch;(none);191456;'
'7c1f60d8cde73e97a45e0c489f4a3b26;1438058212;module;(none);(none);(none);(none)',
'fedora-repos-rawhide;24;0.1;noarch;(none);2149;'
'd41df1e059544d906363605d47477e60;1436940126;module;(none);(none);(none);(none)',
'gpg-pubkey-doc;1.0;1;noarch;(none);1000;'
'00000000000000000000000000000000;1436940126;module;(none);(none);(none);(none)']
PACKAGE_LIST_WITH_AUTOGENERATED = PACKAGE_LIST + ['gpg-pubkey;qwe123;zxcasd123;(none);(none);0;'
'(none);1370645731;(none);(none)']
'(none);1370645731;module;(none);(none)']
PACKAGE_LIST_WITH_AUTOGENERATED_B = [x.encode("utf-8") for x in PACKAGE_LIST_WITH_AUTOGENERATED]

PACKAGE_LIST_SBOM = ['vim-minimal;9.0.803;1.fc36;x86_64;(none);' # arch, no epoch
'1695845;00000000000000000000000000000000;1436940126;'
'1695845;00000000000000000000000000000000;1436940126;module;'
'(none);(none);(none);(none)',
'yum;4.14.0;1.fc36;noarch;(none);' # noarch, no epoch
'22187;00000000000000000000000000000000;1436940126;'
'22187;00000000000000000000000000000000;1436940126;module;'
'(none);(none);(none);(none)',
'kernel-core;6.0.5;200.fc36;x86_64;3;' # arch, epoch
'101213053;00000000000000000000000000000000;1436940126;'
'101213053;00000000000000000000000000000000;1436940126;module;'
'(none);(none);(none);(none)',
'kernel-core;6.0.5;200.fc36;x86_64;3;' # duplicate
'101213053;00000000000000000000000000000000;1436940126;'
'101213053;00000000000000000000000000000000;1436940126;module;'
'(none);(none);(none);(none)']
SBOM_COMPONENTS = [{"type": "library", "name": "vim-minimal", "version": "9.0.803-1.fc36",
"purl": "pkg:rpm/vim-minimal@9.0.803-1.fc36?arch=x86_64"},
Expand Down
7 changes: 5 additions & 2 deletions tests/utils/test_rpm.py
Expand Up @@ -16,7 +16,7 @@

@pytest.mark.parametrize(('tags', 'separator', 'expected'), [
(None, None,
r"-qa --qf '%{NAME};%{VERSION};%{RELEASE};%{ARCH};%{EPOCH};%{SIZE};%{SIGMD5};%{BUILDTIME};%{SIGPGP:pgpsig};%{SIGGPG:pgpsig};%{DSAHEADER:pgpsig};%{RSAHEADER:pgpsig}\n'"), # noqa
r"-qa --qf '%{NAME};%{VERSION};%{RELEASE};%{ARCH};%{EPOCH};%{SIZE};%{SIGMD5};%{BUILDTIME};%{RPMTAG_MODULARITYLABEL};%{SIGPGP:pgpsig};%{SIGGPG:pgpsig};%{DSAHEADER:pgpsig};%{RSAHEADER:pgpsig}\n'"), # noqa
(['NAME', 'VERSION'], "|",
r"-qa --qf '%{NAME}|%{VERSION}\n'"),
])
Expand All @@ -40,8 +40,9 @@ def fake_rpm_line(
size = "2000"
sigmd5 = FAKE_SIGMD5.decode()
buildtime = "23000"
module = "some_module"
return (
f"{name};{version};{release};{arch};{epoch};{size};{sigmd5};{buildtime}"
f"{name};{version};{release};{arch};{epoch};{size};{sigmd5};{buildtime};{module}"
f";{pgp};{gpg};{dsa};{rsa}"
)

Expand All @@ -66,6 +67,7 @@ def fake_rpm_line(
'epoch': 0,
'sigmd5': FAKE_SIGMD5.decode(),
'signature': "01234567890abc",
'module': "some_module",
}
assert res == [
{
Expand Down Expand Up @@ -115,5 +117,6 @@ def fake_rpm_line(
'epoch': None,
'sigmd5': None,
'signature': None,
'module': None,
}
]

0 comments on commit 68b952b

Please sign in to comment.