N0REP0
### ::: Setup :::
### <p.patch>
Trust me, im' a patch!
### openssl md5 p.patch | '.*= ' -> '' >$ PATCH_MD5
### openssl sha256 p.patch | '.*= ' -> '' >$ PATCH_SHA256
### sh -c "echo '$PATCH_MD5' | cut -c 1-2" >$ PRE_MD5
### echo "$OPAMROOT/download-cache/md5/$PRE_MD5/$PATCH_MD5" >$ PATCH_MD5_PATH
### sh -c "echo '$PATCH_SHA256' | cut -c 1-2" >$ PRE_SHA256
### echo "$OPAMROOT/download-cache/sha256/$PRE_SHA256/$PATCH_SHA256" >$ PATCH_SHA256_PATH
### <check-cache.sh>
set -ue

eval "MD5_PATH=\"$PATCH_MD5_PATH\""
eval "SHA256_PATH=\"$PATCH_SHA256_PATH\""

if command -v cygpath 2> /dev/null > /dev/null ; then
  MD5_PATH=`cygpath -u "$MD5_PATH"`
  SHA256_PATH=`cygpath -u "$SHA256_PATH"`
fi

check2sum () {
  kind=$1
  path=$2
  hsh=`openssl "$kind" "$path" | cut -f 2 -d ' '`
  name=`basename "$path"`
  if [ "$name" = "$hsh" ]; then
    echo "with matching checksum"
  else
    echo "with mismatching checksum"
  fi
}
check () {
  path=$1
  if [ -L "$path" ] ; then
    out="link,"
    realpath=`realpath -mLP "$path"`
    if [ "$realpath" = "$MD5_PATH" ]; then
      out="$out to md5 patch"
    elif [ "$realpath" = "$SHA256_PATH" ]; then
      out="$out to sha256 patch"
    else
      out="$out to unknown path $realpath"
    fi
  elif [ -f "$path" ] ; then
    out="patch,"
    if echo "$path" | grep -q md5 ; then
      out="$out `check2sum md5 $path`"
    elif echo "$path" | grep -q sha256 ; then
      out="$out `check2sum sha256 $path`"
    else
      out="$out no checksum validation"
    fi
  else
    out="not found"
  fi
  echo "$out"
}

echo "MD5: $(check "$MD5_PATH")"
echo "SHA256: $(check "$SHA256_PATH")"
### <add-files.sh>
set -ue
pkg=$1
pkgpath="REPO/packages/${pkg%.*}/$pkg"
if [ ! -d $pkgpath/files ] ; then
  mkdir $pkgpath/files
  cp p.patch $pkgpath/files/
