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

Fix opam env messages #3274

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions src/client/opamClient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ let compute_upgrade_t
~upgrade:upgrade_atoms
())

let upgrade_t ?strict_upgrade ?auto_install ?ask ?(check=false) ~all atoms t =
let upgrade_t ?strict_upgrade ?auto_install ?ask ?(check=false) ~shell ~all atoms t =
log "UPGRADE %a"
(slog @@ function [] -> "<all>" | a -> OpamFormula.string_of_atoms a)
atoms;
Expand Down Expand Up @@ -328,15 +328,15 @@ let upgrade_t ?strict_upgrade ?auto_install ?ask ?(check=false) ~all atoms t =
(OpamPackage.Set.elements unopt)));
)
);
OpamSolution.check_solution t result;
OpamSolution.check_solution shell t result;
t

let upgrade t ?check ~all names =
let atoms = OpamSolution.sanitize_atom_list t names in
let t = update_dev_packages_t atoms t in
upgrade_t ?check ~strict_upgrade:(not all) ~all atoms t

let fixup t =
let fixup ~shell t =
log "FIXUP";
let t, full_orphans, orphan_versions = orphans ~transitive:true t in
let all_orphans = full_orphans ++ orphan_versions in
Expand Down Expand Up @@ -400,7 +400,7 @@ let fixup t =
~requested:(OpamPackage.names_of_packages (requested ++ req_rm))
solution
in
OpamSolution.check_solution t result;
OpamSolution.check_solution shell t result;
t

let update
Expand Down Expand Up @@ -726,7 +726,7 @@ let check_conflicts t atoms =
full_orphans,
orphan_versions

let install_t t ?ask atoms add_to_roots ~deps_only =
let install_t t ?ask ~shell atoms add_to_roots ~deps_only =
log "INSTALL %a" (slog OpamFormula.string_of_atoms) atoms;
let names = OpamPackage.Name.Set.of_list (List.rev_map fst atoms) in

Expand Down Expand Up @@ -853,7 +853,7 @@ let install_t t ?ask atoms add_to_roots ~deps_only =
in
OpamSolution.apply ?ask t Install ~requested:names ?add_roots solution
in
OpamSolution.check_solution t solution;
OpamSolution.check_solution shell t solution;
t

let install t ?autoupdate ?add_to_roots ?(deps_only=false) names =
Expand All @@ -865,7 +865,7 @@ let install t ?autoupdate ?add_to_roots ?(deps_only=false) names =
let t = update_dev_packages_t autoupdate_atoms t in
install_t t atoms add_to_roots ~deps_only

let remove_t ?ask ~autoremove ~force atoms t =
let remove_t ?ask ~shell ~autoremove ~force atoms t =
log "REMOVE autoremove:%b %a" autoremove
(slog OpamFormula.string_of_atoms) atoms;

