[70143] trunk/base/src/port1.0/portchecksum.tcl

jmr at macports.org jmr at macports.org
Fri Jul 30 05:32:21 PDT 2010


Revision: 70143
          http://trac.macports.org/changeset/70143
Author:   jmr at macports.org
Date:     2010-07-30 05:32:20 -0700 (Fri, 30 Jul 2010)
Log Message:
-----------
print a link to a helpful wiki page when there is a checksum mismatch and the downloaded file appears to incorrectly contains HTML (#25128)

Modified Paths:
--------------
    trunk/base/src/port1.0/portchecksum.tcl

Modified: trunk/base/src/port1.0/portchecksum.tcl
===================================================================
--- trunk/base/src/port1.0/portchecksum.tcl	2010-07-30 11:01:18 UTC (rev 70142)
+++ trunk/base/src/port1.0/portchecksum.tcl	2010-07-30 12:32:20 UTC (rev 70143)
@@ -260,6 +260,12 @@
                         set fail yes
                     }
                 }
+                if {[tbool fail] && ![regexp {\.html?$} ${distfile}] &&
+                    ![catch {strsed [exec [findBinary file $portutil::autoconf::file_path] $fullpath --brief --mime] {s/;.*$//}} mimetype]
+                    && "text/html" == $mimetype} {
+                    # file --mime-type would be preferable to file --mime and strsed, but is only available as of Snow Leopard
+                    set wrong_mimetype yes
+                }
             }
 
         }
@@ -296,6 +302,18 @@
         ui_info "The correct checksum line may be:"
         ui_info [format "%-20s%s" "checksums" [join $sums [format " \\\n%-20s" ""]]]
 
+        if {[tbool wrong_mimetype]} {
+            # We got an HTML file, though the distfile name does not suggest that one was
+            # expected. Probably a helpful DNS server sent us to its search results page
+            # instead of admitting that the server we asked for doesn't exist, or a mirror that
+            # no longer has the file served its error page with a 200 response.
+            ui_msg "***"
+            ui_msg "The non-matching file appears to be HTML. See this page for possible reasons"
+            ui_msg "for the checksum mismatch:"
+            ui_msg "<http://trac.macports.org/wiki/MisbehavingServers>"
+            ui_msg "***"
+        }
+
         return -code error "[msgcat::mc "Unable to verify file checksums"]"
     }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100730/62d42575/attachment-0001.html>


More information about the macports-changes mailing list