fi
### ::: Setup: extra-sources section :::
### <pkg:good-md5.1>
opam-version: "2.0"
maintainer: "nobody"
authors: "nobody neither"
homepage: "https://no.bo.dy"
bug-reports: "https://still.nobo.dy"
dev-repo: "git+https://no.were"
license: "MIT"
synopsis: "Initially empty"
build: [ "test" "-f" "i-am-a-patch" ]
extra-source "i-am-a-patch" {
  src:"p.patch"
  checksum: [ "md5=patch-md5" ]
}
### <pkg:good-sha256.1>
opam-version: "2.0"
maintainer: "nobody"
authors: "nobody neither"
homepage: "https://no.bo.dy"
bug-reports: "https://still.nobo.dy"
dev-repo: "git+https://no.were"
license: "MIT"
synopsis: "Initially empty"
build: [ "test" "-f" "i-am-a-patch" ]
extra-source "i-am-a-patch" {
  src:"p.patch"
  checksum: [ "sha256=patch-sha256" ]
}
### <pkg:good-md5-good-sha256.1>
opam-version: "2.0"
maintainer: "nobody"
authors: "nobody neither"
homepage: "https://no.bo.dy"
bug-reports: "https://still.nobo.dy"
dev-repo: "git+https://no.were"
license: "MIT"
synopsis: "Initially empty"
build: [ "test" "-f" "i-am-a-patch" ]
extra-source "i-am-a-patch" {
  src:"p.patch"
  checksum: [
    "md5=patch-md5"
    "sha256=patch-sha256"
  ]
}
### <pkg:good-sha256-good-md5.1>
opam-version: "2.0"
maintainer: "nobody"
authors: "nobody neither"
homepage: "https://no.bo.dy"
bug-reports: "https://still.nobo.dy"
dev-repo: "git+https://no.were"
license: "MIT"
synopsis: "Initially empty"
build: [ "test" "-f" "i-am-a-patch" ]
extra-source "i-am-a-patch" {
  src:"p.patch"
  checksum: [
    "sha256=patch-sha256"
    "md5=patch-md5"
  ]
}
### <pkg:no-checksum.1>
opam-version: "2.0"
maintainer: "nobody"
authors: "nobody neither"
homepage: "https://no.bo.dy"
bug-reports: "https://still.nobo.dy"
dev-repo: "git+https://no.were"
license: "MIT"
synopsis: "Initially empty"
build: [ "test" "-f" "i-am-a-patch" ]
extra-source "i-am-a-patch" {
  src:"p.patch"
}
### <pkg:multiple-md5.1>
opam-version: "2.0"
maintainer: "nobody"
authors: "nobody neither"
homepage: "https://no.bo.dy"
bug-reports: "https://still.nobo.dy"
dev-repo: "git+https://no.were"
license: "MIT"
synopsis: "Initially empty"
build: [ "test" "-f" "i-am-a-patch" ]
extra-source "i-am-a-patch" {
  src:"p.patch"
  checksum: [
    "md5=patch-md5"
    "md5=00000000000000000000000000000000"
  ]
}
### <pkg:bad-md5.1>
opam-version: "2.0"
maintainer: "nobody"
authors: "nobody neither"
homepage: "https://no.bo.dy"
bug-reports: "https://still.nobo.dy"
dev-repo: "git+https://no.were"
license: "MIT"
synopsis: "Initially empty"
build: [ "test" "-f" "i-am-a-patch" ]
extra-source "i-am-a-patch" {
  src:"p.patch"
  checksum: [ "md5=00000000000000000000000000000000" ]
}
### <pkg:good-md5-bad-sha256.1>
opam-version: "2.0"
maintainer: "nobody"
authors: "nobody neither"
homepage: "https://no.bo.dy"
bug-reports: "https://still.nobo.dy"
dev-repo: "git+https://no.were"
license: "MIT"
synopsis: "Initially empty"
build: [ "test" "-f" "i-am-a-patch" ]
extra-source "i-am-a-patch" {
  src:"p.patch"
  checksum: [
    "md5=patch-md5"
    "sha256=0000000000000000000000000000000000000000000000000000000000000000"
  ]
}
### <pkg:good-sha256-bad-md5.1>
opam-version: "2.0"
maintainer: "nobody"
authors: "nobody neither"
homepage: "https://no.bo.dy"
bug-reports: "https://still.nobo.dy"
dev-repo: "git+https://no.were"
license: "MIT"
synopsis: "Initially empty"
build: [ "test" "-f" "i-am-a-patch" ]
extra-source "i-am-a-patch" {
  src:"p.patch"
  checksum: [
    "sha256=patch-sha256"
    "md5=00000000000000000000000000000000"
  ]
}
### <pkg:clash-with-all-md5s.666>
opam-version: "2.0"
maintainer: "Satan"
authors: "nobody neither"
homepage: "https://no.bo.dy"
bug-reports: "https://still.nobo.dy"
dev-repo: "git+https://no.were"
license: "MIT"
synopsis: "A (less) very evil package"
build: [ "test" "-f" "i-am-a-patch" ]
extra-source "i-am-a-patch" {
  src:"p.patch"
  checksum: [
    "md5=00000000000000000000000000000000"
    "md5=11111111111111111111111111111111"
    "md5=22222222222222222222222222222222"
    "md5=33333333333333333333333333333333"
    "md5=44444444444444444444444444444444"
    "md5=patch-md5"
    "md5=55555555555555555555555555555555"
    "md5=66666666666666666666666666666666"
    "md5=77777777777777777777777777777777"
    "md5=88888888888888888888888888888888"
    "md5=99999999999999999999999999999999"
    "md5=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    "md5=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
    "md5=cccccccccccccccccccccccccccccccc"
    "md5=dddddddddddddddddddddddddddddddd"
    "md5=eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
    "md5=ffffffffffffffffffffffffffffffff"
    "sha256=0123456789abcdeffedcba98765432100123456789abcdeffedbca9876543210"
  ]
}
### <pkg:not-mentioned.1>
opam-version: "2.0"
maintainer: "nobody"
authors: "nobody neither"
homepage: "https://no.bo.dy"
bug-reports: "https://still.nobo.dy"
dev-repo: "git+https://no.were"
license: "MIT"
synopsis: "Initially empty"
build: [ "test" "-f" "i-am-a-patch" ]
### sh add-files.sh not-mentioned.1
### <pkg:multiple.1>
opam-version: "2.0"
maintainer: "nobody"
authors: "nobody neither"
homepage: "https://no.bo.dy"
bug-reports: "https://still.nobo.dy"
dev-repo: "git+https://no.were"
license: "MIT"
synopsis: "Initially empty"
build: [ "test" "-f" "i-am-a-patch" ]
extra-source "i-am-a-patch" {
  src:"p.patch"
  checksum: [ "md5=patch-md5" ]
}
extra-source "i-am-a-patch" {
  src:"p.patch"
  checksum: [ "md5=patch-md5" ]
}
### <pkg:escape-absolute.1>
opam-version: "2.0"
maintainer: "nobody"
authors: "nobody neither"
homepage: "https://no.bo.dy"
bug-reports: "https://still.nobo.dy"
dev-repo: "git+https://no.were"
license: "MIT"
synopsis: "Initially empty"
extra-source "/etc/passwd" {
  src:"p.patch"
  checksum: "md5=patch-md5"
}
### <pkg:escape-build-good-md5.1>
opam-version: "2.0"
maintainer: "nobody"
authors: "nobody neither"
homepage: "https://no.bo.dy"
bug-reports: "https://still.nobo.dy"
dev-repo: "git+https://no.were"
license: "MIT"
synopsis: "Initially empty"
extra-source "../../../../../shouldnt-exist" {
  src:"p.patch"
  checksum: [ "md5=patch-md5" ]
}
### <pkg:escape-source-good-md5.1>
opam-version: "2.0"
maintainer: "nobody"
authors: "nobody neither"
homepage: "https://no.bo.dy"
bug-reports: "https://still.nobo.dy"
dev-repo: "git+https://no.were"
license: "MIT"
synopsis: "Initially empty"
extra-source "../shouldnt-exist" {
  src:"p.patch"
  checksum: [ "md5=patch-md5" ]
}
### <update-hashes.sh>
set -ue