Expand Down Expand Up @@ -943,7 +943,7 @@ let remove_t ?ask ~autoremove ~force atoms t =
~remove:(OpamSolution.atoms_of_packages to_remove)
())
in
OpamSolution.check_solution t solution;
OpamSolution.check_solution shell t solution;
t
) else if !nothing_to_do then (
OpamConsole.msg "Nothing to do.\n";
Expand All @@ -954,7 +954,7 @@ let remove t ~autoremove ~force names =
let atoms = OpamSolution.sanitize_atom_list t names in
remove_t ~autoremove ~force atoms t

let reinstall_t t ?ask ?(force=false) atoms =
let reinstall_t t ?ask ?(force=false) ~shell atoms =
log "reinstall %a" (slog OpamFormula.string_of_atoms) atoms;

let reinstall, not_installed =
Expand Down Expand Up @@ -992,7 +992,7 @@ let reinstall_t t ?ask ?(force=false) atoms =
~requested
request in

OpamSolution.check_solution t solution;
OpamSolution.check_solution shell t solution;
t

let reinstall t names =
Expand All @@ -1003,9 +1003,9 @@ let reinstall t names =
module PIN = struct
open OpamPinCommand

let post_pin_action st name =
let post_pin_action ~shell st name =
try
upgrade_t ~strict_upgrade:false ~auto_install:true ~ask:true ~all:false
upgrade_t ~shell ~strict_upgrade:false ~auto_install:true ~ask:true ~all:false
[name, None] st
with e ->
OpamConsole.note
Expand All @@ -1032,7 +1032,7 @@ module PIN = struct
"No package named %S found"
(OpamPackage.Name.to_string name)

let pin st name ?(edit=false) ?version ?(action=true) target =
let pin st name ?(edit=false) ?version ?(action=true) ~shell target =
try
let st =
match target with
Expand All @@ -1045,13 +1045,13 @@ module PIN = struct
| `None -> source_pin st name ?version ~edit None
in
if action then
(OpamConsole.msg "\n"; post_pin_action st name)
(OpamConsole.msg "\n"; post_pin_action ~shell st name)
else st
with
| OpamPinCommand.Aborted -> OpamStd.Sys.exit_because `Aborted
| OpamPinCommand.Nothing_to_do -> st

let edit st ?(action=true) ?version name =
let edit st ?(action=true) ?version ~shell name =
let st =
if OpamPackage.has_name st.pinned name then
edit st ?version name
Expand Down Expand Up @@ -1084,9 +1084,9 @@ module PIN = struct
OpamConsole.error_and_exit `Not_found
"Package is not pinned, and no existing version was supplied."
in
if action then post_pin_action st name else st
if action then post_pin_action ~shell st name else st

let unpin st ?(action=true) names =
let unpin ~shell st ?(action=true) names =
let pinned_before = st.pinned in
let st = unpin st names in
let available = Lazy.force st.available_packages in
Expand All @@ -1099,8 +1099,8 @@ module PIN = struct
else (nv.name, None) :: acc)
installed_unpinned []
in
upgrade_t ~strict_upgrade:false ~auto_install:true ~ask:true ~all:false
atoms st
upgrade_t ~shell ~strict_upgrade:false ~auto_install:true ~ask:true
~all:false atoms st
else st

let list = list
Expand Down
23 changes: 12 additions & 11 deletions src/client/opamClient.mli
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ val init:
val install:
rw switch_state ->
?autoupdate:atom list -> ?add_to_roots:bool -> ?deps_only:bool ->
atom list -> rw switch_state
atom list -> shell:shell -> rw switch_state

(** Low-level version of [reinstall], bypassing the package name sanitization
and dev package update, and offering more control *)
val install_t:
rw switch_state -> ?ask:bool ->
rw switch_state -> ?ask:bool -> shell:shell ->
atom list -> bool option -> deps_only:bool ->
rw switch_state

(** Reinstall the given set of packages. *)
val reinstall:
rw switch_state -> atom list -> rw switch_state
rw switch_state -> atom list -> shell:shell -> rw switch_state

(** Low-level version of [reinstall], bypassing the package name sanitization
and dev package update, and offering more control *)
val reinstall_t:
rw switch_state -> ?ask:bool -> ?force:bool -> atom list -> rw switch_state
rw switch_state -> ?ask:bool -> ?force:bool -> shell:shell -> atom list -> rw switch_state

(** Update the local mirrors for the repositories and/or development packages.
Returns [(success, changes, rt)], where [success] is [true] only if all
Expand All @@ -62,21 +62,21 @@ val update:
versions. The specified atoms are kept installed (or newly installed after a
confirmation). The upgrade concerns them only unless [all] is specified. *)
val upgrade:
rw switch_state -> ?check:bool -> all:bool -> atom list -> rw switch_state
rw switch_state -> ?check:bool -> all:bool -> atom list -> shell:shell -> rw switch_state

(** Low-level version of [upgrade], bypassing the package name sanitization
and dev package update, and offering more control *)
val upgrade_t:
?strict_upgrade:bool -> ?auto_install:bool -> ?ask:bool -> ?check:bool ->
all:bool -> atom list -> rw switch_state -> rw switch_state
shell:shell -> all:bool -> atom list -> rw switch_state -> rw switch_state

(** Recovers from an inconsistent universe *)
val fixup: rw switch_state -> rw switch_state
val fixup: shell:shell -> rw switch_state -> rw switch_state

(** Remove the given list of packages. *)
val remove:
rw switch_state -> autoremove:bool -> force:bool -> atom list ->
rw switch_state
shell:shell -> rw switch_state

module PIN: sig

Expand All @@ -86,15 +86,16 @@ module PIN: sig
rw switch_state ->
OpamPackage.Name.t ->
?edit:bool -> ?version:version -> ?action:bool ->
shell:shell ->
[< `Source of url | `Version of version | `Dev_upstream | `None ] ->
rw switch_state

val edit:
rw switch_state -> ?action:bool -> ?version:version -> OpamPackage.Name.t ->
rw switch_state
rw switch_state -> ?action:bool -> ?version:version -> shell:shell ->
OpamPackage.Name.t -> rw switch_state

val unpin:
rw switch_state ->
shell:shell -> rw switch_state ->
?action:bool -> OpamPackage.Name.t list -> rw switch_state

(** List the current pinned packages. *)
Expand Down
Loading