Ticket #18259: quickindex.diff
File quickindex.diff, 11.8 KB (added by jmroot (Joshua Root), 16 years ago) |
---|
-
src/port/port.tcl
684 684 set installed_epoch [lindex $i 5] 685 685 686 686 # Get info about the port from the index 687 if {[catch {set res [mport search $portname no exact]} result]} {687 if {[catch {set res [mportlookup $portname]} result]} { 688 688 global errorInfo 689 689 ui_debug "$errorInfo" 690 fatal " search forportname $portname failed: $result"690 fatal "lookup of portname $portname failed: $result" 691 691 } 692 692 if {[llength $res] < 2} { 693 693 if {[macports::ui_isset ports_debug]} { … … 1355 1355 # otherwise try to map the portname to a url 1356 1356 if {$porturl eq ""} { 1357 1357 # Verify the portname, getting portinfo to map to a porturl 1358 if {[catch {mport search $portname no exact} result]} {1358 if {[catch {mportlookup $portname} result]} { 1359 1359 ui_debug "$::errorInfo" 1360 break_softcontinue " search forportname $portname failed: $result" 1 status1360 break_softcontinue "lookup of portname $portname failed: $result" 1 status 1361 1361 } 1362 1362 if {[llength $result] < 2} { 1363 1363 break_softcontinue "Port $portname not found" 1 status 1364 1364 } 1365 set found [expr [llength $result] / 2]1366 if {$found > 1} {1367 ui_warn "Found $found port $portname definitions, displaying first one."1368 }1369 1365 array unset portinfo 1370 1366 array set portinfo [lindex $result 1] 1371 1367 set porturl $portinfo(porturl) … … 1700 1696 } 1701 1697 1702 1698 foreachport $portlist { 1703 # Search forthe port.1704 if {[catch {mport search $portname no exact} result]} {1699 # Look up the port. 1700 if {[catch {mportlookup $portname} result]} { 1705 1701 ui_debug $::errorInfo 1706 break_softcontinue "The search for'$portname' failed: $result" \1702 break_softcontinue "The lookup of '$portname' failed: $result" \ 1707 1703 1 status 1708 1704 } 1709 1705 if {[llength $result] < 2} { … … 2160 2156 set installed_epoch [lindex $i 5] 2161 2157 2162 2158 # Get info about the port from the index 2163 if {[catch {set res [mport search $portname no exact]} result]} {2159 if {[catch {set res [mportlookup $portname]} result]} { 2164 2160 global errorInfo 2165 2161 ui_debug "$errorInfo" 2166 2162 break_softcontinue "search for portname $portname failed: $result" 1 status … … 2268 2264 return 1 2269 2265 } 2270 2266 foreachport $portlist { 2271 # search forport2272 if {[catch {mport search $portname no exact} result]} {2267 # look up port 2268 if {[catch {mportlookup $portname} result]} { 2273 2269 global errorInfo 2274 2270 ui_debug "$errorInfo" 2275 break_softcontinue " search forportname $portname failed: $result" 1 status2271 break_softcontinue "lookup of portname $portname failed: $result" 1 status 2276 2272 } 2277 2273 if {[llength $result] < 2} { 2278 2274 break_softcontinue "Port $portname not found" 1 status … … 2582 2578 if {$porturl == ""} { 2583 2579 2584 2580 # Verify the portname, getting portinfo to map to a porturl 2585 if {[catch {set res [mport search $portname no exact]} result]} {2581 if {[catch {set res [mportlookup $portname]} result]} { 2586 2582 global errorInfo 2587 2583 ui_debug "$errorInfo" 2588 break_softcontinue " search forportname $portname failed: $result" 1 status2584 break_softcontinue "lookup of portname $portname failed: $result" 1 status 2589 2585 } 2590 2586 if {[llength $res] < 2} { 2591 2587 break_softcontinue "Port $portname not found" 1 status … … 2739 2735 # otherwise try to map the portname to a url 2740 2736 if {$porturl == ""} { 2741 2737 # Verify the portname, getting portinfo to map to a porturl 2742 if {[catch {set res [mport search $portname no exact]} result]} {2738 if {[catch {set res [mportlookup $portname]} result]} { 2743 2739 global errorInfo 2744 2740 ui_debug "$errorInfo" 2745 break_softcontinue " search forportname $portname failed: $result" 1 status2741 break_softcontinue "lookup of portname $portname failed: $result" 1 status 2746 2742 } 2747 2743 if {[llength $res] < 2} { 2748 2744 break_softcontinue "Port $portname not found" 1 status -
src/macports1.0/macports.tcl
708 708 unsetenv $envkey 709 709 } 710 710 } 711 712 # load the quick index 713 _mports_load_quickindex 711 714 } 712 715 713 716 proc macports::worker_init {workername portpath porturl portbuildpath options variations} { … … 1654 1657 return $matches 1655 1658 } 1656 1659 1660 proc mportlookup {name} { 1661 global macports::portdbpath macports::sources macports::quick_indices macports::quick_offsets 1662 1663 set found 0 1664 set matches [list] 1665 foreach source $sources { 1666 set source [lindex $source 0] 1667 if {[macports::getprotocol $source] != "mports"} { 1668 set result [lsearch -sorted [lindex ${quick_indices} $found] [string tolower $name]] 1669 if {$result == -1} { 1670 continue 1671 } 1672 set offset [lindex [lindex ${quick_offsets} $found] $result] 1673 incr found 1 1674 if {[catch {set fd [open [macports::getindex $source] r]} result]} { 1675 ui_warn "Can't open index file for source: $source" 1676 } else { 1677 try { 1678 seek $fd $offset 1679 gets $fd line 1680 set name [lindex $line 0] 1681 set len [lindex $line 1] 1682 set line [read $fd $len] 1683 1684 array set portinfo $line 1685 1686 switch -regexp -- [macports::getprotocol ${source}] { 1687 {^rsync$} { 1688 # Rsync files are local 1689 set source_url "file://[macports::getsourcepath $source]" 1690 } 1691 {^https?$|^ftp$} { 1692 if {[_source_is_snapshot $source filename extension]} { 1693 # daily snapshot tarball 1694 set source_url "file://[macports::getsourcepath $source]" 1695 } else { 1696 # default action 1697 set source_url $source 1698 } 1699 } 1700 default { 1701 set source_url $source 1702 } 1703 } 1704 if {[info exists portinfo(portarchive)]} { 1705 set porturl ${source_url}/$portinfo(portarchive) 1706 } elseif {[info exists portinfo(portdir)]} { 1707 set porturl ${source_url}/$portinfo(portdir) 1708 } 1709 if {[info exists porturl]} { 1710 lappend line porturl $porturl 1711 ui_debug "Found port in $porturl" 1712 } else { 1713 ui_debug "Found port info: $line" 1714 } 1715 lappend matches $name 1716 lappend matches $line 1717 close $fd 1718 break 1719 } catch {*} { 1720 ui_warn "It looks like your PortIndex file may be corrupt." 1721 throw 1722 } finally { 1723 catch {close $fd} 1724 } 1725 } 1726 } else { 1727 array set attrs [list name $name] 1728 set res [macports::index::search $macports::portdbpath $source [array get attrs]] 1729 if {[llength $res] > 0} { 1730 eval lappend matches $res 1731 break 1732 } 1733 } 1734 } 1735 1736 return $matches 1737 } 1738 1739 proc _mports_load_quickindex {args} { 1740 global macports::sources macports::quick_indices macports::quick_offsets 1741 1742 set found 0 1743 set quick_indices [list] 1744 set quick_offsets [list] 1745 foreach source $sources { 1746 set source [lindex $source 0] 1747 set index [macports::getindex $source] 1748 if {![file exists ${index}.quick] || [file mtime ${index}] > [file mtime ${index}.quick]} { 1749 if {[catch {set fd [open ${index} r]} result] || [catch {set quickfd [open ${index}.quick w]} result]} { 1750 ui_warn "Can't open index file for source: $source" 1751 } else { 1752 try { 1753 set offset [tell $fd] 1754 set quicklist [list] 1755 while {[gets $fd line] >= 0} { 1756 if {[llength $line] != 2} { 1757 continue 1758 } 1759 set name [lindex $line 0] 1760 lappend quicklist [list [string tolower $name] $offset] 1761 1762 set len [lindex $line 1] 1763 seek $fd $len current 1764 set offset [tell $fd] 1765 } 1766 puts $quickfd [lsort -index 0 $quicklist] 1767 } catch {*} { 1768 ui_warn "It looks like your PortIndex file may be corrupt." 1769 throw 1770 } finally { 1771 close $fd 1772 close $quickfd 1773 } 1774 } 1775 } 1776 # quick index should now exist 1777 if {[catch {set fd [open ${index}.quick r]} result]} { 1778 ui_warn "Can't open quick index file for source: $source" 1779 } else { 1780 incr found 1 1781 set quicklist [gets $fd] 1782 close $fd 1783 foreach l $quicklist { 1784 lappend this_indices [lindex $l 0] 1785 lappend this_offsets [lindex $l 1] 1786 } 1787 lappend quick_indices $this_indices 1788 lappend quick_offsets $this_offsets 1789 } 1790 } 1791 if {!$found} { 1792 return -code error "No index(es) found! Have you synced your source indexes?" 1793 } 1794 } 1795 1657 1796 proc mportinfo {mport} { 1658 1797 set workername [ditem_key $mport workername] 1659 1798 return [$workername eval array get PortInfo] … … 1756 1895 } 1757 1896 1758 1897 # Find the porturl 1759 if {[catch {set res [mport search $dep_portname false exact]} error]} {1898 if {[catch {set res [mportlookup $dep_portname]} error]} { 1760 1899 global errorInfo 1761 1900 ui_debug "$errorInfo" 1762 ui_error "Internal error: port searchfailed: $error"1901 ui_error "Internal error: port lookup failed: $error" 1763 1902 return 1 1764 1903 } 1765 1904 1766 1905 unset -nocomplain porturl 1767 foreach {name array} $res { 1768 array set portinfo $array 1769 if {[info exists portinfo(porturl)]} { 1770 set porturl $portinfo(porturl) 1771 break 1772 } 1906 array set portinfo [lindex $res 1] 1907 if {[info exists portinfo(porturl)]} { 1908 set porturl $portinfo(porturl) 1773 1909 } 1774 1910 1775 1911 if {![info exists porturl]} { … … 1938 2074 } 1939 2075 1940 2076 # check if the port is in tree 1941 if {[catch {mport search $portname false exact} result]} {2077 if {[catch {mportlookup $portname} result]} { 1942 2078 global errorInfo 1943 2079 ui_debug "$errorInfo" 1944 ui_error "port searchfailed: $result"2080 ui_error "port lookup failed: $result" 1945 2081 return 1 1946 2082 } 1947 2083 # argh! port doesnt exist!