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 623a549
Show file tree
Hide file tree
Showing 2 changed files with 23 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
21 changes: 20 additions & 1 deletion src/state/opamFormatUpgrade.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,26 @@ 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 *)
let info_jobs_changed ~prev_jobs =
OpamConsole.note
"The 'jobs' option was reset, its value was %d and its new value \
will vary according to the current number of cores on your machine. \
If it really was intended, you can set it again using:\n \
opam option jobs=%d --global" prev_jobs prev_jobs;
in
(* We print a note 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. *)
(match OpamFile.Config.jobs conf with
| Some prev_jobs when prev_jobs = max 1 (OpamSysPoll.cores () - 1) -> ()
| Some prev_jobs -> info_jobs_changed ~prev_jobs
| None -> info_jobs_changed ~prev_jobs:1);
OpamFile.Config.with_jobs_opt None conf

let latest_version = OpamFile.Config.root_version

Expand Down

0 comments on commit 623a549

Please sign in to comment.