Repository navigation
Fix package on Fedora 44 by ignoring unexpected Upgrades DNF5 header - #681
nsballmann wants to merge 3 commits into
Conversation
| # Strip off all content that contains Obsoleting, Security: or Update | ||
| body = str.partition(/^(Obsoleting|Security:|Update)/).first | ||
|
|
||
| body = body.gsub(/^Upgrades.*?$/m, '') |
There was a problem hiding this comment.
| body = body.gsub(/^Upgrades.*?$/m, '') | |
| body = body.gsub(/^Upgrades.*?$/m, '') | |
I would keep the empty newline after the body modifications.
| body = body.gsub(/^Upgrades.*?$/m, '') | |
| body.gsub!(/^Upgrades.*?$/m, '') | |
@OpenVoxProject do you prefer the in-place gsub call?
There was a problem hiding this comment.
@muald I just learnt that in Ruby RegExp the anchors ^ and $ match in m mode actually at the line boundaries and not at the string boundaries (according to the back of my head this used to be different... in Python). This means, due to the $ anchor the match will definitely anchor at the end of the first line. As we want the whole first line gone, we then probably don't need the non-greedy ?.
But we definitely need the m mode otherwise $ would anchor at the end of the whole body string.
We do leave an empty newline after the substitution.
Alternatively, without m mode, we could also do this:
| body = body.gsub(/^Upgrades.*?$/m, '') | |
| # https://regex101.com/r/LiVD53/2/substitution | |
| body.gsub!(/^Upgrades.*\R/, '') | |
This would remove only the whole first line of the body, if it starts with Upgrades.
@bastelfreak what do you think?
|
@muald I would probably go with the suggestion from #613 (comment) as this IMHO is the cleanest way of removing the line. |
cf15f71 to
3b06316
Compare
package on Fedora 44 by ignoring unexpected Upgrades DNF5 header
|
@binford2k or @rwaffen is there something to do differently? Adding tests maybe? Are @muald and I doing this in the correct repository, in the first place? |
|
@nsballmann yes this is the right repo. Could you add some tests, with fixtures, to https://github.com/OpenVoxProject/openvox/blob/main/spec/unit/provider/package/yum_spec.rb ? Best would be some Fedora 43 and 44 fixtures so we can ensure that we don't break older versions |
|
@bastelfreak yes, I can try. Though it's the first time for me doing this. Can you please point me to an example from which I can derive this? Do you want this to be scoped to the specific DNF5 version that introduced this or is it okay to scope this on the OS release level? |
ac05c63 to
3aceccc
Compare
|
@bastelfreak I think I added some tests. But it's unclear to me how to scope them to specific major distro releases. |
| @@ -133,7 +133,7 @@ def self.check_updates(disablerepo, enablerepo, disableexcludes) | |||
| def self.parse_updates(str) | |||
| # Strip off all content that contains Obsoleting, Security: or Update | |||
| body = str.partition(/^(Obsoleting|Security:|Update)/).first | |||
There was a problem hiding this comment.
Wouldn't it work to add Upgrades to this?
There was a problem hiding this comment.
@bastelfreak sorry for not responding that long. It was really a lengthy... Cyber Awareness October...
I'm no Ruby expert, but no I don't think this would work. In my understanding .partition() splits the whole content into partitions. I think the .first would then give the first element of the resulting array and due to the new header this would by an empty partition before the partition we're interested in, due to the new (unexpected) dividing element.
I think that's the reason @muald chose to modify body.
There was a problem hiding this comment.
Either way, .partition is returning some empty strings. Have you considered just filtering them out with .reject!(&:empty?)?
|
I tested this on Fedora 44 (dnf5 5.4.6, openvox-agent 8.31.1-1.fc44). With Without this patch, On 5.4.6 the header is just On adding s = "Upgrades\ncurl.x86_64 8.18.0-14.fc44 updates\n"
s.partition(/^(Obsoleting|Security:|Update|Upgrades)/).first # => ""The existing entries mark sections that come after the update list. DNF5 prints One note on the pattern as written: it is correct, but only because of the lazy |
|
@nsballmann a suggestion for the tests, in case it helps with the review:
With the fix reverted, the "with updates header" example and the bare-header example above fail, and with the fix all pass. On scoping the tests to distro releases: I don't think it's needed. |
@stondo yes, I'm aware. I just wanted to present multiple options to find one that will be generally understood in the project. Regex are usually a source for confusion, therefore I try to find a Regex which does what we require but is readable enough to be acceptable. |
@stondo seems like I overlooked that variant. Thank you. I would add you as author in a separate commit. Are you okay with that? |
Signed-off-by: Markus Urbanczyk <markus.urbanczyk@evosoft.com> Signed-off-by: Nils Ballmann <nils.ballmann@siemens.com>
Signed-off-by: Nils Ballmann <nils.ballmann@siemens.com>
3aceccc to
5f6aef5
Compare
Co-authored-by: Stefano Tondo <stondo@gmail.com> Signed-off-by: Nils Ballmann <nils.ballmann@siemens.com>
|
@nsballmann yes, that's fine with me, thanks. The new test is the same one I ran on Fedora 44. One small point, if you want it: the two |
Short description
Remove the Upgrades header. The update process in Fedora 44 was blocked by this header.
#555 (comment)
The header was introduced 7 months ago.
https://github.com/rpm-software-management/dnf5/blob/main/dnf5/commands/check-upgrade/check-upgrade.cpp#L211
Checklist
I have:
Signed-off-byannotation to each of my commitsGenerated-byorAssisted-byannotations to each of my commits created with the help of an AI agent