New Ticket     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Changeset 35647

Show
Ignore:
Timestamp:
04/01/2008 06:09:48 (4 years ago)
Author:
raimue@…
Message:

macports1.0/macports.tcl:
Implement fetching of daily snapshot tarballs as an alternative to rsync.
Just add the following line to sources.conf instead of rsync:
 http://macports.org/files/ports.tar.gz

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/base/src/macports1.0/macports.tcl

    r35630 r35647  
    12861286proc macports::getsourcepath {url} { 
    12871287    global macports::portdbpath 
     1288 
    12881289    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 
    12891296    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 
     1305proc _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 
    12901317} 
    12911318 
     
    13241351proc mportsync {} { 
    13251352    global macports::sources macports::portdbpath macports::rsync_options tcl_platform 
     1353    global macports::portverbose 
    13261354    global macports::autoconf::rsync_path  
    13271355     
     
    13861414            } 
    13871415            {^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                } 
    13911462            } 
    13921463            default { 
     
    14641535                                    set source_url "file://[macports::getsourcepath $source]" 
    14651536                                } 
     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                                } 
    14661546                                default { 
    14671547                                    set source_url $source