Skip to content
Permalink
Browse files

Add a hack to help resolve problems in fetching from sourceforge mirr…

…ors.

If we receive a redirect during a fetch, and the url has sourceforge in it,
and the url redirected to contains the words "failedmirror" then assume this
was actually a sourceforge mirror failure, and continue to attempt the fetch
at more mirrors.

git-svn-id: https://svn.macports.org/repository/macports/trunk/base@17197 d073be05-634f-4543-b044-5fe20cf6d1d6
  • Loading branch information
jdberry committed Mar 27, 2006
1 parent af9d7c5 commit 3b173e8e23e0f67a0bdf91f4b8e1168e80495963
Showing with 24 additions and 6 deletions.
  1. +24 −6 src/port1.0/portfetch.tcl
@@ -1,6 +1,6 @@
# et:ts=4
# portfetch.tcl
# $Id: portfetch.tcl,v 1.107 2005/10/12 22:10:28 pguyot Exp $
# $Id: portfetch.tcl,v 1.108 2006/03/27 21:32:27 jberry Exp $
#
# Copyright (c) 2002 - 2003 Apple Computer, Inc.
# All rights reserved.
@@ -399,22 +399,40 @@ proc fetchfiles {args} {
set url_var master_sites
global portfetch::$url_var
}
unset -nocomplain fetched
foreach site [set $url_var] {
ui_msg "$UI_PREFIX [format [msgcat::mc "Attempting to fetch %s from %s"] $distfile $site]"
set file_url [portfetch::assemble_url $site $distfile]
if {![catch {eval curl fetch $fetch_options {$file_url} ${distpath}/${distfile}.TMP} result] &&
set effectiveURL ""
if {![catch {eval curl fetch --effective-url effectiveURL $fetch_options {$file_url} ${distpath}/${distfile}.TMP} result] &&
![catch {system "mv ${distpath}/${distfile}.TMP ${distpath}/${distfile}"}]} {
set fetched 1
break

# Special hack to check for sourceforge mirrors, which don't return a proper error code on failure
if {![string equal $effectiveURL $file_url] &&
[string match "*sourceforge*" $file_url] &&
[string match "*failedmirror*" $effectiveURL]} {

# *SourceForge hackage in effect*
# The url seen by curl seems to have been a redirect to the sourceforge mirror page
ui_debug "[msgcat::mc "Fetching from sourceforge mirror failed"]"
exec rm -f ${distpath}/${distfile}.TMP

# Continue on to try the next mirror, if any
} else {

# Successful fetch
set fetched 1
break

}

} else {
ui_debug "[msgcat::mc "Fetching failed:"]: $result"
exec rm -f ${distpath}/${distfile}.TMP
}
}
if {![info exists fetched]} {
return -code error [msgcat::mc "fetch failed"]
} else {
unset fetched
}
}
}

0 comments on commit 3b173e8

Please sign in to comment.
You can’t perform that action at this time.