Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset the "jobs" config variable when upgrading to opam 2.2 #5904

Merged
merged 2 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ users)

## Version
* Bump version to 2.2.0~beta3~dev [#5917 @kit-ty-kate]
* Bump the version number after the release of 2.2.0~beta1 [#5785 @kit-ty-kate]
* Upgrade the opam-root-version to 2.2~beta [#5904 @kit-ty-kate]

## Global CLI

Expand Down Expand Up @@ -64,6 +66,8 @@ users)
## External dependencies

## Format upgrade
* Handle init OCaml `sys-ocaml-*` eval variables during format upgrade from 2.0 -> 2.1 -> 2.2 [#5829 @dra27]
* Reset the "jobs" config variable when upgrading from opam 2.1 to 2.2, instead of 2.0 to 2.1 [#5904 @kit-ty-kate - fix #5816]

## Sandbox

Expand Down Expand Up @@ -106,6 +110,7 @@ users)
### Tests
* tree: add a test for packages that have variables in their transitive dependencies [#5919 @rjbou]
* tree: add test for `opam tree pkg --with-test --no-switch` [#5919 @rjbou]
* Update opam root version test with root version bump [#5904 @rjbou]

### Engine

Expand Down
2 changes: 1 addition & 1 deletion src/format/opamFile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ module ConfigSyntax = struct
let atomic = false
let format_version = OpamVersion.of_string "2.1"
let file_format_version = OpamVersion.of_string "2.0"
let root_version = OpamVersion.of_string "2.2~alpha"
let root_version = OpamVersion.of_string "2.2~beta"

let default_old_root_version = OpamVersion.of_string "2.1~~previous"

Expand Down
21 changes: 13 additions & 8 deletions src/state/opamFormatUpgrade.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,18 @@ let sys_config_variables_unix_2_1 = [
"Host C Runtime Library type of the OCaml compiler present on your system";
]

let from_2_0_to_2_1 ~on_the_fly _ conf =
let from_2_0_to_2_1 ~on_the_fly:_ _ conf =
apply_eval_variables conf [] sys_config_variables_unix_2_1, gtc_none

let v2_2_alpha = OpamVersion.of_string "2.2~alpha"

let from_2_1_to_2_2_alpha ~on_the_fly:_ _ conf =
apply_eval_variables conf sys_config_variables_unix_2_1
OpamEnv.sys_ocaml_eval_variables, gtc_none

let v2_2_beta = OpamVersion.of_string "2.2~beta"

let from_2_2_alpha_to_2_2_beta ~on_the_fly _ 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.
Expand All @@ -1130,15 +1141,8 @@ let from_2_0_to_2_1 ~on_the_fly _ conf =
| 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);
let conf = apply_eval_variables conf [] sys_config_variables_unix_2_1 in
kit-ty-kate marked this conversation as resolved.
Show resolved Hide resolved
OpamFile.Config.with_jobs_opt None conf, gtc_none

let v2_2_alpha = OpamVersion.of_string "2.2~alpha"

let from_2_1_to_2_2_alpha ~on_the_fly:_ _ conf =
apply_eval_variables conf sys_config_variables_unix_2_1
OpamEnv.sys_ocaml_eval_variables, gtc_none

(* To add an upgrade layer
* If it is a light upgrade, returns as second element if the repo or switch
need an light upgrade with `gtc_*` values.
Expand Down Expand Up @@ -1234,6 +1238,7 @@ let as_necessary ?reinit requested_lock global_lock root config =
v2_1, from_2_0_to_2_1;
]) @ [
v2_2_alpha, from_2_1_to_2_2_alpha;
v2_2_beta, from_2_2_alpha_to_2_2_beta;
]
|> List.filter (fun (v,_) ->
OpamVersion.compare root_version v < 0)
Expand Down
2 changes: 2 additions & 0 deletions tests/reftests/init-ocaml-eval-variables.unix.test
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ This version of opam requires an update to the layout of ${BASEDIR}/OPAM from ve
You may want to back it up before going further.

Continue? [y/n] y
[NOTE] The 'jobs' option was reset, its value was 1 and its new value will vary according to the current number of cores on your machine. You can restore the fixed value using:
opam option jobs=1 --global
Format upgrade done.
Set to '4' the field jobs in global configuration
### opam-cat $OPAMROOT/config | grep eval-variables
Expand Down
2 changes: 2 additions & 0 deletions tests/reftests/init-ocaml-eval-variables.win32.test
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ This version of opam requires an update to the layout of ${BASEDIR}/OPAM from ve
You may want to back it up before going further.

Continue? [y/n] y
[NOTE] The 'jobs' option was reset, its value was 1 and its new value will vary according to the current number of cores on your machine. You can restore the fixed value using:
opam option jobs=1 --global
Format upgrade done.
Set to '4' the field jobs in global configuration
### opam-cat $OPAMROOT/config | grep eval-variables
Expand Down
Loading
Loading