From 25c129559efe19765619a1a39ee48a435416ffd4 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Fri, 12 Nov 2021 14:35:50 +0000 Subject: [PATCH 1/3] Use --assume-depext in CLI 2.0 mode --- master_changes.md | 3 +++ src/client/opamArg.ml | 4 ++-- src/client/opamArg.mli | 2 +- src/client/opamCommands.ml | 14 +++++++------- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/master_changes.md b/master_changes.md index 78cfb2eac73..974bdc65e39 100644 --- a/master_changes.md +++ b/master_changes.md @@ -8,6 +8,9 @@ New option/command/subcommand are prefixed with ◈. ## Global CLI * + * Fix typo in error message for opam var [#4786 @kit-ty-kate - fix #4785] + * Add cli 2.2 handling [#4853 @rjbou] + * --assume-depext is the default in CLI 2.0 mode [#4908 @dra27] ## Plugins * diff --git a/src/client/opamArg.ml b/src/client/opamArg.ml index 36dc304618f..437f6758465 100644 --- a/src/client/opamArg.ml +++ b/src/client/opamArg.ml @@ -600,7 +600,7 @@ let create_build_options assume_depexts; no_depexts; } -let apply_build_options b = +let apply_build_options cli b = let open OpamStd.Option.Op in let flag f = if f then Some true else None in OpamRepositoryConfig.update @@ -633,7 +633,7 @@ let apply_build_options b = ?show:(flag b.show) ?fake:(flag b.fake) ?skip_dev_update:(flag b.skip_update) - ?assume_depexts:(flag (b.assume_depexts || b.no_depexts)) + ?assume_depexts:(flag (b.assume_depexts || b.no_depexts || OpamCLIVersion.Op.(cli @= cli2_0))) ~scrubbed_environment_variables () diff --git a/src/client/opamArg.mli b/src/client/opamArg.mli index 35da8ee0a83..1fcea19c7f7 100644 --- a/src/client/opamArg.mli +++ b/src/client/opamArg.mli @@ -191,7 +191,7 @@ val recurse: OpamCLIVersion.Sourced.t -> bool Term.t val subpath: OpamCLIVersion.Sourced.t -> string option Term.t (** Applly build options *) -val apply_build_options: build_options -> unit +val apply_build_options: OpamCLIVersion.Sourced.t -> build_options -> unit (** Lock options *) val locked: ?section:string -> OpamCLIVersion.Sourced.t -> bool Term.t diff --git a/src/client/opamCommands.ml b/src/client/opamCommands.ml index be1044551f1..08fd6aad863 100644 --- a/src/client/opamCommands.ml +++ b/src/client/opamCommands.ml @@ -311,7 +311,7 @@ let init cli = show_opamrc bypass_checks () = apply_global_options cli global_options; - apply_build_options build_options; + apply_build_options cli build_options; (* If show option is set, dump opamrc and exit *) if show_opamrc then (OpamFile.InitConfig.write_to_channel stdout @@ @@ -1615,7 +1615,7 @@ let install cli = restore destdir assume_built check recurse subpath depext_only download_only atoms_or_locals () = apply_global_options cli global_options; - apply_build_options build_options; + apply_build_options cli build_options; if atoms_or_locals = [] && not restore then `Error (true, "required argument PACKAGES is missing") else @@ -1731,7 +1731,7 @@ let remove cli = let remove global_options build_options autoremove force destdir recurse subpath atom_locs () = apply_global_options cli global_options; - apply_build_options build_options; + apply_build_options cli build_options; OpamGlobalState.with_ `Lock_none @@ fun gt -> match destdir with | Some d -> @@ -1804,7 +1804,7 @@ let reinstall cli = let reinstall global_options build_options assume_built recurse subpath atoms_locs cmd () = apply_global_options cli global_options; - apply_build_options build_options; + apply_build_options cli build_options; let open OpamPackage.Set.Op in OpamGlobalState.with_ `Lock_none @@ fun gt -> match cmd, atoms_locs with @@ -1975,7 +1975,7 @@ let upgrade cli = let upgrade global_options build_options fixup check only_installed all recurse subpath atom_locs () = apply_global_options cli global_options; - apply_build_options build_options; + apply_build_options cli build_options; let all = all || atom_locs = [] in OpamGlobalState.with_ `Lock_none @@ fun gt -> if fixup then @@ -2553,7 +2553,7 @@ let switch cli = OpamConsole.warning "Option %s is deprecated, ignoring it." (OpamConsole.colorise `bold "--no-autoinstall"); apply_global_options cli global_options; - apply_build_options build_options; + apply_build_options cli build_options; let invariant_arg ?repos rt args = match args, packages, formula, empty with | [], None, None, false -> None @@ -3107,7 +3107,7 @@ let pin ?(unpin_only=false) cli = with_version command params () = apply_global_options cli global_options; - apply_build_options build_options; + apply_build_options cli build_options; let locked = OpamStateConfig.(!r.locked) <> None in let action = not no_act in let get_command = function From c6c516a76e915119a4f3c277e3ce6dd0c19ee0f6 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Fri, 12 Nov 2021 16:00:57 +0000 Subject: [PATCH 2/3] Use --no-depexts instead of --assume-depexts Means that packages which are unavailable can still be installed, as in opam 2.0. --- master_changes.md | 2 +- src/client/opamArg.ml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/master_changes.md b/master_changes.md index 974bdc65e39..f71803ad9b3 100644 --- a/master_changes.md +++ b/master_changes.md @@ -10,7 +10,7 @@ New option/command/subcommand are prefixed with ◈. * * Fix typo in error message for opam var [#4786 @kit-ty-kate - fix #4785] * Add cli 2.2 handling [#4853 @rjbou] - * --assume-depext is the default in CLI 2.0 mode [#4908 @dra27] + * --no-depexts is the default in CLI 2.0 mode [#4908 @dra27] ## Plugins * diff --git a/src/client/opamArg.ml b/src/client/opamArg.ml index 437f6758465..3c485019e0a 100644 --- a/src/client/opamArg.ml +++ b/src/client/opamArg.ml @@ -624,7 +624,7 @@ let apply_build_options cli b = OpamPackage.Name.Set.of_list) ?unlock_base:(flag b.unlock_base) ?locked:(if b.locked then Some (Some b.lock_suffix) else None) - ?no_depexts:(flag b.no_depexts) + ?no_depexts:(flag b.no_depexts || OpamCLIVersion.Op.(cli @= cli2_0)) (); OpamClientConfig.update ?keep_build_dir:(flag b.keep_build_dir) @@ -633,7 +633,7 @@ let apply_build_options cli b = ?show:(flag b.show) ?fake:(flag b.fake) ?skip_dev_update:(flag b.skip_update) - ?assume_depexts:(flag (b.assume_depexts || b.no_depexts || OpamCLIVersion.Op.(cli @= cli2_0))) + ?assume_depexts:(flag (b.assume_depexts || b.no_depexts)) ~scrubbed_environment_variables () From d8be1b256fbc409dafd473fcc5132e7f44ff48bf Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Fri, 12 Nov 2021 17:41:59 +0100 Subject: [PATCH 3/3] fixup! Use --no-depexts instead of --assume-depexts --- src/client/opamArg.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/opamArg.ml b/src/client/opamArg.ml index 3c485019e0a..ed221b5e1d2 100644 --- a/src/client/opamArg.ml +++ b/src/client/opamArg.ml @@ -624,7 +624,7 @@ let apply_build_options cli b = OpamPackage.Name.Set.of_list) ?unlock_base:(flag b.unlock_base) ?locked:(if b.locked then Some (Some b.lock_suffix) else None) - ?no_depexts:(flag b.no_depexts || OpamCLIVersion.Op.(cli @= cli2_0)) + ?no_depexts:(flag (b.no_depexts || OpamCLIVersion.Op.(cli @= cli2_0))) (); OpamClientConfig.update ?keep_build_dir:(flag b.keep_build_dir)