-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guess strip for patch from patch itself #18
base: master
Are you sure you want to change the base?
Conversation
Some RPM spec files use non-standart way of applying patches: they don't use %patch macro but call 'patch' directly from inlined script or use 'git apply'. In such cases gbp can't detect patch strip value and fails. This patch adds a bit of logic to guess patch strip value from patch itself is possible.
Thanks, one issue though: The patch object might not refer to an existing file (yet) so guessing might fail. I'd rather see the code to guess the strip level called separately for the RPM guessing case. Maybe @marquiz has another comment. |
...oh and we need a testcase that checks this one we know which way we want it. |
I'm trying to guess the strip level by analyzing paths to files being patched, but without checking if they exist because of the same reason you gave - file might not exist. |
gbp/patch_series.py
Outdated
@@ -42,7 +45,10 @@ class Patch(object): | |||
def __init__(self, path, topic=None, strip=None): | |||
self.path = path | |||
self.topic = topic | |||
self.strip = strip | |||
if strip: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use
if strip is not None:
That would allow strip level of 0 to be valid
How does gbp fail in this case? Currently, gbp does not play out nicely with these kind of spec files as it basically ignores (or at least should ignore) the patches. Gbp should not actually fail because it doesn't recognize that the patches are applied and it should not import/export them at all. Anyway, I'm ok with the patch – with the unit test added (plu see my code comment). |
It fail to import patches, in fact, it just ignore them. There is another patch (that looks like a hack) that help me to import those patches by force. I can send it too. |
Thanks for the update but please check how gbp-pq uses the patch I want to retain this behaviour for the gbp-pq case. It's perfectly Patch(object):
...
@classmethod
def from_file(cls, patch):
strip = _guess_patch_level(path)
return cls.__init__(path, strip, ...) and use Patch.from_file to build the patch object where you need it. This will also make it obvious where we have the strip level guessed and where not. Oh, and it would be awesome if we could move these things either onto |
Do you have that other patch (that looks like a hack) somewhere? I think it would be trivial to add for "force importing" all patches (i.e. all Patch: tags). The problem with that is that without manually modifying the spec file gbp will not be able to build/modify the it correctly: gbp-pq export will add %patch macros for each Patch: tag and you would end up with patches applied twice. It might be worthwhile to add such a "force" option to gbp-import-srpm, though. It should probably print a warning if patches without a corresponding %patch macro are found, so that the user would be instructed to modify the spec file by hand to make it gbp-compatible. |
@agx I'll try to add separate method as you've suggested, and will update the patch. Unfortunately, I'm not familiar with code-review via mailing list. I'll send any new patch to ML, but could we continue to discuss this patch here? And, would it be OK if I create a pull-request for new patch here and send it to mailing list, or it's necessary to send patches to ML? @marquiz Those patches in my private branch, I'll update them a bit and will send a bit later. Yes, I have also a patch to not create %patch macros when exporting :) I'm going to combine them together then. |
On Fri, May 20, 2016 at 01:34:01AM -0700, Dmitry Teselkin wrote:
Just stick to the current workflow for this PR - i think I can |
Some RPM spec files use non-standart way of applying patches:
they don't use %patch macro but call 'patch' directly from
inlined script or use 'git apply'. In such cases gbp can't
detect patch strip value and fails.
For example, take a look at centos spec for libvirt [1].
This patch adds a bit of logic to guess patch strip value
from patch itself if possible.
[1] https://git.centos.org/blob/rpms!!libvirt/d7192236d3c0510c5debbd75087d36d481a4ead1/SPECS!libvirt.spec