diff --git a/src/client/opamArg.ml b/src/client/opamArg.ml index b3e2fac8ea4..81d1c10e482 100644 --- a/src/client/opamArg.ml +++ b/src/client/opamArg.ml @@ -458,6 +458,8 @@ type global_options = { no_auto_upgrade : bool; working_dir : bool; ignore_pin_depends : bool; + no_checksums: bool; + req_checksums : bool; cli : OpamCLIVersion.t; } @@ -469,6 +471,7 @@ let create_global_options opt_root external_solver use_internal_solver cudf_file solver_preferences best_effort safe_mode json no_auto_upgrade working_dir ignore_pin_depends + no_checksums req_checksums d_no_aspcud _ = if d_no_aspcud then OpamConsole.warning @@ -485,7 +488,9 @@ let create_global_options { git_version; debug_level; verbose; quiet; color; opt_switch; confirm_level; yes; strict; opt_root; external_solver; use_internal_solver; cudf_file; solver_preferences; best_effort; safe_mode; json; - no_auto_upgrade; working_dir; ignore_pin_depends; cli } + no_auto_upgrade; working_dir; ignore_pin_depends; + no_checksums; req_checksums; + cli } let apply_global_options cli o = if o.git_version then ( @@ -532,7 +537,10 @@ let apply_global_options cli o = (* - repository options - *) (* ?download_tool:(OpamTypes.arg list * dl_tool_kind) Lazy.t *) (* ?retries:int *) - (* ?force_checksums:bool option *) + ?force_checksums:(if o.req_checksums then Some (Some true) + else if o.no_checksums then Some (Some false) + else None) + (* ?repo_tarring: bool *) (* - solver options *) ?cudf_file:(some o.cudf_file) ?solver @@ -630,8 +638,6 @@ type build_options = { reuse_build_dir: bool; inplace_build : bool; make : string option; - no_checksums : bool; - req_checksums : bool; build_test : bool; build_doc : bool; dev_setup : bool; @@ -649,14 +655,14 @@ type build_options = { } let create_build_options - keep_build_dir reuse_build_dir inplace_build make no_checksums - req_checksums build_test build_doc dev_setup show dryrun skip_update + keep_build_dir reuse_build_dir inplace_build make + build_test build_doc dev_setup show dryrun skip_update fake jobs ignore_constraints_on unlock_base locked lock_suffix assume_depexts no_depexts = { - keep_build_dir; reuse_build_dir; inplace_build; make; no_checksums; - req_checksums; build_test; build_doc; dev_setup; show; dryrun; skip_update; + keep_build_dir; reuse_build_dir; inplace_build; make; + build_test; build_doc; dev_setup; show; dryrun; skip_update; fake; jobs; ignore_constraints_on; unlock_base; locked; lock_suffix; assume_depexts; no_depexts; } @@ -664,13 +670,14 @@ let create_build_options 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 (* ?download_tool:(OpamTypes.arg list * dl_tool_kind) Lazy.t *) (* ?retries:int *) - ?force_checksums:(if b.req_checksums then Some (Some true) - else if b.no_checksums then Some (Some false) - else None) + (* ?force_checksums:bool option *) + (* ?repo_tarring: bool *) (); +*) OpamStateConfig.update (* ?root: -- handled globally *) ?jobs:(b.jobs >>| fun j -> lazy j) @@ -1378,6 +1385,17 @@ let global_options cli = through $(i,opam pin) or through $(i,opam install DIR). This is \ equivalent to setting $(b,IGNOREPINDEPENDS=true)." in + let no_checksums = + mk_flag ~cli cli_original ~section ["no-checksums"] + "Do not verify the checksum of downloaded archives.\ + This is equivalent to setting $(b,\\$OPAMNOCHECKSUMS) to \"true\"." + in + let req_checksums = + mk_flag ~cli cli_original ~section ["require-checksums"] + "Reject the installation of packages that don't provide a checksum for \ + the upstream archives. \ This is equivalent to setting \ + $(b,\\$OPAMREQUIRECHECKSUMS) to \"true\"." + in Term.(const create_global_options $git_version $debug $debug_level $verbose $quiet $color $switch $yes $confirm_level @@ -1385,6 +1403,7 @@ let global_options cli = $use_internal_solver $cudf_file $solver_preferences $best_effort $safe_mode $json_flag $no_auto_upgrade $working_dir $ignore_pin_depends + $no_checksums $req_checksums $d_no_aspcud $cli_arg) (* lock options *) @@ -1404,17 +1423,6 @@ let lock_suffix ?section cli = "Set locked files suffix to $(i,SUFFIX)." Arg.(string) ("locked") -(* Checksums options *) -let no_checksums ?section cli from_cli = - mk_flag ~cli from_cli ?section ["no-checksums"] - "Do not verify the checksum of downloaded archives.\ - This is equivalent to setting $(b,\\$OPAMNOCHECKSUMS) to \"true\"." -let require_checksums ?section cli from_cli = - mk_flag ~cli from_cli ?section ["require-checksums"] - "Reject the installation of packages that don't provide a checksum for\ - the upstream archives. This is equivalent to setting \ - $(b,\\$OPAMREQUIRECHECKSUMS) to \"true\"." - (* Options common to all build commands *) let build_option_section = "PACKAGE BUILD OPTIONS" let man_build_option_section = @@ -1443,8 +1451,6 @@ let build_options cli = affects packages that are explicitly listed on the command-line. \ This is equivalent to setting $(b,\\$OPAMINPLACEBUILD) to \"true\"." in - let no_checksums = no_checksums ~section cli cli_original in - let req_checksums = require_checksums ~section cli cli_original in let build_test = mk_flag_replaced ~cli ~section [ cli_between cli2_0 cli2_1 ~replaced:"--with-test", ["build-test"]; @@ -1531,7 +1537,7 @@ let build_options cli = in Term.(const create_build_options $keep_build_dir $reuse_build_dir $inplace_build $make - $no_checksums $req_checksums $build_test $build_doc $dev_setup $show + $build_test $build_doc $dev_setup $show $dryrun $skip_update $fake $jobs_flag ~section cli cli_original $ignore_constraints_on $unlock_base $locked $lock_suffix $assume_depexts $no_depexts) diff --git a/src/client/opamArg.mli b/src/client/opamArg.mli index 0c577b8c435..5f7bfd88201 100644 --- a/src/client/opamArg.mli +++ b/src/client/opamArg.mli @@ -170,6 +170,8 @@ type global_options = { no_auto_upgrade : bool; working_dir : bool; ignore_pin_depends : bool; + no_checksums: bool; + req_checksums : bool; cli : OpamCLIVersion.t; } @@ -207,12 +209,6 @@ val apply_build_options: OpamCLIVersion.Sourced.t -> build_options -> unit val locked: ?section:string -> OpamCLIVersion.Sourced.t -> bool Term.t val lock_suffix: ?section:string -> OpamCLIVersion.Sourced.t -> string Term.t -(** Checksum options *) -val no_checksums: - ?section:string -> OpamCLIVersion.Sourced.t -> validity -> bool Term.t -val require_checksums: - ?section:string -> OpamCLIVersion.Sourced.t -> validity -> bool Term.t - (** {3 Package listing and filtering options} *) (** Man section name *) diff --git a/src/client/opamCommands.ml b/src/client/opamCommands.ml index 3225f69b3e1..0fc9556e223 100644 --- a/src/client/opamCommands.ml +++ b/src/client/opamCommands.ml @@ -3649,19 +3649,8 @@ let source cli = "Choose package without consideration for \ the current (or any other) switch (installed or pinned packages, etc.)" in - let no_checksums = no_checksums cli (cli_from cli2_2) in - let req_checksums = require_checksums cli (cli_from cli2_2) in - let source global_options atom dev_repo pin no_switch dir - no_checksums req_checksums () = + let source global_options atom dev_repo pin no_switch dir () = apply_global_options cli global_options; - let force_checksums = - if req_checksums then Some (Some true) - else if no_checksums then Some (Some false) - else None - in - OpamStd.Option.iter (fun force_checksums -> - OpamRepositoryConfig.update ~force_checksums ()) - force_checksums; OpamGlobalState.with_ `Lock_none @@ fun gt -> let get_package_dir t = let nv = @@ -3789,8 +3778,7 @@ let source cli = mk_command ~cli cli_original "source" ~doc ~man Term.(const source $global_options cli - $atom $dev_repo $pin $no_switch $dir - $no_checksums $req_checksums) + $atom $dev_repo $pin $no_switch $dir) (* LINT *) let lint_doc = "Checks and validate package description ('opam') files."