From b7afc8d8cf00762b7167673b83673990288e4603 Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Thu, 9 Sep 2010 14:16:05 -0700 Subject: brew-audit - check SourceForge urls --- Library/Contributions/examples/brew-audit.rb | 39 ++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'Library') 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 } -- cgit v1.2.3