Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opam search now look in configurable locations. #1655

Merged
merged 3 commits into from Aug 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Makefile
Expand Up @@ -215,7 +215,7 @@ SRC_opam-admin = \
opam_repo_check.ml \
opam_stats.ml \
opam_depexts_change.ml \
opam_libraries.ml \
opam_findlib.ml \
opam_admin.ml

define PROJ_opam-admin
Expand Down
19 changes: 16 additions & 3 deletions src/client/opamClient.ml
Expand Up @@ -19,6 +19,7 @@ open OpamTypesBase
open OpamState.Types
open OpamMisc.OP
open OpamPackage.Set.Op
open OpamFilename.OP

let log fmt = OpamGlobals.log "CLIENT" fmt
let slog = OpamGlobals.slog
Expand All @@ -34,6 +35,7 @@ type package_details = {
tags: string list;
syntax: string list Lazy.t;
libraries: string list Lazy.t;
others: string list Lazy.t; (* words in lines in files *)
}

let details_of_package t name versions =
Expand Down Expand Up @@ -69,9 +71,19 @@ let details_of_package t name versions =
if OpamState.eval_filter t ~opam OpamVariable.Map.empty filter
then Some s else None)
(OpamFile.OPAM.libraries opam)) in
let others = lazy (
match OpamState.repository_and_prefix_of_package t nv with
| None -> []
| Some (repo, prefix) ->
List.fold_left (fun acc filename ->
let file = OpamPath.Repository.packages repo prefix nv // filename in
let file = OpamFile.Lines.safe_read file in
List.flatten file @ acc
) [] !OpamGlobals.search_files
) in
{ name; current_version; installed_version;
synopsis; descr; tags;
syntax; libraries }
syntax; libraries; others; }

let details_of_package_regexps t packages ~exact_name ~case_sensitive regexps =
log "names_of_regexp regexps=%a"
Expand Down Expand Up @@ -118,7 +130,7 @@ let details_of_package_regexps t packages ~exact_name ~case_sensitive regexps =
(* Filter the list of packages, depending on user predicates *)
let packages_map =
OpamPackage.Name.Map.filter
(fun name { synopsis; descr; tags; syntax; libraries } ->
(fun name { synopsis; descr; tags; syntax; libraries; others } ->
regexps = []
|| exact_match (OpamPackage.Name.to_string name)
|| not exact_name &&
Expand All @@ -127,7 +139,8 @@ let details_of_package_regexps t packages ~exact_name ~case_sensitive regexps =
|| partial_match (Lazy.force descr)
|| partial_matchs tags
|| partial_matchs (Lazy.force libraries)
|| partial_matchs (Lazy.force syntax))
|| partial_matchs (Lazy.force syntax)
|| partial_matchs (Lazy.force others))
) packages_map in

if not (OpamPackage.Set.is_empty packages)
Expand Down