From 5e37faf28172442505fd8bbf7f9d274b0d239538 Mon Sep 17 00:00:00 2001 From: Kate Date: Fri, 26 Sep 2025 03:55:14 +0100 Subject: [PATCH 01/29] Remove macOS specific metadata from the release archive Extra ._* and .DS_Store files are present and can interfere with at least the OpenBSD build, in some cases --- release/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/Makefile b/release/Makefile index fea8d7804e8..887444d1b56 100644 --- a/release/Makefile +++ b/release/Makefile @@ -30,7 +30,7 @@ $(OUTDIR)/opam-full-$(VERSION).tar.gz: mkdir -p "$(OUTDIR)" git clone $(GIT_URL) -b $(TAG) "$(OUTDIR)/opam-full-$(VERSION)" $(MAKE) -C "$(OUTDIR)/opam-full-$(VERSION)" OCAML=$(call pathsearch,ocaml) download-ext - cd "$(OUTDIR)" && tar cz -f $(notdir $@) --exclude .git opam-full-$(VERSION) + cd "$(OUTDIR)" && tar cz -f $(notdir $@) --exclude .git --no-mac-metadata --no-xattrs opam-full-$(VERSION) rm -rf "$(OUTDIR)/opam-full-$(VERSION)" build/Dockerfile.x86_64-linux: Dockerfile.in From 9200f4f4997c88ed0dde3fe278ec660f30634650 Mon Sep 17 00:00:00 2001 From: Kate Date: Fri, 26 Sep 2025 04:02:44 +0100 Subject: [PATCH 02/29] Make the release archive reproducible --- master_changes.md | 1 + release/Makefile | 9 ++++++++- release/readme.md | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/master_changes.md b/master_changes.md index 4b131f048d2..ea2fc406ddb 100644 --- a/master_changes.md +++ b/master_changes.md @@ -91,6 +91,7 @@ users) ## Release scripts * The OpenBSD binary now a full static binary [#6705 @flumf @kit-ty-kate - fix #6241] + * The release archive (`opam-full-*.tar.gz`) is now reproducible [#6706 @kit-ty-kate - fix #6619] ## Install script * Add 2.4.1 to the install scripts [#6617 @kit-ty-kate] diff --git a/release/Makefile b/release/Makefile index 887444d1b56..cc7ee3048bb 100644 --- a/release/Makefile +++ b/release/Makefile @@ -30,7 +30,14 @@ $(OUTDIR)/opam-full-$(VERSION).tar.gz: mkdir -p "$(OUTDIR)" git clone $(GIT_URL) -b $(TAG) "$(OUTDIR)/opam-full-$(VERSION)" $(MAKE) -C "$(OUTDIR)/opam-full-$(VERSION)" OCAML=$(call pathsearch,ocaml) download-ext - cd "$(OUTDIR)" && tar cz -f $(notdir $@) --exclude .git --no-mac-metadata --no-xattrs opam-full-$(VERSION) + ( set -euo pipefail && \ + cd "$(OUTDIR)/opam-full-$(VERSION)" && \ + git archive "$(TAG)" \ + --prefix "opam-full-$(VERSION)/" \ + --mtime "$$(git show -s --format=%ct "$(TAG)" | tail -1)" \ + -o "$(abspath $(OUTDIR)/opam-full-$(VERSION).tar)" \ + $$(for f in $$(git ls-files -i -o -x '*'); do echo "--add-file=$$f" || exit 1; done) && \ + gzip --no-name --best "$(abspath $(OUTDIR)/opam-full-$(VERSION).tar)" ) rm -rf "$(OUTDIR)/opam-full-$(VERSION)" build/Dockerfile.x86_64-linux: Dockerfile.in diff --git a/release/readme.md b/release/readme.md index 2d6f4138d4d..39e873995ed 100644 --- a/release/readme.md +++ b/release/readme.md @@ -65,6 +65,6 @@ ## Device requirements * Mac M1 or above with Rosetta2 * >=70GB of disk space free -* brew dependencies: git, git-lfs, gpg, qemu>=8.1.0 (avoid qemu 9.1.x, see https://gitlab.com/qemu-project/qemu/-/issues/2581), docker>=24.0.0, sshpass +* brew dependencies: git >= 2.40.0, git-lfs, gpg, qemu>=8.1.0 (avoid qemu 9.1.x, see https://gitlab.com/qemu-project/qemu/-/issues/2581), docker>=24.0.0, sshpass * opam repo with the tag fetched * Have the secret key available From ed0fa11c021f297219b9affbd91e83e25010f451 Mon Sep 17 00:00:00 2001 From: Kate Date: Sun, 20 Jul 2025 13:27:53 +0100 Subject: [PATCH 03/29] Add a test showing the behaviour of autopin in presence of a pin-depends --- tests/reftests/autopin.test | 66 +++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tests/reftests/autopin.test b/tests/reftests/autopin.test index eca09c4190d..a4249961caf 100644 --- a/tests/reftests/autopin.test +++ b/tests/reftests/autopin.test @@ -311,3 +311,69 @@ opam believes some required external dependencies are missing. opam can: + echo "some-depext" - some-depext Nothing to do. +### : Make sure pin-depends are installed when using "opam install --deps-only" +### opam switch create pin-deps --empty +### +opam-version: "2.0" +### +opam-version: "2.0" +depends: "pin-dep" +### +basedir=$(printf '%s' "$BASEDIR" | sed 's/\\/\\\\/g') +cat >> local-with-pin-deps/opam << EOF +pin-depends: ["pin-dep.dev" "file://$basedir/pin-dep"] +EOF +### sh add-pin-depends.sh +### opam install --show ./local-with-pin-deps +[ERROR] Package conflict! + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + +No solution found, exiting +# Return code 20 # +### opam pin +### opam install --dry-run ./local-with-pin-deps +[ERROR] Package conflict! + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + +No solution found, exiting +# Return code 20 # +### opam pin +### opam install --deps-only ./local-with-pin-deps +[ERROR] Package conflict! + * Missing dependency: + - deps-of-local-with-pin-deps -> pin-dep + unknown package + +No solution found, exiting +# Return code 20 # +### opam pin +### opam pin remove pin-dep +[NOTE] pin-dep is not pinned. +### opam pin +### opam install ./local-with-pin-deps +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] y +[NOTE] Package pin-dep does not exist in opam repositories registered in the current switch. +[pin-dep.dev] synchronised (no changes) +pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev) +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) +The following actions will be performed: +=== install 2 packages + - install local-with-pin-deps dev (pinned) + - install pin-dep dev (pinned) [required by local-with-pin-deps] + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved local-with-pin-deps.dev (file://${BASEDIR}/local-with-pin-deps) +-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep) +-> installed pin-dep.dev +-> installed local-with-pin-deps.dev +Done. +### opam pin +local-with-pin-deps.dev rsync file://${BASEDIR}/local-with-pin-deps +pin-dep.dev rsync file://${BASEDIR}/pin-dep From 248b82c5d54cda8165b35418d13173c45b684cd8 Mon Sep 17 00:00:00 2001 From: Kate Date: Sun, 20 Jul 2025 13:38:41 +0100 Subject: [PATCH 04/29] Add a test showing the behaviour of opam switch create in presence of pin-depends --- master_changes.md | 1 + src/client/opamPinCommand.ml | 4 ++-- src/client/opamSwitchCommand.ml | 2 +- tests/reftests/autopin.test | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/master_changes.md b/master_changes.md index a3f95dd48cc..fd88e467406 100644 --- a/master_changes.md +++ b/master_changes.md @@ -120,6 +120,7 @@ users) * Replace every polymorphic uses of `List.mem` by a version that doesn't use `Repr.equal` [#6644 @kit-ty-kate] * Simplify the `src_ext/update-sources.sh` script [#6701 @kit-ty-kate] * Homogeneise verbose command output between sandboxed and non sandboxed one [#6675 @rjbou] + * Add the `install-pin-depends`, `ignore-pin-depends` and `switch-clean-up` named questions [#6611 @kit-ty-kate] ## Internal: Unix diff --git a/src/client/opamPinCommand.ml b/src/client/opamPinCommand.ml index 468060e7ee9..6d26477b955 100644 --- a/src/client/opamPinCommand.ml +++ b/src/client/opamPinCommand.ml @@ -423,7 +423,7 @@ let rec handle_pin_depends st nv opam = (OpamConsole.colorise `bold (OpamPackage.to_string nv)) (OpamConsole.colorise `underline (OpamUrl.to_string url))) extra_pins); - if OpamConsole.confirm "Pin and install them?" then + if OpamConsole.confirm ~name:"install-pin-depends" "Pin and install them?" then (let extra_pins = fetch_all_pins st (List.map (fun (nv, u) -> { pinned_name = OpamPackage.name nv; @@ -438,7 +438,7 @@ let rec handle_pin_depends st nv opam = source_pin st pin.pinned_name ?version:pin.pinned_version (Some pin.pinned_url) ~ignore_extra_pins:true) st extra_pins) - else if OpamConsole.confirm + else if OpamConsole.confirm ~name:"ignore-pin-depends" "Try to install anyway, assuming `--ignore-pin-depends'?" then st else OpamStd.Sys.exit_because `Aborted) diff --git a/src/client/opamSwitchCommand.ml b/src/client/opamSwitchCommand.ml index e93630075d2..2720fb4ce21 100644 --- a/src/client/opamSwitchCommand.ml +++ b/src/client/opamSwitchCommand.ml @@ -348,7 +348,7 @@ let create in OpamStd.Exn.finalise e @@ fun () -> let gt, st = - if OpamConsole.confirm "Switch initialisation failed: clean up? \ + if OpamConsole.confirm ~name:"switch-clean-up" "Switch initialisation failed: clean up? \ ('n' will leave the switch partially installed)" then clear_switch gt st.switch, st else if update_config && not simulate diff --git a/tests/reftests/autopin.test b/tests/reftests/autopin.test index a4249961caf..71dcc02b1d5 100644 --- a/tests/reftests/autopin.test +++ b/tests/reftests/autopin.test @@ -377,3 +377,35 @@ Done. ### opam pin local-with-pin-deps.dev rsync file://${BASEDIR}/local-with-pin-deps pin-dep.dev rsync file://${BASEDIR}/pin-dep +### : Make sure pin-depends during switch creations are not pinned twice +### unset OPAMCONFIRMLEVEL +### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:switch-clean-up=yes opam switch create ./local-with-pin-deps +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] n +Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: ["ocaml" {>= "4.05.0"}] +[ERROR] Could not determine which packages to install for this switch: + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + + +Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y +# Return code 20 # +### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:switch-clean-up=yes opam switch create ./local-with-pin-deps --deps-only + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: ["ocaml" {>= "4.05.0"}] +[ERROR] Could not determine which packages to install for this switch: + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + + +Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y +# Return code 20 # From d9bac1763bd99a107543ff05d294cc262f402abc Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Tue, 7 Oct 2025 16:19:06 +0200 Subject: [PATCH 05/29] reftest: add complete tests for the pin-depends feature --- master_changes.md | 3 +- src/client/opamSolution.ml | 3 +- tests/reftests/dune.inc | 42 +++ tests/reftests/pin-depends-ignore.test | 436 +++++++++++++++++++++++++ tests/reftests/pin-depends.test | 408 +++++++++++++++++++++++ 5 files changed, 890 insertions(+), 2 deletions(-) create mode 100644 tests/reftests/pin-depends-ignore.test create mode 100644 tests/reftests/pin-depends.test diff --git a/master_changes.md b/master_changes.md index fd88e467406..d6011daa1fe 100644 --- a/master_changes.md +++ b/master_changes.md @@ -120,7 +120,7 @@ users) * Replace every polymorphic uses of `List.mem` by a version that doesn't use `Repr.equal` [#6644 @kit-ty-kate] * Simplify the `src_ext/update-sources.sh` script [#6701 @kit-ty-kate] * Homogeneise verbose command output between sandboxed and non sandboxed one [#6675 @rjbou] - * Add the `install-pin-depends`, `ignore-pin-depends` and `switch-clean-up` named questions [#6611 @kit-ty-kate] + * Add the `install-pin-depends`, `ignore-pin-depends`, `proceed-actions` and `switch-clean-up` named questions [#6611 @kit-ty-kate @rjbou] ## Internal: Unix @@ -152,6 +152,7 @@ users) * Add a test showing the behaviour of nested extra-files [#6715 @kit-ty-kate] * Add opam file loading tests to `update.test` to demonstrate current behaviour of loading full repository instead of only changed files. [#6614 @arozovyk @rjbou @kit-ty-kate] * Fix `env.test` in cases where calling `env` inside of a script outputs a `__CF_USER_TEXT_ENCODING` environment variable that isn't present in `sh -c env` [#6719 @kit-ty-kate] + * Add complete tests for the `pin-depends` feature [#6611 @rjbou] ### Engine * Fix gcc < 14.3 bug on mingw i686 [#6624 @kit-ty-kate] diff --git a/src/client/opamSolution.ml b/src/client/opamSolution.ml index 27d86786b42..f616bac3848 100644 --- a/src/client/opamSolution.ml +++ b/src/client/opamSolution.ml @@ -1098,7 +1098,8 @@ let confirmation ?ask requested solution = in ask <> Some true && OpamPackage.Name.Set.equal requested solution_packages || let stats = OpamSolver.stats solution in - OpamConsole.confirm "\nProceed with %s?" (OpamSolver.string_of_stats stats) + OpamConsole.confirm ~name:"proceed-actions" "\nProceed with %s?" + (OpamSolver.string_of_stats stats) let run_hook_job t name ?(local=[]) ?(allow_stdout=false) w = let shell_env = OpamEnv.get_full ~set_opamroot:true ~set_opamswitch:true ~force_path:true t in diff --git a/tests/reftests/dune.inc b/tests/reftests/dune.inc index ab856721083..01e38363d2c 100644 --- a/tests/reftests/dune.inc +++ b/tests/reftests/dune.inc @@ -1553,6 +1553,48 @@ %{targets} (run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:pat-sub.test} %{read-lines:testing-env})))) +(rule + (alias reftest-pin-depends-ignore) + (enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1)))) + (action + (diff pin-depends-ignore.test pin-depends-ignore.out))) + +(alias + (name reftest) + (enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1)))) + (deps (alias reftest-pin-depends-ignore))) + +(rule + (targets pin-depends-ignore.out) + (deps root-N0REP0) + (enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1)))) + (package opam) + (action + (with-stdout-to + %{targets} + (run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:pin-depends-ignore.test} %{read-lines:testing-env})))) + +(rule + (alias reftest-pin-depends) + (enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1)))) + (action + (diff pin-depends.test pin-depends.out))) + +(alias + (name reftest) + (enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1)))) + (deps (alias reftest-pin-depends))) + +(rule + (targets pin-depends.out) + (deps root-N0REP0) + (enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1)))) + (package opam) + (action + (with-stdout-to + %{targets} + (run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:pin-depends.test} %{read-lines:testing-env})))) + (rule (alias reftest-pin-depsonly-wtest-6501) (enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1)))) diff --git a/tests/reftests/pin-depends-ignore.test b/tests/reftests/pin-depends-ignore.test new file mode 100644 index 00000000000..21b87f26cc5 --- /dev/null +++ b/tests/reftests/pin-depends-ignore.test @@ -0,0 +1,436 @@ +N0REP0 +### # to change! +### sed -i.bak 's/"ocaml" {>= "4.05.0"}//' OPAM/config +### unset OPAMCONFIRMLEVEL +### :I: Local install with pin depends +### +opam-version: "2.0" +### +opam-version: "2.0" +depends: "pin-dep" +### +basedir=$(printf '%s' "$BASEDIR" | sed 's/\\/\\\\/g') +cat >> local-with-pin-deps/opam << EOF +pin-depends: ["pin-dep.dev" "file://$basedir/pin-dep"] +EOF +### sh add-pin-depends.sh +### :I:1: Dependent package not present in repo +### opam switch create pin-deps-wo-repo-empty-1 --empty +### :I:1:a: Show +### opam install --show ./local-with-pin-deps --ignore-pin-depends +[ERROR] Package conflict! + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + +No solution found, exiting +# Return code 20 # +### opam pin +### :I:1:b: Dry run +### opam install --dry-run ./local-with-pin-deps --ignore-pin-depends +[ERROR] Package conflict! + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + +No solution found, exiting +# Return code 20 # +### opam pin +### :I:1:c: Deps only +### opam switch create pin-deps-I-1-c --empty +### opam install --deps-only ./local-with-pin-deps --ignore-pin-depends +[ERROR] Package conflict! + * Missing dependency: + - deps-of-local-with-pin-deps -> pin-dep + unknown package + +No solution found, exiting +# Return code 20 # +### opam pin +### :I:1:d: install without pin depends +### opam switch create pin-deps-I-1-d --empty +### opam install ./local-with-pin-deps --ignore-pin-depends +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) +[ERROR] Package conflict! + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + +No solution found, exiting +# Return code 20 # +### opam pin +local-with-pin-deps.dev (uninstalled) rsync file://${BASEDIR}/local-with-pin-deps +### :I:2: Dependent package present in repo +### +opam-version: "2.0" +### opam switch create pin-deps-w-repo-empty-1 --empty +### :I:2:a: Show +### opam install --show ./local-with-pin-deps --ignore-pin-depends +The following actions would be performed: +=== install 2 packages + - install local-with-pin-deps dev (pinned) + - install pin-dep 1 [required by local-with-pin-deps] +### opam pin +### :I:2:b: Dry run +### OPAMAUTOANSWER=proceed-actions=yes opam install --dry-run ./local-with-pin-deps --ignore-pin-depends +The following actions will be simulated: +=== install 2 packages + - install local-with-pin-deps dev (pinned) + - install pin-dep 1 [required by local-with-pin-deps] + +Proceed with 2 installations? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Installing pin-dep.1. +-> installed pin-dep.1 +Installing local-with-pin-deps.dev. +-> installed local-with-pin-deps.dev +Done. +### opam pin +### :I:2:c: Deps only +### opam switch create pin-deps-I-2-c --empty +### OPAMAUTOANSWER=proceed-actions=yes opam install --deps-only ./local-with-pin-deps --ignore-pin-depends +The following actions will be performed: +=== install 1 package + - install pin-dep 1 [required by local-with-pin-deps] + +Proceed with 1 installation? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed pin-dep.1 +Done. +### opam pin +### :I:2:d: install without pin depends +### opam switch create pin-deps-I-2-d --empty +### OPAMAUTOANSWER=proceed-actions=yes opam install ./local-with-pin-deps --ignore-pin-depends +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) +The following actions will be performed: +=== install 2 packages + - install local-with-pin-deps dev (pinned) + - install pin-dep 1 [required by local-with-pin-deps] + +Proceed with 2 installations? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved local-with-pin-deps.dev (file://${BASEDIR}/local-with-pin-deps) +-> installed pin-dep.1 +-> installed local-with-pin-deps.dev +Done. +### opam pin +local-with-pin-deps.dev rsync file://${BASEDIR}/local-with-pin-deps +### :II: At switch creation +### :II:1: Dependency not known +### rm -r REPO/packages/pin-dep +### opam update default + +<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><> +[default] synchronised from file://${BASEDIR}/REPO +Now run 'opam upgrade' to apply any package updates. +### :II:1:a: With deps-only +### OPAMAUTOANSWER=switch-clean-up=yes opam switch create ./local-with-pin-deps --deps-only --ignore-pin-depends + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: [] +[ERROR] Could not determine which packages to install for this switch: + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + + +Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y +# Return code 20 # +### opam pin --switch=./local-with-pin-deps +[ERROR] The selected switch ${BASEDIR}/local-with-pin-deps is not installed. +# Return code 2 # +### opam switch remove ./local-with-pin-deps -y +The compiler switch ${BASEDIR}/local-with-pin-deps does not exist. +# Return code 5 # +### :II:1:b: Normal +### OPAMAUTOANSWER=switch-clean-up=yes opam switch create ./local-with-pin-deps --ignore-pin-depends +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: [] +[ERROR] Could not determine which packages to install for this switch: + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + + +Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y +# Return code 20 # +### opam pin --switch=./local-with-pin-deps +[ERROR] The selected switch ${BASEDIR}/local-with-pin-deps is not installed. +# Return code 2 # +### opam switch remove ./local-with-pin-deps -y +The compiler switch ${BASEDIR}/local-with-pin-deps does not exist. +# Return code 5 # +### :II:2: Dependency known +### +opam-version: "2.0" +### :II:2:a: with deps-only +### OPAMAUTOANSWER=proceed-actions=yes opam switch create ./local-with-pin-deps --deps-only --ignore-pin-depends + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: [] +[NOTE] No invariant was set, you may want to use `opam switch set-invariant' to keep a stable compiler version on upgrades. +The following actions will be performed: +=== install 1 package + - install pin-dep 1 [required by local-with-pin-deps] + +Proceed with 1 installation? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed pin-dep.1 +Done. +### opam pin --switch=./local-with-pin-deps +### opam switch remove ./local-with-pin-deps -y +Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y +### :II:2:b: Normal +### OPAMAUTOANSWER=proceed-actions=yes opam switch create ./local-with-pin-deps --ignore-pin-depends +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: [] +[NOTE] No invariant was set, you may want to use `opam switch set-invariant' to keep a stable compiler version on upgrades. +The following actions will be performed: +=== install 2 packages + - install local-with-pin-deps dev (pinned) + - install pin-dep 1 [required by local-with-pin-deps] + +Proceed with 2 installations? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved local-with-pin-deps.dev (file://${BASEDIR}/local-with-pin-deps) +-> installed pin-dep.1 +-> installed local-with-pin-deps.dev +Done. +### opam pin --switch=./local-with-pin-deps +local-with-pin-deps.dev rsync file://${BASEDIR}/local-with-pin-deps +### opam switch remove ./local-with-pin-deps -y +Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y +### :::::::::::::::::::::::::: +### :: WIH IGNOREPINDEPENDS :: +### :::::::::::::::::::::::::: +### :III: Local install with pin depends +### rm -r REPO/packages/pin-dep +### opam update default + +<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><> +[default] synchronised from file://${BASEDIR}/REPO +Now run 'opam upgrade' to apply any package updates. +### OPAMIGNOREPINDEPENDS=true +### +opam-version: "2.0" +### +opam-version: "2.0" +depends: "pin-dep" +### +basedir=$(printf '%s' "$BASEDIR" | sed 's/\\/\\\\/g') +cat >> local-with-pin-deps/opam << EOF +pin-depends: ["pin-dep.dev" "file://$basedir/pin-dep"] +EOF +### sh add-pin-depends.sh +### :III:1: Dependent package not present in repo +### opam switch create pin-deps-wo-repo-empty-3 --empty +### :III:1:a: Show +### opam install --show ./local-with-pin-deps +[ERROR] Package conflict! + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + +No solution found, exiting +# Return code 20 # +### opam pin +### :III:1:b: Dry run +### opam install --dry-run ./local-with-pin-deps +[ERROR] Package conflict! + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + +No solution found, exiting +# Return code 20 # +### opam pin +### :III:1:c: Deps only +### opam switch create pin-deps-III-1-c --empty +### opam install --deps-only ./local-with-pin-deps +[ERROR] Package conflict! + * Missing dependency: + - deps-of-local-with-pin-deps -> pin-dep + unknown package + +No solution found, exiting +# Return code 20 # +### opam pin +### :III:1:d: install without pin depends +### opam switch create pin-deps-III-1-d --empty +### opam install ./local-with-pin-deps +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) +[ERROR] Package conflict! + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + +No solution found, exiting +# Return code 20 # +### opam pin +local-with-pin-deps.dev (uninstalled) rsync file://${BASEDIR}/local-with-pin-deps +### :III:2: Dependent package present in repo +### +opam-version: "2.0" +### opam switch create pin-deps-w-repo-empty --empty +### :III:2:a: Show +### opam install --show ./local-with-pin-deps +The following actions would be performed: +=== install 2 packages + - install local-with-pin-deps dev (pinned) + - install pin-dep 1 [required by local-with-pin-deps] +### opam pin +### :III:2:b: Dry run +### OPAMAUTOANSWER=proceed-actions=yes opam install --dry-run ./local-with-pin-deps +The following actions will be simulated: +=== install 2 packages + - install local-with-pin-deps dev (pinned) + - install pin-dep 1 [required by local-with-pin-deps] + +Proceed with 2 installations? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Installing pin-dep.1. +-> installed pin-dep.1 +Installing local-with-pin-deps.dev. +-> installed local-with-pin-deps.dev +Done. +### opam pin +### :III:2:c: Deps only +### opam switch create pin-deps-III-2-c --empty +### OPAMAUTOANSWER=proceed-actions=yes opam install --deps-only ./local-with-pin-deps +The following actions will be performed: +=== install 1 package + - install pin-dep 1 [required by local-with-pin-deps] + +Proceed with 1 installation? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed pin-dep.1 +Done. +### opam pin +### :III:2:d: install without pin depends +### opam switch create pin-deps-III-2-d --empty +### OPAMAUTOANSWER=proceed-actions=yes opam install ./local-with-pin-deps +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) +The following actions will be performed: +=== install 2 packages + - install local-with-pin-deps dev (pinned) + - install pin-dep 1 [required by local-with-pin-deps] + +Proceed with 2 installations? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved local-with-pin-deps.dev (file://${BASEDIR}/local-with-pin-deps) +-> installed pin-dep.1 +-> installed local-with-pin-deps.dev +Done. +### opam pin +local-with-pin-deps.dev rsync file://${BASEDIR}/local-with-pin-deps +### :IV: At switch creation +### :IV:1: Dependency not known +### rm -r REPO/packages/pin-dep +### opam update default + +<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><> +[default] synchronised from file://${BASEDIR}/REPO +Now run 'opam upgrade' to apply any package updates. +### :IV:1:a: With deps-only +### OPAMAUTOANSWER=switch-clean-up=yes opam switch create ./local-with-pin-deps --deps-only + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: [] +[ERROR] Could not determine which packages to install for this switch: + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + + +Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y +# Return code 20 # +### opam pin --switch=./local-with-pin-deps +[ERROR] The selected switch ${BASEDIR}/local-with-pin-deps is not installed. +# Return code 2 # +### opam switch remove ./local-with-pin-deps -y +The compiler switch ${BASEDIR}/local-with-pin-deps does not exist. +# Return code 5 # +### :IV:1:b: Normal +### OPAMAUTOANSWER=switch-clean-up=yes opam switch create ./local-with-pin-deps +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: [] +[ERROR] Could not determine which packages to install for this switch: + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + + +Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y +# Return code 20 # +### opam pin --switch=./local-with-pin-deps +[ERROR] The selected switch ${BASEDIR}/local-with-pin-deps is not installed. +# Return code 2 # +### opam switch remove ./local-with-pin-deps -y +The compiler switch ${BASEDIR}/local-with-pin-deps does not exist. +# Return code 5 # +### :IV:2: Dependency known +### +opam-version: "2.0" +### :IV:2:a: with deps-only +### OPAMAUTOANSWER=proceed-actions=yes opam switch create ./local-with-pin-deps --deps-only + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: [] +[NOTE] No invariant was set, you may want to use `opam switch set-invariant' to keep a stable compiler version on upgrades. +The following actions will be performed: +=== install 1 package + - install pin-dep 1 [required by local-with-pin-deps] + +Proceed with 1 installation? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed pin-dep.1 +Done. +### opam pin --switch=./local-with-pin-deps +### opam switch remove ./local-with-pin-deps -y +Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y +### :IV:2:b: Normal +### OPAMAUTOANSWER=proceed-actions=yes opam switch create ./local-with-pin-deps +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: [] +[NOTE] No invariant was set, you may want to use `opam switch set-invariant' to keep a stable compiler version on upgrades. +The following actions will be performed: +=== install 2 packages + - install local-with-pin-deps dev (pinned) + - install pin-dep 1 [required by local-with-pin-deps] + +Proceed with 2 installations? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved local-with-pin-deps.dev (file://${BASEDIR}/local-with-pin-deps) +-> installed pin-dep.1 +-> installed local-with-pin-deps.dev +Done. +### opam pin --switch=./local-with-pin-deps +local-with-pin-deps.dev rsync file://${BASEDIR}/local-with-pin-deps +### opam switch remove ./local-with-pin-deps -y +Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y diff --git a/tests/reftests/pin-depends.test b/tests/reftests/pin-depends.test new file mode 100644 index 00000000000..e356e1b9052 --- /dev/null +++ b/tests/reftests/pin-depends.test @@ -0,0 +1,408 @@ +N0REP0 +### ### Ty to keep synchronised with pin-depends-ignore +### # to change! +### sed -i.bak 's/"ocaml" {>= "4.05.0"}//' OPAM/config +### unset OPAMCONFIRMLEVEL +### :I: Local install with pin depends +### +opam-version: "2.0" +### +opam-version: "2.0" +depends: "pin-dep" +### +basedir=$(printf '%s' "$BASEDIR" | sed 's/\\/\\\\/g') +cat >> local-with-pin-deps/opam << EOF +pin-depends: ["pin-dep.dev" "file://$basedir/pin-dep"] +EOF +### sh add-pin-depends.sh +### :I:1: Dependent package not present in repo +### opam switch create pin-deps-wo-repo-empty --empty +### :I:1:a: Show +### opam install --show ./local-with-pin-deps +[ERROR] Package conflict! + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + +No solution found, exiting +# Return code 20 # +### opam pin +### :I:1:b: Dry run +### opam install --dry-run ./local-with-pin-deps +[ERROR] Package conflict! + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + +No solution found, exiting +# Return code 20 # +### opam pin +### :I:1:c: Deps only without pin depends +### opam switch create pin-deps-I-1-c --empty +### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes opam install --deps-only ./local-with-pin-deps +[ERROR] Package conflict! + * Missing dependency: + - deps-of-local-with-pin-deps -> pin-dep + unknown package + +No solution found, exiting +# Return code 20 # +### opam pin +### :I:1:d: Deps only with pin depends +### opam switch create pin-deps-I-1-d --empty +### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam install --deps-only ./local-with-pin-deps +[ERROR] Package conflict! + * Missing dependency: + - deps-of-local-with-pin-deps -> pin-dep + unknown package + +No solution found, exiting +# Return code 20 # +### opam pin +### :I:1:e: install without pin depends +### opam switch create pin-deps-I-1-e --empty +### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes opam install ./local-with-pin-deps +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] n +Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) +[ERROR] Package conflict! + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + +No solution found, exiting +# Return code 20 # +### opam pin +local-with-pin-deps.dev (uninstalled) rsync file://${BASEDIR}/local-with-pin-deps +### :I:1:f: install with pin depends +### opam switch create pin-deps-I-1-f --empty +### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam install ./local-with-pin-deps +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] y +[NOTE] Package pin-dep does not exist in opam repositories registered in the current switch. +[pin-dep.dev] synchronised (no changes) +pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev) +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) +The following actions will be performed: +=== install 2 packages + - install local-with-pin-deps dev (pinned) + - install pin-dep dev (pinned) [required by local-with-pin-deps] + +Proceed with 2 installations? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved local-with-pin-deps.dev (file://${BASEDIR}/local-with-pin-deps) +-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep) +-> installed pin-dep.dev +-> installed local-with-pin-deps.dev +Done. +### opam pin +local-with-pin-deps.dev rsync file://${BASEDIR}/local-with-pin-deps +pin-dep.dev rsync file://${BASEDIR}/pin-dep +### :I:2: Dependent package present in repo +### +opam-version: "2.0" +### opam switch create pin-deps-w-repo-empty --empty +### :I:2:a: Show +### opam install --show ./local-with-pin-deps +The following actions would be performed: +=== install 2 packages + - install local-with-pin-deps dev (pinned) + - install pin-dep 1 [required by local-with-pin-deps] +### opam pin +### :I:2:b: Dry run +### OPAMAUTOANSWER=proceed-actions=yes opam install --dry-run ./local-with-pin-deps +The following actions will be simulated: +=== install 2 packages + - install local-with-pin-deps dev (pinned) + - install pin-dep 1 [required by local-with-pin-deps] + +Proceed with 2 installations? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Installing pin-dep.1. +-> installed pin-dep.1 +Installing local-with-pin-deps.dev. +-> installed local-with-pin-deps.dev +Done. +### opam pin +### :I:2:c: Deps only without pin depends +### opam switch create pin-deps-I-2-c --empty +### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:proceed-actions=yes opam install --deps-only ./local-with-pin-deps +The following actions will be performed: +=== install 1 package + - install pin-dep 1 [required by local-with-pin-deps] + +Proceed with 1 installation? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed pin-dep.1 +Done. +### opam pin +### :I:2:d: Deps only without pin depends +### opam switch create pin-deps-I-2-d --empty +### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam install --deps-only ./local-with-pin-deps +The following actions will be performed: +=== install 1 package + - install pin-dep 1 [required by local-with-pin-deps] + +Proceed with 1 installation? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed pin-dep.1 +Done. +### :I:2:e: install without pin depends +### opam switch create pin-deps-I-2-e --empty +### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:proceed-actions=yes opam install ./local-with-pin-deps +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] n +Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) +The following actions will be performed: +=== install 2 packages + - install local-with-pin-deps dev (pinned) + - install pin-dep 1 [required by local-with-pin-deps] + +Proceed with 2 installations? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved local-with-pin-deps.dev (file://${BASEDIR}/local-with-pin-deps) +-> installed pin-dep.1 +-> installed local-with-pin-deps.dev +Done. +### opam pin +local-with-pin-deps.dev rsync file://${BASEDIR}/local-with-pin-deps +### :I:2:f: install with pin depends +### opam switch create pin-deps-I-2-f --empty +### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam install ./local-with-pin-deps +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] y +[pin-dep.dev] synchronised (no changes) +pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev) +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) +The following actions will be performed: +=== install 2 packages + - install local-with-pin-deps dev (pinned) + - install pin-dep dev (pinned) [required by local-with-pin-deps] + +Proceed with 2 installations? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved local-with-pin-deps.dev (file://${BASEDIR}/local-with-pin-deps) +-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep) +-> installed pin-dep.dev +-> installed local-with-pin-deps.dev +Done. +### opam pin +local-with-pin-deps.dev rsync file://${BASEDIR}/local-with-pin-deps +pin-dep.dev rsync file://${BASEDIR}/pin-dep +### :II: At switch creation +### :II:1: Dependency not known +### rm -r REPO/packages/pin-dep +### opam update default + +<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><> +[default] synchronised from file://${BASEDIR}/REPO +Now run 'opam upgrade' to apply any package updates. +### :II:1:a: Answer no to pin depends install deps-only +### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:switch-clean-up=yes opam switch create ./local-with-pin-deps --deps-only + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: [] +[ERROR] Could not determine which packages to install for this switch: + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + + +Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y +# Return code 20 # +### opam pin --switch=./local-with-pin-deps +[ERROR] The selected switch ${BASEDIR}/local-with-pin-deps is not installed. +# Return code 2 # +### opam switch remove ./local-with-pin-deps -y +The compiler switch ${BASEDIR}/local-with-pin-deps does not exist. +# Return code 5 # +### :II:1:b: Answer no to pin depends install +### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:switch-clean-up=yes opam switch create ./local-with-pin-deps +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] n +Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: [] +[ERROR] Could not determine which packages to install for this switch: + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + + +Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y +# Return code 20 # +### opam pin --switch=./local-with-pin-deps +[ERROR] The selected switch ${BASEDIR}/local-with-pin-deps is not installed. +# Return code 2 # +### opam switch remove ./local-with-pin-deps -y +The compiler switch ${BASEDIR}/local-with-pin-deps does not exist. +# Return code 5 # +### :II:1:c: Answer yes to pin depends install deps-only +### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes:switch-clean-up=yes opam switch create ./local-with-pin-deps --deps-only + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: [] +[ERROR] Could not determine which packages to install for this switch: + * Missing dependency: + - local-with-pin-deps -> pin-dep + unknown package + + +Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y +# Return code 20 # +### opam pin --switch=./local-with-pin-deps +[ERROR] The selected switch ${BASEDIR}/local-with-pin-deps is not installed. +# Return code 2 # +### opam switch remove ./local-with-pin-deps -y +The compiler switch ${BASEDIR}/local-with-pin-deps does not exist. +# Return code 5 # +### :II:1:d: Answer yes to pin depends install +### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam switch create ./local-with-pin-deps +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] y +[NOTE] Package pin-dep does not exist in opam repositories registered in the current switch. +[pin-dep.dev] synchronised (no changes) +pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev) +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: [] +[NOTE] No invariant was set, you may want to use `opam switch set-invariant' to keep a stable compiler version on upgrades. +The following actions will be performed: +=== install 2 packages + - install local-with-pin-deps dev (pinned) + - install pin-dep dev (pinned) [required by local-with-pin-deps] + +Proceed with 2 installations? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved local-with-pin-deps.dev (file://${BASEDIR}/local-with-pin-deps) +-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep) +-> installed pin-dep.dev +-> installed local-with-pin-deps.dev +Done. +### opam pin --switch=./local-with-pin-deps +local-with-pin-deps.dev rsync file://${BASEDIR}/local-with-pin-deps +pin-dep.dev rsync file://${BASEDIR}/pin-dep +### opam switch remove ./local-with-pin-deps -y +Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y +### :II:2: Dependency known +### +opam-version: "2.0" +### :II:2:a: Answer no to pin depends install deps only +### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:proceed-actions=yes opam switch create ./local-with-pin-deps --deps-only + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: [] +[NOTE] No invariant was set, you may want to use `opam switch set-invariant' to keep a stable compiler version on upgrades. +The following actions will be performed: +=== install 1 package + - install pin-dep 1 [required by local-with-pin-deps] + +Proceed with 1 installation? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed pin-dep.1 +Done. +### opam pin --switch=./local-with-pin-deps +### opam switch remove ./local-with-pin-deps -y +Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y +### :II:2:b: Answer no to pin depends install +### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:proceed-actions=yes opam switch create ./local-with-pin-deps +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] n +Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: [] +[NOTE] No invariant was set, you may want to use `opam switch set-invariant' to keep a stable compiler version on upgrades. +The following actions will be performed: +=== install 2 packages + - install local-with-pin-deps dev (pinned) + - install pin-dep 1 [required by local-with-pin-deps] + +Proceed with 2 installations? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved local-with-pin-deps.dev (file://${BASEDIR}/local-with-pin-deps) +-> installed pin-dep.1 +-> installed local-with-pin-deps.dev +Done. +### opam pin --switch=./local-with-pin-deps +local-with-pin-deps.dev rsync file://${BASEDIR}/local-with-pin-deps +### opam switch remove ./local-with-pin-deps -y +Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y +### :II:2:c: Answer yes to pin depends install deps-only +### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam switch create ./local-with-pin-deps --deps-only + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: [] +[NOTE] No invariant was set, you may want to use `opam switch set-invariant' to keep a stable compiler version on upgrades. +The following actions will be performed: +=== install 1 package + - install pin-dep 1 [required by local-with-pin-deps] + +Proceed with 1 installation? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed pin-dep.1 +Done. +### opam pin --switch=./local-with-pin-deps +### opam switch remove ./local-with-pin-deps -y +Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y +### :II:2:d: Answer yes to pin depends install +### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam switch create ./local-with-pin-deps +[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] y +[pin-dep.dev] synchronised (no changes) +pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev) +local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev) + +<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> +Switch invariant: [] +[NOTE] No invariant was set, you may want to use `opam switch set-invariant' to keep a stable compiler version on upgrades. +The following actions will be performed: +=== install 2 packages + - install local-with-pin-deps dev (pinned) + - install pin-dep dev (pinned) [required by local-with-pin-deps] + +Proceed with 2 installations? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved local-with-pin-deps.dev (file://${BASEDIR}/local-with-pin-deps) +-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep) +-> installed pin-dep.dev +-> installed local-with-pin-deps.dev +Done. +### opam pin --switch=./local-with-pin-deps +local-with-pin-deps.dev rsync file://${BASEDIR}/local-with-pin-deps +pin-dep.dev rsync file://${BASEDIR}/pin-dep +### opam switch remove ./local-with-pin-deps -y +Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y From 5c323767389de1209ece598fd112db24e94e1d52 Mon Sep 17 00:00:00 2001 From: Kate Date: Sun, 20 Jul 2025 13:06:15 +0100 Subject: [PATCH 06/29] Fix pinned depends being ignored on simulated pins --- src/client/opamAuxCommands.ml | 8 +++ tests/reftests/autopin.test | 33 ++++++++++--- tests/reftests/pin-depends.test | 86 +++++++++++++++++++++++++-------- 3 files changed, 100 insertions(+), 27 deletions(-) diff --git a/src/client/opamAuxCommands.ml b/src/client/opamAuxCommands.ml index 7996a98656e..12f4249c3fc 100644 --- a/src/client/opamAuxCommands.ml +++ b/src/client/opamAuxCommands.ml @@ -545,6 +545,14 @@ let autopin st ?(simulate=false) ?quiet ?locked ?recurse ?subpath else OpamUpdate.dev_packages st ~working_dir:OpamPackage.Set.empty already_pinned in + let st = + (* NOTE: We skip pin-depends on non-simulated because handle_pin_depends has + already been called in source_pin *) + if not simulate || OpamClientConfig.(!r.ignore_pin_depends) then st else + OpamPackage.Set.fold (fun nv st -> + OpamPinCommand.handle_pin_depends st nv (OpamSwitchState.opam st nv)) + (OpamPackage.Set.union pins already_pinned_set) st + in st, simulate_pinned_atoms pins atoms let check_and_revert_sandboxing root config = diff --git a/tests/reftests/autopin.test b/tests/reftests/autopin.test index 71dcc02b1d5..73f95860e3d 100644 --- a/tests/reftests/autopin.test +++ b/tests/reftests/autopin.test @@ -343,16 +343,31 @@ No solution found, exiting # Return code 20 # ### opam pin ### opam install --deps-only ./local-with-pin-deps -[ERROR] Package conflict! - * Missing dependency: - - deps-of-local-with-pin-deps -> pin-dep - unknown package +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] y +[NOTE] Package pin-dep does not exist in opam repositories registered in the current switch. +[pin-dep.dev] synchronised (no changes) +pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev) +The following actions will be performed: +=== install 1 package + - install pin-dep dev (pinned) [required by local-with-pin-deps] -No solution found, exiting -# Return code 20 # +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep) +-> installed pin-dep.dev +Done. ### opam pin +pin-dep.dev rsync file://${BASEDIR}/pin-dep ### opam pin remove pin-dep -[NOTE] pin-dep is not pinned. +Ok, pin-dep is no longer pinned to file://${BASEDIR}/pin-dep (version dev) +The following actions will be performed: +=== remove 1 package + - remove pin-dep dev + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> removed pin-dep.dev +Done. ### opam pin ### opam install ./local-with-pin-deps [NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. @@ -398,6 +413,10 @@ Switch invariant: ["ocaml" {>= "4.05.0"}] Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y # Return code 20 # ### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:switch-clean-up=yes opam switch create ./local-with-pin-deps --deps-only +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] n +Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y <><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> Switch invariant: ["ocaml" {>= "4.05.0"}] diff --git a/tests/reftests/pin-depends.test b/tests/reftests/pin-depends.test index e356e1b9052..f34cb797813 100644 --- a/tests/reftests/pin-depends.test +++ b/tests/reftests/pin-depends.test @@ -40,6 +40,10 @@ No solution found, exiting ### :I:1:c: Deps only without pin depends ### opam switch create pin-deps-I-1-c --empty ### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes opam install --deps-only ./local-with-pin-deps +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] n +Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y [ERROR] Package conflict! * Missing dependency: - deps-of-local-with-pin-deps -> pin-dep @@ -51,14 +55,24 @@ No solution found, exiting ### :I:1:d: Deps only with pin depends ### opam switch create pin-deps-I-1-d --empty ### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam install --deps-only ./local-with-pin-deps -[ERROR] Package conflict! - * Missing dependency: - - deps-of-local-with-pin-deps -> pin-dep - unknown package +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] y +[NOTE] Package pin-dep does not exist in opam repositories registered in the current switch. +[pin-dep.dev] synchronised (no changes) +pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev) +The following actions will be performed: +=== install 1 package + - install pin-dep dev (pinned) [required by local-with-pin-deps] -No solution found, exiting -# Return code 20 # +Proceed with 1 installation? [Y/n] y + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep) +-> installed pin-dep.dev +Done. ### opam pin +pin-dep.dev rsync file://${BASEDIR}/pin-dep ### :I:1:e: install without pin depends ### opam switch create pin-deps-I-1-e --empty ### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes opam install ./local-with-pin-deps @@ -134,6 +148,10 @@ Done. ### :I:2:c: Deps only without pin depends ### opam switch create pin-deps-I-2-c --empty ### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:proceed-actions=yes opam install --deps-only ./local-with-pin-deps +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] n +Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y The following actions will be performed: === install 1 package - install pin-dep 1 [required by local-with-pin-deps] @@ -147,14 +165,20 @@ Done. ### :I:2:d: Deps only without pin depends ### opam switch create pin-deps-I-2-d --empty ### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam install --deps-only ./local-with-pin-deps +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] y +[pin-dep.dev] synchronised (no changes) +pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev) The following actions will be performed: === install 1 package - - install pin-dep 1 [required by local-with-pin-deps] + - install pin-dep dev (pinned) [required by local-with-pin-deps] Proceed with 1 installation? [Y/n] y <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> --> installed pin-dep.1 +-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep) +-> installed pin-dep.dev Done. ### :I:2:e: install without pin depends ### opam switch create pin-deps-I-2-e --empty @@ -215,6 +239,10 @@ pin-dep.dev rsync file://${BASEDIR}/pin-dep Now run 'opam upgrade' to apply any package updates. ### :II:1:a: Answer no to pin depends install deps-only ### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:switch-clean-up=yes opam switch create ./local-with-pin-deps --deps-only +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] n +Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y <><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> Switch invariant: [] @@ -259,23 +287,30 @@ The compiler switch ${BASEDIR}/local-with-pin-deps does not exist. # Return code 5 # ### :II:1:c: Answer yes to pin depends install deps-only ### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes:switch-clean-up=yes opam switch create ./local-with-pin-deps --deps-only +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] y +[NOTE] Package pin-dep does not exist in opam repositories registered in the current switch. +[pin-dep.dev] synchronised (no changes) +pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev) <><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> Switch invariant: [] -[ERROR] Could not determine which packages to install for this switch: - * Missing dependency: - - local-with-pin-deps -> pin-dep - unknown package +[NOTE] No invariant was set, you may want to use `opam switch set-invariant' to keep a stable compiler version on upgrades. +The following actions will be performed: +=== install 1 package + - install pin-dep dev (pinned) [required by local-with-pin-deps] +Proceed with 1 installation? [Y/n] y -Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y -# Return code 20 # +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep) +-> installed pin-dep.dev +Done. ### opam pin --switch=./local-with-pin-deps -[ERROR] The selected switch ${BASEDIR}/local-with-pin-deps is not installed. -# Return code 2 # +pin-dep.dev rsync file://${BASEDIR}/pin-dep ### opam switch remove ./local-with-pin-deps -y -The compiler switch ${BASEDIR}/local-with-pin-deps does not exist. -# Return code 5 # +Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y ### :II:1:d: Answer yes to pin depends install ### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam switch create ./local-with-pin-deps [NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch. @@ -313,6 +348,10 @@ Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are yo opam-version: "2.0" ### :II:2:a: Answer no to pin depends install deps only ### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:proceed-actions=yes opam switch create ./local-with-pin-deps --deps-only +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] n +Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y <><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> Switch invariant: [] @@ -359,20 +398,27 @@ local-with-pin-deps.dev rsync file://${BASEDIR}/local-with-pin-deps Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y ### :II:2:c: Answer yes to pin depends install deps-only ### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam switch create ./local-with-pin-deps --deps-only +The following additional pinnings are required by local-with-pin-deps.dev: + - pin-dep.dev at file://${BASEDIR}/pin-dep +Pin and install them? [Y/n] y +[pin-dep.dev] synchronised (no changes) +pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev) <><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> Switch invariant: [] [NOTE] No invariant was set, you may want to use `opam switch set-invariant' to keep a stable compiler version on upgrades. The following actions will be performed: === install 1 package - - install pin-dep 1 [required by local-with-pin-deps] + - install pin-dep dev (pinned) [required by local-with-pin-deps] Proceed with 1 installation? [Y/n] y <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> --> installed pin-dep.1 +-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep) +-> installed pin-dep.dev Done. ### opam pin --switch=./local-with-pin-deps +pin-dep.dev rsync file://${BASEDIR}/pin-dep ### opam switch remove ./local-with-pin-deps -y Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y ### :II:2:d: Answer yes to pin depends install From f88b70077bd77b5efb937806bf133e69602a465b Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Wed, 8 Oct 2025 16:37:17 +0200 Subject: [PATCH 07/29] Add 'OpamFormula.equal' function --- master_changes.md | 1 + src/format/opamFormula.ml | 2 ++ src/format/opamFormula.mli | 1 + 3 files changed, 4 insertions(+) diff --git a/master_changes.md b/master_changes.md index d6011daa1fe..86895d4c269 100644 --- a/master_changes.md +++ b/master_changes.md @@ -212,6 +212,7 @@ users) * `OpamFormula.equal_relop`: was added [#6644 @kit-ty-kate] * `OpamTypesBase.{action,pkg_flag,simple_arg,arg,filter,command}_equal`: were added [#6644 @kit-ty-kate] * `OpamVariable.variable_contents_equal`: was added [#6644 @kit-ty-kate] + * `OpamFormula`: add `equal` function for `OpamFormula.t` [#6730 @rjbou] ## opam-core * `OpamConsole.confirm`: now takes an optional `name` argument [#6709 @kit-ty-kate] diff --git a/src/format/opamFormula.ml b/src/format/opamFormula.ml index 542b406c56b..9fc4827efc4 100644 --- a/src/format/opamFormula.ml +++ b/src/format/opamFormula.ml @@ -276,6 +276,8 @@ let compare_nc (n1, c1) (n2, c2) = let compare = compare_formula compare_nc +let equal f1 f2 = compare f1 f2 = 0 + let rec eval atom = function | Empty -> true | Atom x -> atom x diff --git a/src/format/opamFormula.mli b/src/format/opamFormula.mli index 444b1070938..c5dac1d7532 100644 --- a/src/format/opamFormula.mli +++ b/src/format/opamFormula.mli @@ -170,6 +170,7 @@ val check_version_formula: version_formula -> OpamPackage.Version.t -> bool type t = (OpamPackage.Name.t * version_formula) formula val compare: t -> t -> int +val equal: t -> t -> bool (** Returns [true] if [package] verifies [formula] (i.e. it is within at least one package set that is a solution of the formula, and is named in the From 561a7ebc56cbbfa71b8094f9aeb1c8e2cfae0102 Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Wed, 8 Oct 2025 16:37:54 +0200 Subject: [PATCH 08/29] option: make global option default-invariant modifiable --- master_changes.md | 1 + src/client/opamConfigCommand.ml | 17 ++++++++++ tests/reftests/pin-depends-ignore.test | 5 +-- tests/reftests/pin-depends.test | 6 ++-- tests/reftests/var-option.test | 47 +++++++++++++++++++++++++- 5 files changed, 70 insertions(+), 6 deletions(-) diff --git a/master_changes.md b/master_changes.md index 86895d4c269..6658147985f 100644 --- a/master_changes.md +++ b/master_changes.md @@ -51,6 +51,7 @@ users) ## Var/Option * Make the computation of `pkg:opamfile` match its specification [#6659 @kit-ty-kate - fix #5346] + * Make global option `default-invariant` modifiable [#6730 @rjbou] ## Update / Upgrade * Fix the false-positive mismatch debug warning during `opam update` when faced with nested extra-files on Windows [#6715 @kit-ty-kate] diff --git a/src/client/opamConfigCommand.ml b/src/client/opamConfigCommand.ml index 50c813c55a7..1fd67fef36c 100644 --- a/src/client/opamConfigCommand.ml +++ b/src/client/opamConfigCommand.ml @@ -841,6 +841,23 @@ let global_allowed_fields, global_allowed_sections = Config.with_eval_variables (InitConfig.eval_variables in_config); "repository-validation-command", Atomic, Config.with_validation_hook_opt (Config.validation_hook Config.empty); + "default-invariant", Modifiable ( + (fun nc c -> Config.with_default_invariant + (OpamFormula.And ((Config.default_invariant nc), + (Config.default_invariant c))) c), + (fun nc c -> + let to_remove = + OpamFormula.ands_to_list (Config.default_invariant nc) + in + let ndinv = + OpamFormula.ands_to_list (Config.default_invariant c) + |> List.filter (fun subinv -> + OpamStd.List.mem (fun f f' -> not (OpamFormula.equal f f')) + subinv to_remove) + |> OpamFormula.ands + in + Config.with_default_invariant ndinv c)), + Config.with_default_invariant (InitConfig.default_invariant in_config); "depext", Atomic, Config.with_depext (Config.depext Config.empty); "depext-run-installs", Atomic, diff --git a/tests/reftests/pin-depends-ignore.test b/tests/reftests/pin-depends-ignore.test index 21b87f26cc5..22ec19248cf 100644 --- a/tests/reftests/pin-depends-ignore.test +++ b/tests/reftests/pin-depends-ignore.test @@ -1,6 +1,7 @@ N0REP0 -### # to change! -### sed -i.bak 's/"ocaml" {>= "4.05.0"}//' OPAM/config +### ### Try to keep synchronised with pin-depends +### opam option default-invariant=[] +Set to '[]' the field default-invariant in global configuration ### unset OPAMCONFIRMLEVEL ### :I: Local install with pin depends ### diff --git a/tests/reftests/pin-depends.test b/tests/reftests/pin-depends.test index f34cb797813..126ea4678f3 100644 --- a/tests/reftests/pin-depends.test +++ b/tests/reftests/pin-depends.test @@ -1,7 +1,7 @@ N0REP0 -### ### Ty to keep synchronised with pin-depends-ignore -### # to change! -### sed -i.bak 's/"ocaml" {>= "4.05.0"}//' OPAM/config +### ### Try to keep synchronised with pin-depends-ignore +### opam option default-invariant=[] +Set to '[]' the field default-invariant in global configuration ### unset OPAMCONFIRMLEVEL ### :I: Local install with pin depends ### diff --git a/tests/reftests/var-option.test b/tests/reftests/var-option.test index 8a8c9af8662..eec8001904b 100644 --- a/tests/reftests/var-option.test +++ b/tests/reftests/var-option.test @@ -43,6 +43,8 @@ Set to '[]' the field wrap-install-commands in global configuration Set to '[]' the field wrap-remove-commands in global configuration ### opam option jobs=7 --global Set to '7' the field jobs in global configuration +### opam option 'default-invariant=["i-nv" { >= "12.3.4" }]' +Set to '["i-nv" { >= "12.3.4" }]' the field default-invariant in global configuration ### opam install i-got-the-variables --yes The following actions will be performed: === install 2 packages @@ -220,6 +222,7 @@ Try 'opam var --help' or 'opam --help' for more information. <><> Global configuration <><><><><><><><><><><><><><><><><><><><><><><><><><><> archive-mirrors {} best-effort-prefix-criteria {} +default-invariant ["i-nv" {>= "12.3.4"}] depext true depext-bypass {} depext-cannot-install false @@ -484,6 +487,46 @@ Removed '"http://lorem.labore"' from field archive-mirrors in global configurati ### opam option archive-mirrors= Reverted field archive-mirrors in global configuration ### opam option archive-mirrors +### # Check addition and removal on formulae +### opam option default-invariant +["i-nv" {>= "12.3.4"}] +### opam option 'default-invariant="lmaco"' +Set to '"lmaco"' the field default-invariant in global configuration +### opam option default-invariant +["lmaco"] +### opam option 'default-invariant=["lmaco" { > "52.5" }]' +Set to '["lmaco" { > "52.5" }]' the field default-invariant in global configuration +### opam option default-invariant +["lmaco" {> "52.5"}] +### opam option 'default-invariant+="another"' +Added '"another"' to field default-invariant in global configuration +### opam option default-invariant +["another" "lmaco" {> "52.5"}] +### opam option 'default-invariant+=["another" { = "3.12" }]' +Added '["another" { = "3.12" }]' to field default-invariant in global configuration +### opam option default-invariant +["another" {= "3.12"} "another" "lmaco" {> "52.5"}] +### opam option 'default-invariant-="another"' +Removed '"another"' from field default-invariant in global configuration +### opam option default-invariant +["another" {= "3.12"} "lmaco" {> "52.5"}] +### opam option 'default-invariant-=["another" { = "3.12" }]' +Removed '["another" { = "3.12" }]' from field default-invariant in global configuration +### opam option default-invariant +["lmaco" {> "52.5"}] +### opam option default-invariant=[] +Set to '[]' the field default-invariant in global configuration +### opam option default-invariant +[] +### # wwe don't want to retrieve the init config one +### # opam option default-invariant= +### # Reverted field default-invariant in global configuration +### # opam option default-invariant +### # ["ocaml" {>= "4.05.0"}] +### opam option 'default-invariant=["i-nv" { >= "12.3.4" }]' +Set to '["i-nv" { >= "12.3.4" }]' the field default-invariant in global configuration +### opam option default-invariant +["i-nv" {>= "12.3.4"}] ### # Check that eval-variable is removed when a global variable is removed ### opam option global-variables [[foo "global-foo" "Set through 'opam var'"] [bin "global-bin" "Set through 'opam var'"] [os-version "dolor" "Set through 'opam var'"] [os-family "ipsum" "Set through 'opam var'"] [os-distribution "lorem" "Set through 'opam var'"] [os "linux" "Set through 'opam var'"] [make "make" "Set through 'opam var'"] [arch "x86_64" "Set through 'opam var'"] [sys-ocaml-version "4.08.0" "Set through 'opam var'"]] @@ -526,7 +569,7 @@ Removed variable dolore in global configuration # Return code 2 # ### opam option bar=sit --global [ERROR] There is no option named 'bar'. The allowed options are: -jobs download-command download-jobs archive-mirrors solver-criteria solver-upgrade-criteria solver-fixup-criteria best-effort-prefix-criteria solver global-variables eval-variables repository-validation-command depext depext-run-installs depext-cannot-install depext-bypass sys-pkg-manager-cmd git-location swh-fallback pre-build-commands pre-install-commands pre-remove-commands pre-session-commands wrap-build-commands wrap-install-commands wrap-remove-commands post-build-commands post-install-commands post-remove-commands post-session-commands +jobs download-command download-jobs archive-mirrors solver-criteria solver-upgrade-criteria solver-fixup-criteria best-effort-prefix-criteria solver global-variables eval-variables repository-validation-command default-invariant depext depext-run-installs depext-cannot-install depext-bypass sys-pkg-manager-cmd git-location swh-fallback pre-build-commands pre-install-commands pre-remove-commands pre-session-commands wrap-build-commands wrap-install-commands wrap-remove-commands post-build-commands post-install-commands post-remove-commands post-session-commands # Return code 2 # ### opam option bar=sit --switch var-option [ERROR] There is no option named 'bar'. The allowed options are: @@ -660,6 +703,7 @@ stublibs ${BASEDIR}/OPAM/phantom/lib/stublibs <><> Global configuration <><><><><><><><><><><><><><><><><><><><><><><><><><><> archive-mirrors {} best-effort-prefix-criteria {} +default-invariant ["i-nv" {>= "12.3.4"}] depext true depext-bypass {} depext-cannot-install false @@ -692,6 +736,7 @@ No switch installed ### opam option --global archive-mirrors {} best-effort-prefix-criteria {} +default-invariant ["i-nv" {>= "12.3.4"}] depext true depext-bypass {} depext-cannot-install false From 75043fdb072daa260340cae66601989ff26fece1 Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Thu, 18 Sep 2025 12:50:17 +0200 Subject: [PATCH 09/29] compat: add Lazy.map_val --- master_changes.md | 1 + src/core/opamCompat.ml | 6 ++++++ src/core/opamCompat.mli | 3 +++ 3 files changed, 10 insertions(+) diff --git a/master_changes.md b/master_changes.md index 6658147985f..bdf129daa98 100644 --- a/master_changes.md +++ b/master_changes.md @@ -248,3 +248,4 @@ users) * `OpamSystem`: add lower-level `parse_patch` that preprocesses and parses a patch file. [#6614 @arozovyk] * `OpamFilename.patch`: use variants to make the input either `Filename.t` or reuse `Patch.diffs` directly. Remove the `?preprocess` argument since the preprocess logic is moved to the `OpamFilename.parse_patch` function that is called only in `OpamVCS` (mirroring the previous logic). [#6614 @arozovyk] * `OpamSystem.patch`: change the signature to work directly with `Patch.diffs` (implementation is now the previously `internal_patch` function), parsing is now done separately. [#6614 @arozovyk] + * `OpamCompat.Lazy`: add `map_val` [#6679 @rjbou] diff --git a/src/core/opamCompat.ml b/src/core/opamCompat.ml index d37896dbab0..d8a543cc92d 100644 --- a/src/core/opamCompat.ml +++ b/src/core/opamCompat.ml @@ -101,6 +101,12 @@ module Lazy = struct let map f x = lazy (f (Lazy.force x)) + (** NOTE: OCaml >= 4.13 *) + let map_val f x = + if Lazy.is_val x + then Lazy.from_val (f (Lazy.force x)) + else lazy (f (Lazy.force x)) + include Stdlib.Lazy end diff --git a/src/core/opamCompat.mli b/src/core/opamCompat.mli index 3f96e81d536..f076f415679 100644 --- a/src/core/opamCompat.mli +++ b/src/core/opamCompat.mli @@ -40,6 +40,9 @@ end module Lazy : sig (* NOTE: OCaml >= 4.13 *) val map : ('a -> 'b) -> 'a Lazy.t -> 'b Lazy.t + + (* NOTE: OCaml >= 4.13 *) + val map_val: ('a -> 'b) -> 'a Lazy.t -> 'b Lazy.t end module Unix : sig From 86bac204700287743fcf14d19dc10a2329b668d7 Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Thu, 9 Oct 2025 19:02:00 +0200 Subject: [PATCH 10/29] Add logging for write & read files --- master_changes.md | 1 + src/core/opamSystem.ml | 2 ++ tests/reftests/action-disk.test | 46 +++++++++++++++++++++++++++++++++ tests/reftests/dot-install.test | 38 ++++++++++++++++++++++++--- 4 files changed, 84 insertions(+), 3 deletions(-) diff --git a/master_changes.md b/master_changes.md index bdf129daa98..ddd8a05ca3c 100644 --- a/master_changes.md +++ b/master_changes.md @@ -122,6 +122,7 @@ users) * Simplify the `src_ext/update-sources.sh` script [#6701 @kit-ty-kate] * Homogeneise verbose command output between sandboxed and non sandboxed one [#6675 @rjbou] * Add the `install-pin-depends`, `ignore-pin-depends`, `proceed-actions` and `switch-clean-up` named questions [#6611 @kit-ty-kate @rjbou] + * Add logging for file reads and writes [#6679 @rjbou] ## Internal: Unix diff --git a/src/core/opamSystem.ml b/src/core/opamSystem.ml index 60ea19c35e8..d0908d298b6 100644 --- a/src/core/opamSystem.ml +++ b/src/core/opamSystem.ml @@ -254,6 +254,7 @@ let string_of_channel ic = Buffer.contents b let read file = + log ~level:5 "read %s" file; let ic = try open_in_bin file with Sys_error _ -> raise (File_not_found file) in @@ -264,6 +265,7 @@ let read file = let write file contents = mkdir (Filename.dirname file); + log ~level:5 "write %s" file; let oc = try open_out_bin file with Sys_error _ -> raise (File_not_found file) diff --git a/tests/reftests/action-disk.test b/tests/reftests/action-disk.test index ab97b9ef150..bb46e389c16 100644 --- a/tests/reftests/action-disk.test +++ b/tests/reftests/action-disk.test @@ -64,11 +64,22 @@ SYSTEM copydir ${BASEDIR}/REPO/packages/main-repo/main- SYSTEM mkdir ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.2 SYSTEM copy ${BASEDIR}/REPO/packages/main-repo/main-repo.2/opam -> ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.2/opam SYSTEM copy ${BASEDIR}/REPO/repo -> ${BASEDIR}/OPAM/repo/default.new/repo +SYSTEM read ${BASEDIR}/OPAM/repo/default/repo +SYSTEM read ${BASEDIR}/OPAM/repo/default.new/repo +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/opam +SYSTEM read ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.2/opam +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/opam +SYSTEM read ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.1/opam +SYSTEM write ${BASEDIR}/OPAM/log/patch-xxx SYSTEM rmdir ${BASEDIR}/OPAM/repo/default.new SYSTEM rm ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.1/opam SYSTEM rm ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.2/opam SYSTEM rm ${BASEDIR}/OPAM/repo/default.new/repo [default] synchronised from file://${BASEDIR}/REPO +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/opam +SYSTEM write ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/opam +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/opam +SYSTEM write ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/opam FILE(repo) Read ${BASEDIR}/OPAM/repo/default/repo in 0.000s Processing: [default: loading data] FILE(opam) Read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/opam in 0.000s @@ -128,6 +139,11 @@ FILE(switch-config) Wrote ${BASEDIR}/OPAM/install-from-repo/.opam-sw FILE(switch-config) Wrote ${BASEDIR}/OPAM/install-from-repo/.opam-switch/switch-config atomically in 0.000s FILE(environment) Wrote ${BASEDIR}/OPAM/install-from-repo/.opam-switch/environment atomically in 0.000s FILE(config) Wrote ${BASEDIR}/OPAM/config atomically in 0.000s +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.sh +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.csh +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.fish +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.ps1 +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.cmd SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (write => none) SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-switch/lock (write => none) SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) @@ -512,6 +528,11 @@ FILE(switch-config) Wrote ${BASEDIR}/OPAM/install-from-path-pin-all/ FILE(switch-config) Wrote ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/switch-config atomically in 0.000s FILE(environment) Wrote ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/environment atomically in 0.000s FILE(config) Wrote ${BASEDIR}/OPAM/config atomically in 0.000s +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.sh +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.csh +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.fish +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.ps1 +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.cmd SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (write => none) SYSTEM LOCK ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/lock (write => none) SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) @@ -544,8 +565,10 @@ Processing 1/1: [main-ppin: rsync] SYSTEM rmdir ${OPAMTMP} [NOTE] Package main-ppin does not exist in opam repositories registered in the current switch. SYSTEM rmdir ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/overlay/main-ppin +SYSTEM read ${BASEDIR}/main-ppin/main-ppin.opam SYSTEM mkdir ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/overlay SYSTEM mkdir ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/overlay/main-ppin +SYSTEM write ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/overlay/main-ppin/opam FILE(switch-state) Wrote ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/switch-state atomically in 0.000s FILE(environment) Wrote ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/environment atomically in 0.000s main-ppin is now pinned to file://${BASEDIR}/main-ppin (version dev) @@ -860,7 +883,9 @@ FILE(switch-state) Wrote ${BASEDIR}/OPAM/install-from-path-pin-all/ FILE(opam) Read ${BASEDIR}/main-ppin/main-ppin.opam in 0.000s [NOTE] Package main-ppin does not exist in opam repositories registered in the current switch. SYSTEM rmdir ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/overlay/main-ppin +SYSTEM read ${BASEDIR}/main-ppin/main-ppin.opam SYSTEM mkdir ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/overlay/main-ppin +SYSTEM write ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/overlay/main-ppin/opam FILE(switch-state) Wrote ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/switch-state atomically in 0.000s FILE(environment) Wrote ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/environment atomically in 0.000s main-ppin is now pinned to file://${BASEDIR}/main-ppin (version dev) @@ -1147,6 +1172,11 @@ FILE(switch-config) Wrote ${BASEDIR}/OPAM/install-from-git-pin-all/. FILE(switch-config) Wrote ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/switch-config atomically in 0.000s FILE(environment) Wrote ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/environment atomically in 0.000s FILE(config) Wrote ${BASEDIR}/OPAM/config atomically in 0.000s +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.sh +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.csh +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.fish +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.ps1 +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.cmd SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (write => none) SYSTEM LOCK ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/lock (write => none) SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) @@ -1189,8 +1219,10 @@ Processing 1/1: [main-gpin: git] SYSTEM rmdir ${OPAMTMP} [NOTE] Package main-gpin does not exist in opam repositories registered in the current switch. SYSTEM rmdir ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/overlay/main-gpin +SYSTEM read ${BASEDIR}/main-gpin/main-gpin.opam SYSTEM mkdir ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/overlay SYSTEM mkdir ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/overlay/main-gpin +SYSTEM write ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/overlay/main-gpin/opam FILE(switch-state) Wrote ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/switch-state atomically in 0.000s FILE(environment) Wrote ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/environment atomically in 0.000s main-gpin is now pinned to git+file://${BASEDIR}/main-gpin#master (version dev) @@ -1525,7 +1557,9 @@ FILE(switch-state) Wrote ${BASEDIR}/OPAM/install-from-git-pin-all/. FILE(opam) Read ${BASEDIR}/main-gpin/main-gpin.opam in 0.000s [NOTE] Package main-gpin does not exist in opam repositories registered in the current switch. SYSTEM rmdir ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/overlay/main-gpin +SYSTEM read ${BASEDIR}/main-gpin/main-gpin.opam SYSTEM mkdir ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/overlay/main-gpin +SYSTEM write ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/overlay/main-gpin/opam FILE(switch-state) Wrote ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/switch-state atomically in 0.000s FILE(environment) Wrote ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/environment atomically in 0.000s main-gpin is now pinned to git+file://${BASEDIR}/main-gpin#master (version dev) @@ -1827,6 +1861,11 @@ FILE(switch-config) Wrote ${BASEDIR}/OPAM/install-from-version-pin/. FILE(switch-config) Wrote ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/switch-config atomically in 0.000s FILE(environment) Wrote ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/environment atomically in 0.000s FILE(config) Wrote ${BASEDIR}/OPAM/config atomically in 0.000s +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.sh +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.csh +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.fish +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.ps1 +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.cmd SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (write => none) SYSTEM LOCK ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/lock (write => none) SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) @@ -2189,6 +2228,11 @@ Done. FILE(switch-state) Wrote ${BASEDIR}/OPAM/package-switch/.opam-switch/switch-state atomically in 0.000s FILE(environment) Wrote ${BASEDIR}/OPAM/package-switch/.opam-switch/environment atomically in 0.000s FILE(config) Wrote ${BASEDIR}/OPAM/config atomically in 0.000s +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.sh +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.csh +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.fish +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.ps1 +SYSTEM write ${BASEDIR}/OPAM/opam-init/variables.cmd SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (write => none) SYSTEM LOCK ${BASEDIR}/OPAM/package-switch/.opam-switch/lock (write => none) SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) @@ -2291,8 +2335,10 @@ FILE(switch-config) Wrote ${BASEDIR}/main-ppin/_opam/.opam-switch/sw FILE(opam) Read ${BASEDIR}/main-ppin/main-ppin.opam in 0.000s [NOTE] Package main-ppin does not exist in opam repositories registered in the current switch. SYSTEM rmdir ${BASEDIR}/main-ppin/_opam/.opam-switch/overlay/main-ppin +SYSTEM read ${BASEDIR}/main-ppin/main-ppin.opam SYSTEM mkdir ${BASEDIR}/main-ppin/_opam/.opam-switch/overlay SYSTEM mkdir ${BASEDIR}/main-ppin/_opam/.opam-switch/overlay/main-ppin +SYSTEM write ${BASEDIR}/main-ppin/_opam/.opam-switch/overlay/main-ppin/opam FILE(switch-state) Wrote ${BASEDIR}/main-ppin/_opam/.opam-switch/switch-state atomically in 0.000s FILE(environment) Wrote ${BASEDIR}/main-ppin/_opam/.opam-switch/environment atomically in 0.000s main-ppin is now pinned to file://${BASEDIR}/main-ppin (version dev) diff --git a/tests/reftests/dot-install.test b/tests/reftests/dot-install.test index 0d70b16509d..95195929381 100644 --- a/tests/reftests/dot-install.test +++ b/tests/reftests/dot-install.test @@ -204,13 +204,15 @@ Done. Not found: ${BASEDIR}/OPAM/inst/share/dot/a-file ==> dot changes Not found: ${BASEDIR}/OPAM/inst/.opam-switch/install/dot.changes -### OPAMDEBUGSECTIONS="SYSTEM FILE(.config)" OPAMDEBUG=-1 +### OPAMDEBUGSECTIONS="SYSTEM FILE(.config)" OPAMDEBUG=-5 ### : check install files ordering : ### opam install lot-of-files | grep "mkdir\|install\|FILE" +FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s === install 1 package - install lot-of-files ~dev SYSTEM mkdir ${BASEDIR}/OPAM/inst/.opam-switch/build/lot-of-files.~dev SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/lot-of-files/lot-of-files.~dev/files/lot-of-files.install.in -> ${BASEDIR}/OPAM/inst/.opam-switch/build/lot-of-files.~dev/lot-of-files.install.in +FILE(.config) Read ${BASEDIR}/OPAM/inst/.opam-switch/build/lot-of-files.~dev/lot-of-files.config in 0.000s FILE(.config) Wrote ${BASEDIR}/OPAM/inst/.opam-switch/config/lot-of-files.config atomically in 0.000s SYSTEM install ${BASEDIR}/OPAM/inst/.opam-switch/build/lot-of-files.~dev/fichier -> ${BASEDIR}/OPAM/inst/bin/fichier (755) SYSTEM mkdir ${BASEDIR}/OPAM/inst/lib/lot-of-files @@ -226,6 +228,7 @@ SYSTEM install ${BASEDIR}/OPAM/inst/.opam-switch/build/ SYSTEM install ${BASEDIR}/OPAM/inst/.opam-switch/build/lot-of-files.~dev/a-file -> ${BASEDIR}/OPAM/inst/etc/lot-of-files/a-file (644) SYSTEM install ${BASEDIR}/OPAM/inst/.opam-switch/build/lot-of-files.~dev/a-file -> ${BASEDIR}/OPAM/dosiero (644) -> installed lot-of-files.~dev +FILE(.config) Read ${BASEDIR}/OPAM/inst/.opam-switch/config/lot-of-files.config in 0.000s SYSTEM mkdir ${BASEDIR}/OPAM/inst/.opam-switch/packages/lot-of-files.~dev SYSTEM mkdir ${BASEDIR}/OPAM/inst/.opam-switch/packages/lot-of-files.~dev/files SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/lot-of-files/lot-of-files.~dev/files/lot-of-files.install.in -> ${BASEDIR}/OPAM/inst/.opam-switch/packages/lot-of-files.~dev/files/lot-of-files.install.in @@ -243,8 +246,15 @@ lib_root: [ share: [ "a-file" ] ### touch -### OPAMDEBUGSECTIONS="SYSTEM TRACK" OPAMDEBUG=-1 +### OPAMDEBUGSECTIONS="SYSTEM TRACK" OPAMDEBUG=-5 ### opam install no-specified-dir | '[0-9]{14}' -> "now" +FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s +SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) +SYSTEM LOCK ${BASEDIR}/OPAM/repo/state-magicv.cache (none => read) +SYSTEM LOCK ${BASEDIR}/OPAM/repo/state-magicv.cache (read => none) +SYSTEM LOCK ${BASEDIR}/OPAM/rem-dir/.opam-switch/lock (none => write) +SYSTEM LOCK ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/cache (none => read) +SYSTEM LOCK ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/cache (read => none) SYSTEM mkdir ${BASEDIR}/OPAM/rem-dir/.opam-switch/backup The following actions will be performed: === install 1 package @@ -255,6 +265,7 @@ SYSTEM rmdir ${BASEDIR}/OPAM/rem-dir/.opam-switch/build SYSTEM mkdir ${BASEDIR}/OPAM/rem-dir/.opam-switch/build/no-specified-dir.1 SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/no-specified-dir/no-specified-dir.1/files/no-specified-dir.install -> ${BASEDIR}/OPAM/rem-dir/.opam-switch/build/no-specified-dir.1/no-specified-dir.install SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/no-specified-dir/no-specified-dir.1/files/a-file -> ${BASEDIR}/OPAM/rem-dir/.opam-switch/build/no-specified-dir.1/a-file +TRACK before install: 2 elements scanned in 0.000s SYSTEM mkdir ${BASEDIR}/OPAM/rem-dir/lib/another SYSTEM mkdir ${BASEDIR}/OPAM/rem-dir/lib/another/somedir SYSTEM install ${BASEDIR}/OPAM/rem-dir/.opam-switch/build/no-specified-dir.1/a-file -> ${BASEDIR}/OPAM/rem-dir/lib/another/somedir/an-installed-file (644) @@ -269,8 +280,13 @@ SYSTEM mkdir ${BASEDIR}/OPAM/rem-dir/.opam-switch/packa SYSTEM mkdir ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/no-specified-dir.1/files SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/no-specified-dir/no-specified-dir.1/files/no-specified-dir.install -> ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/no-specified-dir.1/files/no-specified-dir.install SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/no-specified-dir/no-specified-dir.1/files/a-file -> ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/no-specified-dir.1/files/a-file +SYSTEM LOCK ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/cache (none => write) +SYSTEM LOCK ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/cache (write => none) Done. +SYSTEM LOCK ${BASEDIR}/OPAM/rem-dir/.opam-switch/lock (write => none) SYSTEM rm ${BASEDIR}/OPAM/rem-dir/.opam-switch/backup/state-now.export +SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) +SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => none) ### ocaml cat.ml rem-dir no-specified-dir ==> no-specified-dir installed file touch @@ -286,7 +302,14 @@ added: [ "share|no-specified-dir" {"D"} "share|no-specified-dir|a-file" {"F:af5d4d883c8c9c50711d86a7e1807cab"} ] -### opam remove no-specified-dir | '[0-9]{14}' -> "now" +### opam remove no-specified-dir | '[0-9]{14}' -> "now" | grep -v "were already removed" | unordered +FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s +SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) +SYSTEM LOCK ${BASEDIR}/OPAM/repo/state-magicv.cache (none => read) +SYSTEM LOCK ${BASEDIR}/OPAM/repo/state-magicv.cache (read => none) +SYSTEM LOCK ${BASEDIR}/OPAM/rem-dir/.opam-switch/lock (none => write) +SYSTEM LOCK ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/cache (none => read) +SYSTEM LOCK ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/cache (read => none) The following actions will be performed: === remove 1 package - remove no-specified-dir 1 @@ -306,11 +329,20 @@ SYSTEM rmdir ${BASEDIR}/OPAM/rem-dir/lib/another/somedi SYSTEM rmdir ${BASEDIR}/OPAM/rem-dir/lib/another SYSTEM rm ${BASEDIR}/OPAM/rem-dir/.opam-switch/install/no-specified-dir.changes -> removed no-specified-dir.1 +SYSTEM LOCK ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/cache (none => write) +SYSTEM LOCK ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/cache (write => none) SYSTEM rm ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/cache SYSTEM rmdir ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/no-specified-dir.1 +SYSTEM rm ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/no-specified-dir.1/opam +SYSTEM rm ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/no-specified-dir.1/files/no-specified-dir.install +SYSTEM rm ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/no-specified-dir.1/files/a-file SYSTEM rmdir ${BASEDIR}/OPAM/rem-dir/.opam-switch/sources/no-specified-dir.1 Done. +SYSTEM LOCK ${BASEDIR}/OPAM/rem-dir/.opam-switch/lock (write => none) +SYSTEM LOCK ${BASEDIR}/OPAM/rem-dir/.opam-switch/lock (none => none) SYSTEM rm ${BASEDIR}/OPAM/rem-dir/.opam-switch/backup/state-now.export +SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) +SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => none) ### test -d OPAM/rem-dir/lib/another/somedir # Return code 1 # ### find OPAM/rem-dir/lib | unordered From ceff73d5aebdfb7bec7c96e1a2b0cca6714428eb Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Thu, 9 Oct 2025 16:49:50 +0200 Subject: [PATCH 11/29] reftest: complete action-disk.test with the behaviour of extra-files --- master_changes.md | 1 + tests/reftests/action-disk.test | 58 ++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/master_changes.md b/master_changes.md index ddd8a05ca3c..44721d8ea50 100644 --- a/master_changes.md +++ b/master_changes.md @@ -155,6 +155,7 @@ users) * Add opam file loading tests to `update.test` to demonstrate current behaviour of loading full repository instead of only changed files. [#6614 @arozovyk @rjbou @kit-ty-kate] * Fix `env.test` in cases where calling `env` inside of a script outputs a `__CF_USER_TEXT_ENCODING` environment variable that isn't present in `sh -c env` [#6719 @kit-ty-kate] * Add complete tests for the `pin-depends` feature [#6611 @rjbou] + * Complete `action-disk.test` with the behaviour of `extra-files` [#6679 @rjbou] ### Engine * Fix gcc < 14.3 bug on mingw i686 [#6624 @kit-ty-kate] diff --git a/tests/reftests/action-disk.test b/tests/reftests/action-disk.test index bb46e389c16..a7928e07acc 100644 --- a/tests/reftests/action-disk.test +++ b/tests/reftests/action-disk.test @@ -23,18 +23,25 @@ install: [ remove: [ "touch" "removal-file" ] ### I'm a file +### +I'm an extra-file ### tar czf archive.tgz content ### openssl md5 archive.tgz | '.*= ' -> '' >$ MD5 ### sh -c "echo '$MD5' | cut -c 1-2" >$ PRE_MD5 +### openssl md5 x-file | '.*= ' -> '' >$ XMD5 ### for nv in "$@"; do arch=archive.tgz - file="REPO/packages/${nv%.*}/$nv/opam" + dir="REPO/packages/${nv%.*}/$nv" + file="$dir/opam" + mkdir -p "$dir/files" + cp x-file "$dir/files/x-file.$nv" cat >> "$file" << EOF url { src: "$arch" checksum: "md5=$MD5" } +extra-files: [ "x-file.$nv" "md5=$XMD5" ] EOF done ### sh add-url.sh main-repo.1 main-repo.2 @@ -60,26 +67,40 @@ SYSTEM mkdir ${BASEDIR}/OPAM/repo/default.new/packages/ SYSTEM copydir ${BASEDIR}/REPO/packages/main-repo/main-repo.1 -> ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.1 SYSTEM mkdir ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.1 SYSTEM copy ${BASEDIR}/REPO/packages/main-repo/main-repo.1/opam -> ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.1/opam +SYSTEM copydir ${BASEDIR}/REPO/packages/main-repo/main-repo.1/files -> ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.1/files +SYSTEM mkdir ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.1/files +SYSTEM copy ${BASEDIR}/REPO/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.1/files/x-file.main-repo.1 SYSTEM copydir ${BASEDIR}/REPO/packages/main-repo/main-repo.2 -> ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.2 SYSTEM mkdir ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.2 SYSTEM copy ${BASEDIR}/REPO/packages/main-repo/main-repo.2/opam -> ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.2/opam +SYSTEM copydir ${BASEDIR}/REPO/packages/main-repo/main-repo.2/files -> ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.2/files +SYSTEM mkdir ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.2/files +SYSTEM copy ${BASEDIR}/REPO/packages/main-repo/main-repo.2/files/x-file.main-repo.2 -> ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.2/files/x-file.main-repo.2 SYSTEM copy ${BASEDIR}/REPO/repo -> ${BASEDIR}/OPAM/repo/default.new/repo SYSTEM read ${BASEDIR}/OPAM/repo/default/repo SYSTEM read ${BASEDIR}/OPAM/repo/default.new/repo SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/opam SYSTEM read ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.2/opam +SYSTEM read ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.2/files/x-file.main-repo.2 SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/opam SYSTEM read ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.1/opam +SYSTEM read ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.1/files/x-file.main-repo.1 SYSTEM write ${BASEDIR}/OPAM/log/patch-xxx SYSTEM rmdir ${BASEDIR}/OPAM/repo/default.new SYSTEM rm ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.1/opam +SYSTEM rm ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.1/files/x-file.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.2/opam +SYSTEM rm ${BASEDIR}/OPAM/repo/default.new/packages/main-repo/main-repo.2/files/x-file.main-repo.2 SYSTEM rm ${BASEDIR}/OPAM/repo/default.new/repo [default] synchronised from file://${BASEDIR}/REPO +SYSTEM write ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 +SYSTEM write ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/opam SYSTEM write ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/opam SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/opam SYSTEM write ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/opam +SYSTEM mkdir ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files +SYSTEM mkdir ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files FILE(repo) Read ${BASEDIR}/OPAM/repo/default/repo in 0.000s Processing: [default: loading data] FILE(opam) Read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/opam in 0.000s @@ -196,6 +217,7 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-sw SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/content +SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-file.main-repo.1 Processing 2/3: [main-repo: touch build-file] + touch "build-file" (CWD=${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1) -> compiled main-repo.1 @@ -212,6 +234,8 @@ FILE(.config) Cannot find ${BASEDIR}/OPAM/install-from-repo/.o SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1 FILE(opam) Wrote ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1/opam atomically in 0.000s +SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1/files +SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache (none => write) CACHE(installed) Writing the installed cache to ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache ... CACHE(installed) ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache written in 0.000s @@ -256,10 +280,12 @@ SYSTEM rm ${OPAMTMP}/content -> retrieved main-repo.1 (cached) SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/content +SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-file.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/build-file SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/content +SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-file.main-repo.1 Processing 2/4: [main-repo: touch build-file] + touch "build-file" (CWD=${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1) -> compiled main-repo.1 @@ -268,6 +294,7 @@ SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam- SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/content +SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-file.main-repo.1 Processing 3/4: [main-repo: touch removal-file] + touch "removal-file" (CWD=${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1) FILE(.install) Cannot find ${BASEDIR}/OPAM/install-from-repo/.opam-switch/install/main-repo.install @@ -293,12 +320,15 @@ FILE(environment) Wrote ${BASEDIR}/OPAM/install-from-repo/.opam-sw FILE(.config) Cannot find ${BASEDIR}/OPAM/install-from-repo/.opam-switch/config/main-repo.config SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache FILE(opam) Wrote ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1/opam atomically in 0.000s +SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 +SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache (none => write) CACHE(installed) Writing the installed cache to ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache ... CACHE(installed) ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache written in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache (write => none) SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/content +SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-file.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/removal-file Done. SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-switch/lock (write => none) @@ -352,6 +382,7 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-sw SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2/content +SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2/x-file.main-repo.2 Processing 2/4: [main-repo: touch build-file] + touch "build-file" (CWD=${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2) -> compiled main-repo.2 @@ -359,6 +390,7 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-sw SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/content +SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-file.main-repo.1 Processing 3/4: [main-repo: touch removal-file] + touch "removal-file" (CWD=${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1) FILE(.install) Cannot find ${BASEDIR}/OPAM/install-from-repo/.opam-switch/install/main-repo.install @@ -385,15 +417,19 @@ FILE(.config) Cannot find ${BASEDIR}/OPAM/install-from-repo/.o SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.2 FILE(opam) Wrote ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.2/opam atomically in 0.000s +SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.2/files +SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.2/files/x-file.main-repo.2 SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache (none => write) CACHE(installed) Writing the installed cache to ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache ... CACHE(installed) ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache written in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache (write => none) SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/content +SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-file.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/removal-file SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1 +SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1/opam SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1/content @@ -442,6 +478,7 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-sw SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/content +SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/x-file.main-repo.2 Processing 2/2: [main-repo: touch removal-file] + touch "removal-file" (CWD=${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2) FILE(.install) Cannot find ${BASEDIR}/OPAM/install-from-repo/.opam-switch/install/main-repo.install @@ -461,10 +498,12 @@ CACHE(installed) ${BASEDIR}/OPAM/install-from-repo/.opam-switch/p SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache (write => none) SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/content +SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/x-file.main-repo.2 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/removal-file SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.2 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.2/opam +SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.2/files/x-file.main-repo.2 SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2/content Done. @@ -1931,6 +1970,7 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-version-pin/. SYSTEM copydir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo/content -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/content +SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-file.main-repo.1 Processing 2/3: [main-repo: touch build-file] + touch "build-file" (CWD=${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1) -> compiled main-repo.1 @@ -1947,6 +1987,8 @@ FILE(.config) Cannot find ${BASEDIR}/OPAM/install-from-version SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1 FILE(opam) Wrote ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1/opam atomically in 0.000s +SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1/files +SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 SYSTEM LOCK ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache (none => write) CACHE(installed) Writing the installed cache to ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache ... CACHE(installed) ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache written in 0.000s @@ -1991,10 +2033,12 @@ SYSTEM rm ${OPAMTMP}/content -> retrieved main-repo.1 (cached) SYSTEM rmdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/content +SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-file.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/build-file SYSTEM copydir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo/content -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/content +SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-file.main-repo.1 Processing 2/4: [main-repo: touch build-file] + touch "build-file" (CWD=${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1) -> compiled main-repo.1 @@ -2003,6 +2047,7 @@ SYSTEM copydir ${BASEDIR}/OPAM/install-from-version-pin SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo/content -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/content +SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-file.main-repo.1 Processing 3/4: [main-repo: touch removal-file] + touch "removal-file" (CWD=${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1) FILE(.install) Cannot find ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/install/main-repo.install @@ -2028,12 +2073,15 @@ FILE(environment) Wrote ${BASEDIR}/OPAM/install-from-version-pin/. FILE(.config) Cannot find ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/config/main-repo.config SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache FILE(opam) Wrote ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1/opam atomically in 0.000s +SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 +SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 SYSTEM LOCK ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache (none => write) CACHE(installed) Writing the installed cache to ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache ... CACHE(installed) ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache written in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache (write => none) SYSTEM rmdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/content +SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-file.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/removal-file Done. SYSTEM LOCK ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/lock (write => none) @@ -2078,6 +2126,7 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-version-pin/. SYSTEM copydir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo/content -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/content +SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-file.main-repo.1 Processing 2/2: [main-repo: touch removal-file] + touch "removal-file" (CWD=${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1) FILE(.install) Cannot find ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/install/main-repo.install @@ -2097,9 +2146,11 @@ CACHE(installed) ${BASEDIR}/OPAM/install-from-version-pin/.opam-s SYSTEM LOCK ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache (write => none) SYSTEM rmdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/content +SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-file.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/removal-file SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache SYSTEM rmdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1 +SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1/opam Done. SYSTEM LOCK ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/lock (write => none) @@ -2204,6 +2255,7 @@ SYSTEM rmdir ${BASEDIR}/OPAM/package-switch/.opam-switc SYSTEM copydir ${BASEDIR}/OPAM/package-switch/.opam-switch/sources/main-repo.2 -> ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2 SYSTEM mkdir ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2 SYSTEM copy ${BASEDIR}/OPAM/package-switch/.opam-switch/sources/main-repo.2/content -> ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/content +SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 -> ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/x-file.main-repo.2 Processing 2/3: [main-repo: touch build-file] + touch "build-file" (CWD=${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2) -> compiled main-repo.2 @@ -2220,6 +2272,8 @@ FILE(.config) Cannot find ${BASEDIR}/OPAM/package-switch/.opam SYSTEM rm ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/cache SYSTEM mkdir ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/main-repo.2 FILE(opam) Wrote ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/main-repo.2/opam atomically in 0.000s +SYSTEM mkdir ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/main-repo.2/files +SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 -> ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/main-repo.2/files/x-file.main-repo.2 SYSTEM LOCK ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/cache (none => write) CACHE(installed) Writing the installed cache to ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/cache ... CACHE(installed) ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/cache written in 0.000s @@ -2433,10 +2487,12 @@ FILE(config) Wrote ${BASEDIR}/OPAM/config atomically in 0.000 SYSTEM rmdir ${BASEDIR}/OPAM/package-switch SYSTEM rm ${BASEDIR}/OPAM/package-switch/lib/main-repo/content SYSTEM rm ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/content +SYSTEM rm ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/x-file.main-repo.2 SYSTEM rm ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/build-file SYSTEM rm ${BASEDIR}/OPAM/package-switch/.opam-switch/install/main-repo.changes SYSTEM rm ${BASEDIR}/OPAM/package-switch/.opam-switch/lock SYSTEM rm ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/main-repo.2/opam +SYSTEM rm ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/main-repo.2/files/x-file.main-repo.2 SYSTEM rm ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/cache SYSTEM rm ${BASEDIR}/OPAM/package-switch/.opam-switch/switch-config SYSTEM rm ${BASEDIR}/OPAM/package-switch/.opam-switch/sources/main-repo.2/content From 7a504c0881b56cb6d315c19abaad4d562c8377a1 Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Thu, 9 Oct 2025 17:17:30 +0200 Subject: [PATCH 12/29] reftest: complete action-disk.test with the behaviour of extra-source --- master_changes.md | 1 + tests/reftests/action-disk.test | 55 +++++++++++++++++++++++++++------ 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/master_changes.md b/master_changes.md index 44721d8ea50..27d0bc1d744 100644 --- a/master_changes.md +++ b/master_changes.md @@ -156,6 +156,7 @@ users) * Fix `env.test` in cases where calling `env` inside of a script outputs a `__CF_USER_TEXT_ENCODING` environment variable that isn't present in `sh -c env` [#6719 @kit-ty-kate] * Add complete tests for the `pin-depends` feature [#6611 @rjbou] * Complete `action-disk.test` with the behaviour of `extra-files` [#6679 @rjbou] + * Complete `action-disk.test` with the behaviour of `extra-source` [#6679 @rjbou] ### Engine * Fix gcc < 14.3 bug on mingw i686 [#6624 @kit-ty-kate] diff --git a/tests/reftests/action-disk.test b/tests/reftests/action-disk.test index a7928e07acc..4bcbd5876a3 100644 --- a/tests/reftests/action-disk.test +++ b/tests/reftests/action-disk.test @@ -25,11 +25,16 @@ remove: [ "touch" "removal-file" ] I'm a file ### I'm an extra-file +### +I'm an extra-source ### tar czf archive.tgz content ### openssl md5 archive.tgz | '.*= ' -> '' >$ MD5 ### sh -c "echo '$MD5' | cut -c 1-2" >$ PRE_MD5 ### openssl md5 x-file | '.*= ' -> '' >$ XMD5 +### openssl md5 x-source | '.*= ' -> '' >$ XSMD5 +### sh -c "echo '$XSMD5' | cut -c 1-2" >$ PRE_XSMD5 ### +basedir=$(printf '%s' "$BASEDIR" | sed 's/\\/\\\\/g') for nv in "$@"; do arch=archive.tgz dir="REPO/packages/${nv%.*}/$nv" @@ -38,10 +43,14 @@ for nv in "$@"; do cp x-file "$dir/files/x-file.$nv" cat >> "$file" << EOF url { - src: "$arch" + src: "$basedir/$arch" checksum: "md5=$MD5" } extra-files: [ "x-file.$nv" "md5=$XMD5" ] +extra-source "x-source.$nv" { + src: "$basedir/x-source" + checksum: "md5=$XSMD5" +} EOF done ### sh add-url.sh main-repo.1 main-repo.2 @@ -169,7 +178,7 @@ SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (write => none) SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-switch/lock (write => none) SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => none) -### opam install main-repo.1 | grep -v '^- ./$' | sed-cmd rsync tar cp touch mkdir | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "md5[^[:alnum:]].?${PRE_MD5}" -> md5/pre +### opam install main-repo.1 | grep -v '^- ./$' | sed-cmd rsync tar cp touch mkdir | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "md5[^[:alnum:]].?${PRE_MD5}" -> md5/pre | "${PRE_XSMD5}[^[:alnum:]].?${XSMD5}" -> xspre/xshash | "md5[^[:alnum:]].?${PRE_XSMD5}" -> md5/prexs FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s @@ -212,11 +221,21 @@ SYSTEM rmdir ${OPAMTMP} SYSTEM rm ${OPAMTMP}/content SYSTEM rmdir ${OPAMTMP} SYSTEM rm ${OPAMTMP}/archive.tgz +SYSTEM mkdir ${OPAMTMP} +Processing 1/3: [main-repo.1/x-source.main-repo.1: dl] ++ rsync "-rLptgoDvc" "--exclude" ".git" "--exclude" "_darcs" "--exclude" ".hg" "--exclude" ".#*" "--exclude" "_opam*" "--exclude" "_build" "--delete" "--delete-excluded" "${BASEDIR}/x-source" "${OPAMTMP}" +- x-source +- +SYSTEM mkdir ${BASEDIR}/OPAM/download-cache/md5/prexs +SYSTEM copy ${OPAMTMP}/x-source -> ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash +SYSTEM rmdir ${OPAMTMP} +SYSTEM rm ${OPAMTMP}/x-source -> retrieved main-repo.1 (file://${BASEDIR}/archive.tgz) SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1 SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/content +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-source.main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-file.main-repo.1 Processing 2/3: [main-repo: touch build-file] + touch "build-file" (CWD=${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1) @@ -245,7 +264,7 @@ SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-swi SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/backup/state-today.export SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => none) -### opam reinstall main-repo.1 | sed-cmd tar cp touch mkdir | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | unordered +### opam reinstall main-repo.1 | sed-cmd tar cp touch mkdir | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "${PRE_XSMD5}[^[:alnum:]].?${XSMD5}" -> xspre/xshash | unordered FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s @@ -280,6 +299,10 @@ SYSTEM rm ${OPAMTMP}/content -> retrieved main-repo.1 (cached) SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/content +SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-source.main-repo.1 +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-source.main-repo.1 +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-source.main-repo.1 +SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-source.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-file.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/build-file SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1 @@ -336,7 +359,7 @@ SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-swi SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/backup/state-today.export SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => none) -### opam upgrade main-repo | sed-cmd tar touch mkdir cp | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | unordered +### opam upgrade main-repo | sed-cmd tar touch mkdir cp | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "${PRE_XSMD5}[^[:alnum:]].?${XSMD5}" -> xspre/xshash | unordered FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s @@ -382,6 +405,9 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-sw SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2/content +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2/x-source.main-repo.2 +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-source.main-repo.1 +SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-source.main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2/x-file.main-repo.2 Processing 2/4: [main-repo: touch build-file] + touch "build-file" (CWD=${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2) @@ -439,7 +465,7 @@ SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-swi SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/backup/state-today.export SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => none) -### opam remove main-repo | sed-cmd tar touch | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | unordered +### opam remove main-repo | sed-cmd tar touch | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "${PRE_XSMD5}[^[:alnum:]].?${XSMD5}" -> xspre/xshash | unordered FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s @@ -478,6 +504,8 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-sw SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/content +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/x-source.main-repo.2 +SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/x-source.main-repo.2 SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/x-file.main-repo.2 Processing 2/2: [main-repo: touch removal-file] + touch "removal-file" (CWD=${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2) @@ -1933,7 +1961,7 @@ SYSTEM LOCK ${BASEDIR}/OPAM/install-from-version-pin/.o SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/backup/state-today.export SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => none) -### opam install main-repo | grep -v '^- ./$' | sed-cmd tar rsync cp touch mkdir | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash +### opam install main-repo | grep -v '^- ./$' | sed-cmd tar rsync cp touch mkdir | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "${PRE_XSMD5}[^[:alnum:]].?${XSMD5}" -> xspre/xshash FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s @@ -1970,6 +1998,7 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-version-pin/. SYSTEM copydir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo/content -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/content +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-source.main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-file.main-repo.1 Processing 2/3: [main-repo: touch build-file] + touch "build-file" (CWD=${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1) @@ -1998,7 +2027,7 @@ SYSTEM LOCK ${BASEDIR}/OPAM/install-from-version-pin/.o SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/backup/state-today.export SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => none) -### opam reinstall main-repo | grep -v '^- ./$' | sed-cmd tar rsync cp touch mkdir | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | unordered +### opam reinstall main-repo | grep -v '^- ./$' | sed-cmd tar rsync cp touch mkdir | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "${PRE_XSMD5}[^[:alnum:]].?${XSMD5}" -> xspre/xshash | unordered FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s @@ -2033,6 +2062,10 @@ SYSTEM rm ${OPAMTMP}/content -> retrieved main-repo.1 (cached) SYSTEM rmdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/content +SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-source.main-repo.1 +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-source.main-repo.1 +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-source.main-repo.1 +SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-source.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-file.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/build-file SYSTEM copydir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1 @@ -2089,7 +2122,7 @@ SYSTEM LOCK ${BASEDIR}/OPAM/install-from-version-pin/.o SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/backup/state-today.export SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => none) -### opam remove main-repo | grep -v '^- ./$' | sed-cmd tar rsync touch | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | unordered +### opam remove main-repo | grep -v '^- ./$' | sed-cmd tar rsync touch | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "${PRE_XSMD5}[^[:alnum:]].?${XSMD5}" -> xspre/xshash | unordered FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s @@ -2126,6 +2159,8 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-version-pin/. SYSTEM copydir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo/content -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/content +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-source.main-repo.1 +SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-source.main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-file.main-repo.1 Processing 2/2: [main-repo: touch removal-file] + touch "removal-file" (CWD=${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1) @@ -2194,7 +2229,7 @@ Usage: opam switch [OPTION]… [COMMAND] [ARG]… Try 'opam switch --help' or 'opam --help' for more information. # Return code 2 # ### :III:2: with package -### opam switch create package-switch --package main-repo | grep -v '^- ./$' | sed-cmd rsync tar cp touch mkdir | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "md5[^[:alnum:]].?${PRE_MD5}" -> md5/pre +### opam switch create package-switch --package main-repo | grep -v '^- ./$' | sed-cmd rsync tar cp touch mkdir | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "md5[^[:alnum:]].?${PRE_MD5}" -> md5/pre | "${PRE_XSMD5}[^[:alnum:]].?${XSMD5}" -> xspre/xshash FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => write) @@ -2255,6 +2290,7 @@ SYSTEM rmdir ${BASEDIR}/OPAM/package-switch/.opam-switc SYSTEM copydir ${BASEDIR}/OPAM/package-switch/.opam-switch/sources/main-repo.2 -> ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2 SYSTEM mkdir ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2 SYSTEM copy ${BASEDIR}/OPAM/package-switch/.opam-switch/sources/main-repo.2/content -> ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/content +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/x-source.main-repo.2 SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 -> ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/x-file.main-repo.2 Processing 2/3: [main-repo: touch build-file] + touch "build-file" (CWD=${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2) @@ -2487,6 +2523,7 @@ FILE(config) Wrote ${BASEDIR}/OPAM/config atomically in 0.000 SYSTEM rmdir ${BASEDIR}/OPAM/package-switch SYSTEM rm ${BASEDIR}/OPAM/package-switch/lib/main-repo/content SYSTEM rm ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/content +SYSTEM rm ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/x-source.main-repo.2 SYSTEM rm ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/x-file.main-repo.2 SYSTEM rm ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/build-file SYSTEM rm ${BASEDIR}/OPAM/package-switch/.opam-switch/install/main-repo.changes From 1c71f5eb8b7885abdf67ca79c7d74b75cbfef44d Mon Sep 17 00:00:00 2001 From: Kate Date: Tue, 9 Sep 2025 10:43:25 +0100 Subject: [PATCH 13/29] OpamFile.OPAM API: No longer assume that internal opam repositories are directories Co-authored-by: Raja Boujbel --- master_changes.md | 7 ++++ src/client/opamAction.ml | 60 ++++++++++++++++--------------- src/client/opamCommands.ml | 51 +++++++++++++------------- src/client/opamPinCommand.ml | 51 +++++++++++++------------- src/client/opamSwitchCommand.ml | 15 ++++---- src/format/opamFile.ml | 39 +++++++++++--------- src/format/opamFile.mli | 14 +++----- src/state/opamFileTools.ml | 10 +++--- src/state/opamPinned.ml | 10 ++++-- src/state/opamPinned.mli | 3 +- src/state/opamRepositoryState.ml | 10 +++++- src/state/opamRepositoryState.mli | 7 ++++ src/state/opamSwitchAction.ml | 26 ++++++++------ src/state/opamSwitchState.ml | 10 ++++++ src/state/opamSwitchState.mli | 4 +++ src/state/opamUpdate.ml | 15 ++++---- tests/reftests/action-disk.test | 53 +++++++++++++++++---------- tests/reftests/dot-install.test | 18 ++++++---- tests/reftests/extrafile.test | 40 ++++++++++++--------- tests/reftests/update.test | 4 +-- 20 files changed, 265 insertions(+), 182 deletions(-) diff --git a/master_changes.md b/master_changes.md index 27d0bc1d744..07fe4466f2a 100644 --- a/master_changes.md +++ b/master_changes.md @@ -29,6 +29,7 @@ users) ## Install * More fine grained error message in case of bad hash or missing extra-files error (and remove raw fatal error) [#6696 @rjbou] + * Do not ignore extra-files whose name is invalid and fail early in that case [#6679 @rjbou @kit-ty-kate] ## Build (package) @@ -38,6 +39,7 @@ users) * Show the invalid character when detecting an erroneous package name [#6638 @lefessan - fix #6396] * Handle non-displayable characters when detecting an erroneous package name or version [#6640 @kit-ty-kate] * Remove duplicated directory separator when displaying some rare filenames [#6703 @rjbou] + * The name of missing or erroneous extra-files are not displayed instead of their path in error messages [#6679 @kit-ty-kate @rjbou] ## Switch @@ -64,6 +66,7 @@ users) ## Source * Better error message, especially in case of `Failure` [#6696 @rjbou] * Raise a warning instead of an error when an item of `extra-files` is missing [#6696 @rjbou] + * Do not ignore extra-files whose name is invalid and raise a warning in that case [#6679 @rjbou @kit-ty-kate] ## Lint @@ -208,11 +211,15 @@ users) ## opam-state * `OpamSwitchState.files`: was removed [#6662 @kit-ty-kate] + * `OpamSwitchState.overlay_opam_file`: was added [6679 @rjbou] * `OpamRepositoryState` add `load_opams_from_diff` to update package definitions based on file change operations (diff) [#6614 @arozovyk] + * `OpamRepositoryState.get_repo_files`: was added [#6679 @kit-ty-kate @rjbou] ## opam-solver ## opam-format + * `OpamFile.OPAM.get_metadata_dir`: was removed [#6679 @kit-ty-kate] + * `OpamFile.OPAM.get_extra_files`: no longer takes a named `repos_roots` argument and instead takes a named `get_repo_files` argument. It also now returns the content of the files instead of their path [#6679 @kit-ty-kate @rjbou] * `OpamFormula.equal_relop`: was added [#6644 @kit-ty-kate] * `OpamTypesBase.{action,pkg_flag,simple_arg,arg,filter,command}_equal`: were added [#6644 @kit-ty-kate] * `OpamVariable.variable_contents_equal`: was added [#6644 @kit-ty-kate] diff --git a/src/client/opamAction.ml b/src/client/opamAction.ml index d171ec6ff4b..86bb9dfc4a2 100644 --- a/src/client/opamAction.ml +++ b/src/client/opamAction.ml @@ -476,49 +476,51 @@ let prepare_package_source st nv dir = let extra_files = let extra_files = OpamFile.OPAM.get_extra_files - ~repos_roots:(OpamRepositoryState.get_root st.switch_repos) + ~get_repo_files:(OpamRepositoryState.get_repo_files st.switch_repos) opam in if extra_files <> [] then extra_files else - match OpamFile.OPAM.extra_files opam with - | None -> [] - | Some xs -> - (* lookup in switch-local hashmap overlay *) - let extra_files_dir = - OpamPath.Switch.extra_files_dir st.switch_global.root st.switch - in - List.filter_map (fun (base, hash) -> - let src = - OpamFilename.create extra_files_dir - (OpamFilename.Base.of_string (OpamHash.contents hash)) - in - if OpamFilename.exists src then - Some (src, base, hash) - else None) - xs + match OpamFile.OPAM.extra_files opam with + | None -> [] + | Some xs -> + (* lookup in switch-local hashmap overlay *) + let extra_files_dir = + OpamPath.Switch.extra_files_dir st.switch_global.root st.switch + in + List.map (fun (base, hash) -> + let content = + let src = + OpamFilename.create extra_files_dir + (OpamFilename.Base.of_string (OpamHash.contents hash)) + in + if OpamFilename.exists src then + Some (lazy (OpamFilename.read src)) + else + None + in + (base, content, hash)) + xs in let bad_hash, missing = - List.fold_left (fun (bad_hash, missing) (src, base, hash) -> - if OpamFilename.exists src then - let file = OpamFilename.to_string src in - if OpamHash.check_file file hash then - (OpamFilename.copy ~src ~dst:(OpamFilename.create dir base); - bad_hash, missing) - else - (src::bad_hash), missing - else - bad_hash, (src::missing)) + List.fold_left (fun (bad_hash, missing) (base, content, hash) -> + match content with + | None -> bad_hash, (base::missing) + | Some (lazy content) when OpamHash.check_string content hash -> + OpamFilename.write (OpamFilename.create dir base) content; + bad_hash, missing + | Some _ -> + (base::bad_hash), missing) ([], []) extra_files in let bad_hash_msg bad_hash = Printf.sprintf "%s: Bad hash for extra-file\n%s" (OpamPackage.to_string nv) - (OpamStd.Format.itemize OpamFilename.to_string bad_hash) + (OpamStd.Format.itemize OpamFilename.Base.to_string bad_hash) in let missing_msg missing = Printf.sprintf "%s: Missing extra-file for\n%s" (OpamPackage.to_string nv) - (OpamStd.Format.itemize OpamFilename.to_string missing) + (OpamStd.Format.itemize OpamFilename.Base.to_string missing) in match bad_hash, missing with | [], [] -> None diff --git a/src/client/opamCommands.ml b/src/client/opamCommands.ml index aff2bb5c213..e62784cfaec 100644 --- a/src/client/opamCommands.ml +++ b/src/client/opamCommands.ml @@ -3963,32 +3963,33 @@ let lint cli = (OpamGlobalState.with_ `Lock_none @@ fun gt -> OpamSwitchState.with_ `Lock_none gt @@ fun st -> try - let nv = match pkg with - | name, Some v -> OpamPackage.create name v - | name, None -> OpamSwitchState.get_package st name + let name, nv = match pkg with + | name, Some v -> name, OpamPackage.create name v + | name, None -> name, OpamSwitchState.get_package st name in - let opam = OpamSwitchState.opam st nv in - match OpamPinned.orig_opam_file st (OpamPackage.name nv) opam with - | None -> raise Not_found - | Some file -> - let label = - match OpamFile.OPAM.metadata_dir opam with - | None -> None - | Some (None, abs) -> - let filename = - if OpamFilename.starts_with - (OpamPath.Switch.Overlay.dir gt.root st.switch) - (OpamFilename.of_string abs) then - Printf.sprintf "/%s" (OpamPackage.to_string nv) - else abs + if OpamSwitchState.is_pinned st name then + match OpamSwitchState.overlay_opam_file st name with + | Some file -> + let label = + Printf.sprintf "/%s" (OpamPackage.to_string nv) + in + [`pkg (file, label)] + | None -> raise Not_found + else + let opam = OpamSwitchState.opam st nv in + match OpamPinned.orig_opam_file st (OpamPackage.name nv) opam with + | None -> raise Not_found + | Some file -> + let label = + let reponame = + match OpamFile.OPAM.metadata_dir opam with + | None | Some (None, _) -> "repo" + | Some (Some repo, _) -> OpamRepositoryName.to_string repo in - Some filename - | Some (Some repo, _rel) -> - Some (Printf.sprintf "<%s>/%s" - (OpamRepositoryName.to_string repo) - (OpamPackage.to_string nv)) - in - [`pkg (file, label)] + Printf.sprintf "<%s>/%s" + reponame (OpamPackage.to_string nv) + in + [`pkg (file, label)] with Not_found -> OpamConsole.error_and_exit `Not_found "No opam file found for %s%s" (OpamPackage.Name.to_string (fst pkg)) @@ -4021,7 +4022,7 @@ let lint cli = | `pkg (file, label) -> OpamFileTools.lint_file ~check_upstream ~handle_dirname:false file, - label + Some label | `stdin -> OpamFileTools.lint_channel ~check_upstream ~handle_dirname:false stdin_f stdin, diff --git a/src/client/opamPinCommand.ml b/src/client/opamPinCommand.ml index 6d26477b955..4b43a9a6a3d 100644 --- a/src/client/opamPinCommand.ml +++ b/src/client/opamPinCommand.ml @@ -102,7 +102,7 @@ let copy_files st opam = let name = OpamFile.OPAM.name opam in let files = OpamFile.OPAM.get_extra_files - ~repos_roots:(OpamRepositoryState.get_root st.switch_repos) + ~get_repo_files:(OpamRepositoryState.get_repo_files st.switch_repos) opam in if files = [] then @@ -118,30 +118,31 @@ let copy_files st opam = OpamPath.Switch.Overlay.files st.switch_global.root st.switch name in let files = - List.fold_left (fun acc (src, rel_file, hash) -> - if not (OpamFilename.exists src) then - (OpamConsole.warning "Overlay file of %s %s not found, ignoring" - (OpamPackage.Name.to_string name) - (OpamFilename.to_string src); - acc) - else - let hash = - if not (OpamHash.check_file (OpamFilename.to_string src) hash) then - if OpamFormatConfig.(!r.strict) then - OpamConsole.error_and_exit `File_error - "Hash mismatch on %s %s (strict mode)" - (OpamPackage.Name.to_string name) - (OpamFilename.to_string src) - else - (OpamConsole.warning - "Hash doesn't match for overlay file of %s %s, adjusted" - (OpamPackage.Name.to_string name) - (OpamFilename.to_string src); - OpamHash.compute (OpamFilename.to_string src)) - else hash - in - OpamFilename.copy ~src ~dst:(OpamFilename.create destdir rel_file); - (rel_file, hash) :: acc) + List.fold_left (fun acc (rel_file, content, hash) -> + match content with + | None -> + OpamConsole.warning "Overlay file of %s %s not found, ignoring" + (OpamPackage.Name.to_string name) + (OpamFilename.Base.to_string rel_file); + acc + | Some (lazy content) -> + let hash = + if not (OpamHash.check_string content hash) then + if OpamFormatConfig.(!r.strict) then + OpamConsole.error_and_exit `File_error + "Hash mismatch on %s %s (strict mode)" + (OpamPackage.Name.to_string name) + (OpamFilename.Base.to_string rel_file) + else + (OpamConsole.warning + "Hash doesn't match for overlay file of %s %s, adjusted" + (OpamPackage.Name.to_string name) + (OpamFilename.Base.to_string rel_file); + OpamHash.compute_from_string content) + else hash + in + OpamFilename.write (OpamFilename.create destdir rel_file) content; + (rel_file, hash) :: acc) [] files in OpamFile.OPAM.with_extra_files (List.rev files) opam diff --git a/src/client/opamSwitchCommand.ml b/src/client/opamSwitchCommand.ml index 2720fb4ce21..1c07900642e 100644 --- a/src/client/opamSwitchCommand.ml +++ b/src/client/opamSwitchCommand.ml @@ -627,18 +627,19 @@ let export rt ?(freeze=false) ?(full=false) opams OpamPackage.Name.Map.empty in let extra_files = - let repos_roots = OpamRepositoryState.get_root rt in + let get_repo_files = OpamRepositoryState.get_repo_files rt in OpamPackage.Map.fold (fun nv opam hmap -> - match OpamFile.OPAM.get_extra_files ~repos_roots opam with + match OpamFile.OPAM.get_extra_files ~get_repo_files opam with | [] -> hmap | files -> let hmap, err = - List.fold_left (fun (hmap,err) (file, base, hash) -> - if OpamFilename.exists file && - OpamHash.check_file (OpamFilename.to_string file) hash then - let value = Base64.encode_string ~pad:false (OpamFilename.read file) in + List.fold_left (fun (hmap,err) (base, content, hash) -> + match content with + | Some (lazy content) when + OpamHash.check_string content hash -> + let value = Base64.encode_string ~pad:false content in OpamHash.Map.add hash value hmap, err - else hmap, base::err) + | None | Some _ -> hmap, base::err) (hmap,[]) files in if err <> [] then diff --git a/src/format/opamFile.ml b/src/format/opamFile.ml index 9d26b587976..6de4b06d252 100644 --- a/src/format/opamFile.ml +++ b/src/format/opamFile.ml @@ -3553,23 +3553,30 @@ module OPAM = struct let equal o1 o2 = with_metadata_dir None o1 = with_metadata_dir None o2 - let get_metadata_dir ~repos_roots o = - match metadata_dir o with - | None -> None - | Some (None, abs) -> - Some (OpamFilename.Dir.of_string abs) - | Some (Some r, rel) -> - Some OpamFilename.Op.(repos_roots r / rel) - - let get_extra_files ~repos_roots o = - OpamStd.Option.Op.( - (get_metadata_dir ~repos_roots o >>= fun mdir -> - let files_dir = OpamFilename.Op.(mdir / "files") in + let get_extra_files ~get_repo_files o = + let open OpamFilename.Op in + let open OpamStd.Option.Op in + (match metadata_dir o with + | None -> None + | Some (None, abs) -> + let files_dir = OpamFilename.Dir.of_string abs / "files" in extra_files o >>| List.map @@ fun (basename, hash) -> - OpamFilename.create files_dir basename, - basename, hash) - +! [] - ) + let content = + let f = OpamFilename.create files_dir basename in + if OpamFilename.exists f then + Some (lazy (OpamFilename.read f)) + else + None + in + (basename, content, hash) + | Some (Some r, rel) -> + let files = get_repo_files r (rel ^ Filename.dir_sep ^ "files") in + extra_files o >>| List.map @@ fun (basename, hash) -> + let content = + OpamStd.List.assoc_opt OpamFilename.Base.equal basename files + in + (basename, content, hash)) + +! [] let print_errors ?file o = if o.format_errors <> [] then diff --git a/src/format/opamFile.mli b/src/format/opamFile.mli index ffb6aa28ff2..51dadd0fee5 100644 --- a/src/format/opamFile.mli +++ b/src/format/opamFile.mli @@ -585,22 +585,18 @@ module OPAM: sig This can be used to locate e.g. the files/ overlays *) val metadata_dir: t -> (repository_name option * string) option - (** Gets the resolved metadata dir, given a mapping of repository names to - their roots *) - val get_metadata_dir: - repos_roots:(repository_name -> dirname) -> t -> dirname option - (** Names and hashes of the files below files/ *) val extra_files: t -> (OpamFilename.Base.t * OpamHash.t) list option (** From locked opam file *) val locked: t -> string option - (** Looks up the extra files, and returns their full paths, relative path to - the package source, and hash. Doesn't check the hashes. *) + (** Looks up the extra files, and returns their relative path to + the package source, content if it exists and hash. + Doesn't check the hashes. *) val get_extra_files: - repos_roots:(repository_name -> dirname) -> - t -> (filename * basename * OpamHash.t) list + get_repo_files:(repository_name -> string -> (basename * string Lazy.t) list) -> + t -> (basename * string Lazy.t option * OpamHash.t) list (** Returns the errors that were found when parsing the file, associated to their fields (that were consequently ignored) *) diff --git a/src/state/opamFileTools.ml b/src/state/opamFileTools.ml index 8038f1f1d33..4349f5ca3e3 100644 --- a/src/state/opamFileTools.ml +++ b/src/state/opamFileTools.ml @@ -1310,10 +1310,12 @@ let try_read rd f = let add_aux_files ?dir ?(files_subdir_hashes=false) opam = let dir = match dir with | None -> - OpamFile.OPAM.get_metadata_dir ~repos_roots:(fun r -> - failwith ("Repository "^OpamRepositoryName.to_string r^ - " not registered for add_aux_files!")) - opam + (match OpamFile.OPAM.metadata_dir opam with + | None -> None + | Some (None, dir) -> Some (OpamFilename.Dir.of_string dir) + | Some (Some r, _) -> + failwith ("Repository "^OpamRepositoryName.to_string r^ + " not registered for add_aux_files!")) | some -> some in match dir with diff --git a/src/state/opamPinned.ml b/src/state/opamPinned.ml index 50343442165..2476f4ca277 100644 --- a/src/state/opamPinned.ml +++ b/src/state/opamPinned.ml @@ -277,9 +277,13 @@ let files_in_source_w_target ?locked ?recurse ?subpath (files_in_source ?locked ?recurse ?subpath dir) let orig_opam_file st name opam = - OpamFile.OPAM.get_metadata_dir - ~repos_roots:(OpamRepositoryState.get_root st.switch_repos) - opam >>= fun dir -> + (match OpamFile.OPAM.metadata_dir opam with + | None -> None + | Some (None, abs) -> + Some (OpamFilename.Dir.of_string abs) + | Some (Some r, rel) -> + Some (OpamRepositoryState.get_root st.switch_repos r / rel)) + >>= fun dir -> let opam_files = [ dir // (OpamPackage.Name.to_string name ^ ".opam"); dir // "opam" diff --git a/src/state/opamPinned.mli b/src/state/opamPinned.mli index 06d0649697b..c83687285dd 100644 --- a/src/state/opamPinned.mli +++ b/src/state/opamPinned.mli @@ -59,7 +59,8 @@ val files_in_source_w_target: val name_of_opam_filename: ?locked:string -> dirname -> filename -> name option (** Finds back the location of the opam file this package definition was loaded - from *) + from. As it read from repository, use this function if you need to preserve + format, otherwise prefer {OpamSwitchState.overlay_opam_file}. *) val orig_opam_file: 'a switch_state -> OpamPackage.Name.t -> OpamFile.OPAM.t -> OpamFile.OPAM.t OpamFile.t option diff --git a/src/state/opamRepositoryState.ml b/src/state/opamRepositoryState.ml index 95edd692f7d..f979e49d999 100644 --- a/src/state/opamRepositoryState.ml +++ b/src/state/opamRepositoryState.ml @@ -87,6 +87,15 @@ let get_root rt name = let get_repo_root rt repo = get_root_raw rt.repos_global.root rt.repos_tmp repo.repo_name +let get_repo_files rt name dir = + let dir = OpamFilename.Op.(get_root rt name / dir) in + let files = OpamFilename.rec_files dir in + List.map (fun file -> + OpamFilename.Base.of_string + (OpamSystem.back_to_forward (OpamFilename.remove_prefix dir file)), + lazy (OpamFilename.read file)) + files + let read_package_opam ~repo_name ~repo_root package_dir = match OpamFileTools.read_repo_opam ~repo_name ~repo_root package_dir with | Some opam -> @@ -220,7 +229,6 @@ let remove_from_repos_tmp rt name = let cleanup rt = Hashtbl.iter (fun _ tmp_dir -> clean_repo_tmp tmp_dir) rt.repos_tmp; Hashtbl.clear rt.repos_tmp - let load lock_kind gt = log "LOAD-REPOSITORY-STATE %@ %a" (slog OpamFilename.Dir.to_string) gt.root; let lock = OpamFilename.flock lock_kind (OpamPath.repos_lock gt.root) in diff --git a/src/state/opamRepositoryState.mli b/src/state/opamRepositoryState.mli index c9bfdddfee0..a6f077d765d 100644 --- a/src/state/opamRepositoryState.mli +++ b/src/state/opamRepositoryState.mli @@ -78,6 +78,13 @@ val get_root: 'a repos_state -> repository_name -> OpamFilename.Dir.t (** Same as {!get_root}, but with a repository rather than just a name as argument *) val get_repo_root: 'a repos_state -> repository -> OpamFilename.Dir.t +(** [get_repo_files rt name dir] Returns files in repository root of repository + [name] from subdirectory [dir]. The returned list contains the basenames of + files, and the content of each file lazily. It is intended to be used with + {OpamFile.get_extra_files} to retrieve `files/` files. *) +val get_repo_files: + 'a repos_state -> repository_name -> string -> (basename * string Lazy.t) list + (* (\** Runs the given function with access to a (possibly temporary) directory * containing the extracted structure of the given repository, and cleans it up * afterwards if temporary. The basename of the directory is guaranteed to diff --git a/src/state/opamSwitchAction.ml b/src/state/opamSwitchAction.ml index cdc6228cda0..4de422f6eab 100644 --- a/src/state/opamSwitchAction.ml +++ b/src/state/opamSwitchAction.ml @@ -146,17 +146,23 @@ let install_metadata st nv = OpamFile.OPAM.write (OpamPath.Switch.installed_opam st.switch_global.root st.switch nv) opam; - List.iter (fun (f, rel_path, _hash) -> - let dst = - OpamFilename.create - (OpamPath.Switch.installed_opam_files_dir - st.switch_global.root st.switch nv) - rel_path - in - OpamFilename.mkdir (OpamFilename.dirname dst); - OpamFilename.copy ~src:f ~dst) + List.iter (fun (rel_path, content, _hash) -> + match content with + | None -> + log "%s: error installing extra files, empty content for %s" + (OpamPackage.to_string nv) + (OpamFilename.Base.to_string rel_path) + | Some content -> + let dst = + OpamFilename.create + (OpamPath.Switch.installed_opam_files_dir + st.switch_global.root st.switch nv) + rel_path + in + OpamFilename.mkdir (OpamFilename.dirname dst); + OpamFilename.write dst (Lazy.force content)) (OpamFile.OPAM.get_extra_files - ~repos_roots:(OpamRepositoryState.get_root st.switch_repos) + ~get_repo_files:(OpamRepositoryState.get_repo_files st.switch_repos) opam) let remove_metadata st packages = diff --git a/src/state/opamSwitchState.ml b/src/state/opamSwitchState.ml index 6df32f2e103..f17a76eec77 100644 --- a/src/state/opamSwitchState.ml +++ b/src/state/opamSwitchState.ml @@ -769,6 +769,16 @@ let source_dir st nv = then OpamPath.Switch.pinned_package st.switch_global.root st.switch nv.name else OpamPath.Switch.sources st.switch_global.root st.switch nv +let overlay_opam_file st name = + if is_pinned st name then + let file = + OpamPath.Switch.Overlay.opam st.switch_global.root st.switch name + in + if OpamFile.exists file then + Some file + else None + else None + let depexts st nv = let env v = OpamPackageVar.resolve_switch ~package:nv st v in depexts_raw ~env nv st.opams diff --git a/src/state/opamSwitchState.mli b/src/state/opamSwitchState.mli index 26a90fc31e3..3109e536387 100644 --- a/src/state/opamSwitchState.mli +++ b/src/state/opamSwitchState.mli @@ -155,6 +155,10 @@ val dev_packages: 'a switch_state -> package_set on wether it's pinned). *) val source_dir: 'a switch_state -> package -> dirname +(** Returns the opam file overlay stored internally for pinned packages *) +val overlay_opam_file: + 'a switch_state -> OpamPackage.Name.t -> OpamFile.OPAM.t OpamFile.t option + (** Returns the set of active external dependencies for the package, computed from the values of the system-specific variables *) val depexts: 'a switch_state -> package -> OpamSysPkg.Set.t diff --git a/src/state/opamUpdate.ml b/src/state/opamUpdate.ml index 9123073e835..43efdd590e1 100644 --- a/src/state/opamUpdate.ml +++ b/src/state/opamUpdate.ml @@ -351,16 +351,15 @@ let pinned_package st ?version ?(autolock=false) ?(working_dir=false) name = then OpamFile.OPAM.with_version version opam else opam in - List.iter (fun (file, rel_file, hash) -> - if OpamFilename.exists file && - OpamHash.check_file (OpamFilename.to_string file) hash then - OpamFilename.copy ~src:file - ~dst:(OpamFilename.create files_dir rel_file) - else + List.iter (fun (rel_file, content, hash) -> + match content with + | Some (lazy content) when OpamHash.check_string content hash -> + OpamFilename.write (OpamFilename.create files_dir rel_file) content + | None | Some _ -> OpamConsole.warning "Ignoring file %s with invalid hash" - (OpamFilename.to_string file)) + (OpamFilename.Base.to_string rel_file)) (OpamFile.OPAM.get_extra_files - ~repos_roots:(OpamRepositoryState.get_root st.switch_repos) + ~get_repo_files:(OpamRepositoryState.get_repo_files st.switch_repos) opam); OpamFile.OPAM.write opam_file (OpamFile.OPAM.with_extra_files_opt None opam); diff --git a/tests/reftests/action-disk.test b/tests/reftests/action-disk.test index 4bcbd5876a3..943f50991dd 100644 --- a/tests/reftests/action-disk.test +++ b/tests/reftests/action-disk.test @@ -236,7 +236,8 @@ SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam- SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/content SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-source.main-repo.1 -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-file.main-repo.1 +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 +SYSTEM write ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-file.main-repo.1 Processing 2/3: [main-repo: touch build-file] + touch "build-file" (CWD=${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1) -> compiled main-repo.1 @@ -254,7 +255,8 @@ SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switc SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1 FILE(opam) Wrote ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1/opam atomically in 0.000s SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1/files -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 +SYSTEM write ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache (none => write) CACHE(installed) Writing the installed cache to ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache ... CACHE(installed) ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache written in 0.000s @@ -301,14 +303,19 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-sw SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/content SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-source.main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-source.main-repo.1 +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 +SYSTEM write ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-file.main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-source.main-repo.1 +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 +SYSTEM write ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-file.main-repo.1 +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 +SYSTEM write ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-source.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-file.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/build-file SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/content -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-file.main-repo.1 Processing 2/4: [main-repo: touch build-file] + touch "build-file" (CWD=${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1) -> compiled main-repo.1 @@ -317,7 +324,6 @@ SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam- SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/content -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-file.main-repo.1 Processing 3/4: [main-repo: touch removal-file] + touch "removal-file" (CWD=${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1) FILE(.install) Cannot find ${BASEDIR}/OPAM/install-from-repo/.opam-switch/install/main-repo.install @@ -343,8 +349,6 @@ FILE(environment) Wrote ${BASEDIR}/OPAM/install-from-repo/.opam-sw FILE(.config) Cannot find ${BASEDIR}/OPAM/install-from-repo/.opam-switch/config/main-repo.config SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache FILE(opam) Wrote ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1/opam atomically in 0.000s -SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache (none => write) CACHE(installed) Writing the installed cache to ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache ... CACHE(installed) ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache written in 0.000s @@ -406,9 +410,14 @@ SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam- SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2/content SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2/x-source.main-repo.2 +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 +SYSTEM write ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2/x-file.main-repo.2 SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-source.main-repo.1 +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 +SYSTEM write ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-file.main-repo.1 +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 +SYSTEM write ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.2/files/x-file.main-repo.2 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-source.main-repo.1 -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2/x-file.main-repo.2 Processing 2/4: [main-repo: touch build-file] + touch "build-file" (CWD=${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2) -> compiled main-repo.2 @@ -416,7 +425,6 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-sw SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/content -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-file.main-repo.1 Processing 3/4: [main-repo: touch removal-file] + touch "removal-file" (CWD=${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1) FILE(.install) Cannot find ${BASEDIR}/OPAM/install-from-repo/.opam-switch/install/main-repo.install @@ -444,7 +452,6 @@ SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switc SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.2 FILE(opam) Wrote ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.2/opam atomically in 0.000s SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.2/files -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/main-repo.2/files/x-file.main-repo.2 SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache (none => write) CACHE(installed) Writing the installed cache to ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache ... CACHE(installed) ${BASEDIR}/OPAM/install-from-repo/.opam-switch/packages/cache written in 0.000s @@ -505,8 +512,9 @@ SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam- SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/content SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/x-source.main-repo.2 +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 +SYSTEM write ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/x-file.main-repo.2 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/x-source.main-repo.2 -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/x-file.main-repo.2 Processing 2/2: [main-repo: touch removal-file] + touch "removal-file" (CWD=${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2) FILE(.install) Cannot find ${BASEDIR}/OPAM/install-from-repo/.opam-switch/install/main-repo.install @@ -1999,7 +2007,8 @@ SYSTEM copydir ${BASEDIR}/OPAM/install-from-version-pin SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo/content -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/content SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-source.main-repo.1 -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-file.main-repo.1 +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 +SYSTEM write ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-file.main-repo.1 Processing 2/3: [main-repo: touch build-file] + touch "build-file" (CWD=${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1) -> compiled main-repo.1 @@ -2017,7 +2026,8 @@ SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opa SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1 FILE(opam) Wrote ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1/opam atomically in 0.000s SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1/files -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 +SYSTEM write ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 SYSTEM LOCK ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache (none => write) CACHE(installed) Writing the installed cache to ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache ... CACHE(installed) ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache written in 0.000s @@ -2064,14 +2074,19 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-version-pin/. SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/content SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-source.main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-source.main-repo.1 +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 +SYSTEM write ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-file.main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-source.main-repo.1 +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 +SYSTEM write ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-file.main-repo.1 +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 +SYSTEM write ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-source.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-file.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/build-file SYSTEM copydir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo/content -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/content -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-file.main-repo.1 Processing 2/4: [main-repo: touch build-file] + touch "build-file" (CWD=${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1) -> compiled main-repo.1 @@ -2080,7 +2095,6 @@ SYSTEM copydir ${BASEDIR}/OPAM/install-from-version-pin SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo/content -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/content -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-file.main-repo.1 Processing 3/4: [main-repo: touch removal-file] + touch "removal-file" (CWD=${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1) FILE(.install) Cannot find ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/install/main-repo.install @@ -2106,8 +2120,6 @@ FILE(environment) Wrote ${BASEDIR}/OPAM/install-from-version-pin/. FILE(.config) Cannot find ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/config/main-repo.config SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache FILE(opam) Wrote ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1/opam atomically in 0.000s -SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/main-repo.1/files/x-file.main-repo.1 SYSTEM LOCK ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache (none => write) CACHE(installed) Writing the installed cache to ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache ... CACHE(installed) ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/packages/cache written in 0.000s @@ -2160,8 +2172,9 @@ SYSTEM copydir ${BASEDIR}/OPAM/install-from-version-pin SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo/content -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/content SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-source.main-repo.1 +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 +SYSTEM write ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-file.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-source.main-repo.1 -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-file.main-repo.1 Processing 2/2: [main-repo: touch removal-file] + touch "removal-file" (CWD=${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1) FILE(.install) Cannot find ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/install/main-repo.install @@ -2291,7 +2304,8 @@ SYSTEM copydir ${BASEDIR}/OPAM/package-switch/.opam-swi SYSTEM mkdir ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2 SYSTEM copy ${BASEDIR}/OPAM/package-switch/.opam-switch/sources/main-repo.2/content -> ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/content SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/x-source.main-repo.2 -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 -> ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/x-file.main-repo.2 +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 +SYSTEM write ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/x-file.main-repo.2 Processing 2/3: [main-repo: touch build-file] + touch "build-file" (CWD=${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2) -> compiled main-repo.2 @@ -2309,7 +2323,8 @@ SYSTEM rm ${BASEDIR}/OPAM/package-switch/.opam-switch/p SYSTEM mkdir ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/main-repo.2 FILE(opam) Wrote ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/main-repo.2/opam atomically in 0.000s SYSTEM mkdir ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/main-repo.2/files -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 -> ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/main-repo.2/files/x-file.main-repo.2 +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 +SYSTEM write ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/main-repo.2/files/x-file.main-repo.2 SYSTEM LOCK ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/cache (none => write) CACHE(installed) Writing the installed cache to ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/cache ... CACHE(installed) ${BASEDIR}/OPAM/package-switch/.opam-switch/packages/cache written in 0.000s diff --git a/tests/reftests/dot-install.test b/tests/reftests/dot-install.test index 95195929381..303c418c8c5 100644 --- a/tests/reftests/dot-install.test +++ b/tests/reftests/dot-install.test @@ -211,7 +211,8 @@ FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s === install 1 package - install lot-of-files ~dev SYSTEM mkdir ${BASEDIR}/OPAM/inst/.opam-switch/build/lot-of-files.~dev -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/lot-of-files/lot-of-files.~dev/files/lot-of-files.install.in -> ${BASEDIR}/OPAM/inst/.opam-switch/build/lot-of-files.~dev/lot-of-files.install.in +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/lot-of-files/lot-of-files.~dev/files/lot-of-files.install.in +SYSTEM write ${BASEDIR}/OPAM/inst/.opam-switch/build/lot-of-files.~dev/lot-of-files.install.in FILE(.config) Read ${BASEDIR}/OPAM/inst/.opam-switch/build/lot-of-files.~dev/lot-of-files.config in 0.000s FILE(.config) Wrote ${BASEDIR}/OPAM/inst/.opam-switch/config/lot-of-files.config atomically in 0.000s SYSTEM install ${BASEDIR}/OPAM/inst/.opam-switch/build/lot-of-files.~dev/fichier -> ${BASEDIR}/OPAM/inst/bin/fichier (755) @@ -231,7 +232,8 @@ SYSTEM install ${BASEDIR}/OPAM/inst/.opam-switch/build/ FILE(.config) Read ${BASEDIR}/OPAM/inst/.opam-switch/config/lot-of-files.config in 0.000s SYSTEM mkdir ${BASEDIR}/OPAM/inst/.opam-switch/packages/lot-of-files.~dev SYSTEM mkdir ${BASEDIR}/OPAM/inst/.opam-switch/packages/lot-of-files.~dev/files -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/lot-of-files/lot-of-files.~dev/files/lot-of-files.install.in -> ${BASEDIR}/OPAM/inst/.opam-switch/packages/lot-of-files.~dev/files/lot-of-files.install.in +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/lot-of-files/lot-of-files.~dev/files/lot-of-files.install.in +SYSTEM write ${BASEDIR}/OPAM/inst/.opam-switch/packages/lot-of-files.~dev/files/lot-of-files.install.in ### : Removal of non specified directories in .install : ### opam switch create rem-dir --empty --debug-level=0 ### mkdir -p OPAM/rem-dir/lib/shared @@ -263,8 +265,10 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> SYSTEM rmdir ${BASEDIR}/OPAM/rem-dir/.opam-switch/build/no-specified-dir.1 SYSTEM mkdir ${BASEDIR}/OPAM/rem-dir/.opam-switch/build/no-specified-dir.1 -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/no-specified-dir/no-specified-dir.1/files/no-specified-dir.install -> ${BASEDIR}/OPAM/rem-dir/.opam-switch/build/no-specified-dir.1/no-specified-dir.install -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/no-specified-dir/no-specified-dir.1/files/a-file -> ${BASEDIR}/OPAM/rem-dir/.opam-switch/build/no-specified-dir.1/a-file +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/no-specified-dir/no-specified-dir.1/files/no-specified-dir.install +SYSTEM write ${BASEDIR}/OPAM/rem-dir/.opam-switch/build/no-specified-dir.1/no-specified-dir.install +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/no-specified-dir/no-specified-dir.1/files/a-file +SYSTEM write ${BASEDIR}/OPAM/rem-dir/.opam-switch/build/no-specified-dir.1/a-file TRACK before install: 2 elements scanned in 0.000s SYSTEM mkdir ${BASEDIR}/OPAM/rem-dir/lib/another SYSTEM mkdir ${BASEDIR}/OPAM/rem-dir/lib/another/somedir @@ -278,8 +282,10 @@ TRACK after install: 9 elements, 7 added, scanned in 0 SYSTEM rm ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/cache SYSTEM mkdir ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/no-specified-dir.1 SYSTEM mkdir ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/no-specified-dir.1/files -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/no-specified-dir/no-specified-dir.1/files/no-specified-dir.install -> ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/no-specified-dir.1/files/no-specified-dir.install -SYSTEM copy ${BASEDIR}/OPAM/repo/default/packages/no-specified-dir/no-specified-dir.1/files/a-file -> ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/no-specified-dir.1/files/a-file +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/no-specified-dir/no-specified-dir.1/files/no-specified-dir.install +SYSTEM write ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/no-specified-dir.1/files/no-specified-dir.install +SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/no-specified-dir/no-specified-dir.1/files/a-file +SYSTEM write ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/no-specified-dir.1/files/a-file SYSTEM LOCK ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/cache (none => write) SYSTEM LOCK ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/cache (write => none) Done. diff --git a/tests/reftests/extrafile.test b/tests/reftests/extrafile.test index d78fef8ff8e..7114bcfee35 100644 --- a/tests/reftests/extrafile.test +++ b/tests/reftests/extrafile.test @@ -261,7 +261,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> bad-md5.1: Bad hash for extra-file - - ${BASEDIR}/OPAM/repo/default/packages/bad-md5/bad-md5.1/files/p.patch + - p.patch @@ -279,7 +279,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> bad-md5.1: Bad hash for extra-file - - ${BASEDIR}/OPAM/repo/default/packages/bad-md5/bad-md5.1/files/p.patch + - p.patch @@ -292,7 +292,7 @@ bad-md5.1: Bad hash for extra-file ### opam source bad-md5 | '.n"' -> '"' [WARNING] Some errors extracting to ${BASEDIR}/bad-md5.1: bad-md5.1: Bad hash for extra-file - - ${BASEDIR}/OPAM/repo/default/packages/bad-md5/bad-md5.1/files/p.patch + - p.patch ### test -f bad-md5.1/p.patch @@ -301,7 +301,7 @@ bad-md5.1: Bad hash for extra-file ### opam source bad-md5 --require-checksums | '.n"' -> '"' [WARNING] Some errors extracting to ${BASEDIR}/bad-md5.1: bad-md5.1: Bad hash for extra-file - - ${BASEDIR}/OPAM/repo/default/packages/bad-md5/bad-md5.1/files/p.patch + - p.patch ### test -f bad-md5.1/p.patch @@ -325,7 +325,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> good-md5-bad-sha256.1: Bad hash for extra-file - - ${BASEDIR}/OPAM/repo/default/packages/good-md5-bad-sha256/good-md5-bad-sha256.1/files/p.patch + - p.patch @@ -343,7 +343,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> good-md5-bad-sha256.1: Bad hash for extra-file - - ${BASEDIR}/OPAM/repo/default/packages/good-md5-bad-sha256/good-md5-bad-sha256.1/files/p.patch + - p.patch @@ -356,7 +356,7 @@ good-md5-bad-sha256.1: Bad hash for extra-file ### opam source good-md5-bad-sha256 | '.n"' -> '"' [WARNING] Some errors extracting to ${BASEDIR}/good-md5-bad-sha256.1: good-md5-bad-sha256.1: Bad hash for extra-file - - ${BASEDIR}/OPAM/repo/default/packages/good-md5-bad-sha256/good-md5-bad-sha256.1/files/p.patch + - p.patch ### test -f good-md5-bad-sha256.1/p.patch @@ -364,7 +364,7 @@ good-md5-bad-sha256.1: Bad hash for extra-file ### opam source good-md5-bad-sha256 --require-checksums | '.n"' -> '"' [WARNING] Some errors extracting to ${BASEDIR}/good-md5-bad-sha256.1: good-md5-bad-sha256.1: Bad hash for extra-file - - ${BASEDIR}/OPAM/repo/default/packages/good-md5-bad-sha256/good-md5-bad-sha256.1/files/p.patch + - p.patch ### test -f good-md5-bad-sha256.1/p.patch @@ -511,7 +511,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> not-present.1: Missing extra-file for - - ${BASEDIR}/OPAM/repo/default/packages/not-present/not-present.1/files/p.patch + - p.patch @@ -529,7 +529,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> not-present.1: Missing extra-file for - - ${BASEDIR}/OPAM/repo/default/packages/not-present/not-present.1/files/p.patch + - p.patch @@ -542,7 +542,7 @@ not-present.1: Missing extra-file for ### opam source not-present [WARNING] Some errors extracting to ${BASEDIR}/not-present.1: not-present.1: Missing extra-file for - - ${BASEDIR}/OPAM/repo/default/packages/not-present/not-present.1/files/p.patch + - p.patch ### test -f not-present.1/p.patch @@ -569,7 +569,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> escape-absolute.1: Missing extra-file for - - ${BASEDIR}/OPAM/repo/default/packages/escape-absolute/escape-absolute.1/files/etc/passwdd + - /etc/passwdd @@ -587,7 +587,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> escape-absolute.1: Missing extra-file for - - ${BASEDIR}/OPAM/repo/default/packages/escape-absolute/escape-absolute.1/files/etc/passwdd + - /etc/passwdd @@ -600,7 +600,7 @@ escape-absolute.1: Missing extra-file for ### opam source escape-absolute [WARNING] Some errors extracting to ${BASEDIR}/escape-absolute.1: escape-absolute.1: Missing extra-file for - - ${BASEDIR}/OPAM/repo/default/packages/escape-absolute/escape-absolute.1/files/etc/passwdd + - /etc/passwdd ### test -f escape-absolute.1/p.patch @@ -629,8 +629,9 @@ The following actions will be performed: - install escape-good-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -[ERROR] The compilation of escape-good-md5.1 failed at "test -f p.patch". +escape-good-md5.1: Missing extra-file for + - ../../../no-checksum/no-checksum.1/files/p.patch @@ -646,8 +647,9 @@ The following actions will be performed: - install escape-good-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -[ERROR] The compilation of escape-good-md5.1 failed at "test -f p.patch". +escape-good-md5.1: Missing extra-file for + - ../../../no-checksum/no-checksum.1/files/p.patch @@ -658,7 +660,11 @@ The following actions will be performed: - No changes have been performed # Return code 31 # ### opam source escape-good-md5 -Successfully extracted to ${BASEDIR}/escape-good-md5.1 +[WARNING] Some errors extracting to ${BASEDIR}/escape-good-md5.1: + escape-good-md5.1: Missing extra-file for + - ../../../no-checksum/no-checksum.1/files/p.patch + + ### test -f escape-good-md5.1/p.patch # Return code 1 # ### :::::::::::::::::::::::: diff --git a/tests/reftests/update.test b/tests/reftests/update.test index 251c08e5a79..3b2b9ef705b 100644 --- a/tests/reftests/update.test +++ b/tests/reftests/update.test @@ -737,7 +737,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> eta.1: Bad hash for extra-file - - ${BASEDIR}/OPAM/repo/incremental/packages/eta/eta.1/files/eta.installl + - eta.installl @@ -773,7 +773,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> eta.1: Missing extra-file for - - ${BASEDIR}/OPAM/repo/incremental/packages/eta/eta.1/files/eta.installl + - eta.installl From 09a2d060797e66f38ce6f7a17147369f0e0df669 Mon Sep 17 00:00:00 2001 From: Kate Date: Mon, 10 Feb 2025 16:16:52 +0000 Subject: [PATCH 14/29] reftest: Add a test showing the behaviour of opam when faced with outdated git submodule in its local cache --- master_changes.md | 1 + tests/reftests/git.test | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/master_changes.md b/master_changes.md index 07fe4466f2a..a74bfd4e7fe 100644 --- a/master_changes.md +++ b/master_changes.md @@ -160,6 +160,7 @@ users) * Add complete tests for the `pin-depends` feature [#6611 @rjbou] * Complete `action-disk.test` with the behaviour of `extra-files` [#6679 @rjbou] * Complete `action-disk.test` with the behaviour of `extra-source` [#6679 @rjbou] + * Add a test showing the behaviour of opam when faced with outdated git submodule in its local cache [#6153 @kit-ty-kate] ### Engine * Fix gcc < 14.3 bug on mingw i686 [#6624 @kit-ty-kate] diff --git a/tests/reftests/git.test b/tests/reftests/git.test index 5f7d54346a6..91fa4e285fb 100644 --- a/tests/reftests/git.test +++ b/tests/reftests/git.test @@ -21,7 +21,7 @@ mkdir -p REPO/packages/submodule/submodule.1 ESCAPED_BASEDIR=$(printf '%s' "$BASEDIR" | sed 's/\\/\\\\/g') cat > REPO/packages/submodule/submodule.1/opam << EOF opam-version: "2.0" -build: ["ls" "vendor/some-file"] +build: ["cat" "vendor/some-file"] url { src: "git+file://${ESCAPED_BASEDIR}/use-submodule" } @@ -42,6 +42,7 @@ The following actions will be performed: -> retrieved submodule.1 (git+file://${BASEDIR}/use-submodule) -> installed submodule.1 Done. +### cp -r ./submodule ./submodule.bak ### rm -r ./submodule ### opam remove submodule The following actions will be performed: @@ -70,3 +71,35 @@ OpamSolution.Fetch_fail("git+file://${BASEDIR}/use-submodule") +- - No changes have been performed # Return code 40 # +### :::::::::::::::::::::::::::::::::::::::::::::: +### : Submodules should be re-fetched when they are outdated / haven't been fetched correctly +### :::::::::::::::::::::::::::::::::::::::::::::: +### mv ./submodule.bak ./submodule +### opam install submodule +The following actions will be performed: +=== install 1 package + - install submodule 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved submodule.1 (no changes) +[ERROR] The compilation of submodule.1 failed at "cat vendor/some-file". + +##% output ### +# cat: vendor/some-file: No such file or directory + + + +<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> ++- The following actions failed +| - build submodule 1 ++- +- No changes have been performed +# Return code 31 # +### : Simulate corruption / --working-dir +### +changed content +### opam update --dev +### opam reinstall -v submodule +submodule is not installed. Install it? [Y/n] n +'${OPAM} reinstall -v submodule' failed. +# Return code 10 # From dd7f5ebee8af7852c14d9d1dd1dc2160cbe3eebd Mon Sep 17 00:00:00 2001 From: Kate Date: Wed, 31 Jul 2024 09:57:54 +0100 Subject: [PATCH 15/29] Check the status of git submodules when checking if a repository is up-to-date --- master_changes.md | 1 + src/repository/opamGit.ml | 14 ++++++++++++- tests/reftests/action-disk.test | 7 +++++++ tests/reftests/git.test | 37 +++++++++++++++++---------------- 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/master_changes.md b/master_changes.md index a74bfd4e7fe..c51d134c4b3 100644 --- a/master_changes.md +++ b/master_changes.md @@ -88,6 +88,7 @@ users) ## Sandbox ## VCS + * Check the status of git submodules when checking if a repository is up-to-date [#6132 @kit-ty-kate] ## Build * Update the dependency constraint on `patch` to now require its stable version [#6663 @kit-ty-kate] diff --git a/src/repository/opamGit.ml b/src/repository/opamGit.ml index 52670eb0f73..c6fa52682bc 100644 --- a/src/repository/opamGit.ml +++ b/src/repository/opamGit.ml @@ -214,7 +214,19 @@ module VCS : OpamVCS.VCS = struct @ List.map OpamFilename.SubPath.to_string (Option.to_list subpath)) @@> function - | { OpamProcess.r_code = 0; _ } -> Done true + | { OpamProcess.r_code = 0; _ } -> + git repo_root ["submodule"; "status"; "--recursive"] @@> fun r -> + if r.r_code = 0 && + (* NOTE: We check the first character of each lines of the output + to verify that every submodules are in their expected state. + The git submodule manual states: + Each SHA-1 will possibly be prefixed with - if the submodule is + not initialized, + if the currently checked out submodule commit + does not match the SHA-1 found in the index of the containing + repository and U if the submodule has merge conflicts. *) + List.for_all (fun s -> String.length s > 0 && s.[0] = ' ') r.r_stdout + then Done true + else (OpamProcess.cleanup ~force:true r; Done false) | { OpamProcess.r_code = 1; _ } as r -> OpamProcess.cleanup ~force:true r; Done false | r -> OpamSystem.process_error r diff --git a/tests/reftests/action-disk.test b/tests/reftests/action-disk.test index 943f50991dd..851f148f40b 100644 --- a/tests/reftests/action-disk.test +++ b/tests/reftests/action-disk.test @@ -1338,6 +1338,7 @@ Processing 1/1: [main-gpin.dev: git] + git "remote" "set-url" "origin" "file://${BASEDIR}/main-gpin" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) + git "fetch" "-q" "file://${BASEDIR}/main-gpin" "--update-shallow" "+master:refs/remotes/opam-ref-master" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) + git "diff" "--no-ext-diff" "--quiet" "refs/remotes/opam-ref-master" "--" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) ++ git "submodule" "status" "--recursive" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) SYSTEM rmdir ${OPAMTMP} [main-gpin.dev] synchronised (no changes) FILE(package-version-list) Cannot find ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/reinstall @@ -1355,6 +1356,7 @@ Processing 1/3: [main-gpin.dev: git] + git "remote" "set-url" "origin" "file://${BASEDIR}/main-gpin" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) + git "fetch" "-q" "file://${BASEDIR}/main-gpin" "--update-shallow" "+master:refs/remotes/opam-ref-master" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) + git "diff" "--no-ext-diff" "--quiet" "refs/remotes/opam-ref-master" "--" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) ++ git "submodule" "status" "--recursive" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) SYSTEM rmdir ${OPAMTMP} -> retrieved main-gpin.dev (no changes) SYSTEM rmdir ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/build/main-gpin.dev @@ -1420,6 +1422,7 @@ Processing 1/1: [main-gpin.dev: git] + git "remote" "set-url" "origin" "file://${BASEDIR}/main-gpin" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) + git "fetch" "-q" "file://${BASEDIR}/main-gpin" "--update-shallow" "+master:refs/remotes/opam-ref-master" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) + git "diff" "--no-ext-diff" "--quiet" "refs/remotes/opam-ref-master" "--" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) ++ git "submodule" "status" "--recursive" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) SYSTEM rmdir ${OPAMTMP} [main-gpin.dev] synchronised (no changes) FILE(package-version-list) Cannot find ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/reinstall @@ -1437,6 +1440,7 @@ Processing 1/4: [main-gpin.dev: git] + git "remote" "set-url" "origin" "file://${BASEDIR}/main-gpin" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) + git "fetch" "-q" "file://${BASEDIR}/main-gpin" "--update-shallow" "+master:refs/remotes/opam-ref-master" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) + git "diff" "--no-ext-diff" "--quiet" "refs/remotes/opam-ref-master" "--" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) ++ git "submodule" "status" "--recursive" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) SYSTEM rmdir ${OPAMTMP} -> retrieved main-gpin.dev (no changes) SYSTEM rmdir ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/build/main-gpin.dev @@ -1527,6 +1531,7 @@ Processing 1/2: [main-gpin.dev: git] + git "remote" "set-url" "origin" "file://${BASEDIR}/main-gpin" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) + git "fetch" "-q" "file://${BASEDIR}/main-gpin" "--update-shallow" "+master:refs/remotes/opam-ref-master" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) + git "diff" "--no-ext-diff" "--quiet" "refs/remotes/opam-ref-master" "--" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) ++ git "submodule" "status" "--recursive" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) SYSTEM rmdir ${OPAMTMP} -> retrieved main-gpin.dev (no changes) SYSTEM rmdir ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/remove/main-gpin.dev @@ -1728,6 +1733,7 @@ Processing 1/1: [main-gpin.dev: git] + git "remote" "set-url" "origin" "file://${BASEDIR}/main-gpin" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) + git "fetch" "-q" "file://${BASEDIR}/main-gpin" "--update-shallow" "+master:refs/remotes/opam-ref-master" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) + git "diff" "--no-ext-diff" "--quiet" "refs/remotes/opam-ref-master" "--" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) ++ git "submodule" "status" "--recursive" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) SYSTEM rmdir ${OPAMTMP} [main-gpin.dev] synchronised (no changes) FILE(package-version-list) Cannot find ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/reinstall @@ -1745,6 +1751,7 @@ Processing 1/4: [main-gpin.dev: git] + git "remote" "set-url" "origin" "file://${BASEDIR}/main-gpin" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) + git "fetch" "-q" "file://${BASEDIR}/main-gpin" "--update-shallow" "+master:refs/remotes/opam-ref-master" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) + git "diff" "--no-ext-diff" "--quiet" "refs/remotes/opam-ref-master" "--" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) ++ git "submodule" "status" "--recursive" (CWD=${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/sources/main-gpin) SYSTEM rmdir ${OPAMTMP} -> retrieved main-gpin.dev (no changes) SYSTEM rmdir ${BASEDIR}/OPAM/install-from-git-pin-all/.opam-switch/build/main-gpin.dev diff --git a/tests/reftests/git.test b/tests/reftests/git.test index 91fa4e285fb..f7d11afdb93 100644 --- a/tests/reftests/git.test +++ b/tests/reftests/git.test @@ -81,25 +81,26 @@ The following actions will be performed: - install submodule 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> --> retrieved submodule.1 (no changes) -[ERROR] The compilation of submodule.1 failed at "cat vendor/some-file". - -##% output ### -# cat: vendor/some-file: No such file or directory - - - -<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> -+- The following actions failed -| - build submodule 1 -+- -- No changes have been performed -# Return code 31 # +-> retrieved submodule.1 (git+file://${BASEDIR}/use-submodule) +-> installed submodule.1 +Done. ### : Simulate corruption / --working-dir ### changed content ### opam update --dev -### opam reinstall -v submodule -submodule is not installed. Install it? [Y/n] n -'${OPAM} reinstall -v submodule' failed. -# Return code 10 # +[NOTE] submodule.1 has previously been updated with --working-dir, not resetting unless explicitly selected +### opam reinstall -v submodule | sed-cmd cat +The following actions will be performed: +=== recompile 1 package + - recompile submodule 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 1/4: [submodule.1: git] +-> retrieved submodule.1 (git+file://${BASEDIR}/use-submodule) +Processing 2/4: [submodule: cat] ++ cat "vendor/some-file" (CWD=${BASEDIR}/OPAM/submodule/.opam-switch/build/submodule.1) +- changed content +-> compiled submodule.1 +-> removed submodule.1 +-> installed submodule.1 +Done. From 2555bd4078df36514d73aeb3763e6fb55e2a8dfe Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Wed, 14 May 2025 18:33:50 +0200 Subject: [PATCH 16/29] reftest: add --depext-only test --- master_changes.md | 1 + tests/reftests/depext-only.test | 109 ++++++++++++++++++++++++++++++++ tests/reftests/dune.inc | 21 ++++++ 3 files changed, 131 insertions(+) create mode 100644 tests/reftests/depext-only.test diff --git a/master_changes.md b/master_changes.md index c51d134c4b3..fba34c3b523 100644 --- a/master_changes.md +++ b/master_changes.md @@ -162,6 +162,7 @@ users) * Complete `action-disk.test` with the behaviour of `extra-files` [#6679 @rjbou] * Complete `action-disk.test` with the behaviour of `extra-source` [#6679 @rjbou] * Add a test showing the behaviour of opam when faced with outdated git submodule in its local cache [#6153 @kit-ty-kate] + * Add reftest for `--depext-only` option [#6516 @rjbou] ### Engine * Fix gcc < 14.3 bug on mingw i686 [#6624 @kit-ty-kate] diff --git a/tests/reftests/depext-only.test b/tests/reftests/depext-only.test new file mode 100644 index 00000000000..3ccdf0e452c --- /dev/null +++ b/tests/reftests/depext-only.test @@ -0,0 +1,109 @@ +N0REP0 +### opam var --global os-family=dummy-success +Added '[os-family "dummy-success" "Set through 'opam var'"]' to field global-variables in global configuration +### OPAMNODEPEXTS=0 OPAMCONFIRMLEVEL=unsafe-yes +### OPAMYES=1 +### +opam-version: "2.0" +depexts: "sys-foo" +### +opam-version: "2.0" +depends: "foo" +### :I: Common usage +### :I:1: Direct depext +### opam switch create direct --empty +### opam install foo --depext-only | sed-cmd echo + +The following system packages will first need to be installed: + sys-foo + +<><> Handling external dependencies <><><><><><><><><><><><><><><><><><><><><><> + ++ echo "sys-foo" +- sys-foo +### opam list -s +### :I:2: Transitive dependency +### opam switch create transitive --empty +### opam install bar --depext-only | sed-cmd echo + +The following system packages will first need to be installed: + sys-foo + +<><> Handling external dependencies <><><><><><><><><><><><><><><><><><><><><><> + ++ echo "sys-foo" +- sys-foo +### :I:3: Conflict +### opam switch create conflict --empty +### +opam-version: "2.0" +depends: "bar" +depexts: "sys-baz" +conflicts: "foo" +### opam install baz --depext-only +[ERROR] Package conflict! + * Incompatible packages: + - baz -> bar -> foo + - baz + +### :I:4: Nothing to do +### opam switch create nothing --empty +### opam install foo | sed-cmd echo +The following actions will be performed: +=== install 1 package + - install foo 1 + +The following system packages will first need to be installed: + sys-foo + +<><> Handling external dependencies <><><><><><><><><><><><><><><><><><><><><><> + +opam believes some required external dependencies are missing. opam can: +> 1. Run echo to install them (may need root/sudo access) + 2. Display the recommended echo command and wait while you run it manually (e.g. in another terminal) + 3. Continue anyway, and, upon success, permanently register that this external dependency is present, but not detectable + 4. Abort the installation + +[1/2/3/4] 1 + ++ echo "sys-foo" +- sys-foo + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed foo.1 +Done. +### OPAMVAR_os_family=dummy-success:sys-foo: opam install foo --depext-only +[NOTE] Package foo is already installed (current version is 1). +### opam install foo --depext-only | sed-cmd echo +[WARNING] Opam package foo.1 depends on the following system package that can no longer be found: sys-foo + +The following system packages will first need to be installed: + sys-foo + +<><> Handling external dependencies <><><><><><><><><><><><><><><><><><><><><><> + ++ echo "sys-foo" +- sys-foo +### :I:5: No depext +### OPAMNODEPEXTS=1 opam install foo --depext-only +opam: --depext-only and --no-depexts can't be used together +Usage: opam install [OPTION]… [PACKAGES]… +Try 'opam install --help' or 'opam --help' for more information. +# Return code 2 # +### :I:6: No confirmation +### opam switch create refuse --empty +### OPAMCONFIRMLEVEL=no OPAMYES=0 +### opam install foo --depext-only | sed-cmd echo + +The following system packages will first need to be installed: + sys-foo + +<><> Handling external dependencies <><><><><><><><><><><><><><><><><><><><><><> + ++ echo "sys-foo" +- sys-foo +### :I:7: Not available +### opam switch create not-avail --empty +### OPAMVAR_os_family=dummy-success::something-else opam install foo --depext-only +[ERROR] Package foo depends on the unavailable system package 'sys-foo'. You can use `--no-depexts' to attempt installation anyway. +# Return code 5 # diff --git a/tests/reftests/dune.inc b/tests/reftests/dune.inc index 01e38363d2c..2bf5eb08839 100644 --- a/tests/reftests/dune.inc +++ b/tests/reftests/dune.inc @@ -440,6 +440,27 @@ %{targets} (run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:cudf-preprocess.test} %{read-lines:testing-env})))) +(rule + (alias reftest-depext-only) + (enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1)))) + (action + (diff depext-only.test depext-only.out))) + +(alias + (name reftest) + (enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1)))) + (deps (alias reftest-depext-only))) + +(rule + (targets depext-only.out) + (deps root-N0REP0) + (enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1)))) + (package opam) + (action + (with-stdout-to + %{targets} + (run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:depext-only.test} %{read-lines:testing-env})))) + (rule (alias reftest-depexts) (enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1)))) From b2c9c73953009dd8bdc6a78e4fef8d5ff92cb211 Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Wed, 14 May 2025 18:36:24 +0200 Subject: [PATCH 17/29] depext-only: no longer ignore conflict exit code --- master_changes.md | 1 + src/client/opamClient.ml | 8 ++++---- tests/reftests/depext-only.test | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/master_changes.md b/master_changes.md index fba34c3b523..833a4891188 100644 --- a/master_changes.md +++ b/master_changes.md @@ -30,6 +30,7 @@ users) ## Install * More fine grained error message in case of bad hash or missing extra-files error (and remove raw fatal error) [#6696 @rjbou] * Do not ignore extra-files whose name is invalid and fail early in that case [#6679 @rjbou @kit-ty-kate] + * BUG: Fix `opam install pkg --depext-only` exit with code 0 instead of 20 (not found) [#6516 @rjbou - fix #6488] ## Build (package) diff --git a/src/client/opamClient.ml b/src/client/opamClient.ml index cdd3a5617d2..2d63eaaa43c 100644 --- a/src/client/opamClient.ml +++ b/src/client/opamClient.ml @@ -2347,7 +2347,7 @@ let install_t t ?ask ?(ignore_conflicts=false) ?(depext_only=false) (OpamCudf.string_of_explanations (OpamSwitchState.unavailable_reason t) explanations) extra_message; - t, if depext_only then None else Some (Conflicts cs) + t, Conflicts cs | Success solution -> let skip = let inst = OpamSolver.new_packages solution in @@ -2363,7 +2363,7 @@ let install_t t ?ask ?(ignore_conflicts=false) ?(depext_only=false) if depext_only then (OpamSolution.install_depexts ~force_depext:true ~confirm:false t ~pkg_to_install:(OpamSolver.all_packages solution) - ~pkg_installed:t.installed), None + ~pkg_installed:t.installed), Success (OK []) else let add_roots = match add_to_roots, deps_only with @@ -2392,9 +2392,9 @@ let install_t t ?ask ?(ignore_conflicts=false) ?(depext_only=false) ~print_requested:(print_requested requested formula) ?add_roots ~skip ~download_only ~assume_built solution in - t, Some (Success res) + t, Success res in - Stdlib.Option.iter (OpamSolution.check_solution t) solution; + OpamSolution.check_solution t solution; t let install t ?formula ?autoupdate ?add_to_roots diff --git a/tests/reftests/depext-only.test b/tests/reftests/depext-only.test index 3ccdf0e452c..1430e54be0a 100644 --- a/tests/reftests/depext-only.test +++ b/tests/reftests/depext-only.test @@ -46,6 +46,8 @@ conflicts: "foo" - baz -> bar -> foo - baz +No solution found, exiting +# Return code 20 # ### :I:4: Nothing to do ### opam switch create nothing --empty ### opam install foo | sed-cmd echo From 9339706a7992eebf797f8c08d29820d2aa6dcfd2 Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Fri, 10 Oct 2025 20:23:43 +0200 Subject: [PATCH 18/29] reftest: add missing documentation for 'unset" builtin --- tests/reftests/readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/reftests/readme.md b/tests/reftests/readme.md index eb4e5aad320..dc7ff6c52ae 100644 --- a/tests/reftests/readme.md +++ b/tests/reftests/readme.md @@ -75,6 +75,7 @@ output... these package names or packages. * `opam-cache repo [nvs]`: print the content of repository cache. If `[nvs]` is specified, filter over these package names or packages. + * `unset FOO` unset variables from environment - if you need more shell power, create a script using then run it. Or just use `sh -c`... but beware for compatibility. From 4acd8f2329976b32ea15b5e49af2ebeeb2b72fde Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Fri, 10 Oct 2025 20:31:35 +0200 Subject: [PATCH 19/29] reftest: add 'sed-hash' command to replace single hashes and hashes paths in opam outputs --- master_changes.md | 1 + tests/reftests/action-disk.test | 66 +++--- tests/reftests/admin-cache.test | 46 ++-- tests/reftests/admin.test | 50 +++-- tests/reftests/archive.test | 246 +++++++++++----------- tests/reftests/download.test | 14 +- tests/reftests/extrasource.test | 194 ++++++++--------- tests/reftests/hooks-variables.test | 13 +- tests/reftests/hooks-variables.unix.test | 13 +- tests/reftests/hooks-variables.win32.test | 13 +- tests/reftests/opam-repo-ci.test | 6 +- tests/reftests/readme.md | 1 + tests/reftests/reftests.test | 102 +++++++++ tests/reftests/run.ml | 38 ++++ tests/reftests/update.test | 48 ++--- 15 files changed, 490 insertions(+), 361 deletions(-) diff --git a/master_changes.md b/master_changes.md index 833a4891188..be53fdffbe7 100644 --- a/master_changes.md +++ b/master_changes.md @@ -172,6 +172,7 @@ users) * Allow `sed-cmd` to parse even if no space is after the command [#6675 @rjbou] * Harden the regexp used for substituting variable checksums [#6710 @kit-ty-kate] * Add the `unset` builtin [#6708 @kit-ty-kate] + * Add the `sed-hash` command to replace hashes in opam output [#XXX @rjbou] ## Github Actions * bump `actions/checkout` from 4 to 5 [#6643 @kit-ty-kate] diff --git a/tests/reftests/action-disk.test b/tests/reftests/action-disk.test index 851f148f40b..9bfced5ad2e 100644 --- a/tests/reftests/action-disk.test +++ b/tests/reftests/action-disk.test @@ -29,10 +29,8 @@ I'm an extra-file I'm an extra-source ### tar czf archive.tgz content ### openssl md5 archive.tgz | '.*= ' -> '' >$ MD5 -### sh -c "echo '$MD5' | cut -c 1-2" >$ PRE_MD5 ### openssl md5 x-file | '.*= ' -> '' >$ XMD5 ### openssl md5 x-source | '.*= ' -> '' >$ XSMD5 -### sh -c "echo '$XSMD5' | cut -c 1-2" >$ PRE_XSMD5 ### basedir=$(printf '%s' "$BASEDIR" | sed 's/\\/\\\\/g') for nv in "$@"; do @@ -178,7 +176,7 @@ SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (write => none) SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-switch/lock (write => none) SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => none) -### opam install main-repo.1 | grep -v '^- ./$' | sed-cmd rsync tar cp touch mkdir | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "md5[^[:alnum:]].?${PRE_MD5}" -> md5/pre | "${PRE_XSMD5}[^[:alnum:]].?${XSMD5}" -> xspre/xshash | "md5[^[:alnum:]].?${PRE_XSMD5}" -> md5/prexs +### opam install main-repo.1 | grep -v '^- ./$' | sed-cmd rsync tar cp touch mkdir | sed-hash $MD5 md5 | sed-hash $XSMD5 xs-hash FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s @@ -209,7 +207,7 @@ Processing 1/3: [main-repo.1: rsync] SYSTEM mkdir ${BASEDIR}/OPAM/download-cache SYSTEM mkdir ${BASEDIR}/OPAM/download-cache/md5 SYSTEM mkdir ${BASEDIR}/OPAM/download-cache/md5/pre -SYSTEM copy ${OPAMTMP}/archive.tgz -> ${BASEDIR}/OPAM/download-cache/md5/pre/hash +SYSTEM copy ${OPAMTMP}/archive.tgz -> ${BASEDIR}/OPAM/download-cache/md5/pre/+md5+ SYSTEM mkdir ${OPAMTMP} Processing 1/3: [main-repo.1: extract] + tar "xfz" "${OPAMTMP}/archive.tgz" "-C" "${OPAMTMP}" @@ -226,8 +224,8 @@ Processing 1/3: [main-repo.1/x-source.main-repo.1: dl] + rsync "-rLptgoDvc" "--exclude" ".git" "--exclude" "_darcs" "--exclude" ".hg" "--exclude" ".#*" "--exclude" "_opam*" "--exclude" "_build" "--delete" "--delete-excluded" "${BASEDIR}/x-source" "${OPAMTMP}" - x-source - -SYSTEM mkdir ${BASEDIR}/OPAM/download-cache/md5/prexs -SYSTEM copy ${OPAMTMP}/x-source -> ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash +SYSTEM mkdir ${BASEDIR}/OPAM/download-cache/md5/pre +SYSTEM copy ${OPAMTMP}/x-source -> ${BASEDIR}/OPAM/download-cache/md5/pre/+xs-hash+ SYSTEM rmdir ${OPAMTMP} SYSTEM rm ${OPAMTMP}/x-source -> retrieved main-repo.1 (file://${BASEDIR}/archive.tgz) @@ -235,7 +233,7 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-sw SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/content -SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-source.main-repo.1 +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/pre/+xs-hash+ -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-source.main-repo.1 SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 SYSTEM write ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-file.main-repo.1 Processing 2/3: [main-repo: touch build-file] @@ -266,7 +264,7 @@ SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-swi SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/backup/state-today.export SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => none) -### opam reinstall main-repo.1 | sed-cmd tar cp touch mkdir | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "${PRE_XSMD5}[^[:alnum:]].?${XSMD5}" -> xspre/xshash | unordered +### opam reinstall main-repo.1 | sed-cmd tar cp touch mkdir | sed-hash $MD5 md5 | sed-hash $XSMD5 xs-hash | unordered FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s @@ -293,7 +291,7 @@ SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switc SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1 SYSTEM mkdir ${OPAMTMP} Processing 1/4: [main-repo.1: extract] -+ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/hash" "-C" "${OPAMTMP}" ++ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/+md5+" "-C" "${OPAMTMP}" SYSTEM copydir ${OPAMTMP} -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1 SYSTEM copy ${OPAMTMP}/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.1/content SYSTEM rmdir ${OPAMTMP} @@ -302,10 +300,10 @@ SYSTEM rm ${OPAMTMP}/content SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/content SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-source.main-repo.1 -SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-source.main-repo.1 +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/pre/+xs-hash+ -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-source.main-repo.1 +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/pre/+xs-hash+ -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-source.main-repo.1 SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 SYSTEM write ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.1/x-file.main-repo.1 -SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-source.main-repo.1 SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 SYSTEM write ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-file.main-repo.1 SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 @@ -363,7 +361,7 @@ SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-swi SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/backup/state-today.export SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => none) -### opam upgrade main-repo | sed-cmd tar touch mkdir cp | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "${PRE_XSMD5}[^[:alnum:]].?${XSMD5}" -> xspre/xshash | unordered +### opam upgrade main-repo | sed-cmd tar touch mkdir cp | sed-hash $MD5 md5 | sed-hash $XSMD5 xs-hash | unordered FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s @@ -389,7 +387,7 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-sw SYSTEM mkdir ${OPAMTMP} SYSTEM mkdir ${OPAMTMP} Processing 1/4: [main-repo.1, main-repo.2: extract] -+ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/hash" "-C" "${OPAMTMP}" ++ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/+md5+" "-C" "${OPAMTMP}" SYSTEM copydir ${OPAMTMP} -> ${OPAMTMP} SYSTEM copy ${OPAMTMP}/content -> ${OPAMTMP}/content SYSTEM rmdir ${OPAMTMP} @@ -409,10 +407,10 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-sw SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2/content -SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2/x-source.main-repo.2 +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/pre/+xs-hash+ -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2/x-source.main-repo.2 +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/pre/+xs-hash+ -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-source.main-repo.1 SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 SYSTEM write ${BASEDIR}/OPAM/install-from-repo/.opam-switch/build/main-repo.2/x-file.main-repo.2 -SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-source.main-repo.1 SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 SYSTEM write ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.1/x-file.main-repo.1 SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 @@ -472,7 +470,7 @@ SYSTEM LOCK ${BASEDIR}/OPAM/install-from-repo/.opam-swi SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/backup/state-today.export SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => none) -### opam remove main-repo | sed-cmd tar touch | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "${PRE_XSMD5}[^[:alnum:]].?${XSMD5}" -> xspre/xshash | unordered +### opam remove main-repo | sed-cmd tar touch | sed-hash $MD5 md5 | sed-hash $XSMD5 xs-hash | unordered FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s @@ -501,7 +499,7 @@ SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switc SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2 SYSTEM mkdir ${OPAMTMP} Processing 1/2: [main-repo.2: extract] -+ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/hash" "-C" "${OPAMTMP}" ++ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/+md5+" "-C" "${OPAMTMP}" SYSTEM copydir ${OPAMTMP} -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2 SYSTEM copy ${OPAMTMP}/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2/content SYSTEM rmdir ${OPAMTMP} @@ -511,7 +509,7 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-repo/.opam-sw SYSTEM copydir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2 -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2 SYSTEM copy ${BASEDIR}/OPAM/install-from-repo/.opam-switch/sources/main-repo.2/content -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/content -SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/x-source.main-repo.2 +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/pre/+xs-hash+ -> ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/x-source.main-repo.2 SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 SYSTEM write ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/x-file.main-repo.2 SYSTEM rm ${BASEDIR}/OPAM/install-from-repo/.opam-switch/remove/main-repo.2/x-source.main-repo.2 @@ -677,6 +675,7 @@ SYSTEM mkdir ${OPAMTMP} Processing 1/1: [main-ppin.dev: rsync] + rsync "-rLptgoDvc" "--exclude" ".git" "--exclude" "_darcs" "--exclude" ".hg" "--exclude" ".#*" "--exclude" "_opam*" "--exclude" "_build" "--delete" "--delete-excluded" "${BASEDIR}/main-ppin/" "${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/sources/main-ppin" - +- SYSTEM rmdir ${OPAMTMP} [main-ppin.dev] synchronised (no changes) FILE(package-version-list) Cannot find ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/reinstall @@ -697,7 +696,6 @@ Processing 1/3: [main-ppin.dev: rsync] + rsync "-rLptgoDvc" "--exclude" ".git" "--exclude" "_darcs" "--exclude" ".hg" "--exclude" ".#*" "--exclude" "_opam*" "--exclude" "_build" "--delete" "--delete-excluded" "${BASEDIR}/main-ppin/" "${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/sources/main-ppin" - content - main-ppin.opam -- SYSTEM rmdir ${OPAMTMP} -> retrieved main-ppin.dev (file://${BASEDIR}/main-ppin) SYSTEM rmdir ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/build/main-ppin.dev @@ -755,6 +753,7 @@ SYSTEM mkdir ${OPAMTMP} Processing 1/1: [main-ppin.dev: rsync] + rsync "-rLptgoDvc" "--exclude" ".git" "--exclude" "_darcs" "--exclude" ".hg" "--exclude" ".#*" "--exclude" "_opam*" "--exclude" "_build" "--delete" "--delete-excluded" "${BASEDIR}/main-ppin/" "${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/sources/main-ppin" - +- SYSTEM rmdir ${OPAMTMP} [main-ppin.dev] synchronised (no changes) FILE(package-version-list) Cannot find ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/reinstall @@ -769,7 +768,6 @@ FILE(opam) Read ${BASEDIR}/OPAM/install-from-path-pin-all/. SYSTEM mkdir ${OPAMTMP} Processing 1/4: [main-ppin.dev: rsync] + rsync "-rLptgoDvc" "--exclude" ".git" "--exclude" "_darcs" "--exclude" ".hg" "--exclude" ".#*" "--exclude" "_opam*" "--exclude" "_build" "--delete" "--delete-excluded" "${BASEDIR}/main-ppin/" "${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/sources/main-ppin" -- SYSTEM rmdir ${OPAMTMP} -> retrieved main-ppin.dev (no changes) SYSTEM rmdir ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/build/main-ppin.dev @@ -1039,6 +1037,7 @@ SYSTEM mkdir ${OPAMTMP} Processing 1/1: [main-ppin.dev: rsync] + rsync "-rLptgoDvc" "--exclude" ".git" "--exclude" "_darcs" "--exclude" ".hg" "--exclude" ".#*" "--exclude" "_opam*" "--exclude" "_build" "--delete" "--delete-excluded" "${BASEDIR}/main-ppin/" "${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/sources/main-ppin" - +- SYSTEM rmdir ${OPAMTMP} [main-ppin.dev] synchronised (no changes) FILE(package-version-list) Cannot find ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/reinstall @@ -1053,7 +1052,6 @@ FILE(opam) Read ${BASEDIR}/OPAM/install-from-path-pin-all/. SYSTEM mkdir ${OPAMTMP} Processing 1/4: [main-ppin.dev: rsync] + rsync "-rLptgoDvc" "--exclude" ".git" "--exclude" "_darcs" "--exclude" ".hg" "--exclude" ".#*" "--exclude" "_opam*" "--exclude" "_build" "--delete" "--delete-excluded" "${BASEDIR}/main-ppin/" "${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/sources/main-ppin" -- SYSTEM rmdir ${OPAMTMP} -> retrieved main-ppin.dev (no changes) SYSTEM rmdir ${BASEDIR}/OPAM/install-from-path-pin-all/.opam-switch/build/main-ppin.dev @@ -1976,7 +1974,7 @@ SYSTEM LOCK ${BASEDIR}/OPAM/install-from-version-pin/.o SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/backup/state-today.export SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => none) -### opam install main-repo | grep -v '^- ./$' | sed-cmd tar rsync cp touch mkdir | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "${PRE_XSMD5}[^[:alnum:]].?${XSMD5}" -> xspre/xshash +### opam install main-repo | grep -v '^- ./$' | sed-cmd tar rsync cp touch mkdir | sed-hash $MD5 md5 | sed-hash $XSMD5 xs-hash FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s @@ -2001,7 +1999,7 @@ The following actions will be performed: SYSTEM rmdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo SYSTEM mkdir ${OPAMTMP} Processing 1/3: [main-repo.1: extract] -+ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/hash" "-C" "${OPAMTMP}" ++ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/+md5+" "-C" "${OPAMTMP}" SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources SYSTEM copydir ${OPAMTMP} -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo @@ -2013,7 +2011,7 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-version-pin/. SYSTEM copydir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo/content -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/content -SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-source.main-repo.1 +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/pre/+xs-hash+ -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-source.main-repo.1 SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 SYSTEM write ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-file.main-repo.1 Processing 2/3: [main-repo: touch build-file] @@ -2044,7 +2042,7 @@ SYSTEM LOCK ${BASEDIR}/OPAM/install-from-version-pin/.o SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/backup/state-today.export SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => none) -### opam reinstall main-repo | grep -v '^- ./$' | sed-cmd tar rsync cp touch mkdir | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "${PRE_XSMD5}[^[:alnum:]].?${XSMD5}" -> xspre/xshash | unordered +### opam reinstall main-repo | grep -v '^- ./$' | sed-cmd tar rsync cp touch mkdir | sed-hash $MD5 md5 | sed-hash $XSMD5 xs-hash | unordered FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s @@ -2071,7 +2069,7 @@ SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opa SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo SYSTEM mkdir ${OPAMTMP} Processing 1/4: [main-repo.1: extract] -+ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/hash" "-C" "${OPAMTMP}" ++ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/+md5+" "-C" "${OPAMTMP}" SYSTEM copydir ${OPAMTMP} -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo SYSTEM copy ${OPAMTMP}/content -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo/content SYSTEM rmdir ${OPAMTMP} @@ -2080,10 +2078,10 @@ SYSTEM rm ${OPAMTMP}/content SYSTEM rmdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/content SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-source.main-repo.1 -SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-source.main-repo.1 +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/pre/+xs-hash+ -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-source.main-repo.1 +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/pre/+xs-hash+ -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-source.main-repo.1 SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 SYSTEM write ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/build/main-repo.1/x-file.main-repo.1 -SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-source.main-repo.1 SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 SYSTEM write ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-file.main-repo.1 SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 @@ -2141,7 +2139,7 @@ SYSTEM LOCK ${BASEDIR}/OPAM/install-from-version-pin/.o SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/backup/state-today.export SYSTEM LOCK ${BASEDIR}/OPAM/repo/lock (none => none) SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => none) -### opam remove main-repo | grep -v '^- ./$' | sed-cmd tar rsync touch | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "${PRE_XSMD5}[^[:alnum:]].?${XSMD5}" -> xspre/xshash | unordered +### opam remove main-repo | grep -v '^- ./$' | sed-cmd tar rsync touch | sed-hash $MD5 md5 | sed-hash $XSMD5 xs-hash | unordered FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s @@ -2168,7 +2166,7 @@ SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opa SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo SYSTEM mkdir ${OPAMTMP} Processing 1/2: [main-repo.1: extract] -+ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/hash" "-C" "${OPAMTMP}" ++ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/+md5+" "-C" "${OPAMTMP}" SYSTEM copydir ${OPAMTMP} -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo SYSTEM copy ${OPAMTMP}/content -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo/content SYSTEM rmdir ${OPAMTMP} @@ -2178,7 +2176,7 @@ SYSTEM rmdir ${BASEDIR}/OPAM/install-from-version-pin/. SYSTEM copydir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1 SYSTEM mkdir ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1 SYSTEM copy ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/sources/main-repo/content -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/content -SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-source.main-repo.1 +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/pre/+xs-hash+ -> ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-source.main-repo.1 SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.1/files/x-file.main-repo.1 SYSTEM write ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-file.main-repo.1 SYSTEM rm ${BASEDIR}/OPAM/install-from-version-pin/.opam-switch/remove/main-repo.1/x-source.main-repo.1 @@ -2249,7 +2247,7 @@ Usage: opam switch [OPTION]… [COMMAND] [ARG]… Try 'opam switch --help' or 'opam --help' for more information. # Return code 2 # ### :III:2: with package -### opam switch create package-switch --package main-repo | grep -v '^- ./$' | sed-cmd rsync tar cp touch mkdir | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash | "md5[^[:alnum:]].?${PRE_MD5}" -> md5/pre | "${PRE_XSMD5}[^[:alnum:]].?${XSMD5}" -> xspre/xshash +### opam switch create package-switch --package main-repo | grep -v '^- ./$' | sed-cmd rsync tar cp touch mkdir | sed-hash $MD5 md5 | sed-hash $XSMD5 xs-hash FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s SYSTEM LOCK ${BASEDIR}/OPAM/lock (none => read) SYSTEM LOCK ${BASEDIR}/OPAM/config.lock (none => write) @@ -2298,7 +2296,7 @@ FILE(package-version-list) Cannot find ${BASEDIR}/OPAM/package-switch/.opam SYSTEM rmdir ${BASEDIR}/OPAM/package-switch/.opam-switch/sources/main-repo.2 SYSTEM mkdir ${OPAMTMP} Processing 1/3: [main-repo.2: extract] -+ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/hash" "-C" "${OPAMTMP}" ++ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/+md5+" "-C" "${OPAMTMP}" SYSTEM mkdir ${BASEDIR}/OPAM/package-switch/.opam-switch/sources SYSTEM copydir ${OPAMTMP} -> ${BASEDIR}/OPAM/package-switch/.opam-switch/sources/main-repo.2 SYSTEM mkdir ${BASEDIR}/OPAM/package-switch/.opam-switch/sources/main-repo.2 @@ -2310,7 +2308,7 @@ SYSTEM rmdir ${BASEDIR}/OPAM/package-switch/.opam-switc SYSTEM copydir ${BASEDIR}/OPAM/package-switch/.opam-switch/sources/main-repo.2 -> ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2 SYSTEM mkdir ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2 SYSTEM copy ${BASEDIR}/OPAM/package-switch/.opam-switch/sources/main-repo.2/content -> ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/content -SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/xspre/xshash -> ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/x-source.main-repo.2 +SYSTEM copy ${BASEDIR}/OPAM/download-cache/md5/pre/+xs-hash+ -> ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/x-source.main-repo.2 SYSTEM read ${BASEDIR}/OPAM/repo/default/packages/main-repo/main-repo.2/files/x-file.main-repo.2 SYSTEM write ${BASEDIR}/OPAM/package-switch/.opam-switch/build/main-repo.2/x-file.main-repo.2 Processing 2/3: [main-repo: touch build-file] diff --git a/tests/reftests/admin-cache.test b/tests/reftests/admin-cache.test index ba70d1bf544..14cfc255ac5 100644 --- a/tests/reftests/admin-cache.test +++ b/tests/reftests/admin-cache.test @@ -53,29 +53,17 @@ done ### rm -rf cache ### : computes hashes ### openssl md5 arch-ipsum.tgz | '.*= ' -> '' >$ IP_MD5 -### sh -c "echo '$IP_MD5' | cut -c 1-2" >$ PRE_IP_MD5 ### openssl sha256 arch-ipsum.tgz | '.*= ' -> '' >$ IP_SHA256 -### sh -c "echo '$IP_SHA256' | cut -c 1-2" >$ PRE_IP_SHA256 ### openssl sha512 arch-ipsum.tgz | '.*= ' -> '' >$ IP_SHA512 -### sh -c "echo '$IP_SHA512' | cut -c 1-2" >$ PRE_IP_SHA512 ### openssl md5 arch-dolor.tgz | '.*= ' -> '' >$ DL_MD5 -### sh -c "echo '$DL_MD5' | cut -c 1-2" >$ PRE_DL_MD5 ### openssl sha256 arch-dolor.tgz | '.*= ' -> '' >$ DL_SHA256 -### sh -c "echo '$DL_SHA256' | cut -c 1-2" >$ PRE_DL_SHA256 ### openssl sha512 arch-dolor.tgz | '.*= ' -> '' >$ DL_SHA512 -### sh -c "echo '$DL_SHA512' | cut -c 1-2" >$ PRE_DL_SHA512 ### openssl md5 arch-sit.tgz | '.*= ' -> '' >$ ST_MD5 -### sh -c "echo '$ST_MD5' | cut -c 1-2" >$ PRE_ST_MD5 ### openssl sha256 arch-sit.tgz | '.*= ' -> '' >$ ST_SHA256 -### sh -c "echo '$ST_SHA256' | cut -c 1-2" >$ PRE_ST_SHA256 ### openssl sha512 arch-sit.tgz | '.*= ' -> '' >$ ST_SHA512 -### sh -c "echo '$ST_SHA512' | cut -c 1-2" >$ PRE_ST_SHA512 ### openssl md5 arch-amet.tgz | '.*= ' -> '' >$ MT_MD5 -### sh -c "echo '$MT_MD5' | cut -c 1-2" >$ PRE_MT_MD5 ### openssl sha256 arch-amet.tgz | '.*= ' -> '' >$ MT_SHA256 -### sh -c "echo '$MT_SHA256' | cut -c 1-2" >$ PRE_MT_SHA256 ### openssl sha512 arch-amet.tgz | '.*= ' -> '' >$ MT_SHA512 -### sh -c "echo '$MT_SHA512' | cut -c 1-2" >$ PRE_MT_SHA512 ### pkg=$1 kind=$2 @@ -269,15 +257,15 @@ mv "$file.tmp" "$file" ### sh sedi.sh '/"sha512=.*/d' packages/dolor/dolor.1/opam ### sh sedi.sh '/"md5=.*/d' packages/sit/sit.1/opam ### sh sedi.sh '/"sha512=.*/d' packages/sit/sit.1/opam -### opam show --just-file ./packages/ipsum/ipsum.1/opam --field url.src,url.checksum | "${IP_MD5}" -> IP_MD5 +### opam show --just-file ./packages/ipsum/ipsum.1/opam --field url.src,url.checksum | sed-hash $IP_MD5 ip-md5 url.src: file://${BASEDIR}/arch-ipsum.tgz -url.checksum: md5=IP_MD5 -### opam show --just-file ./packages/dolor/dolor.1/opam --field url.src,url.checksum | "${DL_MD5}" -> DL_MD5 | "${DL_SHA256}" -> DL_SHA256 +url.checksum: md5=+ip-md5+ +### opam show --just-file ./packages/dolor/dolor.1/opam --field url.src,url.checksum | sed-hash $DL_MD5 dl-md5 | sed-hash $DL_SHA256 dl-sha256 url.src: file://${BASEDIR}/arch-dolor.tgz -url.checksum: md5=DL_MD5, sha256=DL_SHA256 -### opam show --just-file ./packages/sit/sit.1/opam --field url.src,url.checksum | "${ST_SHA256}" -> ST_SHA256 +url.checksum: md5=+dl-md5+, sha256=+dl-sha256+ +### opam show --just-file ./packages/sit/sit.1/opam --field url.src,url.checksum | sed-hash $ST_SHA256 st-sha256 url.src: file://${BASEDIR}/arch-sit.tgz -url.checksum: sha256=ST_SHA256 +url.checksum: sha256=+st-sha256+ ### rm -rf cache ### opam admin cache | unordered [dolor.1] synchronised (file://${BASEDIR}/arch-dolor.tgz) @@ -307,15 +295,15 @@ amet : sha512 : exists ### opam admin add-hashes md5 --package sit [file://${BASEDIR}/arch-sit.tgz] found in cache ### opam admin add-hashes sha512 --package sit -### opam show --just-file ./packages/ipsum/ipsum.1/opam --field url.src,url.checksum | "${IP_MD5}" -> IP_MD5 | "${IP_SHA512}" -> IP_SHA512 +### opam show --just-file ./packages/ipsum/ipsum.1/opam --field url.src,url.checksum | sed-hash $IP_MD5 ip-md5 | sed-hash $IP_SHA512 ip-sha512 url.src: file://${BASEDIR}/arch-ipsum.tgz -url.checksum: md5=IP_MD5, sha512=IP_SHA512 -### opam show --just-file ./packages/dolor/dolor.1/opam --field url.src,url.checksum | "${DL_MD5}" -> DL_MD5 | "${DL_SHA256}" -> DL_SHA256 | "${DL_SHA512}" -> DL_SHA512 +url.checksum: md5=+ip-md5+, sha512=+ip-sha512+ +### opam show --just-file ./packages/dolor/dolor.1/opam --field url.src,url.checksum | sed-hash $DL_MD5 dl-md5 | sed-hash $DL_SHA256 dl-sha256 | sed-hash $DL_SHA512 dl-sha512 url.src: file://${BASEDIR}/arch-dolor.tgz -url.checksum: md5=DL_MD5, sha256=DL_SHA256, sha512=DL_SHA512 -### opam show --just-file ./packages/sit/sit.1/opam --field url.src,url.checksum | "${ST_MD5}" -> ST_MD5 | "${ST_SHA256}" -> ST_SHA256 | "${ST_SHA512}" -> ST_SHA512 +url.checksum: md5=+dl-md5+, sha256=+dl-sha256+, sha512=+dl-sha512+ +### opam show --just-file ./packages/sit/sit.1/opam --field url.src,url.checksum | sed-hash $ST_SHA256 st-sha256 | sed-hash $ST_MD5 st-md5 | sed-hash $ST_SHA512 st-sha512 url.src: file://${BASEDIR}/arch-sit.tgz -url.checksum: sha256=ST_SHA256, md5=ST_MD5, sha512=ST_SHA512 +url.checksum: sha256=+st-sha256+, md5=+st-md5+, sha512=+st-sha512+ ### sh cache-analysi.sh ipsum : md5 : exists ipsum : sha256 : not found @@ -368,9 +356,7 @@ opam-version: "2.0" ### openssl md5 arch-lorem.tgz | '.*= ' -> '' >$ LR_MD5 ### sh -c "echo '$LR_MD5' | cut -c 1-2" >$ PRE_LR_MD5 ### openssl sha256 arch-lorem.tgz | '.*= ' -> '' >$ LR_SHA256 -### sh -c "echo '$LR_SHA256' | cut -c 1-2" >$ PRE_LR_SHA256 ### openssl sha512 arch-lorem.tgz | '.*= ' -> '' >$ LR_SHA512 -### sh -c "echo '$LR_SHA512' | cut -c 1-2" >$ PRE_LR_SHA512 ### openssl md5 arch-evil.tgz | "${LR_MD5}" -> LR_MD5 MD5(arch-evil.tgz)= LR_MD5 ### sh add-urls.sh lorem @@ -401,11 +387,11 @@ lorem : sha512 : not found lorem : md5 : exists lorem : sha256 : exists, link to md5 lorem : sha512 : not found -### opam admin cache | "${LR_MD5}" -> LR_MD5 | "${LR_SHA256}" -> LR_SHA256 | "${LR_SHA512}" -> LR_SHA512 +### opam admin cache | sed-hash $LR_SHA512 lr-sha512 | sed-hash $LR_SHA256 lr-sha256 | sed-hash $LR_MD5 lr-md5 [ERROR] Conflicting file hashes, or broken or compromised cache! - - sha512=LR_SHA512 (MISMATCH) - - sha256=LR_SHA256 (MISMATCH) - - md5=LR_MD5 (match) + - sha512=+lr-sha512+ (MISMATCH) + - sha256=+lr-sha256+ (MISMATCH) + - md5=+lr-md5+ (match) [lorem.1] synchronised (file://${BASEDIR}/arch-lorem.tgz) Done. diff --git a/tests/reftests/admin.test b/tests/reftests/admin.test index 45848bcd84c..4f75aad3e4a 100644 --- a/tests/reftests/admin.test +++ b/tests/reftests/admin.test @@ -589,12 +589,18 @@ else fi ### sh add-urls.sh arch1 0 dolor ### sh add-urls.sh arch2 1 sit -### opam show --just-file ./packages/dolor/dolor.1/opam --field url.src,url.checksum | "=[0-9a-f]\+\(,\|$\)" -> =HASH +### openssl md5 arch1.tgz | '.*= ' -> '' >$ ARCH1_MD5 +### openssl sha256 arch1.tgz | '.*= ' -> '' >$ ARCH1_SHA256 +### openssl sha512 arch1.tgz | '.*= ' -> '' >$ ARCH1_SHA512 +### openssl md5 arch2.tgz | '.*= ' -> '' >$ ARCH2_MD5 +### openssl sha256 arch2.tgz | '.*= ' -> '' >$ ARCH2_SHA256 +### openssl sha512 arch2.tgz | '.*= ' -> '' >$ ARCH2_SHA512 +### opam show --just-file ./packages/dolor/dolor.1/opam --field url.src,url.checksum url.src: file://${BASEDIR}/arch1.tgz url.checksum: -### opam show --just-file ./packages/sit/sit.1/opam --field url.src,url.checksum | "=[0-9a-f]\+\(,\|$\)" -> =HASH +### opam show --just-file ./packages/sit/sit.1/opam --field url.src,url.checksum | sed-hash $ARCH2_MD5 arch2-md5 url.src: file://${BASEDIR}/arch2.tgz -url.checksum: md5=HASH +url.checksum: md5=+arch2-md5+ ### sh check-hash-ca.sh root: OPAM no hash-cache @@ -607,12 +613,12 @@ sha256_to_md5: 0 sha256_to_sha512: 0 sha512_to_md5: 0 sha512_to_sha256: 0 -### opam show --just-file ./packages/dolor/dolor.1/opam --field url.src,url.checksum | "=[0-9a-f]\+\(,\|$\)" -> =HASH +### opam show --just-file ./packages/dolor/dolor.1/opam --field url.src,url.checksum | sed-hash $ARCH1_MD5 arch1-md5 url.src: file://${BASEDIR}/arch1.tgz -url.checksum: md5=HASH -### opam show --just-file ./packages/sit/sit.1/opam --field url.src,url.checksum | "=[0-9a-f]\+\(,\|$\)" -> =HASH +url.checksum: md5=+arch1-md5+ +### opam show --just-file ./packages/sit/sit.1/opam --field url.src,url.checksum | sed-hash $ARCH2_MD5 arch2-md5 url.src: file://${BASEDIR}/arch2.tgz -url.checksum: md5=HASH +url.checksum: md5=+arch2-md5+ ### opam admin add-hashes sha256 --packages not-found,dolor,sit.1,sit.2,sed,sed.2 [WARNING] Not found packages not-found, sit.2 and sed.2. Ignoring them. ### sh check-hash-ca.sh @@ -623,13 +629,13 @@ sha256_to_md5: 0 sha256_to_sha512: 0 sha512_to_md5: 0 sha512_to_sha256: 0 -### opam show --just-file ./packages/dolor/dolor.1/opam --field url.src,url.checksum | "=[0-9a-f]\+\(,\|$\)" -> =HASH +### opam show --just-file ./packages/dolor/dolor.1/opam --field url.src,url.checksum | sed-hash $ARCH1_MD5 arch1-md5 | sed-hash $ARCH1_SHA256 arch1-sha256 url.src: file://${BASEDIR}/arch1.tgz -url.checksum: md5=HASH sha256=HASH -### opam show --just-file ./packages/sit/sit.1/opam --field url.src,url.checksum | "=[0-9a-f]\+\(,\|$\)" -> =HASH +url.checksum: md5=+arch1-md5+, sha256=+arch1-sha256+ +### opam show --just-file ./packages/sit/sit.1/opam --field url.src,url.checksum | sed-hash $ARCH2_MD5 arch2-md5 | sed-hash $ARCH2_SHA256 arch2-sha256 url.src: file://${BASEDIR}/arch2.tgz -url.checksum: md5=HASH sha256=HASH -### opam show --just-file ./packages/sed/sed.1/opam --field url.src,url.checksum | "=[0-9a-f]\+\(,\|$\)" -> =HASH +url.checksum: md5=+arch2-md5+, sha256=+arch2-sha256+ +### opam show --just-file ./packages/sed/sed.1/opam --field url.src,url.checksum url.src: url.checksum: ### rm -r packages/an-old-package @@ -644,12 +650,12 @@ sha256_to_md5: 0 sha256_to_sha512: 2 sha512_to_md5: 0 sha512_to_sha256: 0 -### opam show --just-file ./packages/dolor/dolor.1/opam --field url.src,url.checksum | "=[0-9a-f]\+\(,\|$\)" -> =HASH +### opam show --just-file ./packages/dolor/dolor.1/opam --field url.src,url.checksum | sed-hash $ARCH1_MD5 arch1-md5 | sed-hash $ARCH1_SHA256 arch1-sha256 | sed-hash $ARCH1_SHA512 arch1-sha512 url.src: file://${BASEDIR}/arch1.tgz -url.checksum: md5=HASH sha256=HASH sha512=HASH -### opam show --just-file ./packages/sit/sit.1/opam --field url.src,url.checksum | "=[0-9a-f]\+\(,\|$\)" -> =HASH +url.checksum: md5=+arch1-md5+, sha256=+arch1-sha256+, sha512=+arch1-sha512+ +### opam show --just-file ./packages/sit/sit.1/opam --field url.src,url.checksum | sed-hash $ARCH2_MD5 arch2-md5 | sed-hash $ARCH2_SHA256 arch2-sha256 | sed-hash $ARCH2_SHA512 arch2-sha512 url.src: file://${BASEDIR}/arch2.tgz -url.checksum: md5=HASH sha256=HASH sha512=HASH +url.checksum: md5=+arch2-md5+, sha256=+arch2-sha256+, sha512=+arch2-sha512+ ### opam lint --check-upstream ./packages/dolor/dolor.1/opam ./packages/sit/sit.1/opam ${BASEDIR}/packages/dolor/dolor.1/opam: Passed. ${BASEDIR}/packages/sit/sit.1/opam: Passed. @@ -691,8 +697,8 @@ sed -i.bak "s/xf-md5/$XF_MD5/" packages/with-xf/with-xf.1/opam sed -i.bak "s/xf-sha/$XF_SHA256/" packages/with-xf/with-xf.1/opam ### sh hash-xf.sh ### opam admin update-extrafiles -### opam-cat packages/with-xf/with-xf.1/opam | "${XF_MD5}" -> "good-md5" | "${XF_SHA256}" -> "good-sha" -extra-files: [["bad-md5" "md5=good-md5"] ["bad-sha" "sha256=good-sha"] ["good-md5" "md5=good-md5"] ["good-sha" "sha256=good-sha"] ["missing-hash" "md5=good-md5"]] +### opam-cat packages/with-xf/with-xf.1/opam | sed-hash $XF_MD5 xf-md5 | sed-hash $XF_SHA256 xf-sha256 +extra-files: [["bad-md5" "md5=+xf-md5+"] ["bad-sha" "sha256=+xf-sha256+"] ["good-md5" "md5=+xf-md5+"] ["good-sha" "sha256=+xf-sha256+"] ["missing-hash" "md5=+xf-md5+"]] opam-version: "2.0" ### opam-version: "2.0" @@ -704,16 +710,16 @@ extra-files: [ ] ### sh hash-xf.sh ### opam admin update-extrafiles --hash sha256 -### opam-cat packages/with-xf/with-xf.1/opam | "${XF_MD5}" -> "good-md5" | "${XF_SHA256}" -> "good-sha" -extra-files: [["bad-md5" "sha256=good-sha"] ["bad-sha" "sha256=good-sha"] ["good-md5" "sha256=good-sha"] ["good-sha" "sha256=good-sha"] ["missing-hash" "sha256=good-sha"]] +### opam-cat packages/with-xf/with-xf.1/opam | sed-hash $XF_MD5 xf-md5 | sed-hash $XF_SHA256 xf-sha256 +extra-files: [["bad-md5" "sha256=+xf-sha256+"] ["bad-sha" "sha256=+xf-sha256+"] ["good-md5" "sha256=+xf-sha256+"] ["good-sha" "sha256=+xf-sha256+"] ["missing-hash" "sha256=+xf-sha256+"]] opam-version: "2.0" ### opam-version: "2.0" ### mkdir -p packages/with-xf/with-xf.2/files ### cp packages/with-xf/with-xf.1/files/good-md5 packages/with-xf/with-xf.2/files/missing-hash ### opam admin update-extrafiles -### opam-cat packages/with-xf/with-xf.2/opam | "${XF_MD5}" -> "good-md5" | "${XF_SHA256}" -> "good-sha" -extra-files: ["missing-hash" "md5=good-md5"] +### opam-cat packages/with-xf/with-xf.2/opam | sed-hash $XF_MD5 xf-md5 +extra-files: ["missing-hash" "md5=+xf-md5+"] opam-version: "2.0" ### :::::::::::::::::::::::::::::::::::::::::::::::::::::: ### :: Cache is tested in admin-cache.test :: diff --git a/tests/reftests/archive.test b/tests/reftests/archive.test index ff5965783ab..9f0ea9273e8 100644 --- a/tests/reftests/archive.test +++ b/tests/reftests/archive.test @@ -497,26 +497,26 @@ Successfully extracted to ${BASEDIR}/no-checksum.1 ### opam clean --download-cache Clearing cache of downloaded files ### :I:6: multiple md5 -### opam lint --package multiple-md5 +### opam lint --package multiple-md5 | sed-hash $ARCHIVE_MD5 archive-md5 /multiple-md5.1: Errors. error 71: Field 'url.checksum' contains duplicated checksums: "md5: 2 occurences" # Return code 1 # -### opam lint --package multiple-md5 --check-upstream | '[0-9a-z]{32}' -> 'hash' +### opam lint --package multiple-md5 --check-upstream | sed-hash $ARCHIVE_MD5 archive-md5 /multiple-md5.1: Errors. error 60: Upstream check failed: "The archive doesn't match checksum: - - archive: md5=hash, in opam file: md5=hash + - archive: md5=+archive-md5+, in opam file: md5=00000000000000000000000000000000 ." error 71: Field 'url.checksum' contains duplicated checksums: "md5: 2 occurences" # Return code 1 # -### opam install multiple-md5 | '[0-9a-z]{32}' -> 'hash' +### opam install multiple-md5 | sed-hash $ARCHIVE_MD5 archive-md5 The following actions will be performed: === install 1 package - install multiple-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] multiple-md5.1: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+archive-md5+ [ERROR] Failed to get sources of multiple-md5.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -528,15 +528,15 @@ OpamSolution.Fetch_fail("Checksum mismatch") +- - No changes have been performed # Return code 40 # -### opam install multiple-md5 --require-checksums | '[0-9a-z]{32}' -> 'hash' +### opam install multiple-md5 --require-checksums | sed-hash $ARCHIVE_MD5 archive-md5 The following actions will be performed: === install 1 package - install multiple-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] multiple-md5.1: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+archive-md5+ [ERROR] Failed to get sources of multiple-md5.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -548,18 +548,18 @@ OpamSolution.Fetch_fail("Checksum mismatch") +- - No changes have been performed # Return code 40 # -### opam source multiple-md5 | '[0-9a-z]{32}' -> 'hash' +### opam source multiple-md5 | sed-hash $ARCHIVE_MD5 archive-md5 [ERROR] multiple-md5.1: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+archive-md5+ [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f multiple-md5.1/hello # Return code 1 # -### opam source multiple-md5 --require-checksums | '[0-9a-z]{32}' -> 'hash' +### opam source multiple-md5 --require-checksums | sed-hash $ARCHIVE_MD5 archive-md5 [ERROR] multiple-md5.1: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+archive-md5+ [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f multiple-md5.1/hello @@ -569,21 +569,21 @@ Clearing cache of downloaded files ### :I:7: bad md5 ### opam lint --package bad-md5 /bad-md5.1: Passed. -### opam lint --package bad-md5 --check-upstream | '[0-9a-z]{32}' -> 'hash' +### opam lint --package bad-md5 --check-upstream | sed-hash $ARCHIVE_MD5 archive-md5 /bad-md5.1: Errors. error 60: Upstream check failed: "The archive doesn't match checksum: - - archive: md5=hash, in opam file: md5=hash + - archive: md5=+archive-md5+, in opam file: md5=00000000000000000000000000000000 ." # Return code 1 # -### opam install bad-md5 | '[0-9a-z]{32}' -> 'hash' +### opam install bad-md5 | sed-hash $ARCHIVE_MD5 archive-md5 The following actions will be performed: === install 1 package - install bad-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] bad-md5.1: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+archive-md5+ [ERROR] Failed to get sources of bad-md5.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -595,15 +595,15 @@ OpamSolution.Fetch_fail("Checksum mismatch") +- - No changes have been performed # Return code 40 # -### opam install bad-md5 --require-checksums | '[0-9a-z]{32}' -> 'hash' +### opam install bad-md5 --require-checksums | sed-hash $ARCHIVE_MD5 archive-md5 The following actions will be performed: === install 1 package - install bad-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] bad-md5.1: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+archive-md5+ [ERROR] Failed to get sources of bad-md5.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -615,18 +615,18 @@ OpamSolution.Fetch_fail("Checksum mismatch") +- - No changes have been performed # Return code 40 # -### opam source bad-md5 | '[0-9a-z]{32}' -> 'hash' +### opam source bad-md5 | sed-hash $ARCHIVE_MD5 archive-md5 [ERROR] bad-md5.1: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+archive-md5+ [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f bad-md5.1/hello # Return code 1 # -### opam source bad-md5 --require-checksums | '[0-9a-z]{32}' -> 'hash' +### opam source bad-md5 --require-checksums | sed-hash $ARCHIVE_MD5 archive-md5 [ERROR] bad-md5.1: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+archive-md5+ [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f bad-md5.1/hello @@ -636,10 +636,10 @@ Clearing cache of downloaded files ### :I:8: good md5 & bad sha256 ### opam lint --package good-md5-bad-sha256 /good-md5-bad-sha256.1: Passed. -### opam lint --package good-md5-bad-sha256 --check-upstream | '[0-9a-z]{64}' -> 'hash' +### opam lint --package good-md5-bad-sha256 --check-upstream | sed-hash $ARCHIVE_SHA256 archive-sha256 /good-md5-bad-sha256.1: Errors. error 60: Upstream check failed: "The archive doesn't match checksum: - - archive: sha256=hash, in opam file: sha256=hash + - archive: sha256=+archive-sha256+, in opam file: sha256=0000000000000000000000000000000000000000000000000000000000000000 ." # Return code 1 # ### opam reinstall good-md5 @@ -655,19 +655,19 @@ Done. ### sh check-cache.sh MD5: archive, with matching checksum SHA256: not found -### opam install good-md5-bad-sha256 | '[0-9a-z]{32,64}' -> 'hash' +### opam install good-md5-bad-sha256 | sed-hash $ARCHIVE_MD5 archive-md5 | sed-hash $ARCHIVE_SHA256 archive-sha256 The following actions will be performed: === install 1 package - install good-md5-bad-sha256 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] Conflicting file hashes, or broken or compromised cache! - - md5=hash (match) - - sha256=hash (MISMATCH) + - md5=+archive-md5+ (match) + - sha256=0000000000000000000000000000000000000000000000000000000000000000 (MISMATCH) [ERROR] good-md5-bad-sha256.1: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected sha256=hash - got sha256=hash + expected sha256=0000000000000000000000000000000000000000000000000000000000000000 + got sha256=+archive-sha256+ [ERROR] Failed to get sources of good-md5-bad-sha256.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -705,19 +705,19 @@ Done. ### sh check-cache.sh MD5: archive, with matching checksum SHA256: archive, with matching checksum -### opam install good-md5-bad-sha256 | '[0-9a-z]{32,64}' -> 'hash' +### opam install good-md5-bad-sha256 | sed-hash $ARCHIVE_MD5 archive-md5 | sed-hash $ARCHIVE_SHA256 archive-sha256 The following actions will be performed: === install 1 package - install good-md5-bad-sha256 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] Conflicting file hashes, or broken or compromised cache! - - md5=hash (match) - - sha256=hash (MISMATCH) + - md5=+archive-md5+ (match) + - sha256=0000000000000000000000000000000000000000000000000000000000000000 (MISMATCH) [ERROR] good-md5-bad-sha256.1: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected sha256=hash - got sha256=hash + expected sha256=0000000000000000000000000000000000000000000000000000000000000000 + got sha256=+archive-sha256+ [ERROR] Failed to get sources of good-md5-bad-sha256.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -732,15 +732,15 @@ OpamSolution.Fetch_fail("Checksum mismatch") ### sh check-cache.sh MD5: not found SHA256: archive, with matching checksum -### opam install good-md5-bad-sha256 --require-checksums | '[0-9a-z]{32,64}' -> 'hash' +### opam install good-md5-bad-sha256 --require-checksum | sed-hash $ARCHIVE_SHA256 archive-sha256 The following actions will be performed: === install 1 package - install good-md5-bad-sha256 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] good-md5-bad-sha256.1: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected sha256=hash - got sha256=hash + expected sha256=0000000000000000000000000000000000000000000000000000000000000000 + got sha256=+archive-sha256+ [ERROR] Failed to get sources of good-md5-bad-sha256.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -752,18 +752,18 @@ OpamSolution.Fetch_fail("Checksum mismatch") +- - No changes have been performed # Return code 40 # -### opam source good-md5-bad-sha256 | '[0-9a-z]{64}' -> 'md5' +### opam source good-md5-bad-sha256 | sed-hash $ARCHIVE_SHA256 archive-sha256 | sed-hash $ARCHIVE_SHA256 archive-sha256 [ERROR] good-md5-bad-sha256.1: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected sha256=md5 - got sha256=md5 + expected sha256=0000000000000000000000000000000000000000000000000000000000000000 + got sha256=+archive-sha256+ [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f good-md5-bad-sha256.1/hello # Return code 1 # -### opam source good-md5-bad-sha256 --require-checksums | '[0-9a-z]{64}' -> 'md5' +### opam source good-md5-bad-sha256 --require-checksums | sed-hash $ARCHIVE_SHA256 archive-sha256 [ERROR] good-md5-bad-sha256.1: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected sha256=md5 - got sha256=md5 + expected sha256=0000000000000000000000000000000000000000000000000000000000000000 + got sha256=+archive-sha256+ [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f good-md5-bad-sha256.1/hello @@ -773,21 +773,21 @@ Clearing cache of downloaded files ### :I:9: good sha256 & bad md5 ### opam lint --package good-sha256-bad-md5 /good-sha256-bad-md5.1: Passed. -### opam lint --package good-sha256-bad-md5 --check-upstream | '[0-9a-z]{32}' -> 'hash' +### opam lint --package good-sha256-bad-md5 --check-upstream | sed-hash $ARCHIVE_MD5 archive-md5 /good-sha256-bad-md5.1: Errors. error 60: Upstream check failed: "The archive doesn't match checksum: - - archive: md5=hash, in opam file: md5=hash + - archive: md5=+archive-md5+, in opam file: md5=00000000000000000000000000000000 ." # Return code 1 # -### opam install good-sha256-bad-md5 | '[0-9a-z]{32,64}' -> 'hash' +### opam install good-sha256-bad-md5 | sed-hash $ARCHIVE_MD5 archive-md5 The following actions will be performed: === install 1 package - install good-sha256-bad-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] good-sha256-bad-md5.1: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+archive-md5+ [ERROR] Failed to get sources of good-sha256-bad-md5.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -799,15 +799,15 @@ OpamSolution.Fetch_fail("Checksum mismatch") +- - No changes have been performed # Return code 40 # -### opam install good-sha256-bad-md5 --require-checksums | '[0-9a-z]{32,64}' -> 'hash' +### opam install good-sha256-bad-md5 --require-checksums | sed-hash $ARCHIVE_MD5 archive-md5 The following actions will be performed: === install 1 package - install good-sha256-bad-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] good-sha256-bad-md5.1: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+archive-md5+ [ERROR] Failed to get sources of good-sha256-bad-md5.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -819,18 +819,18 @@ OpamSolution.Fetch_fail("Checksum mismatch") +- - No changes have been performed # Return code 40 # -### opam source good-sha256-bad-md5 | '[0-9a-z]{32}' -> 'hash' +### opam source good-sha256-bad-md5 | sed-hash $ARCHIVE_MD5 archive-md5 [ERROR] good-sha256-bad-md5.1: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+archive-md5+ [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f good-sha256-bad-md5.1/hello # Return code 1 # -### opam source good-sha256-bad-md5 --require-checksums | '[0-9a-z]{32}' -> 'hash' +### opam source good-sha256-bad-md5 --require-checksums | sed-hash $ARCHIVE_MD5 archive-md5 [ERROR] good-sha256-bad-md5.1: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+archive-md5+ [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f good-sha256-bad-md5.1/hello @@ -842,38 +842,38 @@ Clearing cache of downloaded files /clash-with-all-md5s.666: Errors. error 71: Field 'url.checksum' contains duplicated checksums: "md5: 17 occurences" # Return code 1 # -### opam lint --package clash-with-all-md5s --check-upstream | '[0-9a-z]{32,64}' -> 'hash' +### opam lint --package clash-with-all-md5s --check-upstream | sed-hash $ARCHIVE_MD5 archive-md5 | sed-hash $ARCHIVE_SHA256 archive-sha256 /clash-with-all-md5s.666: Errors. error 60: Upstream check failed: "The archive doesn't match checksums: - - archive: md5=hash, in opam file: md5=hash - - archive: md5=hash, in opam file: md5=hash - - archive: md5=hash, in opam file: md5=hash - - archive: md5=hash, in opam file: md5=hash - - archive: md5=hash, in opam file: md5=hash - - archive: md5=hash, in opam file: md5=hash - - archive: md5=hash, in opam file: md5=hash - - archive: md5=hash, in opam file: md5=hash - - archive: md5=hash, in opam file: md5=hash - - archive: md5=hash, in opam file: md5=hash - - archive: md5=hash, in opam file: md5=hash - - archive: md5=hash, in opam file: md5=hash - - archive: md5=hash, in opam file: md5=hash - - archive: md5=hash, in opam file: md5=hash - - archive: md5=hash, in opam file: md5=hash - - archive: md5=hash, in opam file: md5=hash - - archive: sha256=hash, in opam file: sha256=hash + - archive: md5=+archive-md5+, in opam file: md5=00000000000000000000000000000000 + - archive: md5=+archive-md5+, in opam file: md5=11111111111111111111111111111111 + - archive: md5=+archive-md5+, in opam file: md5=22222222222222222222222222222222 + - archive: md5=+archive-md5+, in opam file: md5=33333333333333333333333333333333 + - archive: md5=+archive-md5+, in opam file: md5=44444444444444444444444444444444 + - archive: md5=+archive-md5+, in opam file: md5=55555555555555555555555555555555 + - archive: md5=+archive-md5+, in opam file: md5=66666666666666666666666666666666 + - archive: md5=+archive-md5+, in opam file: md5=77777777777777777777777777777777 + - archive: md5=+archive-md5+, in opam file: md5=88888888888888888888888888888888 + - archive: md5=+archive-md5+, in opam file: md5=99999999999999999999999999999999 + - archive: md5=+archive-md5+, in opam file: md5=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + - archive: md5=+archive-md5+, in opam file: md5=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + - archive: md5=+archive-md5+, in opam file: md5=cccccccccccccccccccccccccccccccc + - archive: md5=+archive-md5+, in opam file: md5=dddddddddddddddddddddddddddddddd + - archive: md5=+archive-md5+, in opam file: md5=eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + - archive: md5=+archive-md5+, in opam file: md5=ffffffffffffffffffffffffffffffff + - archive: sha256=+archive-sha256+, in opam file: sha256=0123456789abcdeffedcba98765432100123456789abcdeffedbca9876543210 ." error 71: Field 'url.checksum' contains duplicated checksums: "md5: 17 occurences" # Return code 1 # -### opam install clash-with-all-md5s | '[0-9a-z]{32}' -> 'hash' +### opam install clash-with-all-md5s | sed-hash $ARCHIVE_MD5 archive-md5 The following actions will be performed: === install 1 package - install clash-with-all-md5s 666 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] clash-with-all-md5s.666: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+archive-md5+ [ERROR] Failed to get sources of clash-with-all-md5s.666: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -911,35 +911,35 @@ Done. ### sh check-cache.sh MD5: archive, with matching checksum SHA256: archive, with matching checksum -### opam install clash-with-all-md5s | '[0-9a-z]{32,64}' -> 'hash' +### opam install clash-with-all-md5s | sed-hash $ARCHIVE_MD5 archive-md5 The following actions will be performed: === install 1 package - install clash-with-all-md5s 666 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] Conflicting file hashes, or broken or compromised cache! - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (match) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - sha256=hash (MISMATCH) + - md5=00000000000000000000000000000000 (MISMATCH) + - md5=11111111111111111111111111111111 (MISMATCH) + - md5=22222222222222222222222222222222 (MISMATCH) + - md5=33333333333333333333333333333333 (MISMATCH) + - md5=44444444444444444444444444444444 (MISMATCH) + - md5=+archive-md5+ (match) + - md5=55555555555555555555555555555555 (MISMATCH) + - md5=66666666666666666666666666666666 (MISMATCH) + - md5=77777777777777777777777777777777 (MISMATCH) + - md5=88888888888888888888888888888888 (MISMATCH) + - md5=99999999999999999999999999999999 (MISMATCH) + - md5=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa (MISMATCH) + - md5=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb (MISMATCH) + - md5=cccccccccccccccccccccccccccccccc (MISMATCH) + - md5=dddddddddddddddddddddddddddddddd (MISMATCH) + - md5=eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee (MISMATCH) + - md5=ffffffffffffffffffffffffffffffff (MISMATCH) + - sha256=0123456789abcdeffedcba98765432100123456789abcdeffedbca9876543210 (MISMATCH) [ERROR] clash-with-all-md5s.666: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+archive-md5+ [ERROR] Failed to get sources of clash-with-all-md5s.666: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -954,15 +954,15 @@ OpamSolution.Fetch_fail("Checksum mismatch") ### sh check-cache.sh MD5: not found SHA256: archive, with matching checksum -### opam install clash-with-all-md5s --require-checksums | '[0-9a-z]{32}' -> 'hash' +### opam install clash-with-all-md5s --require-checksums | sed-hash $ARCHIVE_MD5 archive-md5 The following actions will be performed: === install 1 package - install clash-with-all-md5s 666 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] clash-with-all-md5s.666: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+archive-md5+ [ERROR] Failed to get sources of clash-with-all-md5s.666: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -974,18 +974,18 @@ OpamSolution.Fetch_fail("Checksum mismatch") +- - No changes have been performed # Return code 40 # -### opam source clash-with-all-md5s | '[0-9a-z]{32}' -> 'hash' +### opam source clash-with-all-md5s | sed-hash $ARCHIVE_MD5 archive-md5 [ERROR] clash-with-all-md5s.666: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+archive-md5+ [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f clash-with-all-md5s.666/hello # Return code 1 # -### opam source clash-with-all-md5s --require-checksums | '[0-9a-z]{32}' -> 'hash' +### opam source clash-with-all-md5s --require-checksums | sed-hash $ARCHIVE_MD5 archive-md5 [ERROR] clash-with-all-md5s.666: Checksum mismatch for file://${BASEDIR}/archive.tgz: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+archive-md5+ [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f clash-with-all-md5s.666/hello @@ -1122,15 +1122,15 @@ Done. MD5: archive, with matching checksum SHA256: archive, with mismatching checksum ### # what happens here is that sha256 is checked first, there is a mismatch on sha256 archive (checking its sha256 & md5), so it is remove, returns file not available, and then it downloads the archive from url -### opam install good-sha256-good-md5 | '[0-9a-z]{32,64}' -> 'hash' +### opam install good-sha256-good-md5 | sed-hash $ARCHIVE_MD5 archive-md5 | sed-hash $ARCHIVE_SHA256 archive-sha256 The following actions will be performed: === install 1 package - install good-sha256-good-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] Conflicting file hashes, or broken or compromised cache! - - sha256=hash (MISMATCH) - - md5=hash (MISMATCH) + - sha256=+archive-sha256+ (MISMATCH) + - md5=+archive-md5+ (MISMATCH) -> retrieved good-sha256-good-md5.1 (file://${BASEDIR}/archive.tgz) -> installed good-sha256-good-md5.1 @@ -1154,15 +1154,15 @@ Done. ### sh check-cache.sh MD5: archive, with mismatching checksum SHA256: archive, with mismatching checksum -### opam install good-sha256-good-md5 | '[0-9a-z]{32,64}' -> 'hash' +### opam install good-sha256-good-md5 | sed-hash $ARCHIVE_MD5 archive-md | sed-hash $ARCHIVE_SHA256 archive-sha2565 The following actions will be performed: === install 1 package - install good-sha256-good-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] Conflicting file hashes, or broken or compromised cache! - - sha256=hash (MISMATCH) - - md5=hash (MISMATCH) + - sha256=+archive-sha2565+ (MISMATCH) + - md5=+archive-md+ (MISMATCH) -> retrieved good-sha256-good-md5.1 (file://${BASEDIR}/archive.tgz) -> installed good-sha256-good-md5.1 @@ -1220,14 +1220,14 @@ Done. ### sh check-cache.sh MD5: link, to sha256 archive SHA256: archive, with mismatching checksum -### opam install good-sha256.1 | '[0-9a-z]{32,64}' -> 'hash' +### opam install good-sha256.1 | sed-hash $ARCHIVE_SHA256 archive-sha256 The following actions will be performed: === install 1 package - install good-sha256 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] Conflicting file hashes, or broken or compromised cache! - - sha256=hash (MISMATCH) + - sha256=+archive-sha256+ (MISMATCH) -> retrieved good-sha256.1 (file://${BASEDIR}/archive.tgz) -> installed good-sha256.1 diff --git a/tests/reftests/download.test b/tests/reftests/download.test index 3069c485f7b..e4886d1fe5a 100644 --- a/tests/reftests/download.test +++ b/tests/reftests/download.test @@ -161,13 +161,13 @@ Clearing cache of downloaded files ### :II:1: local ### :II:1:a: archive ### tar czf arch.tgz REPO/repo +### openssl md5 arch.tgz | '.*= ' -> '' >$ MD5 ### opam-version: "2.0" ### file="REPO/packages/foo/foo.1/opam" basedir=$(printf '%s' "$BASEDIR" | sed 's/\\/\\\\/g') arch=arch.tgz -MD5=$(openssl md5 "$arch" | cut -d' ' -f2) cat >> "$file" << EOF url { src:"$arch" @@ -182,7 +182,7 @@ EOF Now run 'opam upgrade' to apply any package updates. ### opam clean -c Clearing cache of downloaded files -### opam install foo --download-only -vv --debug-level=-1 | grep -v "^+-" | sed-cmd rsync tar | grep -v "state-.*.export" | "md5[/\\].*" -> "md5-dir/" +### opam install foo --download-only -vv --debug-level=-1 | grep -v "^+-" | sed-cmd rsync tar | grep -v "state-.*.export" | sed-hash $MD5 arch-md5 The following actions will be performed: === install 1 package - install foo 1 @@ -192,8 +192,8 @@ SYSTEM rmdir ${BASEDIR}/OPAM/download/.opam-switch/sour SYSTEM mkdir ${OPAMTMP} Processing 1/1: [foo.1: rsync] + rsync "-rLptgoDvc" "--exclude" ".git" "--exclude" "_darcs" "--exclude" ".hg" "--exclude" ".#*" "--exclude" "_opam*" "--exclude" "_build" "--delete" "--delete-excluded" "${BASEDIR}/arch.tgz" "${OPAMTMP}" -SYSTEM mkdir ${BASEDIR}/OPAM/download-cache/md5-dir/ -SYSTEM copy ${OPAMTMP}/arch.tgz -> ${BASEDIR}/OPAM/download-cache/md5-dir/ +SYSTEM mkdir ${BASEDIR}/OPAM/download-cache/md5/pre +SYSTEM copy ${OPAMTMP}/arch.tgz -> ${BASEDIR}/OPAM/download-cache/md5/pre/+arch-md5+ SYSTEM mkdir ${OPAMTMP} Processing 1/1: [foo.1: extract] + tar "xfz" "${OPAMTMP}/arch.tgz" "-C" "${OPAMTMP}" @@ -259,7 +259,7 @@ url { } ### opam clean -c Clearing cache of downloaded files -### opam install baz --download-only -vv --debug-level=-1 | grep -v "^+-" | sed-cmd wget tar | "${OPAMVERSION}" -> "current" | grep -v "state-.*.export" | "md5[/\\].*" -> "md5-dir/" | grep -v "OPAM[/\\]log" +### opam install baz --download-only -vv --debug-level=-1 | grep -v "^+-" | sed-cmd wget tar | "${OPAMVERSION}" -> "current" | grep -v "state-.*.export" | grep -v "OPAM[/\\]log" The following actions will be performed: === install 1 package - install baz 1 @@ -270,8 +270,8 @@ SYSTEM mkdir ${OPAMTMP} Processing 1/1: [baz.1: http] + wget "--header=Accept: */*" "-t" "3" "-O" "${OPAMTMP}/v1.0.0.tar.gz.part" "-U" "opam/current" "--" "https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz" SYSTEM mv ${OPAMTMP}/v1.0.0.tar.gz.part -> ${OPAMTMP}/v1.0.0.tar.gz -SYSTEM mkdir ${BASEDIR}/OPAM/download-cache/md5-dir/ -SYSTEM copy ${OPAMTMP}/v1.0.0.tar.gz -> ${BASEDIR}/OPAM/download-cache/md5-dir/ +SYSTEM mkdir ${BASEDIR}/OPAM/download-cache/md5/c9 +SYSTEM copy ${OPAMTMP}/v1.0.0.tar.gz -> ${BASEDIR}/OPAM/download-cache/md5/c9/c9c157af4229fbb45d3f59f0d6d75dbe SYSTEM mkdir ${OPAMTMP} Processing 1/1: [baz.1: extract] + tar "xfz" "${OPAMTMP}/v1.0.0.tar.gz" "-C" "${OPAMTMP}" diff --git a/tests/reftests/extrasource.test b/tests/reftests/extrasource.test index 5824cf25b9f..f0378363e01 100644 --- a/tests/reftests/extrasource.test +++ b/tests/reftests/extrasource.test @@ -575,15 +575,15 @@ Clearing cache of downloaded files /multiple-md5.1: Errors. error 72: Field 'extra-sources' contains duplicated checksums: "i-am-a-patch have md5: 2 occurences" # Return code 1 # -### opam install multiple-md5 | '[0-9a-z]{32}' -> 'hash' +### opam install multiple-md5 | sed-hash $PATCH_MD5 patch-md5 The following actions will be performed: === install 1 package - install multiple-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] multiple-md5.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+patch-md5+ [ERROR] Failed to get extra source "i-am-a-patch" of multiple-md5.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -595,15 +595,15 @@ OpamSolution.Fetch_fail("Checksum mismatch") +- - No changes have been performed # Return code 40 # -### opam install multiple-md5 --require-checksums | '[0-9a-z]{32}' -> 'hash' +### opam install multiple-md5 --require-checksums | sed-hash $PATCH_MD5 patch-md5 The following actions will be performed: === install 1 package - install multiple-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] multiple-md5.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+patch-md5+ [ERROR] Failed to get extra source "i-am-a-patch" of multiple-md5.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -615,18 +615,18 @@ OpamSolution.Fetch_fail("Checksum mismatch") +- - No changes have been performed # Return code 40 # -### opam source multiple-md5 | '[0-9a-z]{32}' -> 'hash' +### opam source multiple-md5 | sed-hash $PATCH_MD5 patch-md5 [ERROR] multiple-md5.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+patch-md5+ [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f multiple-md5.1/i-am-a-patch # Return code 1 # -### opam source multiple-md5 --require-checksums | '[0-9a-z]{32}' -> 'hash' +### opam source multiple-md5 --require-checksums | sed-hash $PATCH_MD5 patch-md5 [ERROR] multiple-md5.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+patch-md5+ [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f multiple-md5.1/i-am-a-patch @@ -638,15 +638,15 @@ Clearing cache of downloaded files /bad-md5.1: Passed. ### opam lint --package bad-md5 --check-upstream /bad-md5.1: Passed. -### opam install bad-md5 | '[0-9a-z]{32}' -> 'hash' +### opam install bad-md5 | sed-hash $PATCH_MD5 patch-md5 The following actions will be performed: === install 1 package - install bad-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] bad-md5.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+patch-md5+ [ERROR] Failed to get extra source "i-am-a-patch" of bad-md5.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -658,15 +658,15 @@ OpamSolution.Fetch_fail("Checksum mismatch") +- - No changes have been performed # Return code 40 # -### opam install bad-md5 --require-checksums | '[0-9a-z]{32}' -> 'hash' +### opam install bad-md5 --require-checksums The following actions will be performed: === install 1 package - install bad-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] bad-md5.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=cf8c4c20658f6c3efea4eb2c6b1b34d7 [ERROR] Failed to get extra source "i-am-a-patch" of bad-md5.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -678,18 +678,18 @@ OpamSolution.Fetch_fail("Checksum mismatch") +- - No changes have been performed # Return code 40 # -### opam source bad-md5 | '[0-9a-z]{32}' -> 'hash' +### opam source bad-md5 | sed-hash $PATCH_MD5 patch-md5 [ERROR] bad-md5.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+patch-md5+ [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f bad-md5.1/i-am-a-patch # Return code 1 # -### opam source bad-md5 --require-checksums | '[0-9a-z]{32}' -> 'hash' +### opam source bad-md5 --require-checksums | sed-hash $PATCH_MD5 patch-md5 | sed-hash $PATCH_SHA256 patch-sha256 [ERROR] bad-md5.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+patch-md5+ [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f bad-md5.1/i-am-a-patch @@ -714,19 +714,19 @@ Done. ### sh check-cache.sh MD5: patch, with matching checksum SHA256: not found -### opam install good-md5-bad-sha256 | '[0-9a-z]{32,64}' -> 'hash' +### opam install good-md5-bad-sha256 | sed-hash $PATCH_MD5 patch-md5 | sed-hash $PATCH_SHA256 patch-sha256 The following actions will be performed: === install 1 package - install good-md5-bad-sha256 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] Conflicting file hashes, or broken or compromised cache! - - md5=hash (match) - - sha256=hash (MISMATCH) + - md5=+patch-md5+ (match) + - sha256=0000000000000000000000000000000000000000000000000000000000000000 (MISMATCH) [ERROR] good-md5-bad-sha256.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected sha256=hash - got sha256=hash + expected sha256=0000000000000000000000000000000000000000000000000000000000000000 + got sha256=+patch-sha256+ [ERROR] Failed to get extra source "i-am-a-patch" of good-md5-bad-sha256.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -764,19 +764,19 @@ Done. ### sh check-cache.sh MD5: patch, with matching checksum SHA256: patch, with matching checksum -### opam install good-md5-bad-sha256 | '[0-9a-z]{32,64}' -> 'hash' +### opam install good-md5-bad-sha256 | sed-hash $PATCH_MD5 patch-md5 | sed-hash $PATCH_SHA256 patch-sha256 The following actions will be performed: === install 1 package - install good-md5-bad-sha256 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] Conflicting file hashes, or broken or compromised cache! - - md5=hash (match) - - sha256=hash (MISMATCH) + - md5=+patch-md5+ (match) + - sha256=0000000000000000000000000000000000000000000000000000000000000000 (MISMATCH) [ERROR] good-md5-bad-sha256.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected sha256=hash - got sha256=hash + expected sha256=0000000000000000000000000000000000000000000000000000000000000000 + got sha256=+patch-sha256+ [ERROR] Failed to get extra source "i-am-a-patch" of good-md5-bad-sha256.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -791,15 +791,15 @@ OpamSolution.Fetch_fail("Checksum mismatch") ### sh check-cache.sh MD5: not found SHA256: patch, with matching checksum -### opam install good-md5-bad-sha256 --require-checksums | '[0-9a-z]{32,64}' -> 'hash' +### opam install good-md5-bad-sha256 --require-checksums | sed-hash $PATCH_SHA256 patch-sha256 The following actions will be performed: === install 1 package - install good-md5-bad-sha256 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] good-md5-bad-sha256.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected sha256=hash - got sha256=hash + expected sha256=0000000000000000000000000000000000000000000000000000000000000000 + got sha256=+patch-sha256+ [ERROR] Failed to get extra source "i-am-a-patch" of good-md5-bad-sha256.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -811,18 +811,18 @@ OpamSolution.Fetch_fail("Checksum mismatch") +- - No changes have been performed # Return code 40 # -### opam source good-md5-bad-sha256 | '[0-9a-z]{64}' -> 'md5' +### opam source good-md5-bad-sha256 [ERROR] good-md5-bad-sha256.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected sha256=md5 - got sha256=md5 + expected sha256=0000000000000000000000000000000000000000000000000000000000000000 + got sha256=c00eac22da21925d2077b66a29dc911cddc739b1b0d0909a6cb192344fba55ab [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f good-md5-bad-sha256.1/i-am-a-patch # Return code 1 # -### opam source good-md5-bad-sha256 --require-checksums | '[0-9a-z]{64}' -> 'md5' +### opam source good-md5-bad-sha256 --require-checksums [ERROR] good-md5-bad-sha256.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected sha256=md5 - got sha256=md5 + expected sha256=0000000000000000000000000000000000000000000000000000000000000000 + got sha256=c00eac22da21925d2077b66a29dc911cddc739b1b0d0909a6cb192344fba55ab [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f good-md5-bad-sha256.1/i-am-a-patch @@ -834,15 +834,15 @@ Clearing cache of downloaded files /good-sha256-bad-md5.1: Passed. ### opam lint --package good-sha256-bad-md5 --check-upstream /good-sha256-bad-md5.1: Passed. -### opam install good-sha256-bad-md5 | '[0-9a-z]{32,64}' -> 'hash' +### opam install good-sha256-bad-md5 | sed-hash $PATCH_MD5 patch-md5 The following actions will be performed: === install 1 package - install good-sha256-bad-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] good-sha256-bad-md5.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+patch-md5+ [ERROR] Failed to get extra source "i-am-a-patch" of good-sha256-bad-md5.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -854,15 +854,15 @@ OpamSolution.Fetch_fail("Checksum mismatch") +- - No changes have been performed # Return code 40 # -### opam install good-sha256-bad-md5 --require-checksums | '[0-9a-z]{32,64}' -> 'hash' +### opam install good-sha256-bad-md5 --require-checksums The following actions will be performed: === install 1 package - install good-sha256-bad-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] good-sha256-bad-md5.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=cf8c4c20658f6c3efea4eb2c6b1b34d7 [ERROR] Failed to get extra source "i-am-a-patch" of good-sha256-bad-md5.1: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -874,18 +874,18 @@ OpamSolution.Fetch_fail("Checksum mismatch") +- - No changes have been performed # Return code 40 # -### opam source good-sha256-bad-md5 | '[0-9a-z]{32}' -> 'hash' +### opam source good-sha256-bad-md5 [ERROR] good-sha256-bad-md5.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=cf8c4c20658f6c3efea4eb2c6b1b34d7 [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f good-sha256-bad-md5.1/i-am-a-patch # Return code 1 # -### opam source good-sha256-bad-md5 --require-checksums | '[0-9a-z]{32}' -> 'hash' +### opam source good-sha256-bad-md5 --require-checksums [ERROR] good-sha256-bad-md5.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=cf8c4c20658f6c3efea4eb2c6b1b34d7 [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f good-sha256-bad-md5.1/i-am-a-patch @@ -901,15 +901,15 @@ Clearing cache of downloaded files /clash-with-all-md5s.666: Errors. error 72: Field 'extra-sources' contains duplicated checksums: "i-am-a-patch have md5: 17 occurences" # Return code 1 # -### opam install clash-with-all-md5s | '[0-9a-z]{32}' -> 'hash' +### opam install clash-with-all-md5s | sed-hash $PATCH_MD5 patch-md5 The following actions will be performed: === install 1 package - install clash-with-all-md5s 666 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] clash-with-all-md5s.666/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+patch-md5+ [ERROR] Failed to get extra source "i-am-a-patch" of clash-with-all-md5s.666: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -947,35 +947,35 @@ Done. ### sh check-cache.sh MD5: patch, with matching checksum SHA256: patch, with matching checksum -### opam install clash-with-all-md5s | '[0-9a-z]{32}' -> 'hash' +### opam install clash-with-all-md5s | sed-hash $PATCH_MD5 patch-md5 The following actions will be performed: === install 1 package - install clash-with-all-md5s 666 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] Conflicting file hashes, or broken or compromised cache! - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (match) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - md5=hash (MISMATCH) - - sha256=hash0123456789abcdeffedbca9876543210 (MISMATCH) + - md5=00000000000000000000000000000000 (MISMATCH) + - md5=11111111111111111111111111111111 (MISMATCH) + - md5=22222222222222222222222222222222 (MISMATCH) + - md5=33333333333333333333333333333333 (MISMATCH) + - md5=44444444444444444444444444444444 (MISMATCH) + - md5=+patch-md5+ (match) + - md5=55555555555555555555555555555555 (MISMATCH) + - md5=66666666666666666666666666666666 (MISMATCH) + - md5=77777777777777777777777777777777 (MISMATCH) + - md5=88888888888888888888888888888888 (MISMATCH) + - md5=99999999999999999999999999999999 (MISMATCH) + - md5=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa (MISMATCH) + - md5=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb (MISMATCH) + - md5=cccccccccccccccccccccccccccccccc (MISMATCH) + - md5=dddddddddddddddddddddddddddddddd (MISMATCH) + - md5=eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee (MISMATCH) + - md5=ffffffffffffffffffffffffffffffff (MISMATCH) + - sha256=0123456789abcdeffedcba98765432100123456789abcdeffedbca9876543210 (MISMATCH) [ERROR] clash-with-all-md5s.666/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+patch-md5+ [ERROR] Failed to get extra source "i-am-a-patch" of clash-with-all-md5s.666: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -990,15 +990,15 @@ OpamSolution.Fetch_fail("Checksum mismatch") ### sh check-cache.sh MD5: not found SHA256: patch, with matching checksum -### opam install clash-with-all-md5s --require-checksums | '[0-9a-z]{32}' -> 'hash' +### opam install clash-with-all-md5s --require-checksum | sed-hash $PATCH_MD5 patch-md5s The following actions will be performed: === install 1 package - install clash-with-all-md5s 666 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] clash-with-all-md5s.666/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+patch-md5s+ [ERROR] Failed to get extra source "i-am-a-patch" of clash-with-all-md5s.666: Checksum mismatch OpamSolution.Fetch_fail("Checksum mismatch") @@ -1010,18 +1010,18 @@ OpamSolution.Fetch_fail("Checksum mismatch") +- - No changes have been performed # Return code 40 # -### opam source clash-with-all-md5s | '[0-9a-z]{32}' -> 'hash' +### opam source clash-with-all-md5s | sed-hash $PATCH_MD5 patch-md5 [ERROR] clash-with-all-md5s.666/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+patch-md5+ [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f clash-with-all-md5s.666/i-am-a-patch # Return code 1 # -### opam source clash-with-all-md5s --require-checksums | '[0-9a-z]{32}' -> 'hash' +### opam source clash-with-all-md5s --require-checksum | sed-hash $PATCH_MD5 patch-md5s [ERROR] clash-with-all-md5s.666/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch: - expected md5=hash - got md5=hash + expected md5=00000000000000000000000000000000 + got md5=+patch-md5s+ [ERROR] Download failed: Checksum mismatch # Return code 40 # ### test -f clash-with-all-md5s.666/i-am-a-patch @@ -1213,15 +1213,15 @@ Done. ### sh check-cache.sh MD5: patch, with mismatching checksum SHA256: link, to md5 patch -### opam install good-sha256-good-md5 | '[0-9a-z]{32,64}' -> 'hash' +### opam install good-sha256-good-md5 | sed-hash $PATCH_MD5 patch-md5 | sed-hash $PATCH_SHA256 patch-sha256 The following actions will be performed: === install 1 package - install good-sha256-good-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] Conflicting file hashes, or broken or compromised cache! - - sha256=hash (MISMATCH) - - md5=hash (MISMATCH) + - sha256=+patch-sha256+ (MISMATCH) + - md5=+patch-md5+ (MISMATCH) -> retrieved good-sha256-good-md5.1 (file://${BASEDIR}/p.patch) -> installed good-sha256-good-md5.1 @@ -1247,15 +1247,15 @@ Done. ### sh check-cache.sh MD5: patch, with matching checksum SHA256: patch, with mismatching checksum -### opam install good-sha256-good-md5 | '[0-9a-z]{32,64}' -> 'hash' +### opam install good-sha256-good-md5 | sed-hash $PATCH_MD5 patch-md5 | sed-hash $PATCH_SHA256 patch-sha256 The following actions will be performed: === install 1 package - install good-sha256-good-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] Conflicting file hashes, or broken or compromised cache! - - sha256=hash (MISMATCH) - - md5=hash (MISMATCH) + - sha256=+patch-sha256+ (MISMATCH) + - md5=+patch-md5+ (MISMATCH) -> retrieved good-sha256-good-md5.1 (file://${BASEDIR}/p.patch) -> installed good-sha256-good-md5.1 @@ -1278,15 +1278,15 @@ Done. ### sh check-cache.sh MD5: patch, with mismatching checksum SHA256: patch, with mismatching checksum -### opam install good-sha256-good-md5 | '[0-9a-z]{32,64}' -> 'hash' +### opam install good-sha256-good-md5 | sed-hash $PATCH_MD5 patch-md5 | sed-hash $PATCH_SHA256 patch-sha256 The following actions will be performed: === install 1 package - install good-sha256-good-md5 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] Conflicting file hashes, or broken or compromised cache! - - sha256=hash (MISMATCH) - - md5=hash (MISMATCH) + - sha256=+patch-sha256+ (MISMATCH) + - md5=+patch-md5+ (MISMATCH) -> retrieved good-sha256-good-md5.1 (file://${BASEDIR}/p.patch) -> installed good-sha256-good-md5.1 diff --git a/tests/reftests/hooks-variables.test b/tests/reftests/hooks-variables.test index c5bc374cdb8..595d54195f2 100644 --- a/tests/reftests/hooks-variables.test +++ b/tests/reftests/hooks-variables.test @@ -59,7 +59,6 @@ etc: [ ] ### tar czf archive.tgz printer.sh i-am-a-repo-pkg.install ### openssl md5 archive.tgz | '.*= ' -> '' >$ MD5 -### sh -c "echo '$MD5' | cut -c 1-2" >$ PRE_MD5 ### basedir=$(printf '%s' "$BASEDIR" | sed 's/\\/\\\\/g') cat << EOF >> REPO/packages/i-am-a-repo-pkg/i-am-a-repo-pkg.1/opam @@ -107,7 +106,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -> installed dep.1 Done. -### opam install i-am-a-repo-pkg -vv | "${OPAMVERSION}" -> "++current++" | '[0-9a-z]{64}' -> '+hash+' | $MD5 -> +archive-hash+ | sed-cmd bash tar rsync | etc -> etc +### opam install i-am-a-repo-pkg -vv | "${OPAMVERSION}" -> "++current++" | '[0-9a-z]{64}' -> '+hash+' | sed-hash $MD5 archive-hash | sed-cmd bash tar rsync | etc -> etc The following actions will be performed: === install 1 package - install i-am-a-repo-pkg 1 @@ -287,7 +286,7 @@ Processing 3/3: [i-am-a-repo-pkg: bash ...post-installing...] - installed-files:etc etc/i-am-a-repo-pkg etc/i-am-a-repo-pkg/printer -> installed i-am-a-repo-pkg.1 Done. -### opam remove i-am-a-repo-pkg -vv | "${OPAMVERSION}" -> "++current++" | '[0-9a-z]{64}' -> '+hash+' | '${PRE_MD5}[^[:alnum:]].?${MD5}' -> pre/+archive-hash+ | $MD5 -> +archive-hash+ | sed-cmd bash tar +### opam remove i-am-a-repo-pkg -vv | "${OPAMVERSION}" -> "++current++" | '[0-9a-z]{64}' -> '+hash+' | sed-hash $MD5 archive-hash | sed-cmd bash tar The following actions will be performed: === remove 1 package - remove i-am-a-repo-pkg 1 @@ -411,7 +410,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -> installed dep.1 Done. -### opam install i-am-a-repo-pkg -vv | "${OPAMVERSION}" -> "++current++" | '[0-9a-z]{64}' -> '+hash+' | '${PRE_MD5}[^[:alnum:]].?${MD5}' -> pre/+archive-hash+ | $MD5 -> +archive-hash+ | sed-cmd bash tar | etc -> etc +### opam install i-am-a-repo-pkg -vv | "${OPAMVERSION}" -> "++current++" | '[0-9a-z]{64}' -> '+hash+' | sed-hash $MD5 archive-hash | sed-cmd bash tar | etc -> etc The following actions will be performed: === install 1 package - install i-am-a-repo-pkg 1 @@ -588,7 +587,7 @@ Processing 3/3: [i-am-a-repo-pkg: bash ...post-installing...] - installed-files:etc etc/i-am-a-repo-pkg etc/i-am-a-repo-pkg/printer -> installed i-am-a-repo-pkg.1 Done. -### opam remove i-am-a-repo-pkg -vv | "${OPAMVERSION}" -> "++current++" | '[0-9a-z]{64}' -> '+hash+' | '${PRE_MD5}[^[:alnum:]].?${MD5}' -> pre/+archive-hash+ | $MD5 -> +archive-hash+ | sed-cmd bash tar +### opam remove i-am-a-repo-pkg -vv | "${OPAMVERSION}" -> "++current++" | '[0-9a-z]{64}' -> '+hash+' | sed-hash $MD5 archive-hash | sed-cmd bash tar The following actions will be performed: === remove 1 package - remove i-am-a-repo-pkg 1 @@ -744,7 +743,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -> installed dep.1 Done. -### opam install i-am-a-repo-pkg | "${OPAMVERSION}" -> "++current++" | '[0-9a-z]{64}' -> '+hash+' | '${PRE_MD5}[^[:alnum:]].?${MD5}' -> pre/+archive-hash+ | $MD5 -> +archive-hash+ | sed-cmd bash tar | etc -> etc +### opam install i-am-a-repo-pkg | "${OPAMVERSION}" -> "++current++" | '[0-9a-z]{64}' -> '+hash+' | sed-hash $MD5 archive-hash | sed-cmd bash tar | etc -> etc The following actions will be performed: === install 1 package - install i-am-a-repo-pkg 1 @@ -783,7 +782,7 @@ Done. success:true failure:false installed-files: -### opam remove i-am-a-repo-pkg -vv | "${OPAMVERSION}" -> "++current++" | '[0-9a-z]{64}' -> '+hash+' | '${PRE_MD5}[^[:alnum:]].?${MD5}' -> pre/+archive-hash+ | $MD5 -> +archive-hash+ | sed-cmd bash tar +### opam remove i-am-a-repo-pkg -vv | "${OPAMVERSION}" -> "++current++" | '[0-9a-z]{64}' -> '+hash+' | sed-hash $MD5 archive-hash | sed-cmd bash tar The following actions will be performed: === remove 1 package - remove i-am-a-repo-pkg 1 diff --git a/tests/reftests/hooks-variables.unix.test b/tests/reftests/hooks-variables.unix.test index 9eaf633f06d..2d9ad77d57f 100644 --- a/tests/reftests/hooks-variables.unix.test +++ b/tests/reftests/hooks-variables.unix.test @@ -16,7 +16,6 @@ install: [ "a-install-command" ] remove: [ "a-remove-command" ] ### tar czf archive.tgz printer.sh ### openssl md5 archive.tgz | '.*= ' -> '' >$ MD5 -### sh -c "echo '$MD5' | cut -c 1-2" >$ PRE_MD5 ### basedir=$(printf '%s' "$BASEDIR" | sed 's/\\/\\\\/g') cat << EOF >> REPO/packages/i-am-a-repo-pkg/i-am-a-repo-pkg.1/opam @@ -57,7 +56,7 @@ Set to '[ "bash" "%{hooks}%/printer.sh" "...post-installing..." "exe:%{exe}%" ]' ### opam option --global 'post-remove-commands=[ "bash" "%{hooks}%/printer.sh" "...post-removing..." "exe:%{exe}%" ]' Set to '[ "bash" "%{hooks}%/printer.sh" "...post-removing..." "exe:%{exe}%" ]' the field post-remove-commands in global configuration ### opam switch create global-wrappers --empty -### opam install i-am-a-repo-pkg | $MD5 -> +archive-hash+ | sed-cmd bash tar rsync +### opam install i-am-a-repo-pkg | sed-hash $MD5 archive-hash | sed-cmd bash tar rsync The following actions will be performed: === install 1 package - install i-am-a-repo-pkg 1 @@ -99,7 +98,7 @@ Processing 3/3: [i-am-a-repo-pkg: bash ...post-installing...] - exe: -> installed i-am-a-repo-pkg.1 Done. -### opam remove i-am-a-repo-pkg | $MD5 -> +archive-hash+ | '/md5/$PRE_MD5/' -> '/md5/pre/' | sed-cmd bash tar +### opam remove i-am-a-repo-pkg | sed-hash $MD5 archive-hash | sed-cmd bash tar The following actions will be performed: === remove 1 package - remove i-am-a-repo-pkg 1 @@ -146,7 +145,7 @@ Set to '[ "bash" "%{hooks}%/printer.sh" "...post-building..." "exe:%{exe}%" ]' t Set to '[ "bash" "%{hooks}%/printer.sh" "...post-installing..." "exe:%{exe}%" ]' the field post-install-commands in switch switch-wrappers ### opam option --switch switch-wrappers 'post-remove-commands=[ "bash" "%{hooks}%/printer.sh" "...post-removing..." "exe:%{exe}%" ]' Set to '[ "bash" "%{hooks}%/printer.sh" "...post-removing..." "exe:%{exe}%" ]' the field post-remove-commands in switch switch-wrappers -### opam install i-am-a-repo-pkg | $MD5 -> +archive-hash+ | '/md5/$PRE_MD5/' -> '/md5/pre/' | sed-cmd bash tar +### opam install i-am-a-repo-pkg | sed-hash $MD5 archive-hash | sed-cmd bash tar The following actions will be performed: === install 1 package - install i-am-a-repo-pkg 1 @@ -184,7 +183,7 @@ Processing 3/3: [i-am-a-repo-pkg: bash ...post-installing...] - exe: -> installed i-am-a-repo-pkg.1 Done. -### opam remove i-am-a-repo-pkg | $MD5 -> +archive-hash+ | '/md5/$PRE_MD5/' -> '/md5/pre/' | sed-cmd bash tar +### opam remove i-am-a-repo-pkg | sed-hash $MD5 archive-hash | sed-cmd bash tar The following actions will be performed: === remove 1 package - remove i-am-a-repo-pkg 1 @@ -237,7 +236,7 @@ EOF Processing: [default: loading data] Now run 'opam upgrade' to apply any package updates. ### opam switch create pkg-from-repo --empty -### opam install i-am-a-repo-pkg | $MD5 -> +archive-hash+ | '/md5/$PRE_MD5/' -> '/md5/pre/' | sed-cmd bash tar +### opam install i-am-a-repo-pkg | sed-hash $MD5 archive-hash | sed-cmd bash tar The following actions will be performed: === install 1 package - install i-am-a-repo-pkg 1 @@ -261,7 +260,7 @@ Done. <><> i-am-a-repo-pkg.1 installed successfully <><><><><><><><><><><><><><><><><> => ...A last message... exe: -### opam remove i-am-a-repo-pkg | $MD5 -> +archive-hash+ | '/md5/$PRE_MD5/' -> '/md5/pre/' | sed-cmd bash tar +### opam remove i-am-a-repo-pkg | sed-hash $MD5 archive-hash | sed-cmd bash tar The following actions will be performed: === remove 1 package - remove i-am-a-repo-pkg 1 diff --git a/tests/reftests/hooks-variables.win32.test b/tests/reftests/hooks-variables.win32.test index 41350868e5f..fdb97b66192 100644 --- a/tests/reftests/hooks-variables.win32.test +++ b/tests/reftests/hooks-variables.win32.test @@ -16,7 +16,6 @@ install: [ "a-install-command" ] remove: [ "a-remove-command" ] ### tar czf archive.tgz printer.sh ### openssl md5 archive.tgz | '.*= ' -> '' >$ MD5 -### sh -c "echo '$MD5' | cut -c 1-2" >$ PRE_MD5 ### basedir=$(printf '%s' "$BASEDIR" | sed 's/\\/\\\\/g') cat << EOF >> REPO/packages/i-am-a-repo-pkg/i-am-a-repo-pkg.1/opam @@ -57,7 +56,7 @@ Set to '[ "bash" "%{hooks}%/printer.sh" "...post-installing..." "exe:%{exe}%" ]' ### opam option --global 'post-remove-commands=[ "bash" "%{hooks}%/printer.sh" "...post-removing..." "exe:%{exe}%" ]' Set to '[ "bash" "%{hooks}%/printer.sh" "...post-removing..." "exe:%{exe}%" ]' the field post-remove-commands in global configuration ### opam switch create global-wrappers --empty -### opam install i-am-a-repo-pkg | sed-cmd bash tar rsync +### opam install i-am-a-repo-pkg | sed-hash $MD5 archive-hash | sed-cmd bash tar rsync The following actions will be performed: === install 1 package - install i-am-a-repo-pkg 1 @@ -99,7 +98,7 @@ Processing 3/3: [i-am-a-repo-pkg: bash ...post-installing...] - exe:.exe -> installed i-am-a-repo-pkg.1 Done. -### opam remove i-am-a-repo-pkg | '${PRE_MD5}[^[:alnum:]].?${MD5}' -> pre/+archive-hash+ | sed-cmd bash tar +### opam remove i-am-a-repo-pkg | sed-hash $MD5 archive-hash | sed-cmd bash tar The following actions will be performed: === remove 1 package - remove i-am-a-repo-pkg 1 @@ -146,7 +145,7 @@ Set to '[ "bash" "%{hooks}%/printer.sh" "...post-building..." "exe:%{exe}%" ]' t Set to '[ "bash" "%{hooks}%/printer.sh" "...post-installing..." "exe:%{exe}%" ]' the field post-install-commands in switch switch-wrappers ### opam option --switch switch-wrappers 'post-remove-commands=[ "bash" "%{hooks}%/printer.sh" "...post-removing..." "exe:%{exe}%" ]' Set to '[ "bash" "%{hooks}%/printer.sh" "...post-removing..." "exe:%{exe}%" ]' the field post-remove-commands in switch switch-wrappers -### opam install i-am-a-repo-pkg | '${PRE_MD5}[^[:alnum:]].?${MD5}' -> pre/+archive-hash+ | sed-cmd bash tar +### opam install i-am-a-repo-pkg | sed-hash $MD5 archive-hash | sed-cmd bash tar The following actions will be performed: === install 1 package - install i-am-a-repo-pkg 1 @@ -184,7 +183,7 @@ Processing 3/3: [i-am-a-repo-pkg: bash ...post-installing...] - exe:.exe -> installed i-am-a-repo-pkg.1 Done. -### opam remove i-am-a-repo-pkg | '${PRE_MD5}[^[:alnum:]].?${MD5}' -> pre/+archive-hash+ | sed-cmd bash tar +### opam remove i-am-a-repo-pkg | sed-hash $MD5 archive-hash | sed-cmd bash tar The following actions will be performed: === remove 1 package - remove i-am-a-repo-pkg 1 @@ -237,7 +236,7 @@ EOF Processing: [default: loading data] Now run 'opam upgrade' to apply any package updates. ### opam switch create pkg-from-repo --empty -### opam install i-am-a-repo-pkg | '${PRE_MD5}[^[:alnum:]].?${MD5}' -> pre/+archive-hash+ | sed-cmd bash tar +### opam install i-am-a-repo-pkg | sed-hash $MD5 archive-hash | sed-cmd bash tar The following actions will be performed: === install 1 package - install i-am-a-repo-pkg 1 @@ -261,7 +260,7 @@ Done. <><> i-am-a-repo-pkg.1 installed successfully <><><><><><><><><><><><><><><><><> => ...A last message... exe:.exe -### opam remove i-am-a-repo-pkg | '${PRE_MD5}[^[:alnum:]].?${MD5}' -> pre/+archive-hash+ | sed-cmd bash tar +### opam remove i-am-a-repo-pkg | sed-hash $MD5 archive-hash | sed-cmd bash tar The following actions will be performed: === remove 1 package - remove i-am-a-repo-pkg 1 diff --git a/tests/reftests/opam-repo-ci.test b/tests/reftests/opam-repo-ci.test index 37c2ff6a80c..02506f68be0 100644 --- a/tests/reftests/opam-repo-ci.test +++ b/tests/reftests/opam-repo-ci.test @@ -52,7 +52,7 @@ main is now pinned to version 1 ### # emulate '(cache (opam-archives (target /home/opam/.opam/download-cache)))' ### mkdir -p OPAM/download-cache/md5/$PRE_MD5 ### cp archive.tgz OPAM/download-cache/md5/$PRE_MD5/$MD5 -### opam reinstall main.1 | sed-cmd tar | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash +### opam reinstall main.1 | sed-cmd tar | sed-hash $MD5 arch-md5 main.1 is not installed. Install it? [Y/n] y The following actions will be performed: === install 2 packages @@ -64,7 +64,7 @@ Processing 2/6: [main.1: extract] Processing 3/6: [main.1: extract] -> installed dep.1 Processing 4/6: [main.1: extract] -+ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/hash" "-C" "${OPAMTMP}" ++ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/+arch-md5+" "-C" "${OPAMTMP}" -> retrieved main.1 (cached) -> installed main.1 Done. @@ -85,7 +85,7 @@ The following actions will be performed: Done. ### # Third reinstall ### # no change in source on cache archive -### opam reinstall main.1 --with-test -vv | sed-cmd rsync tar | "${PRE_MD5}[^[:alnum:]].?${MD5}" -> pre/hash +### opam reinstall main.1 --with-test -vv | sed-cmd rsync tar The following actions will be performed: === recompile 1 package - recompile main 1 (pinned) diff --git a/tests/reftests/readme.md b/tests/reftests/readme.md index dc7ff6c52ae..2a8baeb9ba9 100644 --- a/tests/reftests/readme.md +++ b/tests/reftests/readme.md @@ -64,6 +64,7 @@ output... * `| unordered` compares lines without considering their ordering * `| sort` sorts output * `| sed-cmd command` replaces full path resolved command by `command` + * `| sed-hash [name]` replaces HASH (or hash contained in $VAR) by `+name+` or `+hash+` if unspecified * variables from command outputs: `cmd args >$ VAR` - additional commands * `opam-cat file`: prints a normalised opam file diff --git a/tests/reftests/reftests.test b/tests/reftests/reftests.test index e27c07ea452..a7ca8edf3e6 100644 --- a/tests/reftests/reftests.test +++ b/tests/reftests/reftests.test @@ -707,6 +707,108 @@ Something smtg else Something smtg else Something smtg else Something smtg else +### :IV:7: sed-hash +### + - archive: md5=f75b8179e4bbe7e2b4a074dcef62de95, in opam file: md5=f75b8179e4bbe7e2b4a074dcef62de95 + - archive: sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c, in opam file: sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c + - archive: sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c, in opam file: sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c ++ bash "${BASEDIR}/OPAM/opam-init/hooks/printer.sh" "...building..." "opam-version:++current++" "switch:global-wrappers" "jobs:2" "root:${BASEDIR}/OPAM" "make:make" "name:i-am-a-repo-pkg" "version:1" "depends:dep.1" "installed:false" "enable:" "pinned:false" "bin:${BASEDIR}/OPAM/global-wrappers/bin" "sbin:${BASEDIR}/OPAM/global-wrappers/sbin" "lib:${BASEDIR}/OPAM/global-wrappers/lib" "man:${BASEDIR}/OPAM/global-wrappers/man" "doc:${BASEDIR}/OPAM/global-wrappers/doc" "share:${BASEDIR}/OPAM/global-wrappers/share" "etc:${BASEDIR}/OPAM/global-wrappers/etc" "build:${BASEDIR}/OPAM/global-wrappers/.opam-switch/build/i-am-a-repo-pkg.1" "hash:md5=f75b8179e4bbe7e2b4a074dcef62de95" "dev:false" "build-id:+hash+" "opamfile:${OPAMTMP}/opam" "installed-files:" "a-build-command" (CWD=${BASEDIR}/OPAM/global-wrappers/.opam-switch/build/i-am-a-repo-pkg.1) +"eta.installl" "md5=f75b8179e4bbe7e2b4a074dcef62de95" + expected md5=f75b8179e4bbe7e2b4a074dcef62de95 + expected sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c +extra-files: [["bad-md5" "md5=f75b8179e4bbe7e2b4a074dcef62de95"] ["bad-sha" "sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c"] ["good-md5" "md5=f75b8179e4bbe7e2b4a074dcef62de95"] ["good-sha" "sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c"] ["missing-hash" "md5=f75b8179e4bbe7e2b4a074dcef62de95"]] +extra-files: [["bad-md5" "sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c"] ["bad-sha" "sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c"] ["good-md5" "sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c"] ["good-sha" "sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c"] ["missing-hash" "sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c"]] +extra-files: ["missing-hash" "md5=f75b8179e4bbe7e2b4a074dcef62de95"] + got md5=f75b8179e4bbe7e2b4a074dcef62de95 + got sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c + hash:md5=f75b8179e4bbe7e2b4a074dcef62de95 +- hash:md5=f75b8179e4bbe7e2b4a074dcef62de95 + - md5=f75b8179e4bbe7e2b4a074dcef62de95 (match) + - md5=11111111111111111111111111111111 (MISMATCH) +"qux.installl" "md5=f75b8179e4bbe7e2b4a074dcef62de95" + - sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c (MISMATCH) + - sha512=a31cffeeaf410435d5b802e87c7f4b17ec8f1ac433f0ed2366989cc7e26f75f1ec76e0f9a031aa8622e2e27e7b1773d2fa63c387191fa3ed6658e652fb15e645 (MISMATCH) +SYSTEM copy ${OPAMTMP}/archive.tgz -> ${BASEDIR}/OPAM/download-cache/md5/f7/f75b8179e4bbe7e2b4a074dcef62de95 +SYSTEM mkdir ${BASEDIR}/OPAM/download-cache/md5/f7 ++ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/f7/f75b8179e4bbe7e2b4a074dcef62de95" "-C" "${OPAMTMP}" +url.checksum: md5=f75b8179e4bbe7e2b4a074dcef62de95 +url.checksum: md5=f75b8179e4bbe7e2b4a074dcef62de95, sha512=a31cffeeaf410435d5b802e87c7f4b17ec8f1ac433f0ed2366989cc7e26f75f1ec76e0f9a031aa8622e2e27e7b1773d2fa63c387191fa3ed6658e652fb15e645 +url.checksum: md5=f75b8179e4bbe7e2b4a074dcef62de95, sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c +url.checksum: md5=f75b8179e4bbe7e2b4a074dcef62de95, sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c, sha512=a31cffeeaf410435d5b802e87c7f4b17ec8f1ac433f0ed2366989cc7e26f75f1ec76e0f9a031aa8622e2e27e7b1773d2fa63c387191fa3ed6658e652fb15e645 +url.checksum: sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c +url.checksum: sha256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c, md5=f75b8179e4bbe7e2b4a074dcef62de95, sha512=a31cffeeaf410435d5b802e87c7f4b17ec8f1ac433f0ed2366989cc7e26f75f1ec76e0f9a031aa8622e2e27e7b1773d2fa63c387191fa3ed6658e652fb15e645 +### MD5=f75b8179e4bbe7e2b4a074dcef62de95 +### SHA256=3b0a6bcd854adc9a1a590f527751bec278a058b2152ac50b26f4276a1c49e67c +### SHA512=a31cffeeaf410435d5b802e87c7f4b17ec8f1ac433f0ed2366989cc7e26f75f1ec76e0f9a031aa8622e2e27e7b1773d2fa63c387191fa3ed6658e652fb15e645 +### cat hashes | sed-hash $MD5 md5-hash | sed-hash $SHA256 sha256-hash | sed-hash $SHA512 + - archive: md5=+md5-hash+, in opam file: md5=+md5-hash+ + - archive: sha256=+sha256-hash+, in opam file: sha256=+sha256-hash+ + - archive: sha256=+sha256-hash+, in opam file: sha256=+sha256-hash+ ++ bash "${BASEDIR}/OPAM/opam-init/hooks/printer.sh" "...building..." "opam-version:++current++" "switch:global-wrappers" "jobs:2" "root:${BASEDIR}/OPAM" "make:make" "name:i-am-a-repo-pkg" "version:1" "depends:dep.1" "installed:false" "enable:" "pinned:false" "bin:${BASEDIR}/OPAM/global-wrappers/bin" "sbin:${BASEDIR}/OPAM/global-wrappers/sbin" "lib:${BASEDIR}/OPAM/global-wrappers/lib" "man:${BASEDIR}/OPAM/global-wrappers/man" "doc:${BASEDIR}/OPAM/global-wrappers/doc" "share:${BASEDIR}/OPAM/global-wrappers/share" "etc:${BASEDIR}/OPAM/global-wrappers/etc" "build:${BASEDIR}/OPAM/global-wrappers/.opam-switch/build/i-am-a-repo-pkg.1" "hash:md5=+md5-hash+" "dev:false" "build-id:+hash+" "opamfile:${OPAMTMP}/opam" "installed-files:" "a-build-command" (CWD=${BASEDIR}/OPAM/global-wrappers/.opam-switch/build/i-am-a-repo-pkg.1) +"eta.installl" "md5=+md5-hash+" + expected md5=+md5-hash+ + expected sha256=+sha256-hash+ +extra-files: [["bad-md5" "md5=+md5-hash+"] ["bad-sha" "sha256=+sha256-hash+"] ["good-md5" "md5=+md5-hash+"] ["good-sha" "sha256=+sha256-hash+"] ["missing-hash" "md5=+md5-hash+"]] +extra-files: [["bad-md5" "sha256=+sha256-hash+"] ["bad-sha" "sha256=+sha256-hash+"] ["good-md5" "sha256=+sha256-hash+"] ["good-sha" "sha256=+sha256-hash+"] ["missing-hash" "sha256=+sha256-hash+"]] +extra-files: ["missing-hash" "md5=+md5-hash+"] + got md5=+md5-hash+ + got sha256=+sha256-hash+ + hash:md5=+md5-hash+ +- hash:md5=+md5-hash+ + - md5=+md5-hash+ (match) + - md5=11111111111111111111111111111111 (MISMATCH) +"qux.installl" "md5=+md5-hash+" + - sha256=+sha256-hash+ (MISMATCH) + - sha512=+hash+ (MISMATCH) +SYSTEM copy ${OPAMTMP}/archive.tgz -> ${BASEDIR}/OPAM/download-cache/md5/pre/+md5-hash+ +SYSTEM mkdir ${BASEDIR}/OPAM/download-cache/md5/pre ++ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/+md5-hash+" "-C" "${OPAMTMP}" +url.checksum: md5=+md5-hash+ +url.checksum: md5=+md5-hash+, sha512=+hash+ +url.checksum: md5=+md5-hash+, sha256=+sha256-hash+ +url.checksum: md5=+md5-hash+, sha256=+sha256-hash+, sha512=+hash+ +url.checksum: sha256=+sha256-hash+ +url.checksum: sha256=+sha256-hash+, md5=+md5-hash+, sha512=+hash+ +### +SYSTEM copy ${OPAMTMP}/archive.tgz -> ${BASEDIR}/OPAM/download-cache/md5/d5/d55b8179e4bbe7e2b4a074dcef62de95 +SYSTEM mkdir ${BASEDIR}/OPAM/download-cache/md5/d5 ++ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/d5/d55b8179e4bbe7e2b4a074dcef62de95" "-C" "${OPAMTMP}" +### MD5=d55b8179e4bbe7e2b4a074dcef62de95 +### cat hashes-d5 | sed-hash $MD5 md5-hash +SYSTEM copy ${OPAMTMP}/archive.tgz -> ${BASEDIR}/OPAM/download-cache/md5/pre/+md5-hash+ +SYSTEM mkdir ${BASEDIR}/OPAM/download-cache/md5/pre ++ tar "xfz" "${BASEDIR}/OPAM/download-cache/md5/pre/+md5-hash+" "-C" "${OPAMTMP}" +### +0123456789abcdef0123456789abcdef +0a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f6789 +### cat hashes-basic | sed-hash $MD5 +0123456789abcdef0123456789abcdef +0a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f6789 +### cat hashes-basic | sed-hash 0123456789abcdef0123456789abcdef ++hash+ +0a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f6789 +### cat hashes-basic | sed-hash 0a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f6789 +0123456789abcdef0123456789abcdef ++hash+ +### cat hashes-basic | sed-hash 0123456789abcdef0123456789 +Bad 'sed-hash' argument (0123456789abcdef0123456789), expecting a environment variable beginning with '$' or a hash of 32, 64, or 128 characters0123456789abcdef0123456789abcdef +0a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f6789 +### cat hashes-basic | sed-hash 0a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f67 +Bad 'sed-hash' argument (0a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f67), expecting a environment variable beginning with '$' or a hash of 32, 64, or 128 characters0123456789abcdef0123456789abcdef +0a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f6789 +### cat hashes-basic | sed-hash 0a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f678999999 +Bad 'sed-hash' argument (0a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f678999999), expecting a environment variable beginning with '$' or a hash of 32, 64, or 128 characters0123456789abcdef0123456789abcdef +0a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f6789 +### cat hashes-basic | sed-hash FOO +Bad 'sed-hash' argument (FOO), expecting a environment variable beginning with '$' or a hash of 32, 64, or 128 characters0123456789abcdef0123456789abcdef +0a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f6789 +### cat hashes-basic | sed-hash $FOO +0123456789abcdef0123456789abcdef +0a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f6789 +### cat hashes-basic | sed-hash +Bad rewrite "| sed-hash", expecting '| RE -> STR' or '>$ VAR' +0123456789abcdef0123456789abcdef +0a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f67890a1b2c3d4e5f6789 ### ################### ### :V: Additional commands ### ################### diff --git a/tests/reftests/run.ml b/tests/reftests/run.ml index f51c1eb2b99..30399bd1ed1 100644 --- a/tests/reftests/run.ml +++ b/tests/reftests/run.ml @@ -477,6 +477,44 @@ module Parse = struct in let acc, r = aux cmd r acc in get_rewr (unordered, sort, acc) r + | "|" :: "sed-hash" :: hash :: r -> + let length = String.length hash in + if hash.[0] <> '$' + && length <> 32 + && length <> 64 + && length <> 128 + then + (Printf.printf + "Bad 'sed-hash' argument (%s), expecting a environment \ + variable beginning with '$' or a hash of 32, 64, \ + or 128 characters" hash; + unordered, sort, List.rev acc, None) + else + let name, r = + match r with + | "|" :: _ | [] -> "hash", r + | name :: r -> name, r + in + let name = "+"^name^"+" in + let re_hash = posix_re hash in + let sep = alt [ char '/' ; seq [ char '\\'; opt @@ char '\\'] ] in + let pre_t = + seq [ + sep; + repn xdigit 2 (Some 2); + ] in + let pre_hash = + seq [ + pre_t; + sep; + re_hash; + ] in + let pre = seq [ pre_t; eos ] in + (* The order is important *) + let acc = (pre_hash, Sed ("/pre/"^name))::acc in + let acc = (re_hash, Sed name)::acc in + let acc = (pre, Sed "/pre")::acc in + get_rewr (unordered, sort, acc) r | ">$" :: output :: [] -> unordered, sort, List.rev acc, Some (get_str output) | [] -> diff --git a/tests/reftests/update.test b/tests/reftests/update.test index 3b2b9ef705b..44675e767e3 100644 --- a/tests/reftests/update.test +++ b/tests/reftests/update.test @@ -155,8 +155,8 @@ opam-version: "2.0" <><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><> [default] synchronised from file://${BASEDIR}/REPO Now run 'opam upgrade' to apply any package updates. -### opam show qux --field extra-files: | $INSTALL_MD5 -> hash -"qux.installl" "md5=hash" +### opam show qux --field extra-files: | sed-hash $INSTALL_MD5 install-md5 +"qux.installl" "md5=+install-md5+" ### :I:6:b: change extra-file with opam file ### opam-version: "2.0" @@ -166,8 +166,8 @@ opam-version: "2.0" <><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><> [default] synchronised from file://${BASEDIR}/REPO Now run 'opam upgrade' to apply any package updates. -### opam show qux --field extra-files: | $AINSTALL_MD5 -> hash -"qux.installl" "md5=hash" +### opam show qux --field extra-files: | sed-hash $AINSTALL_MD5 ainstall-md5 +"qux.installl" "md5=+ainstall-md5+" ### :I:6:c: remove extra-file with opam file ### opam-version: "2.0" @@ -203,8 +203,8 @@ opam-version: "2.0" FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s opam-file Mismatching extra-files at ${BASEDIR}/OPAM/repo/default/packages/qux/qux.1: wrong checksum (1) Now run 'opam upgrade' to apply any package updates. -### opam show qux --field extra-files: | $INSTALL_MD5 -> hash -"qux.installl" "md5=hash" +### opam show qux --field extra-files: | sed-hash $INSTALL_MD5 install-md5 +"qux.installl" "md5=+install-md5+" ### :I:6:e: remove extra-file without opam file ### opam-version: "2.0" @@ -216,8 +216,8 @@ opam-version: "2.0" [default] synchronised from file://${BASEDIR}/REPO FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s opam-file Missing expected extra files qux.installl at ${BASEDIR}/OPAM/repo/default/packages/qux/qux.1/files -### opam show qux --field extra-files: | $INSTALL_MD5 -> hash -"qux.installl" "md5=hash" +### opam show qux --field extra-files: | sed-hash $INSTALL_MD5 install-md5 +"qux.installl" "md5=+install-md5+" ### :II: Git repo ### opam switch create repo-git-update --empty ### git init -q --initial-branch=master GITREPO @@ -291,8 +291,8 @@ opam-version: "2.0" <><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><> [git-test] synchronised from git+file://${BASEDIR}/GITREPO Now run 'opam upgrade' to apply any package updates. -### opam show qux --field extra-files: | $INSTALL_MD5 -> hash -"qux.installl" "md5=hash" +### opam show qux --field extra-files: | sed-hash $INSTALL_MD5 install-md5 +"qux.installl" "md5=+install-md5+" ### :II:5:b: change extra-file with opam file ### opam-version: "2.0" @@ -304,8 +304,8 @@ opam-version: "2.0" <><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><> [git-test] synchronised from git+file://${BASEDIR}/GITREPO Now run 'opam upgrade' to apply any package updates. -### opam show qux --field extra-files: | $AINSTALL_MD5 -> hash -"qux.installl" "md5=hash" +### opam show qux --field extra-files: | sed-hash $AINSTALL_MD5 ainstall-md5 +"qux.installl" "md5=+ainstall-md5+" ### :II:5:c: remove extra-file with opam file ### opam-version: "2.0" @@ -346,8 +346,8 @@ opam-version: "2.0" [git-test] synchronised from git+file://${BASEDIR}/GITREPO opam-file Mismatching extra-files at ${BASEDIR}/OPAM/repo/git-test/packages/qux/qux.1: wrong checksum (1) Now run 'opam upgrade' to apply any package updates. -### opam show qux --field extra-files: | $INSTALL_MD5 -> hash -"qux.installl" "md5=hash" +### opam show qux --field extra-files | sed-hash $INSTALL_MD5 install-md5 +"qux.installl" "md5=+install-md5+" ### :II:5:e: remove extra-file without opam file ### opam-version: "2.0" @@ -360,8 +360,8 @@ opam-version: "2.0" <><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><> [git-test] synchronised from git+file://${BASEDIR}/GITREPO opam-file Missing expected extra files qux.installl at ${BASEDIR}/OPAM/repo/git-test/packages/qux/qux.1/files -### opam show qux --field extra-files: | $INSTALL_MD5 -> hash -"qux.installl" "md5=hash" +### opam show qux --field extra-files: | sed-hash $INSTALL_MD5 install-md5 +"qux.installl" "md5=+install-md5+" ### :II:6: Package removal with prefix directories ### set -ue @@ -607,8 +607,8 @@ REPO_BACKEND Internal diff (non-empty, 2 changed files) done [incremental] synchronised from file://${BASEDIR}/INCR_REPO FILE(opam) Read ${BASEDIR}/OPAM/repo/incremental/packages/eta/eta.1/opam in 0.000s Now run 'opam upgrade' to apply any package updates. -### opam show eta --field extra-files: | $INSTALL_MD5 -> hash -"eta.installl" "md5=hash" +### opam show eta --field extra-files: +"eta.installl" "md5=d9b673248d119b87a2e1f9766e543aa3" ### opam install eta The following actions will be performed: === install 1 package @@ -632,8 +632,8 @@ REPO_BACKEND Internal diff (non-empty, 2 changed files) done [incremental] synchronised from file://${BASEDIR}/INCR_REPO FILE(opam) Read ${BASEDIR}/OPAM/repo/incremental/packages/eta/eta.1/opam in 0.000s Now run 'opam upgrade' to apply any package updates. -### opam show eta --field extra-files: | $AINSTALL_MD5 -> hash -"eta.installl" "md5=hash" +### opam show eta --field extra-files: | sed-hash $AINSTALL_MD5 ainstall-md5 +"eta.installl" "md5=+ainstall-md5+" ### opam install eta The following actions will be performed: === install 1 package @@ -727,8 +727,8 @@ FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s FILE(opam) Read ${BASEDIR}/OPAM/repo/incremental/packages/eta/eta.1/opam in 0.000s opam-file Mismatching extra-files at ${BASEDIR}/OPAM/repo/incremental/packages/eta/eta.1: wrong checksum (1) Now run 'opam upgrade' to apply any package updates. -### opam show eta --field extra-files: | $INSTALL_MD5 -> hash -"eta.installl" "md5=hash" +### opam show eta --field extra-files: +"eta.installl" "md5=d9b673248d119b87a2e1f9766e543aa3" ### opam install eta The following actions will be performed: === install 1 package @@ -763,8 +763,8 @@ REPO_BACKEND Internal diff (non-empty, 1 changed files) done FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s FILE(opam) Read ${BASEDIR}/OPAM/repo/incremental/packages/eta/eta.1/opam in 0.000s opam-file Missing expected extra files eta.installl at ${BASEDIR}/OPAM/repo/incremental/packages/eta/eta.1/files -### opam show eta --field extra-files: | $INSTALL_MD5 -> hash -"eta.installl" "md5=hash" +### opam show eta --field extra-files: +"eta.installl" "md5=d9b673248d119b87a2e1f9766e543aa3" ### opam install eta The following actions will be performed: === install 1 package From 8fa7a5f5ea4090b81b6e49d07f0fd7e5a831365c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonin=20D=C3=A9cimo?= Date: Tue, 8 Jul 2025 11:51:56 +0200 Subject: [PATCH 20/29] Update to FlexDLL 0.44 for the bootstrap --- .github/scripts/main/ocaml-cache.sh | 2 +- master_changes.md | 1 + release/Makefile | 2 +- src_ext/Makefile | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/scripts/main/ocaml-cache.sh b/.github/scripts/main/ocaml-cache.sh index 8effee34363..cec7b04d376 100644 --- a/.github/scripts/main/ocaml-cache.sh +++ b/.github/scripts/main/ocaml-cache.sh @@ -39,7 +39,7 @@ case "$HOST" in PREFIX="$OCAML_LOCAL";; esac -FLEXDLL_VERSION=0.43 +FLEXDLL_VERSION=0.44 MINGW_W64_VERSION=12.0.0 curl -sLO "https://github.com/ocaml/ocaml/archive/refs/tags/${OCAML_VERSION}.tar.gz" diff --git a/master_changes.md b/master_changes.md index 833a4891188..628798bda7b 100644 --- a/master_changes.md +++ b/master_changes.md @@ -98,6 +98,7 @@ users) * `./configure --enable-static` is now supported on OpenBSD [#6705 @flumf] * Add missing constraints to avoid cmdliner 2.0.0 [#6707 @kit-ty-kate] * Add patch library dependency to opam-state [#6614 @arozovyk] + * Update the bootstrap compiler's flexdll to 0.44 [#6592 @MisterDA] ## Infrastructure diff --git a/release/Makefile b/release/Makefile index fea8d7804e8..f6b8ca12646 100644 --- a/release/Makefile +++ b/release/Makefile @@ -4,7 +4,7 @@ OPAM_VERSION = $(subst -,~,$(VERSION)) GIT_URL = .. OCAMLV = 4.14.2 -FLEXDLLV = 0.43 +FLEXDLLV = 0.44 # currently hardcoded in Dockerfile.in OCAML_URL = https://github.com/ocaml/ocaml/archive/refs/tags/$(OCAMLV).tar.gz FLEXDLL_URL = https://github.com/ocaml/flexdll/archive/refs/tags/$(FLEXDLLV).tar.gz diff --git a/src_ext/Makefile b/src_ext/Makefile index 5c022eb24b5..edab288c281 100644 --- a/src_ext/Makefile +++ b/src_ext/Makefile @@ -11,8 +11,8 @@ PATCH ?= patch URL_ocaml = https://github.com/ocaml/ocaml/archive/refs/tags/4.14.2.tar.gz MD5_ocaml = b28daefda803b5d5910cecf085b1451c -URL_flexdll = https://github.com/ocaml/flexdll/archive/0.43.tar.gz -MD5_flexdll = 6ce706f6c65b2c5adf5791fac678f090 +URL_flexdll = https://github.com/ocaml/flexdll/archive/0.44.tar.gz +MD5_flexdll = 08731d2a5d6465cf7080a14e43e0752e ifndef FETCH ifneq ($(shell command -v curl 2>/dev/null),) From acb7ba2be097940e208ba3d8ff5eb744f2cb2648 Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Mon, 1 Sep 2025 17:48:46 +0200 Subject: [PATCH 21/29] reftest: add remove --force test --- master_changes.md | 1 + tests/reftests/remove.test | 177 +++++++++++++++++++++++++++++++++++++ 2 files changed, 178 insertions(+) diff --git a/master_changes.md b/master_changes.md index 833a4891188..c4712cc70df 100644 --- a/master_changes.md +++ b/master_changes.md @@ -164,6 +164,7 @@ users) * Complete `action-disk.test` with the behaviour of `extra-source` [#6679 @rjbou] * Add a test showing the behaviour of opam when faced with outdated git submodule in its local cache [#6153 @kit-ty-kate] * Add reftest for `--depext-only` option [#6516 @rjbou] + * Add a test for `opam remove --force` [#6672 @rjbou] ### Engine * Fix gcc < 14.3 bug on mingw i686 [#6624 @kit-ty-kate] diff --git a/tests/reftests/remove.test b/tests/reftests/remove.test index 688c7cb1394..2a78cd4ca7f 100644 --- a/tests/reftests/remove.test +++ b/tests/reftests/remove.test @@ -49,3 +49,180 @@ Nothing to do. [NOTE] w is not installed. Nothing to do. +### :::::: remove directory selection, with & without --force (#6570) +### +opam-version: "2.0" +build: "pwd" +install: "pwd" +remove: "pwd" +### +opam-version: "2.0" +build: "pwd" +install: "pwd" +remove: "pwd" +### OPAMVERBOSE=2 +### :: remove installed package +### opam install p | sed-cmd pwd +The following actions will be performed: +=== install 1 package + - install p 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 2/3: [p: pwd] ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/build/p.1) +- ${BASEDIR}/OPAM/default/.opam-switch/build/p.1 +-> compiled p.1 +Processing 3/3: [p: pwd] ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/build/p.1) +- ${BASEDIR}/OPAM/default/.opam-switch/build/p.1 +-> installed p.1 +Done. +### opam remove p | sed-cmd pwd +The following actions will be performed: +=== remove 1 package + - remove p 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 2/2: [p: pwd] ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/remove/p.1) +- ${BASEDIR}/OPAM/default/.opam-switch/remove/p.1 +-> removed p.1 +Done. +### opam install p | sed-cmd pwd +The following actions will be performed: +=== install 1 package + - install p 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 2/3: [p: pwd] ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/build/p.1) +- ${BASEDIR}/OPAM/default/.opam-switch/build/p.1 +-> compiled p.1 +Processing 3/3: [p: pwd] ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/build/p.1) +- ${BASEDIR}/OPAM/default/.opam-switch/build/p.1 +-> installed p.1 +Done. +### opam remove p --force | sed-cmd pwd +The following actions will be performed: +=== remove 1 package + - remove p 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 2/2: [p: pwd] ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/remove/p.1) +- ${BASEDIR}/OPAM/default/.opam-switch/remove/p.1 +-> removed p.1 +Done. +### opam install p --inplace | sed-cmd pwd +The following actions will be performed: +=== install 1 package + - install p 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 2/3: [p: pwd] ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/build/p.1) +- ${BASEDIR}/OPAM/default/.opam-switch/build/p.1 +-> compiled p.1 +Processing 3/3: [p: pwd] ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/build/p.1) +- ${BASEDIR}/OPAM/default/.opam-switch/build/p.1 +-> installed p.1 +Done. +### opam remove p --inplace | sed-cmd pwd +The following actions will be performed: +=== remove 1 package + - remove p 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 2/2: [p: pwd] ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/remove/p.1) +- ${BASEDIR}/OPAM/default/.opam-switch/remove/p.1 +-> removed p.1 +Done. +### :: remove uninstalled package +### opam remove n +[NOTE] n is not installed. + +Nothing to do. +### opam remove n --force | sed-cmd pwd +[NOTE] Forcing removal of (uninstalled) n.1 +[n: pwd] ++ pwd +- ${BASEDIR} +-> removed n.1 +### opam remove n --force --inplace | sed-cmd pwd +[NOTE] Forcing removal of (uninstalled) n.1 +[n: pwd] ++ pwd +- ${BASEDIR} +-> removed n.1 +### :: remove installed and uninstalled package +### opam install p | sed-cmd pwd +The following actions will be performed: +=== install 1 package + - install p 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 2/3: [p: pwd] ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/build/p.1) +- ${BASEDIR}/OPAM/default/.opam-switch/build/p.1 +-> compiled p.1 +Processing 3/3: [p: pwd] ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/build/p.1) +- ${BASEDIR}/OPAM/default/.opam-switch/build/p.1 +-> installed p.1 +Done. +### opam remove n p | sed-cmd pwd +[NOTE] n is not installed. + +The following actions will be performed: +=== remove 1 package + - remove p 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 2/2: [p: pwd] ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/remove/p.1) +- ${BASEDIR}/OPAM/default/.opam-switch/remove/p.1 +-> removed p.1 +Done. +### opam install p | sed-cmd pwd +The following actions will be performed: +=== install 1 package + - install p 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 2/3: [p: pwd] ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/build/p.1) +- ${BASEDIR}/OPAM/default/.opam-switch/build/p.1 +-> compiled p.1 +Processing 3/3: [p: pwd] ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/build/p.1) +- ${BASEDIR}/OPAM/default/.opam-switch/build/p.1 +-> installed p.1 +Done. +### opam remove n p --force | sed-cmd pwd +[NOTE] Forcing removal of (uninstalled) n.1 +[n: pwd] ++ pwd +- ${BASEDIR} +-> removed n.1 +The following actions will be performed: +=== remove 1 package + - remove p 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 2/2: [p: pwd] ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/remove/p.1) +- ${BASEDIR}/OPAM/default/.opam-switch/remove/p.1 +-> removed p.1 +Done. +### :: remove unknown package +### opam remove m +[ERROR] No package named m found. +'${OPAM} remove m' failed. +# Return code 5 # +### opam remove m --force +[ERROR] No package named m found. +'${OPAM} remove m --force' failed. +# Return code 5 # From 5efaaa973053e2ba7eec6cf65df7dcda22588c35 Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Tue, 2 Sep 2025 10:40:59 +0200 Subject: [PATCH 22/29] remove: no longer remove --force commands in current directory --- master_changes.md | 1 + src/client/opamAction.ml | 13 ++++++---- src/client/opamClient.ml | 43 +++++++++++++++++++++------------ tests/reftests/dot-install.test | 3 +++ tests/reftests/remove.test | 12 ++++----- 5 files changed, 45 insertions(+), 27 deletions(-) diff --git a/master_changes.md b/master_changes.md index c4712cc70df..ca605e23bd3 100644 --- a/master_changes.md +++ b/master_changes.md @@ -35,6 +35,7 @@ users) ## Build (package) ## Remove + * [BUG] Fix `opam remove --force` launching commands in current directory [#6672 @rjbou - fix #6570] ## UI * Show the invalid character when detecting an erroneous package name [#6638 @lefessan - fix #6396] diff --git a/src/client/opamAction.ml b/src/client/opamAction.ml index 86bb9dfc4a2..59629b98307 100644 --- a/src/client/opamAction.ml +++ b/src/client/opamAction.ml @@ -842,13 +842,16 @@ let remove_package_aux (* Run the remove script *) let build_dir = - OpamStd.Option.default_map - (OpamFilename.opt_dir - (OpamPath.Switch.remove root t.switch nv)) - build_dir + match build_dir with + | Some build_dir -> build_dir + | None -> + let dir = OpamPath.Switch.remove root t.switch nv in + if not (OpamFilename.exists_dir dir) then + OpamFilename.mkdir dir; + dir in let wrappers = get_wrappers t in - let mk_cmd = make_command t opam ?dir:build_dir in + let mk_cmd = make_command t opam ~dir:build_dir in OpamProcess.Job.of_fun_list ~keep_going:true (List.map (fun cmd () -> mk_cmd cmd) (get_wrapper t opam wrappers OpamFile.Wrappers.pre_remove)) diff --git a/src/client/opamClient.ml b/src/client/opamClient.ml index 2d63eaaa43c..539759db326 100644 --- a/src/client/opamClient.ml +++ b/src/client/opamClient.ml @@ -2413,30 +2413,41 @@ let remove_t ?ask ~autoremove ~force ?(formula=OpamFormula.Empty) atoms t = log "REMOVE autoremove:%b %a" autoremove (slog OpamFormula.string_of_atoms) atoms; - let nothing_to_do = ref true in - let packages, not_installed = - get_installed_atoms t atoms in - if not_installed <> [] then ( - if force then + let packages, not_installed = get_installed_atoms t atoms in + + let nothing_to_do = + if not_installed = [] then + true + else if force then let force_remove atom = - let candidates = OpamPackage.Set.filter (OpamFormula.check atom) t.packages in + let candidates = + OpamPackage.Set.filter (OpamFormula.check atom) t.packages + in try let nv = OpamPackage.max_version candidates (fst atom) in - OpamConsole.note "Forcing removal of (uninstalled) %s" (OpamPackage.to_string nv); + OpamConsole.note "Forcing removal of (uninstalled) %s" + (OpamPackage.to_string nv); + let d = OpamPath.Switch.remove t.switch_global.root t.switch nv in + OpamFilename.rmdir d; + OpamFilename.mkdir d; OpamProcess.Job.run (OpamAction.remove_package t nv); OpamAction.cleanup_package_artefacts t nv; - nothing_to_do := false + false with Not_found -> OpamConsole.error "No package %s found for (forced) removal.\n" - (OpamFormula.short_string_of_atom atom) + (OpamFormula.short_string_of_atom atom); + true in - List.iter force_remove not_installed + List.fold_left (fun nothing_to_do atom -> + force_remove atom && nothing_to_do) + true not_installed else - OpamConsole.note "%s %s not installed.\n" - (OpamStd.Format.pretty_list - (List.map OpamFormula.short_string_of_atom not_installed)) - (match not_installed with [_] -> "is" | _ -> "are") - ); + (OpamConsole.note "%s %s not installed.\n" + (OpamStd.Format.pretty_list + (List.map OpamFormula.short_string_of_atom not_installed)) + (match not_installed with [_] -> "is" | _ -> "are"); + true) + in if autoremove || packages <> [] then ( let packages = OpamPackage.Set.of_list packages in @@ -2489,7 +2500,7 @@ let remove_t ?ask ~autoremove ~force ?(formula=OpamFormula.Empty) atoms t = in OpamSolution.check_solution t solution; t - ) else if !nothing_to_do then ( + ) else if nothing_to_do then ( OpamConsole.msg "Nothing to do.\n"; t ) else t diff --git a/tests/reftests/dot-install.test b/tests/reftests/dot-install.test index 303c418c8c5..ac0310cc329 100644 --- a/tests/reftests/dot-install.test +++ b/tests/reftests/dot-install.test @@ -321,6 +321,8 @@ The following actions will be performed: - remove no-specified-dir 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +SYSTEM mkdir ${BASEDIR}/OPAM/rem-dir/.opam-switch/remove +SYSTEM mkdir ${BASEDIR}/OPAM/rem-dir/.opam-switch/remove/no-specified-dir.1 SYSTEM rmdir ${BASEDIR}/OPAM/rem-dir/lib/no-specified-dir SYSTEM rmdir ${BASEDIR}/OPAM/rem-dir/lib/no-specified-dir SYSTEM rm ${BASEDIR}/OPAM/rem-dir/share/no-specified-dir/a-file @@ -337,6 +339,7 @@ SYSTEM rm ${BASEDIR}/OPAM/rem-dir/.opam-switch/install/ -> removed no-specified-dir.1 SYSTEM LOCK ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/cache (none => write) SYSTEM LOCK ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/cache (write => none) +SYSTEM rmdir ${BASEDIR}/OPAM/rem-dir/.opam-switch/remove/no-specified-dir.1 SYSTEM rm ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/cache SYSTEM rmdir ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/no-specified-dir.1 SYSTEM rm ${BASEDIR}/OPAM/rem-dir/.opam-switch/packages/no-specified-dir.1/opam diff --git a/tests/reftests/remove.test b/tests/reftests/remove.test index 2a78cd4ca7f..514b39fb432 100644 --- a/tests/reftests/remove.test +++ b/tests/reftests/remove.test @@ -148,14 +148,14 @@ Nothing to do. ### opam remove n --force | sed-cmd pwd [NOTE] Forcing removal of (uninstalled) n.1 [n: pwd] -+ pwd -- ${BASEDIR} ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/remove/n.1) +- ${BASEDIR}/OPAM/default/.opam-switch/remove/n.1 -> removed n.1 ### opam remove n --force --inplace | sed-cmd pwd [NOTE] Forcing removal of (uninstalled) n.1 [n: pwd] -+ pwd -- ${BASEDIR} ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/remove/n.1) +- ${BASEDIR}/OPAM/default/.opam-switch/remove/n.1 -> removed n.1 ### :: remove installed and uninstalled package ### opam install p | sed-cmd pwd @@ -204,8 +204,8 @@ Done. ### opam remove n p --force | sed-cmd pwd [NOTE] Forcing removal of (uninstalled) n.1 [n: pwd] -+ pwd -- ${BASEDIR} ++ pwd (CWD=${BASEDIR}/OPAM/default/.opam-switch/remove/n.1) +- ${BASEDIR}/OPAM/default/.opam-switch/remove/n.1 -> removed n.1 The following actions will be performed: === remove 1 package From 5543e9bced0360be83c06ed9e39980bbab9f72d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonin=20D=C3=A9cimo?= Date: Tue, 8 Jul 2025 11:51:56 +0200 Subject: [PATCH 23/29] Update msvs-detect to 0.7.0 --- master_changes.md | 1 + shell/msvs-detect | 313 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 223 insertions(+), 91 deletions(-) diff --git a/master_changes.md b/master_changes.md index 628798bda7b..aa3ed5ff790 100644 --- a/master_changes.md +++ b/master_changes.md @@ -99,6 +99,7 @@ users) * Add missing constraints to avoid cmdliner 2.0.0 [#6707 @kit-ty-kate] * Add patch library dependency to opam-state [#6614 @arozovyk] * Update the bootstrap compiler's flexdll to 0.44 [#6592 @MisterDA] + * Update the `msvs-detect` script used on Windows during compiler bootstrap to 0.7.0 [#6592 @MisterDA] ## Infrastructure diff --git a/shell/msvs-detect b/shell/msvs-detect index 8c72c436aaf..2f4c0f55610 100755 --- a/shell/msvs-detect +++ b/shell/msvs-detect @@ -5,6 +5,7 @@ # Microsoft C Compiler Environment Detection Script # # ################################################################################################ # # Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021 MetaStack Solutions Ltd. # +# Copyright (c) 2022, 2024 David Allsopp Ltd. # # ################################################################################################ # # Author: David Allsopp # # 16-Feb-2016 # @@ -27,7 +28,9 @@ # of this software, even if advised of the possibility of such damage. # # ################################################################################################ # -VERSION=0.5.0 +VERSION=0.7.0 + +set -f # debug [level=2] message debug () @@ -74,7 +77,7 @@ find_in () if [[ -z $1 ]] ; then STATUS=1 else - IFS=* + IFS='*' STATUS=1 for f in $1; do if [[ -e "$f/$2" ]] ; then @@ -140,7 +143,7 @@ check_environment () ASSEMBLER=${ASSEMBLER%86}.exe if [[ $ML_REQUIRED -eq 1 ]] ; then RET=0 - find_in "$1" $ASSEMBLER + find_in "$1" "$ASSEMBLER" if [[ $RET -gt 0 ]] ; then warning "Microsoft Assembler ($ASSEMBLER) not found - $4 ($5)" return 1 @@ -164,7 +167,7 @@ check_environment () # value (i.e. no change) is output. output () { - if [[ $3 = $ENV_ARCH ]] ; then + if [[ $3 = "$ENV_ARCH" ]] ; then VALUE= else VALUE=$2 @@ -175,6 +178,26 @@ output () 1) VALUE=${VALUE//#/\\\#} echo "$1=${VALUE//\$/\$\$}";; + 2) + case $1 in + MSVS_PATH) + prefix='bin';; + MSVS_INC) + prefix='inc';; + MSVS_LIB) + prefix='lib';; + MSVS_ML) + prefix='asm';; + *) + echo Internal fault "$1">&2 + exit 3;; + esac + while IFS= read -r entry; do + if [[ -n $entry ]] ; then + echo "$prefix*$entry" + fi + done <<< "${VALUE//;/$'\n'}" + ;; esac } @@ -184,9 +207,11 @@ output () # 1 - --all # 2 - --help # 3 - --version +# 4 - --installed # OUTPUT --output option # 0 - =shell # 1 - =make +# 2 - =data # MT_REQUIRED --with-mt # ML_REQUIRED --with-assembler # TARGET_ARCH Normalised --arch (x86, x64 or blank for both) @@ -207,19 +232,22 @@ WHICH=$(which which) # Parse command-line. At the moment, the short option which usefully combines with anything is -d, # so for the time being, combining short options is not permitted, as the loop becomes even less # clear with getopts. GNU getopt isn't installed by default on Cygwin... -if [[ $@ != "" ]] ; then +if [[ $# -gt 0 ]] ; then while true ; do case "$1" in # Mode settings ($MODE) -a|--all) MODE=1 shift 1;; - -h|--help) + -i|--installed) MODE=2 shift;; - -v|--version) + -h|--help) MODE=3 shift;; + -v|--version) + MODE=4 + shift;; # Simple flags ($MT_REQUIRED and $ML_REQUIRED) --with-mt) @@ -236,6 +264,8 @@ if [[ $@ != "" ]] ; then ;; make) OUTPUT=1;; + data) + OUTPUT=2;; *) echo "$0: unrecognised option for $1: '$2'">&2 exit 2;; @@ -246,6 +276,9 @@ if [[ $@ != "" ]] ; then -omake|--output=make) OUTPUT=1 shift;; + -odata|--output=data) + OUTPUT=2 + shift;; -o*) echo "$0: unrecognised option for -o: '${1#-o}'">&2 exit 2;; @@ -256,19 +289,19 @@ if [[ $@ != "" ]] ; then # -x, --arch ($TARGET_ARCH) -x|--arch) case "$2" in - 86|x86) + 86|x86|x86_32) TARGET_ARCH=x86;; - 64|x64) + 64|x64|x86_64) TARGET_ARCH=x64;; *) echo "$0: unrecognised option for $1: '$2'">&2 exit 2 esac shift 2;; - -x86|-xx86|--arch=x86|--arch=86) + -x86|-xx86|-xx86_32|--arch=x86|--arch=86|--arch=x86_32) TARGET_ARCH=x86 shift;; - -x64|-xx64|--arch=x64|--arch=64) + -x64|-xx64|-xx86_64|--arch=x64|--arch=64|--arch=x86_64) TARGET_ARCH=x64 shift;; -x*) @@ -312,11 +345,11 @@ if [[ $@ != "" ]] ; then done if [[ -n ${1+x} ]] ; then - if [[ $MODE -eq 1 ]] ; then - echo "$0: cannot specify MSVS_PREFERENCE and --all">&2 + if [[ $MODE -eq 1 || $MODE -eq 2 ]] ; then + echo "$0: cannot specify MSVS_PREFERENCE and --all or --installed">&2 exit 2 else - MSVS_PREFERENCE="$@" + MSVS_PREFERENCE="$*" fi fi fi @@ -324,11 +357,14 @@ fi # Options sanitising if [[ $MODE -eq 1 ]] ; then if [[ -n $TARGET_ARCH ]] ; then - echo "$0: --all and --arch are mutually exclusive">&2 + echo "$0: --all/--installed and --arch are mutually exclusive">&2 exit 2 fi MSVS_PREFERENCE= SCAN_ENV=1 +elif [[ $OUTPUT -eq 2 && -z $TARGET_ARCH ]] ; then + echo "$0: --output=data requires --arch">&2 + exit 2 elif [[ -z ${MSVS_PREFERENCE+x} ]] ; then MSVS_PREFERENCE='@;VS17.*;VS16.*;VS15.*;VS14.0;VS12.0;VS11.0;10.0;9.0;8.0;7.1;7.0' fi @@ -347,7 +383,7 @@ fi NAME="Microsoft C Compiler Environment Detection Script" case $MODE in - 2) + 3) echo "$NAME" echo "Queries the environment and registry to locate Visual Studio / Windows SDK" echo "installations and uses their initialisation scripts (SetEnv.cmd, vcvarsall.bat," @@ -362,9 +398,17 @@ case $MODE in echo " to return packages containing both architectures" echo " -d, --debug[=LEVEL] Set debug messages level" echo " -h, --help Display this help screen" + echo " -i, --installed Display all detected compiler packages; similarly to --all," + echo " except the list includes versions and may include packages" + echo " which don't include the required compiler, tools, or libraries." echo " -o, --output=OUTPUT Set final output. Default is shell. Valid values:" echo " shell - shell assignments, for use with eval" echo " make - make assignments, for inclusion in a Makefile" + echo " data - raw data, for parsing in other systems. The first" + echo " line is the full path to the batch file which was" + echo " analysed. The following lines are the individual" + echo " components of MSVS_PATH, MSVS_INC and MSVS_LIB, each" + echo " prefixed bin*, inc* or lib* respectively." echo " -v, --version Display the version" echo " --with-mt Only consider packages including the Manifest Tool" echo " --with-assembler Only consider packages including an assembler" @@ -384,7 +428,7 @@ case $MODE in echo "The default behaviour is to match the environment compiler followed by the most" echo "recent version of the compiler." exit 0;; - 3) + 4) echo "$NAME" echo "Version $VERSION" exit 0;; @@ -415,7 +459,9 @@ esac # copied to the appropriate version. SDKs after 7.1 do not include compilers, and so are not # captured (as of Visual Studio 2015, the Windows SDK is official part of Visual Studio). declare -A COMPILERS +# shellcheck disable=SC2034 # SDK52_KEY is used in COMPILERS which is eval'd... SDK52_KEY='HKLM\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs\8F9E5EF3-A9A5-491B-A889-C58EFFECE8B3' +# shellcheck disable=SC2016 # ... and is therefore intentionally in a quoted string COMPILERS=( ["VS7.0"]='( ["NAME"]="Visual Studio .NET 2002" @@ -479,6 +525,7 @@ COMPILERS=( ["SDK5.2"]='( ["NAME"]="Windows Server 2003 SP1 SDK" ["VC_VER"]="8.0" + ["VERSION"]="5.2" ["REG_KEY"]="$SDK52_KEY" ["REG_VALUE"]="Install Dir" ["SETENV_RELEASE"]="/RETAIL" @@ -531,10 +578,16 @@ done # Reset FOUND for later use. FOUND=() +if "$WHICH" cl >/dev/null 2>&1 ; then + env_has_cl=1 +else + env_has_cl=0 +fi + # Scan the environment for a C compiler, and check that it's valid. Throughout the rest of the # script, it is assumed that if ENV_ARCH is set then there is a valid environment compiler. if [[ $SCAN_ENV -eq 1 ]] ; then - if "$WHICH" cl >/dev/null 2>&1 ; then + if [[ $env_has_cl -eq 1 ]]; then # Determine its architecture from the Microsoft Logo line. ENV_ARCH=$(cl 2>&1 | head -1 | tr -d '\r') case "${ENV_ARCH#* for }" in @@ -570,9 +623,12 @@ if [[ $SCAN_ENV -eq 1 ]] ; then ENV_cl=${ENV_CL,,} ENV_cl=${ENV_cl/bin\/*_/bin\/} debug "Environment appears to include a compiler at $ENV_CL" - if [[ -n $TARGET_ARCH && $TARGET_ARCH != $ENV_ARCH ]] ; then + # It doesn't matter whether the architecture matches - when the full probe happens in the + # next loop, the corresponding architecture should then be selected (so, for example, if + # the environment compiler is x86 VS2017, but VS2022 is installed, then by default the + # compiler returned for x64 is VS2017's x64 compiler, not VS2022's). + if [[ -n $TARGET_ARCH && $TARGET_ARCH != "$ENV_ARCH" ]] ; then debug "But architecture doesn't match required value" - unset ENV_ARCH fi else unset ENV_ARCH @@ -604,7 +660,7 @@ declare -A COMPILER # Scan the registry for compiler package (vswhere is later) for i in "${!COMPILERS[@]}" ; do - eval COMPILER=${COMPILERS[$i]} + eval "COMPILER=${COMPILERS["$i"]}" if [[ -n ${COMPILER["ENV"]+x} ]] ; then # Visual Studio package - test for its environment variable @@ -612,7 +668,7 @@ for i in "${!COMPILERS[@]}" ; do if [[ -n ${!ENV+x} ]] ; then debug "$ENV is a candidate" TEST_PATH=${!ENV%\"} - TEST_PATH=$(cygpath -u -f - <<< ${TEST_PATH#\"}) + TEST_PATH=$(cygpath -u "${TEST_PATH#\"}") if [[ -e $TEST_PATH/vsvars32.bat ]] ; then debug "Directory pointed to by $ENV contains vsvars32.bat" EXPRESS=0 @@ -646,7 +702,15 @@ for i in "${!COMPILERS[@]}" ; do if [[ $EXPRESS -eq 1 ]] ; then DISPLAY="$DISPLAY Express" fi - FOUND+=(["$i"]="$RESULT [\"DISPLAY\"]=\"$DISPLAY\" [\"IS_EXPRESS\"]=\"$EXPRESS\")") + ENV=VS${COMPILER["ENV"]}COMNTOOLS + ENV=${!ENV%\"} + ENV=${ENV#\"} + if [[ ${COMPILER["ENV"]}0 -ge 800 ]] ; then + SCRIPT="$(cygpath -d "$ENV")\\..\\..\\VC\\vcvarsall.bat" + else + SCRIPT="$(cygpath -d "$ENV")\\vsvars32.bat" + fi + FOUND+=(["$i"]="$RESULT [\"DISPLAY\"]=\"$DISPLAY\" [\"IS_EXPRESS\"]=\"$EXPRESS\" [\"SETENV\"]=\"$SCRIPT\")") debug "${COMPILER["NAME"]} accepted for further detection" else warning "$ENV doesn't agree with registry" @@ -679,6 +743,7 @@ SDK_ROOT='HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows' for i in $(reg query "$SDK_ROOT" 2>/dev/null | tr -d '\r' | sed -ne '/Windows\\v/s/.*\\//p') ; do debug "Analysing SDK key $SDK_ROOT\\$i" INSTALL_DIR=$(reg_string "$SDK_ROOT\\$i" InstallationFolder) + VERSION=$(reg_string "$SDK_ROOT\\$i" ProductVersion) if [[ -n $INSTALL_DIR ]] ; then TEST_PATH=$(cygpath -u "$INSTALL_DIR") if [[ -e $TEST_PATH/Bin/SetEnv.cmd ]] ; then @@ -686,11 +751,11 @@ for i in $(reg query "$SDK_ROOT" 2>/dev/null | tr -d '\r' | sed -ne '/Windows\\v warning "SDK $i is not known to this script - assuming compatibility" DISPLAY="Windows SDK $i" else - eval COMPILER=${COMPILERS["SDK${i#v}"]} + eval "COMPILER=${COMPILERS["SDK${i#v}"]}" DISPLAY=${COMPILER['NAME']} fi RESULT=${COMPILERS['SDK']%)} - FOUND+=(["SDK${i/v/}"]="$RESULT [\"DISPLAY\"]=\"$DISPLAY\" [\"SETENV\"]=\"$INSTALL_DIR\\Bin\\SetEnv.cmd\")") + FOUND+=(["SDK${i/v/}"]="$RESULT [\"DISPLAY\"]=\"$DISPLAY\" [\"VERSION\"]=\"$VERSION\" [\"SETENV\"]=\"$INSTALL_DIR\\Bin\\SetEnv.cmd\")") else if [[ -n ${COMPILERS["SDK${i#v}"]+x} ]] ; then warning "Registry set for Windows SDK $i, but SetEnv.cmd not found" @@ -702,10 +767,10 @@ for i in $(reg query "$SDK_ROOT" 2>/dev/null | tr -d '\r' | sed -ne '/Windows\\v done # Now enumerate Visual Studio 2017+ instances -VSWHERE=$(dirname $(realpath $0))/vswhere.exe +VSWHERE="$(dirname "$(realpath "$0")")/vswhere.exe" if [[ ! -x $VSWHERE ]] ; then VSWHERE="$(printenv 'ProgramFiles(x86)')\\Microsoft Visual Studio\\Installer\\vswhere.exe" - VSWHERE=$(echo $VSWHERE| cygpath -f -) + VSWHERE=$(cygpath "$VSWHERE") fi if [[ -x $VSWHERE ]] ; then debug "$VSWHERE found" @@ -716,26 +781,38 @@ if [[ -x $VSWHERE ]] ; then installationPath) INSTANCE_PATH=${line#*: };; installationVersion) - INSTANCE_VER=${line#*: } - INSTANCE_VER=${INSTANCE_VER%.*} + INSTANCE_FULL_VER=${line#*: } + INSTANCE_VER=${INSTANCE_FULL_VER%.*} INSTANCE_VER=${INSTANCE_VER%.*};; displayName) INSTANCE_NAME=${line#*: } - debug "Looking at $INSTANCE in $INSTANCE_PATH ($INSTANCE_VER $INSTANCE_NAME)" - if [[ -e "$(echo $INSTANCE_PATH| cygpath -f -)/VC/Auxiliary/Build/vcvarsall.bat" ]] ; then + debug "Looking at $INSTANCE in $INSTANCE_PATH ($INSTANCE_FULL_VER $INSTANCE_NAME)" + if [[ -e "$(cygpath "$INSTANCE_PATH")/VC/Auxiliary/Build/vcvarsall.bat" ]] ; then debug "vcvarsall.bat found" - FOUND+=(["VS$INSTANCE_VER"]="([\"DISPLAY\"]=\"$INSTANCE_NAME\" [\"ARCH\"]=\"x86 x64\" [\"SETENV\"]=\"$INSTANCE_PATH\\VC\\Auxiliary\\Build\\vcvarsall.bat\" [\"SETENV_RELEASE\"]=\"\")") + if [[ $MODE -eq 2 ]]; then + INSTANCE_VER="$INSTANCE_VER-$INSTANCE" + fi + FOUND+=(["VS$INSTANCE_VER"]="([\"DISPLAY\"]=\"$INSTANCE_NAME\" [\"VERSION\"]=\"$INSTANCE_FULL_VER\" [\"ARCH\"]=\"x86 x64\" [\"SETENV\"]=\"$INSTANCE_PATH\\VC\\Auxiliary\\Build\\vcvarsall.bat\" [\"SETENV_RELEASE\"]=\"\")") else warning "vcvarsall.bat not found for $INSTANCE" fi;; esac - done < <("$VSWHERE" -all -products '*' -nologo | tr -d '\r') + done < <("$VSWHERE" -all -prerelease -products '*' -nologo | tr -d '\r') fi -if [[ $DEBUG -gt 1 ]] ; then +if [[ $DEBUG -gt 1 || $MODE -eq 2 ]] ; then for i in "${!FOUND[@]}" ; do - echo "Inspect $i">&2 - done + if [[ $MODE -eq 2 ]]; then + eval "COMPILER=${FOUND["$i"]}" + echo " $i (${COMPILER["VERSION"]}; ${COMPILER["SETENV"]})" + else + echo "Inspect $i">&2 + fi + done | sort +fi + +if [[ $MODE -eq 2 ]] ; then + exit 0 fi # Basic scanning is complete, now interrogate the packages which seem to be installed and ensure @@ -754,8 +831,9 @@ for i in "${!FOUND[@]}" ; do CANDIDATES[$i]=""; done -# For --all, act as though MSVS_PREFERENCE were "@" because this causes all packages to be tested. -if [[ $MODE -eq 1 ]] ; then +# For --all/--installed, act as though MSVS_PREFERENCE were "@" because this causes all packages to +# be tested. +if [[ $MODE -gt 0 ]] ; then PREFER_ENV=1 PREFERENCE=("@") else @@ -775,33 +853,33 @@ for i in $MSVS_PREFERENCE ; do else if [[ -n ${COMPILERS[$i]+x} || -n ${COMPILERS[${i%.*}.*]+x} ]] ; then if [[ -n ${CANDIDATES[$i]+x} ]] ; then - unset CANDIDATES[$i] - TEST+=($i) - PREFERENCE+=($i) + unset "CANDIDATES[$i]" + TEST+=("$i") + PREFERENCE+=("$i") elif [[ ${i#*.} = "*" ]] ; then INSTANCES= for j in "${!CANDIDATES[@]}" ; do - if [[ "${j%.*}.*" = $i ]] ; then - unset CANDIDATES[$j] + if [[ "${j%.*}.*" = "$i" ]] ; then + unset "CANDIDATES[$j]" INSTANCES="$INSTANCES $j" fi done INSTANCES="$(sort -r <<< "${INSTANCES// /$'\n'}")" - eval TEST+=($INSTANCES) - eval PREFERENCE+=($INSTANCES) + eval "TEST+=($INSTANCES)" + eval "PREFERENCE+=($INSTANCES)" fi else if [[ -n ${CANDIDATES["VS$i"]+x} ]] ; then - unset CANDIDATES["VS$i"] + unset "CANDIDATES[VS$i]" TEST+=("VS$i") PREFERENCE+=("VS$i") fi SDKS= for j in "${!COMPILERS[@]}" ; do - eval COMPILER=${COMPILERS[$j]} + eval "COMPILER=${COMPILERS["$j"]}" if [[ -n ${COMPILER["VC_VER"]+x} ]] ; then - if [[ $i = ${COMPILER["VC_VER"]} && -n ${CANDIDATES[$j]+x} ]] ; then - unset CANDIDATES[$j] + if [[ $i = "${COMPILER["VC_VER"]}" && -n ${CANDIDATES[$j]+x} ]] ; then + unset "CANDIDATES[$j]" SDKS="$j $SDKS" fi fi @@ -809,8 +887,8 @@ for i in $MSVS_PREFERENCE ; do SDKS=${SDKS% } SDKS="$(sort -r <<< "${SDKS// /$'\n'}")" SDKS=${SDKS//$'\n'/ } - eval TEST+=($SDKS) - eval PREFERENCE+=($SDKS) + eval "TEST+=($SDKS)" + eval "PREFERENCE+=($SDKS)" fi fi done @@ -819,9 +897,9 @@ done # them from FOUND so that they don't accidentally get reported on later. for i in "${!CANDIDATES[@]}" ; do if [[ $PREFER_ENV -eq 1 ]] ; then - TEST+=($i) + TEST+=("$i") else - unset FOUND[$i] + unset "FOUND[$i]" fi done @@ -852,42 +930,37 @@ declare -A ARCHINFO for i in "${TEST[@]}" ; do CURRENT=${FOUND[$i]} - eval COMPILER=$CURRENT + eval "COMPILER=$CURRENT" # At the end of this process, the keys of FOUND will be augmented with the architecture found in # each case (so if "VS14.0" was in FOUND from the scan and both the x86 and x64 compilers are # valid, then at the end of this loop FOUND will contain "VS14.0-x86" and "VS14.0-x64"). - unset FOUND[$i] + unset "FOUND[$i]" if [[ ${COMPILER["IS_EXPRESS"]}0 -gt 0 && -n ${COMPILER["EXPRESS_ARCH_SWITCHES"]+x} ]] ; then - eval ARCHINFO=${COMPILER["EXPRESS_ARCH_SWITCHES"]} + eval "ARCHINFO=${COMPILER['EXPRESS_ARCH_SWITCHES']}" elif [[ -n ${COMPILER["ARCH_SWITCHES"]+x} ]] ; then - eval ARCHINFO=${COMPILER["ARCH_SWITCHES"]} + eval "ARCHINFO=${COMPILER['ARCH_SWITCHES']}" else ARCHINFO=() fi # Determine the script to be executed and any non-architecture specific switches needed. - # $ENV is will contain the value of the environment variable for the compiler (empty for an SDK) - # which is required for Visual Studio 7.x shim later. + # $ENV will contain the value of the environment variable for the compiler (empty for an SDK) + # which is required for the Visual Studio 7.x shim later. + SCRIPT=${COMPILER["SETENV"]} if [[ -n ${COMPILER["ENV"]+x} ]] ; then - ENV=VS${COMPILER["ENV"]}COMNTOOLS - ENV=${!ENV%\"} - ENV=${ENV#\"} - if [[ ${COMPILER["ENV"]}0 -ge 800 ]] ; then - SCRIPT="$(cygpath -d -f - <<< $ENV)\\..\\..\\VC\\vcvarsall.bat" - SCRIPT_SWITCHES= - else - SCRIPT="$(cygpath -d -f - <<< $ENV)\\vsvars32.bat" - SCRIPT_SWITCHES= - fi + SCRIPT_SWITCHES='' else ENV= - SCRIPT=${COMPILER["SETENV"]} - SCRIPT_SWITCHES=${COMPILER["SETENV_RELEASE"]} + if [[ -n ${COMPILER["SETENV_RELEASE"]} ]]; then + SCRIPT_SWITCHES=" ${COMPILER["SETENV_RELEASE"]}" + else + SCRIPT_SWITCHES='' + fi fi # For reasons of escaping, the script is executed using its basename so the directory needs # prepending to PATH. - DIR=$(dirname "$SCRIPT" | cygpath -u -f -) + DIR=$(cygpath -u "$(dirname "$SCRIPT")") if [[ ${COMPILER["IS_EXPRESS"]} -gt 0 && -n ${COMPILER["EXPRESS_ARCH"]+x} ]] ; then ARCHS=${COMPILER["EXPRESS_ARCH"]} @@ -909,16 +982,41 @@ for i in "${TEST[@]}" ; do MSVS_LIB= MSVS_INC= - COMMAND='%EXEC_SCRIPT% && echo XMARKER && echo !PATH! && echo !LIB! && echo !INCLUDE!' + COMMAND='%EXEC_SCRIPT% && echo XMARKER && echo !PATH! && echo !LIB! && echo !INCLUDE! && echo !VCToolsVersion! && echo !VSCMD_VER! && echo !VisualStudioVersion!' + + if [[ $env_has_cl -eq 1 ]]; then + if [[ -n $__VSCMD_PREINIT_PATH ]]; then + TEST_PATH=$(cygpath -p "$__VSCMD_PREINIT_PATH") + elif [[ -n $ORIGINALPATH ]]; then + TEST_PATH="$ORIGINALPATH" + else + TEST_PATH="$PATH" + fi + else + TEST_PATH="$PATH" + fi # Note that EXEC_SCRIPT must have ARCH_SWITCHES first for older Platform SDKs (newer ones parse # arguments properly) if [[ $DEBUG -gt 3 ]] ; then - printf "Scanning %s... " "$(basename "$SCRIPT") $ARCH_SWITCHES $SCRIPT_SWITCHES">&2 + printf "Scanning %s... " "$(basename "$SCRIPT") $ARCH_SWITCHES$SCRIPT_SWITCHES">&2 fi # Setting MSYS2_ARG_CONV_EXCL to * inhibits attempts to convert the flags to COMSPEC as # command line parameters. num=0 + INCLUDE_KEY="$(env | grep -i '^include=')" + LIB_KEY="$(env | grep -i '^lib=')" + INCLUDE_KEY="${INCLUDE_KEY%=*}" + LIB_KEY="${LIB_KEY%=*}" + unset_keys=(-u ORIGINAL_PATH -u ORIGINALPATH -u TARGET_CPU -u TARGET_PLATFORM -u DevEnvDir \ + -u VSINSTALLDIR -u VCToolsVersion -u Framework35Version \ + -u __VSCMD_PREINIT_VCToolsVersion) + if [[ -n $INCLUDE_KEY ]]; then + unset_keys+=(-u "$INCLUDE_KEY") + fi + if [[ -n $LIB_KEY ]]; then + unset_keys+=(-u "$LIB_KEY") + fi while IFS= read -r line; do case $num in 0) @@ -927,17 +1025,32 @@ for i in "${TEST[@]}" ; do MSVS_LIB=${line%% };; 2) MSVS_INC=${line%% };; + 3) + VC_VERSION=${line%% };; + 4) + VSCMD_VER=${line%% };; + 5) + if [[ $VC_VERSION = '!VCToolsVersion!' ]] ; then + VC_VERSION=${line%% } + fi;; esac ((num++)) - done < <(INCLUDE='' LIB='' PATH="?msvs-detect?:$DIR:$PATH" ORIGINALPATH='' \ - EXEC_SCRIPT="$(basename "$SCRIPT") $ARCH_SWITCHES $SCRIPT_SWITCHES" \ - MSYS2_ARG_CONV_EXCL='*' \ - $(cygpath "$COMSPEC") /v:on /c $COMMAND 2>/dev/null | grep -F XMARKER -A 3 | tr -d '\015' | tail -3) + done < <(env "${unset_keys[@]}" PATH="?msvs-detect?:$DIR:/usr/bin:$TEST_PATH" \ + EXEC_SCRIPT="$(basename "$SCRIPT") $ARCH_SWITCHES$SCRIPT_SWITCHES" \ + MSYS2_ARG_CONV_EXCL='*' \ + "$(cygpath "$COMSPEC")" /d /v:on /c "$COMMAND" 2>/dev/null | grep -F XMARKER -A 6 | tr -d '\015' | tail -6) + if [[ $VC_VERSION = '!VisualStudioVersion!' ]] ; then + VC_VERSION="${COMPILER["VERSION"]}" + fi + if [[ $VSCMD_VER = '!VSCMD_VER!' ]]; then + VSCMD_VER='' + fi if [[ $DEBUG -gt 3 ]] ; then - echo done>&2 + echo 'done'>&2 fi if [[ -n $MSVS_PATH ]] ; then + MSVS_PATH_WIN32="${MSVS_PATH/?msvs-detect?*/}" # Translate MSVS_PATH back to Cygwin notation (/cygdrive, etc. and colon-separated) MSVS_PATH=$(cygpath "$MSVS_PATH" -p) # Remove any trailing / from elements of MSVS_PATH @@ -956,18 +1069,22 @@ for i in "${TEST[@]}" ; do if [[ ${i/.*/} = "VS7" ]] ; then find_in "${MSVS_PATH//:/*}" mt.exe if [[ $RET -eq 1 ]] ; then - MSVS_PATH="$MSVS_PATH$(cygpath -u -f - <<< $ENV\\Bin\\winnt):" + MSVS_PATH="$MSVS_PATH$(cygpath -u "$ENV\\Bin\\winnt"):" RET=0 fi fi # Ensure that these derived values give a valid compiler. - if check_environment "${MSVS_PATH//:/*}" "${MSVS_INC//;/*}" "${MSVS_LIB//;/*}" "$i" $arch ; then + if check_environment "${MSVS_PATH//:/*}" "${MSVS_INC//;/*}" "${MSVS_LIB//;/*}" "$i" "$arch" ; then # Put the package back into FOUND, but augmented with the architecture name and with the # derived values. FOUND["$i-$arch"]="${CURRENT%)} [\"MSVS_PATH\"]=\"$MSVS_PATH\" \ + [\"MSVS_PATH_WIN32\"]=\"$MSVS_PATH_WIN32\" \ [\"MSVS_INC\"]=\"$MSVS_INC\" \ [\"MSVS_LIB\"]=\"$MSVS_LIB\" \ + [\"SETENV_SWITCHES\"]=\"$ARCH_SWITCHES$SCRIPT_SWITCHES\" \ + [\"VC_VERSION\"]=\"$VC_VERSION\" \ + [\"VSCMD_VER\"]=\"$VSCMD_VER\" \ [\"ASSEMBLER\"]=\"$ASSEMBLER\")" #"# fixes vim syn match error # Check to see if this is a match for the environment C compiler. @@ -975,7 +1092,7 @@ for i in "${TEST[@]}" ; do TEST_cl=$(PATH="$MSVS_PATH:$PATH" "$WHICH" cl) TEST_cl=${TEST_cl,,} TEST_cl=${TEST_cl/bin\/*_/bin\/} - if [[ $TEST_cl = $ENV_cl ]] ; then + if [[ $TEST_cl = "$ENV_cl" ]] ; then # Create trailing semi-colon versions of the expansions of ENV_ for comparison with MSVS_ ENV_EXPAND_INC="${!ENV_INC%%;};" ENV_EXPAND_LIB="${!ENV_LIB%%;};" @@ -1012,7 +1129,7 @@ for i in "${TEST[@]}" ; do # Does this package match the current preference? Note that PREFERENCE and TEST are constructed in # a cunning (and hopefully not too "You are not expected to understand this" way) such that $PREF # will always equal $i, unless $PREF = "@". - if [[ $PREF = $i ]] ; then + if [[ $PREF = "$i" ]] ; then # In which case, check that the architecture(s)s were found if [[ -n ${FOUND["$i-$LEFT_ARCH"]+x} && -n ${FOUND["$i-$RIGHT_ARCH"]+x} ]] ; then debug "Solved TARGET_ARCH=$TARGET_ARCH with $i" @@ -1041,7 +1158,7 @@ FLIP=(["x86"]="x64" ["x64"]="x86") if [[ $MODE -eq 0 ]] ; then if [[ $PREF = "@" && -n ${ENV_COMPILER} ]] ; then - SOLUTION=${ENV_COMPILER%-$ENV_ARCH} + SOLUTION=${ENV_COMPILER%-"$ENV_ARCH"} # If --arch wasn't specified, then ensure that the other architecture was also found. If --arch # was specified, then validate that the compiler was valid. This should always happen, unless # something went wrong running the script to get MSVS_PATH, MSVS_LIB and MSVS_INC. @@ -1057,7 +1174,6 @@ if [[ $MODE -eq 0 ]] ; then if [[ -z ${SOLUTION+x} ]] ; then ((pref++)) debug "Search remaining: ${PREFERENCE[*]}" - TEST_ARCH=$TARGET_ARCH for i in "${PREFERENCE[@]:$pref}" ; do if [[ -n ${FOUND["$i-$LEFT_ARCH"]+x} && -n ${FOUND["$i-$RIGHT_ARCH"]+x} ]] ; then debug "Solved TARGET_ARCH='$TARGET_ARCH' with $i" @@ -1076,23 +1192,38 @@ fi if [[ $MODE -eq 1 ]] ; then echo "Installed and usable packages:" - for i in "${!FOUND[@]}" ; do - echo " $i" + for key in "${!FOUND[@]}" ; do + eval "COMPILER=${FOUND["$key"]}" + switches="${COMPILER["SETENV_SWITCHES"]}" + if [[ $switches != "${switches% *}" ]]; then + switches="\"$switches\"" + fi + echo "- ${key/-/ } \"${COMPILER["SETENV"]}\" $switches" done | sort exit 0 fi if [[ -n $SOLUTION ]] ; then - eval COMPILER=${FOUND[$SOLUTION-$LEFT_ARCH]} - output MSVS_NAME "${COMPILER["DISPLAY"]}" $LEFT_ARCH - output MSVS_PATH "${COMPILER["MSVS_PATH"]}" $LEFT_ARCH + eval "COMPILER=${FOUND["$SOLUTION-$LEFT_ARCH"]}" + if [[ $OUTPUT -ne 2 ]] ; then + output MSVS_NAME "${COMPILER["DISPLAY"]}" "always" + output MSVS_PATH "${COMPILER["MSVS_PATH"]}" $LEFT_ARCH + else + echo "${COMPILER["DISPLAY"]} (${COMPILER["VERSION"]})" + cmd="${COMPILER["SETENV"]}" + if [[ $cmd != "${cmd% *}" ]]; then + cmd="\"$cmd\"" + fi + echo "cmd*$cmd ${COMPILER["SETENV_SWITCHES"]}" + output MSVS_PATH "${COMPILER["MSVS_PATH_WIN32"]}" $LEFT_ARCH + fi output MSVS_INC "${COMPILER["MSVS_INC"]}" $LEFT_ARCH output MSVS_LIB "${COMPILER["MSVS_LIB"]}" $LEFT_ARCH if [[ $ML_REQUIRED -eq 1 ]] ; then output MSVS_ML "${COMPILER["ASSEMBLER"]%.exe}" always fi if [[ -z $TARGET_ARCH ]] ; then - eval COMPILER=${FOUND[$SOLUTION-$RIGHT_ARCH]} + eval "COMPILER=${FOUND["$SOLUTION-$RIGHT_ARCH"]}" output MSVS64_PATH "${COMPILER["MSVS_PATH"]}" $RIGHT_ARCH output MSVS64_INC "${COMPILER["MSVS_INC"]}" $RIGHT_ARCH output MSVS64_LIB "${COMPILER["MSVS_LIB"]}" $RIGHT_ARCH From b56d54e8e2dbbc70c49ef9196cfebd64df556fb1 Mon Sep 17 00:00:00 2001 From: Kate Date: Mon, 6 Oct 2025 23:47:49 +0100 Subject: [PATCH 24/29] depexts: Harden the parsing of 'apk policy' on Alpine --- master_changes.md | 1 + src/state/opamSysInteract.ml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/master_changes.md b/master_changes.md index d6011daa1fe..2ff3e9eba0f 100644 --- a/master_changes.md +++ b/master_changes.md @@ -77,6 +77,7 @@ users) ## Opamfile ## External dependencies + * Harden the parsing of `apk policy` on Alpine [#6742 @kit-ty-kate] ## Format upgrade * Complete upgrade mechanism to permit on the fly upgrade and write upgrade from repo and switch level [#6416 @rjbou] diff --git a/src/state/opamSysInteract.ml b/src/state/opamSysInteract.ml index 2bedb85c31d..ce1a7716dc9 100644 --- a/src/state/opamSysInteract.ml +++ b/src/state/opamSysInteract.ml @@ -693,7 +693,8 @@ let packages_status ?(env=OpamVariable.Map.empty) config packages = try (* package name *) Re.(Group.get (exec pkg_name l) 1), false, instavail with Not_found -> - if l.[2] <> ' ' then (* only version field is after two spaces *) + if not (OpamCompat.String.starts_with ~prefix:" " l) then + (* only version field is after two spaces *) pkg, false, instavail else if l = " lib/apk/db/installed" then (* from https://git.alpinelinux.org/apk-tools/tree/src/database.c#n58 *) From c1be49a7aa42969e11e69ef8652a8b88dfca7ff7 Mon Sep 17 00:00:00 2001 From: arozovyk Date: Thu, 18 Sep 2025 11:09:36 +0200 Subject: [PATCH 25/29] Add opam-set-os command for cleaner reftest OS family configuration --- master_changes.md | 2 ++ tests/reftests/autopin.test | 2 +- tests/reftests/depexts.test | 36 +++++++++++++++++----------------- tests/reftests/pin-legacy.test | 2 +- tests/reftests/readme.md | 1 + tests/reftests/reftests.test | 13 ++++++++++++ tests/reftests/run.ml | 19 +++++++++++++++--- 7 files changed, 52 insertions(+), 23 deletions(-) diff --git a/master_changes.md b/master_changes.md index 54ce4e27f30..409996f489e 100644 --- a/master_changes.md +++ b/master_changes.md @@ -169,6 +169,7 @@ users) * Add a test showing the behaviour of opam when faced with outdated git submodule in its local cache [#6153 @kit-ty-kate] * Add reftest for `--depext-only` option [#6516 @rjbou] * Add a test for `opam remove --force` [#6672 @rjbou] + * Use the new `opam-set-os` command when applicable [#6741 @arozovyk] ### Engine * Fix gcc < 14.3 bug on mingw i686 [#6624 @kit-ty-kate] @@ -178,6 +179,7 @@ users) * Harden the regexp used for substituting variable checksums [#6710 @kit-ty-kate] * Add the `unset` builtin [#6708 @kit-ty-kate] * Add the `sed-hash` command to replace hashes in opam output [#XXX @rjbou] + * Add `opam-set-os` command for reftests that combines setting global `os-family` variable. [#6741 @arozovyk] ## Github Actions * bump `actions/checkout` from 4 to 5 [#6643 @kit-ty-kate] diff --git a/tests/reftests/autopin.test b/tests/reftests/autopin.test index 73f95860e3d..2fe2d107f40 100644 --- a/tests/reftests/autopin.test +++ b/tests/reftests/autopin.test @@ -38,7 +38,7 @@ depends: [ ] depexts: ["some-depext"] ### OPAMNODEPEXTS=0 OPAMCONFIRMLEVEL=unsafe-yes -### opam var --global os-family=dummy-success +### opam-set-os dummy-success Added '[os-family "dummy-success" "Set through 'opam var'"]' to field global-variables in global configuration ### opam switch create ./foo --deps-only | sed-cmd echo diff --git a/tests/reftests/depexts.test b/tests/reftests/depexts.test index 08c707af3a3..75c24736c7a 100644 --- a/tests/reftests/depexts.test +++ b/tests/reftests/depexts.test @@ -3,7 +3,7 @@ N0REP0 opam-version: "2.0" depexts: "depext-1" ### OPAMNODEPEXTS=0 OPAMCONFIRMLEVEL=unsafe-yes -### opam var --global os-family=dummy-failure +### opam-set-os dummy-failure Added '[os-family "dummy-failure" "Set through 'opam var'"]' to field global-variables in global configuration ### opam switch create test --empty ### :I: Erroneous package manager install is not blocking : @@ -38,7 +38,7 @@ opam believes some required external dependencies are missing. opam can: ### # where '*' is for all and '0' for none ### # installed defaults to none, and availabel defaults to all ### :II:1:a: SUCCESS, all installed -### opam var --global os-family=dummy-success +### opam-set-os dummy-success Added '[os-family "dummy-success" "Set through 'opam var'"]' to field global-variables in global configuration ### opam-version: "2.0" @@ -77,7 +77,7 @@ The following actions will be performed: -> removed foo.1 Done. ### :II:1:b: Success, depext-ok installed, all available -### opam var --global os-family=dummy-success:depext-ok: +### opam-set-os dummy-success:depext-ok: Added '[os-family "dummy-success:depext-ok:" "Set through 'opam var'"]' to field global-variables in global configuration ### opam install foo | sed-cmd echo The following actions will be performed: @@ -113,7 +113,7 @@ The following actions will be performed: -> removed foo.1 Done. ### :II:1:c: Success, none installed, depext-avail available -### opam var --global os-family=dummy-success::depext-avail +### opam-set-os dummy-success::depext-avail Added '[os-family "dummy-success::depext-avail" "Set through 'opam var'"]' to field global-variables in global configuration ### opam install foo [ERROR] Package foo depends on the unavailable system packages 'depext-1', 'depext-ok' and 'depext-unav'. You can use `--no-depexts' to attempt installation anyway. @@ -122,7 +122,7 @@ Added '[os-family "dummy-success::depext-avail" "Set through 'opam var'"]' to fi [NOTE] foo is not installed. Nothing to do. -### opam var --global os-family=dummy-success:*: +### opam-set-os dummy-success:*: Added '[os-family "dummy-success:*:" "Set through 'opam var'"]' to field global-variables in global configuration ### opam install foo The following actions will be performed: @@ -141,7 +141,7 @@ The following actions will be performed: -> removed foo.1 Done. ### :II:1:d: Success, none installed, all available -### opam var --global os-family=dummy-success:0: +### opam-set-os dummy-success:0: Added '[os-family "dummy-success:0:" "Set through 'opam var'"]' to field global-variables in global configuration ### opam install foo | sed-cmd echo The following actions will be performed: @@ -177,7 +177,7 @@ The following actions will be performed: -> removed foo.1 Done. ### :II:1:e: Success, depext-ok installed, depext-avail available -### opam var --global os-family=dummy-success:depext-ok:depext-avail +### opam-set-os dummy-success:depext-ok:depext-avail Added '[os-family "dummy-success:depext-ok:depext-avail" "Set through 'opam var'"]' to field global-variables in global configuration ### opam install foo [ERROR] Package foo depends on the unavailable system packages 'depext-1' and 'depext-unav'. You can use `--no-depexts' to attempt installation anyway. @@ -187,7 +187,7 @@ Added '[os-family "dummy-success:depext-ok:depext-avail" "Set through 'opam var' Nothing to do. ### :II:2:a: SUCCESS, all installed -### opam var --global os-family=dummy-failure +### opam-set-os dummy-failure Added '[os-family "dummy-failure" "Set through 'opam var'"]' to field global-variables in global configuration ### opam-version: "2.0" @@ -223,7 +223,7 @@ opam believes some required external dependencies are missing. opam can: Nothing to do. ### :II:2:b: Failure, depext-ok installed, all available -### opam var --global os-family=dummy-failure:depext-ok: +### opam-set-os dummy-failure:depext-ok: Added '[os-family "dummy-failure:depext-ok:" "Set through 'opam var'"]' to field global-variables in global configuration ### opam install foo | sed-cmd false The following actions will be performed: @@ -256,7 +256,7 @@ opam believes some required external dependencies are missing. opam can: Nothing to do. ### :II:2:c: Failure, none installed, depext-avail available -### opam var --global os-family=dummy-failure::depext-avail +### opam-set-os dummy-failure::depext-avail Added '[os-family "dummy-failure::depext-avail" "Set through 'opam var'"]' to field global-variables in global configuration ### opam install foo [ERROR] Package foo depends on the unavailable system packages 'depext-1', 'depext-ok' and 'depext-unav'. You can use `--no-depexts' to attempt installation anyway. @@ -265,7 +265,7 @@ Added '[os-family "dummy-failure::depext-avail" "Set through 'opam var'"]' to fi [NOTE] foo is not installed. Nothing to do. -### opam var --global os-family=dummy-failure:*: +### opam-set-os dummy-failure:*: Added '[os-family "dummy-failure:*:" "Set through 'opam var'"]' to field global-variables in global configuration ### opam install foo The following actions will be performed: @@ -284,7 +284,7 @@ The following actions will be performed: -> removed foo.1 Done. ### :II:2:d: Failure, none installed, all available -### opam var --global os-family=dummy-failure:0: +### opam-set-os dummy-failure:0: Added '[os-family "dummy-failure:0:" "Set through 'opam var'"]' to field global-variables in global configuration ### opam install foo | sed-cmd false The following actions will be performed: @@ -317,7 +317,7 @@ opam believes some required external dependencies are missing. opam can: Nothing to do. ### :II:2:e: Failure, depext-ok installed, depext-avail available -### opam var --global os-family=dummy-failure:depext-ok:depext-avail +### opam-set-os dummy-failure:depext-ok:depext-avail Added '[os-family "dummy-failure:depext-ok:depext-avail" "Set through 'opam var'"]' to field global-variables in global configuration ### opam install foo [ERROR] Package foo depends on the unavailable system packages 'depext-1' and 'depext-unav'. You can use `--no-depexts' to attempt installation anyway. @@ -332,7 +332,7 @@ Nothing to do. ### opam-version: "2.0" depexts: ["depext-ok" "depext-avail"] -### opam var --global os-family=dummy-success:depext-ok:depext-avail +### opam-set-os dummy-success:depext-ok:depext-avail Added '[os-family "dummy-success:depext-ok:depext-avail" "Set through 'opam var'"]' to field global-variables in global configuration ### :III:1:a: normal install ### opam install bar | sed-cmd echo @@ -401,7 +401,7 @@ Done. ### opam-version: "2.0" depexts: ["depext-ok" "depext-unav"] -### opam var --global os-family=dummy-success:depext-ok:0 +### opam-set-os dummy-success:depext-ok:0 Added '[os-family "dummy-success:depext-ok:0" "Set through 'opam var'"]' to field global-variables in global configuration ### :III:2:a: normal install ### opam install baz @@ -439,7 +439,7 @@ Reverted field depext-bypass in switch bypass ### opam-version: "2.0" depexts: ["depext-ok"] -### opam var --global os-family=dummy-success +### opam-set-os dummy-success Added '[os-family "dummy-success" "Set through 'opam var'"]' to field global-variables in global configuration ### opam install qux | sed-cmd echo The following actions will be performed: @@ -465,7 +465,7 @@ opam believes some required external dependencies are missing. opam can: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -> installed qux.1 Done. -### opam var --global os-family=dummy-success:depext-ok: +### opam-set-os dummy-success:depext-ok: Added '[os-family "dummy-success:depext-ok:" "Set through 'opam var'"]' to field global-variables in global configuration ### opam reinstall qux The following actions will be performed: @@ -476,7 +476,7 @@ The following actions will be performed: -> removed qux.1 -> installed qux.1 Done. -### opam var --global os-family=dummy-success:0: +### opam-set-os dummy-success:0: Added '[os-family "dummy-success:0:" "Set through 'opam var'"]' to field global-variables in global configuration ### opam reinstall qux | sed-cmd echo [WARNING] Opam package qux.1 depends on the following system package that can no longer be found: depext-ok diff --git a/tests/reftests/pin-legacy.test b/tests/reftests/pin-legacy.test index ad57d31d477..32be6166adb 100644 --- a/tests/reftests/pin-legacy.test +++ b/tests/reftests/pin-legacy.test @@ -82,7 +82,7 @@ Done. ### :3: depext update ### ::::::::::::::::::::::: ### OPAMNODEPEXTS=0 OPAMCONFIRMLEVEL=unsafe-yes -### opam var --global os-family=dummy-success +### opam-set-os dummy-success Added '[os-family "dummy-success" "Set through 'opam var'"]' to field global-variables in global configuration ### opam-version: "2.0" diff --git a/tests/reftests/readme.md b/tests/reftests/readme.md index 2a8baeb9ba9..69ffa256fdf 100644 --- a/tests/reftests/readme.md +++ b/tests/reftests/readme.md @@ -77,6 +77,7 @@ output... * `opam-cache repo [nvs]`: print the content of repository cache. If `[nvs]` is specified, filter over these package names or packages. * `unset FOO` unset variables from environment + * `opam-set-os ` combines setting global `os-family` variable - if you need more shell power, create a script using then run it. Or just use `sh -c`... but beware for compatibility. diff --git a/tests/reftests/reftests.test b/tests/reftests/reftests.test index a7ca8edf3e6..ee94f2dac3b 100644 --- a/tests/reftests/reftests.test +++ b/tests/reftests/reftests.test @@ -1056,3 +1056,16 @@ REFTEST_UNSET=test REFTEST_UNSET= ### unset REFTEST_UNSET ### env | grep REFTEST_UNSET +### :V:4: opam-set-os +### opam var --global os-distribution=void +Added '[os-distribution "void" "Set through 'opam var'"]' to field global-variables in global configuration +### opam var --global os-family=void +Added '[os-family "void" "Set through 'opam var'"]' to field global-variables in global configuration +### opam var --global os=void +Added '[os "void" "Set through 'opam var'"]' to field global-variables in global configuration +### opam var os-distribution +void +### opam var os-family +void +### opam var os +void diff --git a/tests/reftests/run.ml b/tests/reftests/run.ml index 30399bd1ed1..f0cf9974ac2 100644 --- a/tests/reftests/run.ml +++ b/tests/reftests/run.ml @@ -284,6 +284,7 @@ type command = output: string option; unordered: bool; sort: bool;} + | Set_os of string | Export of (string * [`eq | `pluseq | `eqplus] * string) list | Unset of string list | Comment of string @@ -537,6 +538,14 @@ module Parse = struct Json { files = args; filter = rewr; } | Some "unset" -> Unset args + | Some "opam-set-os" -> + (match args with + | os :: [] -> Set_os os + | _ -> failwith + (Printf.sprintf + "Bad usage of opam-set-os %s.\n\ + expecting 'opam-set-os [depext-test-specification]" + (String.concat " " args))); | Some "opam-cache" -> let kind, switch, nvs = match args with @@ -1209,9 +1218,13 @@ let run_test ?(vars=[]) ~opam t = in diffl [] (String.split_on_char '\n' r) out); Option.iter (Printf.printf "# Return code %d #\n") errcode; - match output with - | None -> vars - | Some v -> (v, r) :: List.filter (fun (w,_) -> v <> w) vars) + (match output with + | None -> vars + | Some v -> (v, r) :: List.filter (fun (w,_) -> v <> w) vars) + | Set_os os -> + ignore @@ run_cmd ~opam ~dir ~vars + "opam" ["var"; "--global"; Printf.sprintf "os-family=%s" os]; + vars) vars t.commands in From e16b84bbab31597fe235d6b23e9804166c70edea Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Mon, 6 Oct 2025 17:36:32 +0100 Subject: [PATCH 26/29] Don't unnecessarily initialise csh variables csh requires shell variables to be initialised when used with +=, etc. but this isn't necessary for unconditional assignment. --- master_changes.md | 1 + src/state/opamEnv.ml | 14 +++++++++----- tests/reftests/init-scripts.unix.test | 2 -- tests/reftests/init-scripts.win32.test | 2 -- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/master_changes.md b/master_changes.md index 80fc3ab47d7..3f67eb6e0a2 100644 --- a/master_changes.md +++ b/master_changes.md @@ -126,6 +126,7 @@ users) * [NEW] Fetch shared archive sources without checksums [#6627 @psafont - fix #5638] ## Shell + * csh: Don't double-set unconditional variables in `variables.csh` and `env_hook.csh` [#6729 @dra27] ## Internal * Replace every polymorphic uses of `List.mem` by a version that doesn't use `Repr.equal` [#6644 @kit-ty-kate] diff --git a/src/state/opamEnv.ml b/src/state/opamEnv.ml index 4234463ff47..ea0b2a00f27 100644 --- a/src/state/opamEnv.ml +++ b/src/state/opamEnv.ml @@ -970,7 +970,7 @@ let env_hook_script_base = function | SH_fish -> Some OpamScript.env_hook_fish | SH_pwsh _ | SH_cmd -> None -let export_in_shell shell = +let export_in_shell ~unconditional shell = let make_comment comment_opt = OpamStd.Option.to_string (Printf.sprintf "# %s\n") comment_opt in @@ -978,8 +978,12 @@ let export_in_shell shell = Printf.sprintf "%s%s=%s; export %s;\n" (make_comment comment) k v k in let csh (k,v,comment) = - Printf.sprintf "%sif ( ! ${?%s} ) setenv %s \"\"\nsetenv %s %s\n" - (make_comment comment) k k k v in + if unconditional then + Printf.sprintf "%ssetenv %s %s\n" + (make_comment comment) k v + else + Printf.sprintf "%sif ( ! ${?%s} ) setenv %s \"\"\nsetenv %s %s\n" + (make_comment comment) k k k v in let fish (k,v,comment) = (* Fish converts some colon-separated vars to arrays, which have to be treated differently. MANPATH is handled automatically, so better not to @@ -1022,7 +1026,7 @@ let export_in_shell shell = let env_hook_script shell = Option.map (fun script -> - export_in_shell shell ("OPAMNOENVNOTICE", "true", None) + export_in_shell shell ~unconditional:true ("OPAMNOENVNOTICE", "true", None) ^ script) (env_hook_script_base shell) @@ -1129,7 +1133,7 @@ let string_of_update st shell updates = | SH_cmd -> Printf.sprintf "%%%s%%%c%s" envu_var sep string | _ -> Printf.sprintf "\"$%s\":'%s'" envu_var string) in - export_in_shell shell (key, value, envu_comment) in + export_in_shell shell ~unconditional:(envu_op = Eq) (key, value, envu_comment) in OpamStd.List.concat_map "" aux updates let write_script dir (name, body) = diff --git a/tests/reftests/init-scripts.unix.test b/tests/reftests/init-scripts.unix.test index b6338c9cb6c..8547fc628ae 100644 --- a/tests/reftests/init-scripts.unix.test +++ b/tests/reftests/init-scripts.unix.test @@ -74,7 +74,6 @@ set -gx OPAM_SWITCH_PREFIX '${BASEDIR}/root/fake'; set -gx PATH '${BASEDIR}/root/fake/bin' $PATH; ### cat root/opam-init/variables.csh | grep -v man | grep -v MANPATH # Prefix of the current opam switch -if ( ! ${?OPAM_SWITCH_PREFIX} ) setenv OPAM_SWITCH_PREFIX "" setenv OPAM_SWITCH_PREFIX '${BASEDIR}/root/fake' # Binary dir for opam switch fake if ( ! ${?PATH} ) setenv PATH "" @@ -115,7 +114,6 @@ function __opam_env_export_eval --on-event fish_prompt eval (opam env --shell=fish --readonly 2> /dev/null) end ### cat root/opam-init/env_hook.csh -if ( ! ${?OPAMNOENVNOTICE} ) setenv OPAMNOENVNOTICE "" setenv OPAMNOENVNOTICE true alias precmd 'eval `opam env --shell=csh --readonly`' ### test -f root/opam-init/env_hook.cmd diff --git a/tests/reftests/init-scripts.win32.test b/tests/reftests/init-scripts.win32.test index 5bd3be63d81..f800ea696c5 100644 --- a/tests/reftests/init-scripts.win32.test +++ b/tests/reftests/init-scripts.win32.test @@ -70,7 +70,6 @@ PATH='${BASEDIR}/root/fake/bin':"$PATH"; export PATH; ### test -f root/opam-init/variables.fish ### cat root/opam-init/variables.csh | grep -v man | grep -v MANPATH # Prefix of the current opam switch -if ( ! ${?OPAM_SWITCH_PREFIX} ) setenv OPAM_SWITCH_PREFIX "" setenv OPAM_SWITCH_PREFIX '${BASEDIR}/root/fake' # Binary dir for opam switch fake if ( ! ${?PATH} ) setenv PATH "" @@ -111,7 +110,6 @@ function __opam_env_export_eval --on-event fish_prompt eval (opam env --shell=fish --readonly 2> /dev/null) end ### cat root/opam-init/env_hook.csh -if ( ! ${?OPAMNOENVNOTICE} ) setenv OPAMNOENVNOTICE "" setenv OPAMNOENVNOTICE true alias precmd 'eval `opam env --shell=csh --readonly`' ### test -f root/opam-init/env_hook.cmd From 3fa4ac7ba5b36737e77723ae6f8b9161042d08b9 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Wed, 8 Oct 2025 12:07:23 +0100 Subject: [PATCH 27/29] Add a test for variables.sh double-applying --- master_changes.md | 1 + tests/reftests/dune.inc | 21 ++++++++++++++++++++ tests/reftests/env-idempotent.test | 31 ++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 tests/reftests/env-idempotent.test diff --git a/master_changes.md b/master_changes.md index 3f67eb6e0a2..90a2ccb365c 100644 --- a/master_changes.md +++ b/master_changes.md @@ -172,6 +172,7 @@ users) * Add reftest for `--depext-only` option [#6516 @rjbou] * Add a test for `opam remove --force` [#6672 @rjbou] * Use the new `opam-set-os` command when applicable [#6741 @arozovyk] + * Add a test showing that `variables.sh` doesn't re-apply updates if sourced more than once in the same session [#6729 @dra27 @kit-ty-kate] ### Engine * Fix gcc < 14.3 bug on mingw i686 [#6624 @kit-ty-kate] diff --git a/tests/reftests/dune.inc b/tests/reftests/dune.inc index 2bf5eb08839..c7e2640d96d 100644 --- a/tests/reftests/dune.inc +++ b/tests/reftests/dune.inc @@ -734,6 +734,27 @@ %{targets} (run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:empty-conflicts-007.test} %{read-lines:testing-env})))) +(rule + (alias reftest-env-idempotent) + (enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1)))) + (action + (diff env-idempotent.test env-idempotent.out))) + +(alias + (name reftest) + (enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1)))) + (deps (alias reftest-env-idempotent))) + +(rule + (targets env-idempotent.out) + (deps root-N0REP0) + (enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1)))) + (package opam) + (action + (with-stdout-to + %{targets} + (run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:env-idempotent.test} %{read-lines:testing-env})))) + (rule (alias reftest-env) (enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1)))) diff --git a/tests/reftests/env-idempotent.test b/tests/reftests/env-idempotent.test new file mode 100644 index 00000000000..0cd4ac00445 --- /dev/null +++ b/tests/reftests/env-idempotent.test @@ -0,0 +1,31 @@ +N0REP0 +### rm -rf $OPAMROOT +### unset OPAMROOT +### sh -c "command -v opam" >$ OPAMBIN +### +set -eu +export HOME=$PWD +export SHELL=$(command -v bash) +"$@" +### +set -eu +export HOME=$PWD +export SHELL=$(command -v bash) +bash -lc "export PATH=\"\$PATH:$PATH\" HOME=\"$HOME\" SHELL=\"$SHELL\" && $@" +### <.bash_profile> +export PATH=/usr/bin +### bash locally-in-bash.sh opam init -a --bypass-checks --bare REPO --root root --shell=bash | '\\' -> '/' +No configuration file found, using built-in defaults. + +<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><> +[default] Initialised + +User configuration: + Updating ~/.bash_profile. +[NOTE] Make sure that ~/.bash_profile is well sourced in your ~/.bashrc. + + Added 9 lines after line 2 in ~/.bash_profile. +### # we need the switch for variables file +### opam switch create fake --empty --root root +### bash bash-lc.sh "bash bash-lc.sh \"'$OPAMBIN' exec --root root --no-switch -- env\"" | grep -v MANPATH | grep /root/fake/ | '=.*' -> '' +PATH From 97adba197765c1b2d0c575d02420a8fcdbaac0ea Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Tue, 7 Oct 2025 15:30:35 +0100 Subject: [PATCH 28/29] Make variables.* back off if already set --- master_changes.md | 1 + src/state/opamEnv.ml | 21 ++++++++++++++++++++- tests/reftests/env-idempotent.test | 1 - tests/reftests/init-scripts.unix.test | 7 +++++++ tests/reftests/init-scripts.win32.test | 6 ++++++ 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/master_changes.md b/master_changes.md index 90a2ccb365c..7c71ba8965a 100644 --- a/master_changes.md +++ b/master_changes.md @@ -22,6 +22,7 @@ users) ## Init * Remove `getconf` from the list of required runtime tools, which allows `opam init` to work out-of-the-box on Haiku [#6634 @kit-ty-kate - fix #6632] + * The variables scripts now only updates the environment if `OPAM_SWITCH_PREFIX` is unset-or-empty [#6729 @dra27 - fix dbuenzli/topkg#142, #4649, #5761] ## Config report diff --git a/src/state/opamEnv.ml b/src/state/opamEnv.ml index ea0b2a00f27..2694f8d44ed 100644 --- a/src/state/opamEnv.ml +++ b/src/state/opamEnv.ml @@ -1030,6 +1030,23 @@ let env_hook_script shell = ^ script) (env_hook_script_base shell) +let abort_if_set var shell = + (* Each of these incantations aborts the currently running script if [var] is + unset or empty ("null") *) + match shell with + | SH_zsh | SH_bash | SH_sh -> + Printf.sprintf "test -z \"${%s:+x}\" || return\n" var + | SH_csh -> + Printf.sprintf "if ( ${?%s} ) then\n if ( \"$%s\" != \"\") exit\nendif\n" + var var + | SH_pwsh _ -> + Printf.sprintf "if ($env:%s -ne $null -and $env:%s -ne '') { return }\n" + var var + | SH_fish -> + Printf.sprintf "test -z \"$%s\"; or return\n" var + | SH_cmd -> + Printf.sprintf "if defined %s if \"%%%s%%\" neq \"\" goto :EOF\n" var var + let source root shell f = let fname = OpamFilename.to_string (OpamPath.init root // f) in let unix_transform ?using_backslashes () = @@ -1223,7 +1240,9 @@ let write_dynamic_init_scripts st = List.iter (fun shell -> write_script (OpamPath.init st.switch_global.root) - (variables_file shell, string_of_update st shell updates)) + (variables_file shell, + abort_if_set "OPAM_SWITCH_PREFIX" shell + ^ string_of_update st shell updates)) [SH_sh; SH_csh; SH_fish; SH_pwsh Powershell; SH_cmd] with OpamSystem.Locked -> OpamConsole.warning diff --git a/tests/reftests/env-idempotent.test b/tests/reftests/env-idempotent.test index 0cd4ac00445..94de48e6c59 100644 --- a/tests/reftests/env-idempotent.test +++ b/tests/reftests/env-idempotent.test @@ -28,4 +28,3 @@ User configuration: ### # we need the switch for variables file ### opam switch create fake --empty --root root ### bash bash-lc.sh "bash bash-lc.sh \"'$OPAMBIN' exec --root root --no-switch -- env\"" | grep -v MANPATH | grep /root/fake/ | '=.*' -> '' -PATH diff --git a/tests/reftests/init-scripts.unix.test b/tests/reftests/init-scripts.unix.test index 8547fc628ae..eb1dd153437 100644 --- a/tests/reftests/init-scripts.unix.test +++ b/tests/reftests/init-scripts.unix.test @@ -61,6 +61,7 @@ if exist "${BASEDIR}/root/opam-init/variables.cmd" call "${BASEDIR}/root/opam-in if Test-Path "${BASEDIR}/root/opam-init/variables.ps1" { . "${BASEDIR}/root/opam-init/variables.ps1" *> $null } ### : Variables scripts : ### cat root/opam-init/variables.sh | grep -v man | grep -v MANPATH +test -z "${OPAM_SWITCH_PREFIX:+x}" || return # Prefix of the current opam switch OPAM_SWITCH_PREFIX='${BASEDIR}/root/fake'; export OPAM_SWITCH_PREFIX; # Binary dir for opam switch fake @@ -68,22 +69,28 @@ PATH='${BASEDIR}/root/fake/bin':"$PATH"; export PATH; ### test -f root/opam-init/variables.zsh # Return code 1 # ### cat root/opam-init/variables.fish | grep -v man | grep -v MANPATH +test -z "$OPAM_SWITCH_PREFIX"; or return # Prefix of the current opam switch set -gx OPAM_SWITCH_PREFIX '${BASEDIR}/root/fake'; # Binary dir for opam switch fake set -gx PATH '${BASEDIR}/root/fake/bin' $PATH; ### cat root/opam-init/variables.csh | grep -v man | grep -v MANPATH +if ( ${?OPAM_SWITCH_PREFIX} ) then + if ( "$OPAM_SWITCH_PREFIX" != "") exit +endif # Prefix of the current opam switch setenv OPAM_SWITCH_PREFIX '${BASEDIR}/root/fake' # Binary dir for opam switch fake if ( ! ${?PATH} ) setenv PATH "" setenv PATH '${BASEDIR}/root/fake/bin':"$PATH" ### cat root/opam-init/variables.cmd | grep -v man | grep -v MANPATH +if defined OPAM_SWITCH_PREFIX if "%OPAM_SWITCH_PREFIX%" neq "" goto :EOF :: Prefix of the current opam switch set "OPAM_SWITCH_PREFIX=${BASEDIR}/root/fake" :: Binary dir for opam switch fake set "PATH=${BASEDIR}/root/fake/bin:%PATH%" ### cat root/opam-init/variables.ps1 | grep -v man | grep -v MANPATH +if ($env:OPAM_SWITCH_PREFIX -ne $null -and $env:OPAM_SWITCH_PREFIX -ne '') { return } # Prefix of the current opam switch $env:OPAM_SWITCH_PREFIX='${BASEDIR}/root/fake' # Binary dir for opam switch fake diff --git a/tests/reftests/init-scripts.win32.test b/tests/reftests/init-scripts.win32.test index f800ea696c5..b314cde94d9 100644 --- a/tests/reftests/init-scripts.win32.test +++ b/tests/reftests/init-scripts.win32.test @@ -60,6 +60,7 @@ if exist "${BASEDIR}/root/opam-init/variables.cmd" call "${BASEDIR}/root/opam-in if Test-Path "${BASEDIR}/root/opam-init/variables.ps1" { . "${BASEDIR}/root/opam-init/variables.ps1" *> $null } ### : Variables scripts : ### cat root/opam-init/variables.sh | grep -v man | grep -v MANPATH +test -z "${OPAM_SWITCH_PREFIX:+x}" || return # Prefix of the current opam switch OPAM_SWITCH_PREFIX='${BASEDIR}/root/fake'; export OPAM_SWITCH_PREFIX; # Binary dir for opam switch fake @@ -69,17 +70,22 @@ PATH='${BASEDIR}/root/fake/bin':"$PATH"; export PATH; ### # ERROR, broken, see opam#5854 testing only its existence ### test -f root/opam-init/variables.fish ### cat root/opam-init/variables.csh | grep -v man | grep -v MANPATH +if ( ${?OPAM_SWITCH_PREFIX} ) then + if ( "$OPAM_SWITCH_PREFIX" != "") exit +endif # Prefix of the current opam switch setenv OPAM_SWITCH_PREFIX '${BASEDIR}/root/fake' # Binary dir for opam switch fake if ( ! ${?PATH} ) setenv PATH "" setenv PATH '${BASEDIR}/root/fake/bin':"$PATH" ### cat root/opam-init/variables.cmd | grep -v man | grep -v MANPATH +if defined OPAM_SWITCH_PREFIX if "%OPAM_SWITCH_PREFIX%" neq "" goto :EOF :: Prefix of the current opam switch set "OPAM_SWITCH_PREFIX=${BASEDIR}/root/fake" :: Binary dir for opam switch fake set "PATH=${BASEDIR}/root/fake/bin;%PATH%" ### cat root/opam-init/variables.ps1 | grep -v man | grep -v MANPATH +if ($env:OPAM_SWITCH_PREFIX -ne $null -and $env:OPAM_SWITCH_PREFIX -ne '') { return } # Prefix of the current opam switch $env:OPAM_SWITCH_PREFIX='${BASEDIR}/root/fake' # Binary dir for opam switch fake From cc8e824a5b75cd1671dffe11d0491f32f5f18dfb Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Wed, 8 Oct 2025 15:59:03 +0100 Subject: [PATCH 29/29] Add a test showing the "nuking the root" effect Environment variables registered in variables.sh remain even on opam env for a different switch. --- master_changes.md | 1 + tests/reftests/env-idempotent.test | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/master_changes.md b/master_changes.md index 7c71ba8965a..c9acac00d6d 100644 --- a/master_changes.md +++ b/master_changes.md @@ -174,6 +174,7 @@ users) * Add a test for `opam remove --force` [#6672 @rjbou] * Use the new `opam-set-os` command when applicable [#6741 @arozovyk] * Add a test showing that `variables.sh` doesn't re-apply updates if sourced more than once in the same session [#6729 @dra27 @kit-ty-kate] + * Add a test for #6455 showing the effect on opam env if the switch whose settings were applied by `variables.sh` is deleted [#6729 @dra27] ### Engine * Fix gcc < 14.3 bug on mingw i686 [#6624 @kit-ty-kate] diff --git a/tests/reftests/env-idempotent.test b/tests/reftests/env-idempotent.test index 94de48e6c59..399adc3c0c6 100644 --- a/tests/reftests/env-idempotent.test +++ b/tests/reftests/env-idempotent.test @@ -28,3 +28,8 @@ User configuration: ### # we need the switch for variables file ### opam switch create fake --empty --root root ### bash bash-lc.sh "bash bash-lc.sh \"'$OPAMBIN' exec --root root --no-switch -- env\"" | grep -v MANPATH | grep /root/fake/ | '=.*' -> '' +### # Simulate nuking a root entirely +### opam switch create fake2 --empty --root root +### rm -rf root/fake2 +### bash bash-lc.sh "'$OPAMBIN' exec --root root --switch=fake -- env" | grep -v MANPATH | grep /root/fake2/ | '=.*' -> '' +PATH