mxcl/homebrew — pull request #22775 by jacknagel (2013-09-24 04:05:06+00:00)
Title: Patch improvements: DSL, checksums, caching

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.

```rb
# p1 is assumed, otherwise pass a symbol argument
patch do
url '...'
sha1 '...'
end

patch :p0 do
url '...'
sha1 '...'
end

# patches can go in the stable, devel, and head blocks
# as well, rather than using conditionals
stable do
# ...

patch do
url '...'
sha1 '...'
end
end

# embedded patches (__END__)
# note: we use :DATA because we can only use the
# actual DATA constant properly in the build script
patch :DATA
patch :p0, :DATA

# embed a patch without using __END__
# this means it is now possible to have multiple embedded
# patches, and make only some of them conditional
patch :p0, %q{
--- src/main.c 2012-06-30 12:22:29.000000000 +0200
+++ src/main.c 2012-06-30 12:19:11.000000000 +0200
@@ -25,6 +25,7 @@

#include
#include
+#include
#include
#include
#include "queue.h"
}
```

* In addition to the DSL, patches are now cached.

* Defining a patches method still works, but these patches are not cached (as they lack checksums).

* External patches are implemented using Resources, so instead of everything being downloaded up front, patches are downloaded and applied one at a time. The way resources are coupled to their download strategies makes it impossible to preserve the old behavior *and* use the existing caching/checksum machinery. I don't think this is a problem, because they are cached, but it is different.