Skip to content

Commit

Permalink
Merge pull request #5847 from rjbou/spmc-initconfig
Browse files Browse the repository at this point in the history
Add `sys-pkg-manager-cmd`  in init config
  • Loading branch information
kit-ty-kate authored Feb 19, 2024
2 parents ff08f89 + 0ce1cf3 commit 95a4d5e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ users)
* Add rsync package to internal Cygwin packages list (enables local pinning and is used by the VCS backends [#5808 @dra27]
* Recommend enabling Developer Mode on Windows [#5831 @dra27]
* Disable ACL in Cygwin internal install to avoid permission mismatch errors [#5796 @kit-ty-kate - fix #5781]
* Add `sys-pkg-manager-cmd` as an accepted field in opamrc files [#5847 @rjbou - fix #5844]

## Config report

Expand Down Expand Up @@ -133,5 +134,6 @@ users)
## opam-solver

## opam-format
* `OpamFile.InitConfig`: add `sys-pkg-manager-cmd` field [#5847 @rjbou]

## opam-core
4 changes: 3 additions & 1 deletion src/client/opamClient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,9 @@ let update_with_init_config ?(overwrite=false) config init_config =
setifnew C.default_compiler C.with_default_compiler
(I.default_compiler init_config) |>
setifnew C.default_invariant C.with_default_invariant
(I.default_invariant init_config)
(I.default_invariant init_config) |>
setifnew C.sys_pkg_manager_cmd C.with_sys_pkg_manager_cmd
(I.sys_pkg_manager_cmd init_config)

let reinit ?(init_config=OpamInitDefaults.init_config()) ~interactive
?dot_profile ?update_config ?env_hook ?completion ?inplace
Expand Down
19 changes: 18 additions & 1 deletion src/format/opamFile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,7 @@ module InitConfigSyntax = struct
recommended_tools : (string list * string option * filter option) list;
required_tools : (string list * string option * filter option) list;
init_scripts : ((string * string) * filter option) list;
sys_pkg_manager_cmd: filename OpamStd.String.Map.t;
git_location: dirname option;
}

Expand All @@ -1736,6 +1737,7 @@ module InitConfigSyntax = struct
let init_scripts t = t.init_scripts
let criterion kind t =
OpamStd.(List.assoc_opt Compare.equal kind t.solver_criteria)
let sys_pkg_manager_cmd t = t.sys_pkg_manager_cmd
let git_location t = t.git_location

let with_opam_version opam_version t = {t with opam_version}
Expand All @@ -1760,7 +1762,10 @@ module InitConfigSyntax = struct
kind t.solver_criteria)
in
{ t with solver_criteria }
let with_git_location git_location t = { t with git_location = Some git_location }
let with_sys_pkg_manager_cmd sys_pkg_manager_cmd t =
{ t with sys_pkg_manager_cmd }
let with_git_location git_location t =
{ t with git_location = Some git_location }

let empty = {
opam_version = format_version;
Expand All @@ -1779,6 +1784,7 @@ module InitConfigSyntax = struct
recommended_tools = [];
required_tools = [];
init_scripts = [];
sys_pkg_manager_cmd = OpamStd.String.Map.empty;
git_location = None;
}

Expand Down Expand Up @@ -1879,6 +1885,13 @@ module InitConfigSyntax = struct
(Pp.V.string)
(Pp.V.string_tr))
(Pp.opt Pp.V.filter)));
"sys-pkg-manager-cmd", Pp.ppacc
with_sys_pkg_manager_cmd sys_pkg_manager_cmd
((Pp.V.map_list ~depth:2
(Pp.V.map_pair
Pp.V.string
(Pp.V.string -| Pp.of_module "filename" (module OpamFilename))))
-| Pp.of_pair "Distribution Map" OpamStd.String.Map.(of_list, bindings));
"git-location", Pp.ppacc_opt
with_git_location git_location
(Pp.V.string -| Pp.of_module "dirname" (module OpamFilename.Dir));
Expand Down Expand Up @@ -1927,6 +1940,10 @@ module InitConfigSyntax = struct
recommended_tools = list t2.recommended_tools t1.recommended_tools;
required_tools = list t2.required_tools t1.required_tools;
init_scripts = list t2.init_scripts t1.init_scripts;
sys_pkg_manager_cmd =
(if OpamStd.String.Map.is_empty t2.sys_pkg_manager_cmd then
t1.sys_pkg_manager_cmd
else t2.sys_pkg_manager_cmd);
git_location = opt t2.git_location t1.git_location;
}

Expand Down
1 change: 1 addition & 0 deletions src/format/opamFile.mli
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ module InitConfig: sig
val recommended_tools: t -> (string list * string option * filter option) list
val required_tools: t -> (string list * string option * filter option) list
val init_scripts: t -> ((string * string) * filter option) list
val sys_pkg_manager_cmd: t -> filename OpamStd.String.Map.t
val git_location: t -> dirname option

val with_opam_version: opam_version -> t -> t
Expand Down

0 comments on commit 95a4d5e

Please sign in to comment.