[137638] branches/gsoc15-dependency/base/src/macports1.0
ijackson at macports.org
ijackson at macports.org
Mon Jun 15 10:32:02 PDT 2015
Revision: 137638
https://trac.macports.org/changeset/137638
Author: ijackson at macports.org
Date: 2015-06-15 10:32:02 -0700 (Mon, 15 Jun 2015)
Log Message:
-----------
Done: Implement search using libsolv. (portnames only currently)
Information about the matched solv's: It's $name and $line (variant info,
description, version, etc) stored in portindexinfo (a map of $line
with each solv's id) are appended to $matches and returned to macports.tcl
which then returns the $search_res to port.tcl for parsing the output
results. Also add missing catch-finally block to try block in create_pool{}.
Close $fd which was left open even after it was done reading from and prevent
potential memory leak.
Modified Paths:
--------------
branches/gsoc15-dependency/base/src/macports1.0/macports.tcl
branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl
Modified: branches/gsoc15-dependency/base/src/macports1.0/macports.tcl
===================================================================
--- branches/gsoc15-dependency/base/src/macports1.0/macports.tcl 2015-06-15 17:17:38 UTC (rev 137637)
+++ branches/gsoc15-dependency/base/src/macports1.0/macports.tcl 2015-06-15 17:32:02 UTC (rev 137638)
@@ -2746,6 +2746,7 @@
# macports::libsolv::print
set search_res [macports::libsolv::search $pattern \
$case_sensitive $matchstyle]
+ return $search_res
}
} else {
## Use builtin search algorithm.
Modified: branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl
===================================================================
--- branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl 2015-06-15 17:17:38 UTC (rev 137637)
+++ branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl 2015-06-15 17:32:02 UTC (rev 137638)
@@ -40,6 +40,9 @@
## Variable for pool
variable pool
+ ## Variable for portindexinfo
+ variable portindexinfo
+
## Some debugging related printing of variable contents
proc print {} {
variable pool
@@ -59,11 +62,11 @@
# Add additional information regarding version, description, dependency, etc to solv.
proc create_pool {} {
variable pool
+ variable portindexinfo
## Check if libsolv cache (pool) is already created or not.
if {![info exists pool]} {
global macports::sources
- set matches [list]
## Create a new pool instance by calling Pool contructor.
set pool [solv::Pool]
@@ -87,7 +90,15 @@
set line [read $fd $len]
$solvable configure -name $name
+
+ ## Set portinfo of each solv object. Map it to correct solvid.
+ set portindexinfo([$solvable cget -id]) $line
}
+ } catch * {
+ ui_warn "It looks like your PortIndex file for $source may be corrupt."
+ throw
+ } finally {
+ close $fd
}
}
}
@@ -101,12 +112,16 @@
## Search using libsolv. Needs some more work.
# To Do list:
- # Return portinfo to mportsearch which will pass the info to port.tcl to print results.
+ # Add more info to the solv's to search into more details of the ports (description, \
+ # license, version, etc.
# Done:
# Add support for search options i.e. --exact, --case-sensitive, --glob, --regex.
+ # Return portinfo to mportsearch which will pass the info to port.tcl to print results.
proc search {pattern {case_sensitive yes} {matchstyle regexp} } {
variable pool
+ variable portindexinfo
+ set matches [list]
set sel [$pool Selection]
## Initialize search option flag depending on the option passed to port search
@@ -138,7 +153,10 @@
## This prints all the solvable's information that matched the pattern.
foreach s [$sel solvables] {
- puts "solvable = $s [$s __str__]"
+ lappend matches [$s cget -name]
+ lappend matches $portindexinfo([$s cget -id])
}
+
+ return $matches
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20150615/ce87eedd/attachment.html>
More information about the macports-changes
mailing list