for p in `ls REPO/packages/*/*/opam`; do
  sed -i.bak "s/patch-md5/$PATCH_MD5/" $p
  sed -i.bak "s/patch-sha256/$PATCH_SHA256/" $p
done
### sh update-hashes.sh
### opam update default

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### ::: End setup :::
### opam switch create --empty robur
### OPAMSTRICT=no
### :::::::::::::::::
### :I: Hashes
### :::::::::::::::::
### :I:1: good md5
### opam lint --package good-md5
<default>/good-md5.1: Passed.
### opam lint --package good-md5 --check-upstream
<default>/good-md5.1: Passed.
### opam install good-md5
The following actions will be performed:
=== install 1 package
  - install good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-md5.1  (file://${BASEDIR}/p.patch)
-> installed good-md5.1
Done.
### opam remove good-md5
The following actions will be performed:
=== remove 1 package
  - remove good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed   good-md5.1
Done.
### opam install good-md5 --require-checksums
The following actions will be performed:
=== install 1 package
  - install good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-md5.1  (cached)
-> installed good-md5.1
Done.
### opam source good-md5
Successfully extracted to ${BASEDIR}/good-md5.1
### opam clean --download-cache
Clearing cache of downloaded files
### test -f good-md5.1/i-am-a-patch
### :I:2: good sha256
### opam lint --package good-sha256
<default>/good-sha256.1: Passed.
### opam lint --package good-sha256 --check-upstream
<default>/good-sha256.1: Passed.
### opam install good-sha256
The following actions will be performed:
=== install 1 package
  - install good-sha256 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-sha256.1  (file://${BASEDIR}/p.patch)
-> installed good-sha256.1
Done.
### opam remove good-sha256
The following actions will be performed:
=== remove 1 package
  - remove good-sha256 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed   good-sha256.1
Done.
### opam install good-sha256 --require-checksums
The following actions will be performed:
=== install 1 package
  - install good-sha256 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-sha256.1  (cached)
-> installed good-sha256.1
Done.
### opam source good-sha256
Successfully extracted to ${BASEDIR}/good-sha256.1
### test -f good-sha256.1/i-am-a-patch
### opam clean --download-cache
Clearing cache of downloaded files
### :I:3: good md5 & sha256
### opam lint --package good-md5-good-sha256
<default>/good-md5-good-sha256.1: Passed.
### opam lint --package good-md5-good-sha256 --check-upstream
<default>/good-md5-good-sha256.1: Passed.
### opam reinstall good-md5
The following actions will be performed:
=== recompile 1 package
  - recompile good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-md5.1  (file://${BASEDIR}/p.patch)
-> removed   good-md5.1
-> installed good-md5.1
Done.
### sh check-cache.sh
MD5: patch, with matching checksum
SHA256: not found
### opam install good-md5-good-sha256
The following actions will be performed:
=== install 1 package
  - install good-md5-good-sha256 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-md5-good-sha256.1  (cached)
-> installed good-md5-good-sha256.1
Done.
### sh check-cache.sh
MD5: patch, with matching checksum
SHA256: link, to md5 patch
### opam remove good-md5-good-sha256
The following actions will be performed:
=== remove 1 package
  - remove good-md5-good-sha256 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed   good-md5-good-sha256.1
Done.
### opam install good-md5-good-sha256 --require-checksums
The following actions will be performed:
=== install 1 package
  - install good-md5-good-sha256 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-md5-good-sha256.1  (cached)
-> installed good-md5-good-sha256.1
Done.
### opam source good-md5-good-sha256
Successfully extracted to ${BASEDIR}/good-md5-good-sha256.1
### test -f good-md5-good-sha256.1/i-am-a-patch
### opam clean --download-cache
Clearing cache of downloaded files
### :I:4: good sha256 & good md5
### opam lint --package good-sha256-good-md5
<default>/good-sha256-good-md5.1: Passed.
### opam lint --package good-sha256-good-md5 --check-upstream
<default>/good-sha256-good-md5.1: Passed.
### opam clean --download-cache
Clearing cache of downloaded files
### opam reinstall good-md5
The following actions will be performed:
=== recompile 1 package
  - recompile good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-md5.1  (file://${BASEDIR}/p.patch)
-> removed   good-md5.1
-> installed good-md5.1
Done.
### opam install good-sha256-good-md5
The following actions will be performed:
=== install 1 package
  - install good-sha256-good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-sha256-good-md5.1  (cached)
-> installed good-sha256-good-md5.1
Done.
### sh check-cache.sh
MD5: patch, with matching checksum
SHA256: link, to md5 patch
### opam remove good-sha256-good-md5
The following actions will be performed:
=== remove 1 package
  - remove good-sha256-good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed   good-sha256-good-md5.1
Done.
### opam install good-sha256-good-md5 --require-checksums
The following actions will be performed:
=== install 1 package
  - install good-sha256-good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-sha256-good-md5.1  (cached)
-> installed good-sha256-good-md5.1
Done.
### opam source good-sha256-good-md5
Successfully extracted to ${BASEDIR}/good-sha256-good-md5.1
### test -f good-sha256-good-md5.1/i-am-a-patch
### opam clean --download-cache
Clearing cache of downloaded files
### :I:5: no checksum
### opam lint --package no-checksum
<default>/no-checksum.1: Passed.
### opam lint --package no-checksum --check-upstream
<default>/no-checksum.1: Passed.
### opam install no-checksum
The following actions will be performed:
=== install 1 package
  - install no-checksum 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved no-checksum.1  (file://${BASEDIR}/p.patch)
-> installed no-checksum.1
Done.
### opam remove no-checksum
The following actions will be performed:
=== remove 1 package
  - remove no-checksum 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed   no-checksum.1
Done.
### opam install no-checksum --require-checksums
The following actions will be performed:
=== install 1 package
  - install no-checksum 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved no-checksum.1  (file://${BASEDIR}/p.patch)

no-checksum.1/i-am-a-patch: Missing checksum, and `--require-checksums` was set.


<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build no-checksum 1
+- 
- No changes have been performed
# Return code 31 #
### opam source no-checksum
Successfully extracted to ${BASEDIR}/no-checksum.1
### test -f no-checksum.1/i-am-a-patch
### opam clean --download-cache
Clearing cache of downloaded files
### :I:6: multiple md5
### opam lint --package multiple-md5
<default>/multiple-md5.1: Errors.
             error 72: Field 'extra-sources' contains duplicated checksums: "i-am-a-patch have md5: 2 occurences"
# Return code 1 #
### opam lint --package multiple-md5 --check-upstream
<default>/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'
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
[ERROR] Failed to get extra source "i-am-a-patch" of multiple-md5.1: Checksum mismatch

OpamSolution.Fetch_fail("Checksum mismatch")


<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - fetch multiple-md5 1
+- 
- No changes have been performed
# Return code 40 #
### opam install multiple-md5 --require-checksums | '[0-9a-z]{32}' -> 'hash'
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
[ERROR] Failed to get extra source "i-am-a-patch" of multiple-md5.1: Checksum mismatch

OpamSolution.Fetch_fail("Checksum mismatch")


<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - fetch multiple-md5 1
+- 
- No changes have been performed
# Return code 40 #
### opam source multiple-md5 | '[0-9a-z]{32}' -> 'hash'
[ERROR] multiple-md5.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch:
          expected md5=hash
          got      md5=hash
[ERROR] Download failed: Checksum mismatch
# Return code 40 #
### test -f multiple-md5.1/i-am-a-patch
# Return code 1 #
### opam clean --download-cache
Clearing cache of downloaded files
### :I:7: bad md5
### opam lint --package bad-md5
<default>/bad-md5.1: Passed.
### opam lint --package bad-md5 --check-upstream
<default>/bad-md5.1: Passed.
### opam install bad-md5 | '[0-9a-z]{32}' -> 'hash'
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
[ERROR] Failed to get extra source "i-am-a-patch" of bad-md5.1: Checksum mismatch

OpamSolution.Fetch_fail("Checksum mismatch")


<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - fetch bad-md5 1
+- 
- No changes have been performed
# Return code 40 #
### opam install bad-md5 --require-checksums | '[0-9a-z]{32}' -> 'hash'
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
[ERROR] Failed to get extra source "i-am-a-patch" of bad-md5.1: Checksum mismatch

OpamSolution.Fetch_fail("Checksum mismatch")


<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - fetch bad-md5 1
+- 
- No changes have been performed
# Return code 40 #
### opam source bad-md5 | '[0-9a-z]{32}' -> 'hash'
[ERROR] bad-md5.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch:
          expected md5=hash
          got      md5=hash
[ERROR] Download failed: Checksum mismatch
# Return code 40 #
### test -f bad-md5.1/i-am-a-patch
# Return code 1 #
### opam clean --download-cache
Clearing cache of downloaded files
### :I:8: good md5 & bad sha256
### opam lint --package good-md5-bad-sha256
<default>/good-md5-bad-sha256.1: Passed.
### opam lint --package good-md5-bad-sha256 --check-upstream
<default>/good-md5-bad-sha256.1: Passed.
### opam reinstall good-md5
The following actions will be performed:
=== recompile 1 package
  - recompile good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-md5.1  (file://${BASEDIR}/p.patch)
-> removed   good-md5.1
-> installed good-md5.1
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'
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)

[ERROR] good-md5-bad-sha256.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch:
          expected sha256=hash
          got      sha256=hash
[ERROR] Failed to get extra source "i-am-a-patch" of good-md5-bad-sha256.1: Checksum mismatch

OpamSolution.Fetch_fail("Checksum mismatch")


<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - fetch good-md5-bad-sha256 1
+- 
- No changes have been performed
# Return code 40 #
### sh check-cache.sh
MD5: not found
SHA256: not found
### opam reinstall good-md5
The following actions will be performed:
=== recompile 1 package
  - recompile good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-md5.1  (file://${BASEDIR}/p.patch)
-> removed   good-md5.1
-> installed good-md5.1
Done.
### opam reinstall good-sha256
The following actions will be performed:
=== recompile 1 package
  - recompile good-sha256 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-sha256.1  (file://${BASEDIR}/p.patch)
-> removed   good-sha256.1
-> installed good-sha256.1
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'
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)

[ERROR] good-md5-bad-sha256.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch:
          expected sha256=hash
          got      sha256=hash
[ERROR] Failed to get extra source "i-am-a-patch" of good-md5-bad-sha256.1: Checksum mismatch

OpamSolution.Fetch_fail("Checksum mismatch")


<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - fetch good-md5-bad-sha256 1
+- 
- No changes have been performed
# Return code 40 #
### 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'
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
[ERROR] Failed to get extra source "i-am-a-patch" of good-md5-bad-sha256.1: Checksum mismatch

OpamSolution.Fetch_fail("Checksum mismatch")


<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - fetch good-md5-bad-sha256 1
+- 
- No changes have been performed
# Return code 40 #
### opam source good-md5-bad-sha256 | '[0-9a-z]{64}' -> 'md5'
[ERROR] good-md5-bad-sha256.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch:
          expected sha256=md5
          got      sha256=md5
[ERROR] Download failed: Checksum mismatch
# Return code 40 #
### test -f good-md5-bad-sha256.1/i-am-a-patch
# Return code 1 #
### opam clean --download-cache
Clearing cache of downloaded files
### :I:9: good sha256 & bad md5
### opam lint --package good-sha256-bad-md5
<default>/good-sha256-bad-md5.1: Passed.
### opam lint --package good-sha256-bad-md5 --check-upstream
<default>/good-sha256-bad-md5.1: Passed.
### opam install good-sha256-bad-md5 | '[0-9a-z]{32,64}' -> 'hash'
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
[ERROR] Failed to get extra source "i-am-a-patch" of good-sha256-bad-md5.1: Checksum mismatch

OpamSolution.Fetch_fail("Checksum mismatch")


<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - fetch good-sha256-bad-md5 1
+- 
- No changes have been performed
# Return code 40 #
### opam install good-sha256-bad-md5 --require-checksums | '[0-9a-z]{32,64}' -> 'hash'
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
[ERROR] Failed to get extra source "i-am-a-patch" of good-sha256-bad-md5.1: Checksum mismatch

OpamSolution.Fetch_fail("Checksum mismatch")


<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - fetch good-sha256-bad-md5 1
+- 
- No changes have been performed
# Return code 40 #
### opam source good-sha256-bad-md5 | '[0-9a-z]{32}' -> 'hash'
[ERROR] good-sha256-bad-md5.1/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch:
          expected md5=hash
          got      md5=hash
[ERROR] Download failed: Checksum mismatch
# Return code 40 #
### test -f good-sha256-bad-md5.1/i-am-a-patch
# Return code 1 #
### opam clean --download-cache
Clearing cache of downloaded files
### :I:10: clash with all md5
### opam lint --package clash-with-all-md5s
<default>/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 lint --package clash-with-all-md5s --check-upstream
<default>/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'
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
[ERROR] Failed to get extra source "i-am-a-patch" of clash-with-all-md5s.666: Checksum mismatch

OpamSolution.Fetch_fail("Checksum mismatch")


<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - fetch clash-with-all-md5s 666
+- 
- No changes have been performed
# Return code 40 #
### sh check-cache.sh
MD5: not found
SHA256: not found
### opam reinstall good-md5
The following actions will be performed:
=== recompile 1 package
  - recompile good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-md5.1  (file://${BASEDIR}/p.patch)
-> removed   good-md5.1
-> installed good-md5.1
Done.
### opam reinstall good-sha256
The following actions will be performed:
=== recompile 1 package
  - recompile good-sha256 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-sha256.1  (file://${BASEDIR}/p.patch)
-> removed   good-sha256.1
-> installed good-sha256.1
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'
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)

[ERROR] clash-with-all-md5s.666/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch:
          expected md5=hash
          got      md5=hash
[ERROR] Failed to get extra source "i-am-a-patch" of clash-with-all-md5s.666: Checksum mismatch

OpamSolution.Fetch_fail("Checksum mismatch")


<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - fetch clash-with-all-md5s 666
+- 
- No changes have been performed
# Return code 40 #
### 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'
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
[ERROR] Failed to get extra source "i-am-a-patch" of clash-with-all-md5s.666: Checksum mismatch

OpamSolution.Fetch_fail("Checksum mismatch")


<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - fetch clash-with-all-md5s 666
+- 
- No changes have been performed
# Return code 40 #
### opam source clash-with-all-md5s | '[0-9a-z]{32}' -> 'hash'
[ERROR] clash-with-all-md5s.666/i-am-a-patch: Checksum mismatch for file://${BASEDIR}/p.patch:
          expected md5=hash
          got      md5=hash
[ERROR] Download failed: Checksum mismatch
# Return code 40 #
### test -f clash-with-all-md5s.666/i-am-a-patch
# Return code 1 #
### opam clean --download-cache
Clearing cache of downloaded files
### :::::::::::::::::
### :II: Presence
### :::::::::::::::::
### :II:1: not mentioned
### opam lint --package not-mentioned
<default>/not-mentioned.1: Passed.
### opam lint --package not-mentioned --check-upstream
<default>/not-mentioned.1: Passed.
### opam install not-mentioned
The following actions will be performed:
=== install 1 package
  - install not-mentioned 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The compilation of not-mentioned.1 failed at "test -f i-am-a-patch".




<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build not-mentioned 1
+- 
- No changes have been performed
# Return code 31 #
### opam remove not-mentioned
[NOTE] not-mentioned is not installed.

Nothing to do.
### opam install not-mentioned --require-checksums
The following actions will be performed:
=== install 1 package
  - install not-mentioned 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The compilation of not-mentioned.1 failed at "test -f i-am-a-patch".




<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build not-mentioned 1
+- 
- No changes have been performed
# Return code 31 #
### opam source not-mentioned
Successfully extracted to ${BASEDIR}/not-mentioned.1
### test -f not-mentioned.1/i-am-a-patch
# Return code 1 #
### :II:2: Double extra-source
### opam lint --package multiple
<default>/multiple.1: Errors.
             error  3: File format error in 'extra-source': Duplicate section extra-source
# Return code 1 #
### opam lint --package multiple --check-upstream
<default>/multiple.1: Errors.
             error  3: File format error in 'extra-source': Duplicate section extra-source
# Return code 1 #
### opam install multiple
[ERROR] In the opam file for multiple.1:
          - In ${BASEDIR}/OPAM/repo/default/packages/multiple/multiple.1/opam:
            Duplicate section extra-source
        'extra-source' has been ignored.
The following actions will be performed:
=== install 1 package
  - install multiple 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved multiple.1  (file://${BASEDIR}/p.patch)
-> installed multiple.1
Done.
### opam remove multiple
[ERROR] In the opam file for multiple.1:
          - In ${BASEDIR}/OPAM/repo/default/packages/multiple/multiple.1/opam:
            Duplicate section extra-source
        'extra-source' has been ignored.
The following actions will be performed:
=== remove 1 package
  - remove multiple 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed   multiple.1
Done.
### opam install multiple --require-checksums
[ERROR] In the opam file for multiple.1:
          - In ${BASEDIR}/OPAM/repo/default/packages/multiple/multiple.1/opam:
            Duplicate section extra-source
        'extra-source' has been ignored.
The following actions will be performed:
=== install 1 package
  - install multiple 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved multiple.1  (cached)
-> installed multiple.1
Done.
### opam source multiple
Successfully extracted to ${BASEDIR}/multiple.1
### test -f multiple.1/i-am-a-patch
### :::::::::::::::::
### :III: Cache manipulation
### :::::::::::::::::
### :III:1: install with removed md5 frome cache, and kept sha256
### rm "$PATCH_MD5_PATH"
### opam reinstall good-sha256
The following actions will be performed:
=== recompile 1 package
  - recompile good-sha256 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-sha256.1  (file://${BASEDIR}/p.patch)
-> removed   good-sha256.1
-> installed good-sha256.1
Done.
### sh check-cache.sh
MD5: not found
SHA256: patch, with matching checksum
### opam reinstall good-sha256-good-md5
The following actions will be performed:
=== recompile 1 package
  - recompile good-sha256-good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-sha256-good-md5.1  (cached)
-> removed   good-sha256-good-md5.1
-> installed good-sha256-good-md5.1
Done.
### sh check-cache.sh
MD5: link, to sha256 patch
SHA256: patch, with matching checksum
### opam clean --download-cache
Clearing cache of downloaded files
### :III:2: install with removed sha256 frome cache, and kept md5
### opam reinstall good-md5
The following actions will be performed:
=== recompile 1 package
  - recompile good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-md5.1  (file://${BASEDIR}/p.patch)
-> removed   good-md5.1
-> installed good-md5.1
Done.
### sh check-cache.sh
MD5: patch, with matching checksum
SHA256: not found
### opam reinstall good-sha256-good-md5
The following actions will be performed:
=== recompile 1 package
  - recompile good-sha256-good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved good-sha256-good-md5.1  (cached)
-> removed   good-sha256-good-md5.1
-> installed good-sha256-good-md5.1
Done.
### sh check-cache.sh
MD5: patch, with matching checksum
SHA256: link, to md5 patch
### :III:c: corrupt md5 patch in cache
### sh check-cache.sh
MD5: patch, with matching checksum
SHA256: link, to md5 patch
### opam remove good-sha256-good-md5
The following actions will be performed:
=== remove 1 package
  - remove good-sha256-good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed   good-sha256-good-md5.1
Done.
### cp check-cache.sh "$PATCH_MD5_PATH"
### 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'
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)

-> retrieved good-sha256-good-md5.1  (file://${BASEDIR}/p.patch)
-> installed good-sha256-good-md5.1
Done.
### sh check-cache.sh
MD5: link, to sha256 patch
SHA256: patch, with matching checksum
### :III:4: corrupt sha256 patch in cache
### sh check-cache.sh
MD5: link, to sha256 patch
SHA256: patch, with matching checksum
### opam remove good-sha256-good-md5
The following actions will be performed:
=== remove 1 package
  - remove good-sha256-good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed   good-sha256-good-md5.1
Done.
### rm "$PATCH_MD5_PATH" "$PATCH_SHA256_PATH"
### cp p.patch "$PATCH_MD5_PATH"
### cp check-cache.sh "$PATCH_SHA256_PATH"
### 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'
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)

-> retrieved good-sha256-good-md5.1  (file://${BASEDIR}/p.patch)
-> installed good-sha256-good-md5.1
Done.
### sh check-cache.sh
MD5: link, to sha256 patch
SHA256: patch, with matching checksum
### :III:5: Both corrupted
### opam remove good-sha256-good-md5
The following actions will be performed:
=== remove 1 package
  - remove good-sha256-good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed   good-sha256-good-md5.1
Done.
### rm "$PATCH_MD5_PATH" "$PATCH_SHA256_PATH"
### cp check-cache.sh "$PATCH_MD5_PATH"
### cp check-cache.sh "$PATCH_SHA256_PATH"
### 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'
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)

-> retrieved good-sha256-good-md5.1  (file://${BASEDIR}/p.patch)
-> installed good-sha256-good-md5.1
Done.
### sh check-cache.sh
MD5: link, to sha256 patch
SHA256: patch, with matching checksum
### opam clean --download-cache
Clearing cache of downloaded files
### :::::::::::::::::
### :IV: Escaping
### :::::::::::::::::
### :IV:1: absolute
### opam lint --package escape-absolute
<default>/escape-absolute.1: Passed.
### opam lint --package escape-absolute --check-upstream
<default>/escape-absolute.1: Passed.
### opam install escape-absolute
The following actions will be performed:
=== install 1 package
  - install escape-absolute 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved escape-absolute.1  (file://${BASEDIR}/p.patch)
-> installed escape-absolute.1
Done.
### opam install escape-absolute --require-checksums
[NOTE] Package escape-absolute is already installed (current version is 1).
### opam source escape-absolute
Successfully extracted to ${BASEDIR}/escape-absolute.1
### test -f escape-absolute.1/etc/passwd
### :IV:2: good md5
### # /!\ all escape!!!
### opam lint --package escape-build-good-md5
<default>/escape-build-good-md5.1: Passed.
### opam lint --package escape-build-good-md5 --check-upstream
<default>/escape-build-good-md5.1: Passed.
### opam install escape-build-good-md5
The following actions will be performed:
=== install 1 package
  - install escape-build-good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved escape-build-good-md5.1  (cached)
-> installed escape-build-good-md5.1
Done.
### test -f shouldnt-exist
### rm shouldnt-exist
### opam remove escape-build-good-md5
The following actions will be performed:
=== remove 1 package
  - remove escape-build-good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed   escape-build-good-md5.1
Done.
### opam install escape-build-good-md5 --require-checksums
The following actions will be performed:
=== install 1 package
  - install escape-build-good-md5 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved escape-build-good-md5.1  (cached)
-> installed escape-build-good-md5.1
Done.
### test -f shouldnt-exist
### rm shouldnt-exist
### opam source escape-source-good-md5
Successfully extracted to ${BASEDIR}/escape-source-good-md5.1
### test -f shouldnt-exist
