Skip to content

Commit

Permalink
Correct display of multiple missing depexts
Browse files Browse the repository at this point in the history
  • Loading branch information
dra27 committed May 24, 2021
1 parent aa7621e commit 826cc14
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
2 changes: 2 additions & 0 deletions master_changes.md
Expand Up @@ -32,6 +32,8 @@ New option/command/subcommand are prefixed with ◈.
* Keep global lock only if root format upgrade is performed [#4612 @rjbou - fix #4597]
* Improve installation times by only tracking files listed in `.install` instead of the whole switch prefix when there are no `install:` instructions (and no preinstall commands) [#4494 @kit-ty-kate @rjbou - fix #4422]
* Scrub OPAM* environment variables added since 2.0 from package builds to prevent warnings when a package calls opam [#4663 @dra27 - fix #4660]
* Correct the message when more than one depext is missing [#4678 @dra27]
* Only display one conflict message when they are all owing to identical missing depexts [#4678 @dra27]

## Remove
*
Expand Down
15 changes: 12 additions & 3 deletions src/client/opamSolution.ml
Expand Up @@ -137,13 +137,22 @@ let check_availability ?permissive t set atoms =
match OpamSwitchState.depexts_unavailable
t (OpamPackage.Set.max_elt pkgs) with
| Some missing ->
let missing =
List.rev_map OpamSysPkg.to_string (OpamSysPkg.Set.elements missing)
in
let msg =
match missing with
| [pkg] ->
" '" ^ pkg ^ "'"
| pkgs ->
"s " ^ (OpamStd.Format.pretty_list (List.rev_map (Printf.sprintf "'%s'") pkgs))
in
Some
(Printf.sprintf
"Package %s depends on the unavailable system package '%s'. You \
"Package %s depends on the unavailable system package%s. You \
can use `--no-depexts' to attempt installation anyway."
(OpamFormula.short_string_of_atom atom)
(OpamStd.List.concat_map " " OpamSysPkg.to_string
(OpamSysPkg.Set.elements missing)))
msg)
| None -> None
in
let check_atom (name, cstr as atom) =
Expand Down
16 changes: 12 additions & 4 deletions src/state/opamSwitchState.ml
Expand Up @@ -1076,11 +1076,19 @@ let unavailable_reason st ?(default="") (name, vformula) =
else
match depexts_unavailable st (OpamPackage.Set.max_elt candidates) with
| Some missing ->
let missing =
List.rev_map OpamSysPkg.to_string (OpamSysPkg.Set.elements missing)
in
let msg =
match missing with
| [pkg] ->
" '" ^ pkg ^ "'"
| pkgs ->
"s " ^ (OpamStd.Format.pretty_list (List.rev_map (Printf.sprintf "'%s'") pkgs))
in
Printf.sprintf
"depends on the unavailable system package '%s'. Use \
`--assume-depexts' to attempt installation anyway."
(OpamStd.List.concat_map " " OpamSysPkg.to_string
(OpamSysPkg.Set.elements missing))
"depends on the unavailable system package%s. Use \
`--assume-depexts' to attempt installation anyway." msg
| None -> default

let update_package_metadata nv opam st =
Expand Down

0 comments on commit 826cc14

Please sign in to comment.