#3703 RawHeader improvements
Merged by tkopecek. Opened by mikem.
mikem/koji sig-header-fields  into  master

Download 3703.patch

While looking at #3690 I ended up using RawHeader.dump() to do some analysis, and this prompted me to fix a few minor issues there.

  • display signature header tags correctly
  • handle int alignment padding
  • avoid masking built-in next function
  • somewhat more informative output
  • remove strict rpmlib dependency

This also includes fixes from #3714

  • decode option
  • support addition datatypes in get: char, string array, i18n array
  • fix handling for integer types

Fixes https://pagure.io/koji/issue/3713

7 new commits added

  • flake8 fix
  • use surrogateescape to decode in RawHeader
  • decode option in RawHeader, handle integer counts
  • flake8 fix
  • attempt to decode strings in dump
  • also support get for unicode string arrays
  • RawHeader.get can return also string lists

Note: this conflicts with #3690 because RawHeader.dump() will now return a list of ints for RPMTAG_LONGSIGSIZE.

1 new commit added

  • single opt for get, plus simple unit test

So, I'm a little puzzled about what to do for scalar header values. The RawHeader class is deliberately a lower level tool for parsing rpm header structure, whereas rpm itself applies several smarter layers of interpretation. In particular, rpm treats some header fields as scalars and others as arrays without any indication in the header apart from the header tag. E.g. buildtime is a scalar int32 and changelogtime is an int32 array, both both are represented as RPM_INT32_TYPE in the actual header.

We could have RawHeader vary its behavior here based on key, but that would require embedding a bunch of tag data from rpmlib. It's doable, but we'd need to keep it up to date (and it doesn't look like this aspect of the data is exposed in the python api).

To further complicate things, the RawHeader code before this PR had a bug for int values. It only returned the first int one, effectively treating even the int arrays as scalars.

The compromise solution I have here is to add a single option to RawHeader.get as a convenience for callers that want to fetch a value they expect to be singular.

@tkopecek @puiterwijk any thoughts on the above?

It's also worth noting that while the rpm code treats RPM_I18NSTRING_TYPE as an array type like RPM_STRING_ARRAY_TYPE, all actual i18n tags are scalar (summary, description, group).

@tkopecek @puiterwijk any thoughts on the above?

I think that single option is ok for usecases we have.

rebased onto e88639195c9e235b1f8646d86ed232f1b2b74fa6

rebased and added a fix for a unit test that is broken by the behavior change in get().

unit tests failing locally due to (unrelated) #3733

rebased onto 1b02bfc8d46eb8e4edb78e96f7fb142c235e4381

rebased to pull in unit test fix

Metadata Update from @tkopecek:
- Pull-request tagged with: no_qe

Commit c0d537c4 fixes this pull-request

Pull-Request has been merged by tkopecek

Metadata