Skip to content
Closed
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 @@ -26,12 +26,14 @@ users)
## Install

## Build (package)
* No longer create build directory in `dry-run` mode [#6788 @rjbou @hannesm - fix #5918]

## Remove

## UI

## Switch
* No longer save switch-state cache in `dry-run` mode [#6788 @rjbou @hannesm - fix #5918]

## Config

Expand Down Expand Up @@ -113,6 +115,7 @@ users)
## Reftests
### Tests
* Add test cases to `update.test` for version-equivalent renames [#6774 @arozovyk fix #6754]
* Add test for dry-run mode [#6788 @rjbou]

### Engine

Expand Down
57 changes: 30 additions & 27 deletions src/client/opamSolution.ml
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,12 @@ let parallel_apply t
OpamStateConfig.(!r.dev_setup) && found
in
let source_dir = source_dir nv in
(if OpamFilename.exists_dir source_dir
(if OpamStateConfig.(!r.dryrun) then () else
if OpamFilename.exists_dir source_dir
then (if not is_inplace then
OpamFilename.copy_dir ~src:source_dir ~dst:build_dir)
else OpamFilename.mkdir build_dir;
else
OpamFilename.mkdir build_dir;
OpamAction.prepare_package_source t nv build_dir @@+ function
| Some exn -> store_time (); Done (`Exception exn)
| None ->
Expand Down Expand Up @@ -823,31 +825,32 @@ let parallel_apply t
(* 2/ Display errors and finalize *)

let save_installed_cache failed =
OpamSwitchState.Installed_cache.save
(OpamPath.Switch.installed_opams_cache t.switch_global.root t.switch)
(OpamPackage.Set.fold (fun nv opams ->
(* NOTE: We need to know whether an action was successful
or not to know which version of the opam file to store
in the case: the previous one if it failed, or the new
one if it succeeded. *)
let pkg_failed =
List.exists (function
| `Fetch ps -> List.for_all (OpamPackage.equal nv) ps
| `Build p | `Change (_, _, p) | `Install p
| `Reinstall p | `Remove p -> OpamPackage.equal nv p)
failed
in
let add_to_opams opam =
let opam = OpamFile.OPAM.with_metadata_dir None opam in
OpamPackage.Map.add nv opam opams
in
if pkg_failed then
match OpamPackage.Map.find_opt nv t.installed_opams with
| None -> opams
| Some opam -> add_to_opams opam
else
add_to_opams (OpamSwitchState.opam t nv))
t.installed OpamPackage.Map.empty);
if not OpamStateConfig.(!r.dryrun) then
OpamSwitchState.Installed_cache.save
(OpamPath.Switch.installed_opams_cache t.switch_global.root t.switch)
(OpamPackage.Set.fold (fun nv opams ->
(* NOTE: We need to know whether an action was successful
or not to know which version of the opam file to store
in the case: the previous one if it failed, or the new
one if it succeeded. *)
let pkg_failed =
List.exists (function
| `Fetch ps -> List.for_all (OpamPackage.equal nv) ps
| `Build p | `Change (_, _, p) | `Install p
| `Reinstall p | `Remove p -> OpamPackage.equal nv p)
failed
in
let add_to_opams opam =
let opam = OpamFile.OPAM.with_metadata_dir None opam in
OpamPackage.Map.add nv opam opams
in
if pkg_failed then
match OpamPackage.Map.find_opt nv t.installed_opams with
| None -> opams
| Some opam -> add_to_opams opam
else
add_to_opams (OpamSwitchState.opam t nv))
t.installed OpamPackage.Map.empty);
in
begin match action_results with
| `Exception _ | `Error Aborted -> ()
Expand Down
Loading
Loading