Changeset 35647
- Timestamp:
- 04/01/2008 06:09:48 (4 years ago)
- Files:
-
- 1 modified
-
trunk/base/src/macports1.0/macports.tcl (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/base/src/macports1.0/macports.tcl
r35630 r35647 1286 1286 proc macports::getsourcepath {url} { 1287 1287 global macports::portdbpath 1288 1288 1289 set source_path [split $url ://] 1290 1291 if {[_source_is_snapshot $url]} { 1292 # daily snapshot tarball 1293 return [file join $portdbpath sources [join [lrange $source_path 3 end-1] /] ports] 1294 } 1295 1289 1296 return [file join $portdbpath sources [lindex $source_path 3] [lindex $source_path 4] [lindex $source_path 5]] 1297 } 1298 1299 ## 1300 # Checks whether a supplied source URL is for a daily snapshot tarball 1301 # (private) 1302 # 1303 # @param url source URL to check 1304 # @return a list containing filename and extension or an empty list 1305 proc _source_is_snapshot {url {filename ""} {extension ""}} { 1306 upvar $filename myfilename 1307 upvar $extension myextension 1308 1309 if {[regexp {^(?:https?|ftp)://.+/(.+\.(tar\.gz|tar\.bz2))$} $url -> f e]} { 1310 set myfilename $f 1311 set myextension $e 1312 1313 return 1 1314 } 1315 1316 return 0 1290 1317 } 1291 1318 … … 1324 1351 proc mportsync {} { 1325 1352 global macports::sources macports::portdbpath macports::rsync_options tcl_platform 1353 global macports::portverbose 1326 1354 global macports::autoconf::rsync_path 1327 1355 … … 1386 1414 } 1387 1415 {^https?$|^ftp$} { 1388 set indexfile [macports::getindex $source] 1389 file mkdir [file dirname $indexfile] 1390 exec curl -L -s -S -o $indexfile $source/PortIndex 1416 if {[_source_is_snapshot $source filename extension]} { 1417 # sync a daily port snapshot tarball 1418 set indexfile [macports::getindex $source] 1419 set destdir [file dirname $indexfile] 1420 set tarpath [file join [file normalize [file join $destdir ..]] $filename] 1421 1422 file mkdir [file dirname $indexfile] 1423 1424 set verboseflag {} 1425 if {$macports::portverbose == "yes"} { 1426 set verboseflag "-v" 1427 } 1428 1429 if {[catch {eval curl fetch $verboseflag {$source} {$tarpath}} error]} { 1430 ui_error "Fetching $source failed ($error)" 1431 incr numfailed 1432 continue 1433 } 1434 1435 set extflag {} 1436 switch $extension { 1437 {tar.gz} { 1438 set extflag "-z" 1439 } 1440 {tar.bz2} { 1441 set extflag "-j" 1442 } 1443 } 1444 1445 if { [catch { system "cd $destdir/.. && tar ${verboseflag} ${extflag} -xf $filename" } error] } { 1446 ui_error "Extracting $source failed ($error)" 1447 incr numfailed 1448 continue 1449 } 1450 1451 if {[catch {system "chmod -R a+r \"$destdir\""}]} { 1452 ui_warn "Setting world read permissions on parts of the ports tree failed, need root?" 1453 } 1454 1455 file delete $tarpath 1456 } else { 1457 # sync just a PortIndex file 1458 set indexfile [macports::getindex $source] 1459 file mkdir [file dirname $indexfile] 1460 exec curl -L -s -S -o $indexfile $source/PortIndex 1461 } 1391 1462 } 1392 1463 default { … … 1464 1535 set source_url "file://[macports::getsourcepath $source]" 1465 1536 } 1537 {^https?$|^ftp$} { 1538 if {[_source_is_snapshot $source filename extension]} { 1539 # daily snapshot tarball 1540 set source_url "file://[macports::getsourcepath $source]" 1541 } else { 1542 # default action 1543 set source_url $source 1544 } 1545 } 1466 1546 default { 1467 1547 set source_url $source

