diff options
| author | Andre Arko | 2009-09-28 14:06:53 -0700 |
|---|---|---|
| committer | Max Howell | 2009-09-29 23:34:16 +0100 |
| commit | 53fa04ca1b6b2033ac4e94359de44c1566d91fc1 (patch) | |
| tree | 6dca3103542943584b4f7ab730c4285b60d3c1b6 /Library | |
| parent | 2459b35e081275987c15d34ca36cf2e472d20b66 (diff) | |
| download | homebrew-53fa04ca1b6b2033ac4e94359de44c1566d91fc1.tar.bz2 | |
Allow skip_clean as a class method
Pass in a list of any files that you don't want cleaned
with a path relative to the cellar. e.g. `strip_paths ['bin/znc']`
It's backwards compatible with def strip_clean?, at least for now.
The znc formula is updated as an example.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Formula/znc.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 34 |
2 files changed, 27 insertions, 11 deletions
diff --git a/Library/Formula/znc.rb b/Library/Formula/znc.rb index c64b6f1d4..53ae850ad 100644 --- a/Library/Formula/znc.rb +++ b/Library/Formula/znc.rb @@ -13,9 +13,7 @@ class Znc <Formula depends_on 'c-ares' - def skip_clean? path - path == bin+'znc' - end + skip_clean 'bin/znc' def install # This is a 3rd-party module that handles push notifications for Colloquy on the iPhone diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index ef3674453..57db673ba 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -108,8 +108,10 @@ class Formula else HttpDownloadStrategy end end - # tell the user about any caveats regarding this package + + # tell the user about any caveats regarding this package, return a string def caveats; nil end + # patches are automatically applied after extracting the tarball # return an array of strings, or if you need a patch level other than -p0 # return a Hash eg. @@ -121,12 +123,20 @@ class Formula # 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 - # sometimes the clean process breaks things, return true to skip anything - def skip_clean? path; false end + # rarely, you don't want your library symlinked into the main prefix # see gettext.rb for an example def keg_only?; false end + # sometimes the clean process breaks things + # skip cleaning paths in a formula with a class method like this: + # skip_clean [bin+"foo", lib+"bar"] + # redefining skip_clean? in formulas is now deprecated + def skip_clean? path + to_check = path.relative_path_from(prefix).to_s + self.class.skip_clean_paths.include?(to_check) + end + # yields self with current working directory set to the uncompressed tarball def brew validate_variable :name @@ -350,7 +360,8 @@ private raise 'You cannot override Formula.brew' if method == 'brew' end - class <<self + class << self + def self.attr_rw(*attrs) attrs.each do |attr| class_eval %Q{ @@ -360,9 +371,9 @@ private } end end - - attr_rw :url, :version, :homepage, :head, :deps, *CHECKSUM_TYPES - + + attr_rw :url, :version, :homepage, :head, :deps, :skip_clean_paths, *CHECKSUM_TYPES + def depends_on name, *args @deps ||= [] @@ -384,7 +395,14 @@ private # step for some reason I am not sure about @deps << name unless @deps.include? name end - end + + def skip_clean paths + @skip_clean_paths ||= [] + [paths].flatten.each do |p| + @skip_clean_paths << p.to_s unless @skip_clean_paths.include? p.to_s + end + end + end end # see ack.rb for an example usage |
