Skip to content
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
3 changes: 3 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,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
22 changes: 22 additions & 0 deletions tests/reftests/opamroot-versions.test
Original file line number Diff line number Diff line change
Expand Up @@ -681,11 +681,15 @@ No configuration file found, using built-in defaults.
### opam option jobs | "${OPAMROOTVERSION}$" -> "current"
GSTATE LOAD-GLOBAL-STATE @ ${BASEDIR}/OPAM
FMT_UPG On-the-fly config upgrade, from 2.0 to current
[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. If it really was intended, you can set it again using:
opam option jobs=1 --global
FMT_UPG Format upgrade done
### # ro global state, ro repo state, ro switch state
### opam list | "${OPAMROOTVERSION}$" -> "current"
GSTATE LOAD-GLOBAL-STATE @ ${BASEDIR}/OPAM
FMT_UPG On-the-fly config upgrade, from 2.0 to current
[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. If it really was intended, you can set it again using:
opam option jobs=1 --global
FMT_UPG Format upgrade done
RSTATE LOAD-REPOSITORY-STATE @ ${BASEDIR}/OPAM
RSTATE No cache found
Expand All @@ -702,6 +706,8 @@ i-am-sys-compiler 1 One-line description
### opam install i-am-another-package --switch sw-comp | "${OPAMROOTVERSION}$" -> "current"
GSTATE LOAD-GLOBAL-STATE @ ${BASEDIR}/OPAM
FMT_UPG On-the-fly config upgrade, from 2.0 to current
[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. If it really was intended, you can set it again using:
opam option jobs=1 --global
FMT_UPG Format upgrade done
RSTATE LOAD-REPOSITORY-STATE @ ${BASEDIR}/OPAM
RSTATE Cache found
Expand All @@ -727,6 +733,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. If it really was intended, you can set it again using:
opam option jobs=1 --global
Format upgrade done.
RSTATE LOAD-REPOSITORY-STATE @ ${BASEDIR}/OPAM
RSTATE Cache found
Expand Down Expand Up @@ -768,6 +776,8 @@ roots: ["i-am-another-package.2" "i-am-compiler.2" "i-am-package.2"]
### opam list | "${OPAMROOTVERSION}$" -> "current"
GSTATE LOAD-GLOBAL-STATE @ ${BASEDIR}/OPAM
FMT_UPG On-the-fly config upgrade, from 2.0 to current
[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. If it really was intended, you can set it again using:
opam option jobs=1 --global
FMT_UPG Format upgrade done
RSTATE LOAD-REPOSITORY-STATE @ ${BASEDIR}/OPAM
RSTATE No cache found
Expand All @@ -783,6 +793,8 @@ i-am-sys-compiler 2 One-line description
### opam install i-am-package | "${OPAMROOTVERSION}$" -> "current"
GSTATE LOAD-GLOBAL-STATE @ ${BASEDIR}/OPAM
FMT_UPG On-the-fly config upgrade, from 2.0 to current
[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. If it really was intended, you can set it again using:
opam option jobs=1 --global
FMT_UPG Format upgrade done
RSTATE LOAD-REPOSITORY-STATE @ ${BASEDIR}/OPAM
RSTATE Cache found
Expand All @@ -807,6 +819,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. If it really was intended, you can set it again using:
opam option jobs=1 --global
Format upgrade done.
Set to '4' the field jobs in global configuration
### opam-cat $OPAMROOT/config | '"${OPAMROOTVERSION}"' -> "current"
Expand Down Expand Up @@ -848,6 +862,8 @@ roots: ["i-am-package.2" "i-am-sys-compiler.2"]
### opam list | "${OPAMROOTVERSION}$" -> " current"
GSTATE LOAD-GLOBAL-STATE @ ${BASEDIR}/OPAM
FMT_UPG On-the-fly config upgrade, from 2.0 to current
[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. If it really was intended, you can set it again using:
opam option jobs=1 --global
FMT_UPG Format upgrade done
RSTATE LOAD-REPOSITORY-STATE @ ${BASEDIR}/OPAM
RSTATE No cache found
Expand All @@ -862,6 +878,8 @@ i-am-sys-compiler 2 One-line description
### opam install i-am-package | "${OPAMROOTVERSION}$" -> "current"
GSTATE LOAD-GLOBAL-STATE @ ${BASEDIR}/OPAM
FMT_UPG On-the-fly config upgrade, from 2.0 to current
[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. If it really was intended, you can set it again using:
opam option jobs=1 --global
FMT_UPG Format upgrade done
RSTATE LOAD-REPOSITORY-STATE @ ${BASEDIR}/OPAM
RSTATE Cache found
Expand All @@ -886,6 +904,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. If it really was intended, you can set it again using:
opam option jobs=1 --global
Format upgrade done.
Set to '4' the field jobs in global configuration
### opam-cat $OPAMROOT/config | '"${OPAMROOTVERSION}"' -> "current"
Expand Down Expand Up @@ -998,6 +1018,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. If it really was intended, you can set it again using:
opam option jobs=1 --global
Format upgrade done.
RSTATE LOAD-REPOSITORY-STATE @ ${BASEDIR}/OPAM
RSTATE No cache found
Expand Down
6 changes: 6 additions & 0 deletions tests/reftests/upgrade-two-point-o.test
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pinned: ["i-am-compiler.1"]
opam-version: "2.0"
synopsis: "switch with pinned compiler"
### OPAMDEBUGSECTIONS=STATE opam upgrade --show-action --debug-level=-1
[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. If it really was intended, you can set it again using:
opam option jobs=1 --global
STATE LOAD-SWITCH-STATE @ pinned-comp
STATE Definition missing for installed package i-am-compiler.1, copying from repo
STATE Inferred invariant: from base packages { i-am-compiler.1 }, (roots { i-am-compiler.1 }) => ["i-am-compiler" {= "1"}]
Expand All @@ -31,9 +33,13 @@ Everything as up-to-date as possible (run with --verbose to show unavailable upg
However, you may "opam upgrade" these packages explicitly, which will ask permission to downgrade or uninstall the conflicting packages.
Nothing to do.
### opam pin remove i-am-compiler
[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. If it really was intended, you can set it again using:
opam option jobs=1 --global
Ok, i-am-compiler is no longer pinned locally (version 1)
Nothing to do.
### opam upgrade --show-action
[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. If it really was intended, you can set it again using:
opam option jobs=1 --global
Everything as up-to-date as possible (run with --verbose to show unavailable upgrades).
However, you may "opam upgrade" these packages explicitly, which will ask permission to downgrade or uninstall the conflicting packages.
Nothing to do.