Skip to content

Commit

Permalink
Add tag extension for rpm format version detection
Browse files Browse the repository at this point in the history
v6 packages have RPMTAG_RPMFORMAT, but we need to differentiate between
3 and 4 too in various places. As such this is a rather simple-minded
heuristic but it at least gives us a central place where to manage that
detection.
  • Loading branch information
pmatilai committed Nov 21, 2024
1 parent 3467348 commit e7b6651
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/manual/tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ Obsoletenevrs | 5043 | string array | Formatted `name [op version]` obso
Enhancenevrs | 5061 | string array | Formatted `name [op version]` enhance dependency strings.
Recommendnevrs | 5058 | string array | Formatted `name [op version]` recommend dependency strings.
Requirenevrs | 5041 | string array | Formatted `name [op version]` require dependency strings.
Rpmformat | 5114 | int32 | Detected rpm format version (3/4/6)
Suggestnevrs | 5059 | string array | Formatted `name [op version]` suggest dependency strings.
Supplementnevrs | 5060 | string array | Formatted `name [op version]` supplement dependency strings.
Sysusers | 5109 | string array | Formatted systemd-sysusers lines for the package. |
Expand Down
17 changes: 17 additions & 0 deletions lib/tagexts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,22 @@ static int openpgpTag(Header h, rpmtd td, headerGetFlags hgflags)
return td->count != 0;
}

static int rpmformatTag(Header h, rpmtd td, headerGetFlags hgflags)
{
if (headerGet(h, RPMTAG_RPMFORMAT, td, HEADERGET_ALLOC))
return 1;

uint32_t *nump = (uint32_t *)xcalloc(1, sizeof(*nump));
*nump = headerIsEntry(h, RPMTAG_HEADERIMMUTABLE) ? 4 : 3;

td->data = nump;
td->count = 1;
td->type = RPM_INT32_TYPE;
td->flags = RPMTD_ALLOCED;

return 1;
}

static const struct headerTagFunc_s rpmHeaderTagExtensions[] = {
{ RPMTAG_GROUP, groupTag },
{ RPMTAG_DESCRIPTION, descriptionTag },
Expand Down Expand Up @@ -1127,6 +1143,7 @@ static const struct headerTagFunc_s rpmHeaderTagExtensions[] = {
{ RPMTAG_SYSUSERS, sysusersTag },
{ RPMTAG_FILEMIMES, filemimesTag },
{ RPMTAG_OPENPGP, openpgpTag },
{ RPMTAG_RPMFORMAT, rpmformatTag },
{ 0, NULL }
};

Expand Down

0 comments on commit e7b6651

Please sign in to comment.