Skip to content

Commit

Permalink
rpm: fix architecture definition for srpm
Browse files Browse the repository at this point in the history
Before the patch, the architecture of the package was written in
metadata for srpm, but this is not correct. For srpm, the
archetecture field must be filled with "src".

Tip:
To view the value of some tag in the rpm header use:
`rpm --query --package package.src.rpm --queryformat "%{TAG_NAME}\n"`

Related to tarantool/tarantool-qa#148
  • Loading branch information
LeonidVas committed Jan 11, 2022
1 parent e6cd31a commit 3ceb9d5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
26 changes: 23 additions & 3 deletions rpmrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def header_to_other(header, sha256):
"""
pkgid = sha256
name = get_with_decode(header, 'NAME', None)
arch = get_with_decode(header, 'ARCH', None)
arch = get_arch_from_header(header)
epoch = header.get('EPOCH', '0')
rel = get_with_decode(header, 'RELEASE', None)
ver = get_with_decode(header, 'VERSION', None)
Expand Down Expand Up @@ -651,10 +651,30 @@ def get_with_decode(dictionary, key, default='', encoding='utf-8'):
return res


def get_arch_from_header(header):
"""Defines the architecture of the package according to
the data from the header.
Keyword arguments:
header - parsed rpm package header (dict)
Return the architecture the package is for (string)
"""

# The architecture definition condition is based on
# https://github.com/rpm-software-management/yum/blob/4ed25525ee4781907bd204018c27f44948ed83fe/yum/packages.py#L2222
sourcepackage = header.get('SOURCEPACKAGE', None)
sourcerpm = get_with_decode(header, 'SOURCERPM', '')
if sourcepackage == 1 or not sourcerpm:
return 'src'
else:
return get_with_decode(header, 'ARCH', None)


def header_to_filelists(header, sha256):
pkgid = sha256
name = get_with_decode(header, 'NAME', None)
arch = get_with_decode(header, 'ARCH', None)
arch = get_arch_from_header(header)
epoch = header.get('EPOCH', '0')
rel = get_with_decode(header, 'RELEASE', None)
ver = get_with_decode(header, 'VERSION', None)
Expand Down Expand Up @@ -710,7 +730,7 @@ def header_to_primary(
header_end,
size):
name = get_with_decode(header, 'NAME', None)
arch = get_with_decode(header, 'ARCH')
arch = get_arch_from_header(header)
summary = get_with_decode(header, 'SUMMARY')
description = get_with_decode(header, 'DESCRIPTION')
packager = get_with_decode(header, 'PACKAGER', None)
Expand Down
1 change: 1 addition & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def test_header_to_other(self):
sha_256_key = '9a791d16574dc3408f495eb383b6c2669b34fc4545b3c43c8c791fbbe10619d2'
header = {
'NAME': b'Test Package Header Other 1',
'SOURCERPM':b'tpho-0.0.1-1.fc34.src.rpm',
'ARCH': b'aarch64',
'EPOCH': 1,
'RELEASE': b'10.el8_4',
Expand Down

0 comments on commit 3ceb9d5

Please sign in to comment.