dune subst should not fail when adding the version field in opam files

  $ cat > dune-project << EOF
  > (lang dune 3.19)
  > (name test)
  > (version 0.1)
  > (generate_opam_files)
  > (package (name test) (allow_empty))
  > EOF

  $ dune build

  $ cat test.opam
  # This file is generated by dune, edit dune-project instead
  opam-version: "2.0"
  version: "0.1"
  depends: [
    "dune" {>= "3.19"}
    "odoc" {with-doc}
  ]
  build: [
    ["dune" "subst"] {dev}
    [
      "dune"
      "build"
      "-p"
      name
      "-j"
      jobs
      "@install"
      "@runtest" {with-test}
      "@doc" {with-doc}
    ]
  ]
  x-maintenance-intent: ["(latest)"]

  $ dune subst

  $ cat test.opam
  # This file is generated by dune, edit dune-project instead
  opam-version: "2.0"
  version: "0.1"
  depends: [
    "dune" {>= "3.19"}
    "odoc" {with-doc}
  ]
  build: [
    ["dune" "subst"] {dev}
    [
      "dune"
      "build"
      "-p"
      name
      "-j"
      jobs
      "@install"
      "@runtest" {with-test}
      "@doc" {with-doc}
    ]
  ]
  x-maintenance-intent: ["(latest)"]

Release-style builds should take a checked-in opam file as-is:

  $ mkdir release-profile
  $ cd release-profile

  $ cat > dune-project << EOF
  > (lang dune 3.23)
  > (name test)
  > (version 0.1)
  > (generate_opam_files)
  > (package (name test) (allow_empty))
  > EOF

  $ cat > test.opam << EOF
  > version: "0.1"
  > # SOURCE COPY
  > opam-version: "2.0"
  > EOF

  $ dune build @install 2>&1 | sed -n '1,3p'
  File "test.opam", line 1, characters 0-0:
  --- test.opam
  +++ test.opam.generated
  [1]

  $ dune build -p test @install _build/install/default/lib/test/opam
  $ grep '^# SOURCE COPY$' _build/install/default/lib/test/opam
  # SOURCE COPY
  $ grep '^# SOURCE COPY$' test.opam
  # SOURCE COPY
