Skip to content

Commit

Permalink
Reset the "jobs" config variable when upgrading from opam 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-ty-kate committed Sep 20, 2022
1 parent 6eeffc7 commit f721a79
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ users)
* Really install invariant formula if not installed in switch [#5188 @rjbou]
* On import, check that installed pinned packages changed, reinstall if so [#5181 @rjbou - fix #5173]

## Config
* Reset the "jobs" config variable when upgrading from opam 2.0 [#5284 @kit-ty-kate]

## Pin
* Switch the default version when undefined from ~dev to dev [#4949 @kit-ty-kate]
* ◈ New option `opam pin --current` to fix a package in its current state (avoiding pending reinstallations or removals from the repository) [#4973 @AltGr - fix #4970]
Expand Down
15 changes: 14 additions & 1 deletion src/state/opamFormatUpgrade.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,20 @@ let from_2_1_alpha2_to_v2_1_rc root conf =

let from_2_1_rc_to_v2_1 _ conf = conf

let from_2_0_to_v2_1 _ conf = conf
let from_2_0_to_v2_1 _ conf =
(* In opam < 2.1 "jobs" was set during initialisation
This creates problems when upgrading from opam 2.0 as it
sets the job count for good even if the CPU is replaced.
See https://github.com/ocurrent/ocaml-dockerfile/pull/92 *)
(* We print a warning in case the previous value of 'jobs' does not
match the default in opam 2.0 as we can't determine if the value
was modified or if the hardware changed. *)
if OpamFile.Config.jobs conf = Some (OpamSysPoll.cores () - 1) then
OpamConsole.note
"The 'jobs' option was reset, its value was %d. \
If it really was intended, you can set it again using:\n \
opam option jobs=%d --global" j j;
OpamFile.Config.with_jobs_opt None conf

let latest_version = OpamFile.Config.root_version

Expand Down

0 comments on commit f721a79

Please sign in to comment.