-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Patch improvements: DSL, checksums, caching #22775
Conversation
@@ -210,7 +213,7 @@ def options; [] end | |||
# } | |||
# The final option is to return DATA, then put a diff after __END__. You | |||
# can still return a Hash with DATA as the value for a patch level key. | |||
def patches; end | |||
def patches; {} end |
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 see this is changed from returning nil by default to {}
, but there may be formulae that override and end up returning nil anyway. Is that still handled?
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.
Probably not, I put it on my list.
This looks very good to me. Just to be super-explicit: fetch will now download external patches with checksums now, yeh? |
Yep. |
Very cool. |
Going through existing patches, some thoughts:
Perhaps the default for embedded patches should remain |
Another question: git diffs are -p1 by default, right? |
Yeah, that's another (and maybe the primary) reason most embedded patches are |
We could automatically use |
I'd make it explicit for external except maybe MacPorts (if you think that wouldn't be confusing). |
I'm leaning towards punting on adding any magic at this point. We can always re-evaluate and make some stuff implicit later, but we can't undo it (breaking compat) if it turns out to be a bad idea. |
Sounds good. |
Updated a few formulae to serve as examples. I'm not planning to do a bunch of them at once, though, since it requires a bit more work than the dependency updates. We can do them a handful at a time when people get a chance. |
Anyone have any further comments on the DSL? |
Looks good to me. Might be nice if there was a way to do multiple patches in a block that remained readable. |
I cleaned up the flow a bit. Now all patches are fetched and checksummed before any are applied, which matches the current behavior. |
Looks good to me. |
+1. Also something not related to this PR but will be helpful is to introduce some other routine like post_resource_download that is evaluated before patches for unpacking resources, so that patches can be applied to other resources as well. See homebrew/versions/llvm33 for an ugly example. |
Another thing while we're talking about patches is that it would be useful to support Git's binary patches. |
This commit introduces a new patch implementation that supports checksums and caching. Patches are declared in blocks: patch do url ... sha1 ... end A strip level of -p1 is assumed. It can be overridden using a symbol argument: patch :p0 do url ... sha1 ... end Patches can be declared in stable, devel, and head blocks. This form is preferred over using conditionals. stable do # ... patch do url ... sha1 ... end end Embedded (__END__) patches are declared like so: patch :DATA patch :p0, :DATA Patches can also be embedded by passing a string. This makes it possible to provide multiple embedded patches while making only some of them conditional. patch :p0, "..."
@Homebrew/owners anybody want to review this again? Nothing has really changed, I just rebased it, so I think it's ready. I have a separate branch with some updated formulae, I don't want to kill the build bot though. |
I'll try to take a look tonight. |
else | ||
{} | ||
end.each_pair do |strip, urls| | ||
urls = [urls] unless Array === urls |
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.
Is this preferential to urls = urls.to_a
?
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.
Yeah, in this case urls
can be a string (think { :p1 => "https://..." }
)
Looks good to me. |
Looks fine here. |
Merged. I updated the example formula, and I'll update the wiki soon. |
This implements a new patch DSL along with support for checksums and caching.
Here is what the DSL looks like so far. I'm not married to it, so please make suggestions. In particular, I don't find
patch :p0 do
aesthetically pleasing. However I don't want to push everything into one method call (i.e.,patch :p0, 'url', 'checksum'
) because the lines get too long.