[137802] branches/gsoc15-dependency/base/src/macports1.0
ijackson at macports.org
ijackson at macports.org
Sat Jun 20 02:44:33 PDT 2015
Revision: 137802
https://trac.macports.org/changeset/137802
Author: ijackson at macports.org
Date: 2015-06-20 02:44:32 -0700 (Sat, 20 Jun 2015)
Log Message:
-----------
Libsolv Search: Add support to lookup in more fields in solv.
Add support to search in name, description, category and
homepage of the solv's repodata. Pass $field to libsolv search
to make this extended search possible which is set by the options
passed to "port search" i.e. --name, --description, etc.
Update comment headers: To-Do and Done list.
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-20 09:01:49 UTC (rev 137801)
+++ branches/gsoc15-dependency/base/src/macports1.0/macports.tcl 2015-06-20 09:44:32 UTC (rev 137802)
@@ -2745,7 +2745,7 @@
macports::libsolv::create_pool
# macports::libsolv::print
set search_res [macports::libsolv::search $pattern \
- $case_sensitive $matchstyle]
+ $case_sensitive $matchstyle $field]
return $search_res
}
} else {
Modified: branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl
===================================================================
--- branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl 2015-06-20 09:01:49 UTC (rev 137801)
+++ branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl 2015-06-20 09:44:32 UTC (rev 137802)
@@ -59,9 +59,10 @@
## Procedure to create the libsolv pool. This is similar to PortIndex. \
# Read the PortIndex contents and write into libsolv readable solv's.
# To Do:
- # Add additional information regarding arch, vendor, description, dependency, etc to solv.
+ # Add additional information regarding arch, vendor, dependency, etc to solv.
# Done:
# Add epoch, version and revision to each solv.
+ # Add more info to solv about its description, long_description, license, category and homepage.
proc create_pool {} {
variable pool
variable portindexinfo
@@ -145,17 +146,20 @@
## Search using libsolv. Needs some more work.
# To Do list:
- # Add more info to the solv's to search into more details of the ports (description, \
- # license, version, etc.
+ # Add support for searching in License and other fields too. Some changes to be made port.tcl to
+ # support these options to be passed i.e. --license
# 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} } {
+ # Add more info to the solv's to search into more details of the ports (description, \
+ # homepage, category, etc.
+ proc search {pattern {case_sensitive yes} {matchstyle regexp} {field name}} {
variable pool
variable portindexinfo
set matches [list]
set sel [$pool Selection]
+ variable search_option
## Initialize search option flag depending on the option passed to port search
switch -- $matchstyle {
@@ -177,8 +181,21 @@
if {!${case_sensitive}} {
set di_flag [expr $di_flag | $solv::Dataiterator_SEARCH_NOCASE]
}
+
+ ## Set options for search. Binary OR the $search_option to lookup more fields.
+ if {$field eq "name"} {
+ set search_option $solv::SOLVABLE_NAME
+ } elseif {$field eq "description"} {
+ set search_option $solv::SOLVABLE_SUMMARY
+ } elseif {$field eq "long_description"} {
+ set search_option $solv::SOLVABLE_DESCRIPTION
+ } elseif {$field eq "homepage"} {
+ set search_option $solv::SOLVABLE_URL
+ } elseif {$field eq "categories"} {
+ set search_option $solv::SOLVABLE_CATEGORY
+ }
- set di [$pool Dataiterator $solv::SOLVABLE_NAME $pattern $di_flag]
+ set di [$pool Dataiterator $search_option $pattern $di_flag]
while {[set data [$di __next__]] ne "NULL"} {
$sel add_raw $solv::Job_SOLVER_SOLVABLE [$data cget -solvid]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20150620/8ae301dc/attachment.html>
More information about the macports-changes
mailing list