aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorAdam Vandenberg2010-09-09 14:16:05 -0700
committerAdam Vandenberg2010-09-09 14:16:05 -0700
commitb7afc8d8cf00762b7167673b83673990288e4603 (patch)
treee1b7879ff3e7f27309b3064b128d7a349735c0e1 /Library
parenta7e902ce7867c0b7d3b99b4f0ad1a42f70bee0a2 (diff)
downloadbrew-b7afc8d8cf00762b7167673b83673990288e4603.tar.bz2
brew-audit - check SourceForge urls
Diffstat (limited to 'Library')
-rwxr-xr-xLibrary/Contributions/examples/brew-audit.rb39
1 files changed, 34 insertions, 5 deletions
diff --git a/Library/Contributions/examples/brew-audit.rb b/Library/Contributions/examples/brew-audit.rb
index 24ab853c9..1790bde1f 100755
--- a/Library/Contributions/examples/brew-audit.rb
+++ b/Library/Contributions/examples/brew-audit.rb
@@ -14,11 +14,6 @@ def audit_formula_text text
problems << " * Commented cmake support found."
end
- # SourceForge URL madness
- if text =~ /\?use_mirror=/
- problems << " * Remove 'use_mirror' from url."
- end
-
# 2 (or more in an if block) spaces before depends_on, please
if text =~ /^\ ?depends_on/
problems << " * Check indentation of 'depends_on'."
@@ -117,6 +112,39 @@ def audit_formula_options f, text
return problems
end
+def audit_formula_urls f
+ problems = []
+
+ # Check SourceForge urls
+ [(f.url rescue nil), (f.head rescue nil)].each do |p|
+ next if p.nil?
+ # Is it a filedownload (instead of svnroot)
+ next if p =~ %r[/svnroot/]
+ next if p =~ %r[svn\.sourceforge]
+
+ # Is it a sourceforge http(s) URL?
+ next unless p =~ %r[^http?://.*\bsourceforge\.]
+
+ if p =~ /\?use_mirror=/
+ problems << " * Update this url (don't use ?use_mirror)."
+ end
+
+ if p =~ /\/download$/
+ problems << " * Update this url (don't use /download)."
+ end
+
+ if p =~ %r[^http://prdownloads\.]
+ problems << " * Update this url (don't use prdownloads)."
+ end
+
+ if p =~ %r[^http://\w+\.dl\.]
+ problems << " * Update this url (don't use specific dl mirrors)."
+ end
+ end
+
+ return problems
+end
+
def audit_formula_instance f
problems = []
@@ -148,6 +176,7 @@ def audit_some_formulae
problems = []
problems += audit_formula_instance f
+ problems += audit_formula_urls f
text = ""
File.open(f.path, "r") { |afile| text = afile.read }