diff --git a/.github/workflows/ci.ml b/.github/workflows/ci.ml index 907a8861f1f..4f3b4c82383 100644 --- a/.github/workflows/ci.ml +++ b/.github/workflows/ci.ml @@ -369,6 +369,7 @@ let main_test_job ~analyse_job ~build_linux_job ~build_windows_job:_ ~build_macO let host = host_of_platform platform in let ocamlv = "${{ matrix.ocamlv }}" in job ~oc ~workflow ?section ~runs_on:(Runner [runner]) ~env:[("OPAM_TEST", "1")] ~matrix ~needs ("Test-" ^ name_of_platform platform) + ++ only_on MacOS (install_sys_packages ["coreutils"] ~descr:"Install gnu coreutils" [MacOS]) ++ checkout () ++ only_on Linux (run "Install bubblewrap" ["sudo apt install bubblewrap"]) ++ cache Archives diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6a927500805..fbf157ad709 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -325,6 +325,8 @@ jobs: env: OPAM_TEST: 1 steps: + - name: Install gnu coreutils + run: brew install coreutils - name: Checkout tree uses: actions/checkout@v3 - name: src_ext/archives and opam-repository Cache diff --git a/master_changes.md b/master_changes.md index e413f208052..65e46b140c3 100644 --- a/master_changes.md +++ b/master_changes.md @@ -102,10 +102,13 @@ users) ## Reftests ### Tests * Lint: add test for W53, to test extra file with good hash [#5639 @rjbou] + * Add several checksum & cache validation checks for archive, extra-source section, and extra-file field [#5560 @rjbou] + * Move local-cache into archive-field-checks test [#5560 @rjbou] ### Engine ## Github Actions + * Add coreutils install for cheksum validation tests [#5560 @rjbou] ## Doc diff --git a/tests/reftests/archive.test b/tests/reftests/archive.test new file mode 100644 index 00000000000..69c2eaac0e3 --- /dev/null +++ b/tests/reftests/archive.test @@ -0,0 +1,1168 @@ +N0REP0 +### ::: Setup ::: +### +Hi robur! +### tar czf archive.tgz hello +### openssl md5 archive.tgz | '.*= ' -> '' >$ ARCHIVE_MD5 +### openssl sha256 archive.tgz | '.*= ' -> '' >$ ARCHIVE_SHA256 +### sh -c "echo '$ARCHIVE_MD5' | cut -c 1-2" >$ PRE_MD5 +### echo "$OPAMROOT/download-cache/md5/$PRE_MD5/$ARCHIVE_MD5" >$ ARCHIVE_MD5_PATH +### sh -c "echo '$ARCHIVE_SHA256' | cut -c 1-2" >$ PRE_SHA256 +### echo "$OPAMROOT/download-cache/sha256/$PRE_SHA256/$ARCHIVE_SHA256" >$ ARCHIVE_SHA256_PATH +### +set -ue + +eval "MD5_PATH=\"$ARCHIVE_MD5_PATH\"" +eval "SHA256_PATH=\"$ARCHIVE_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 archive" + elif [ "$realpath" = "$SHA256_PATH" ]; then + out="$out to sha256 archive" + else + out="$out to unknown path $realpath" + fi + elif [ -f "$path" ] ; then + out="archive," + 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")" +### ::: Setup: archives in url section ::: +### +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" "hello" ] +url { + src: "archive.tgz" + checksum: [ "md5=archive-md5" ] +} +### +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" "hello" ] +url { + src: "archive.tgz" + checksum: [ "sha256=archive-sha256" ] +} +### +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" "hello" ] +url { + src: "archive.tgz" + checksum: [ + "md5=archive-md5" + "sha256=archive-sha256" + ] +} +### +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" "hello" ] +url { + src: "archive.tgz" + checksum: [ + "sha256=archive-sha256" + "md5=archive-md5" + ] +} +### +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" "hello" ] +url { src: "archive.tgz" } +### +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" "hello" ] +url { + src: "archive.tgz" + checksum: [ + "md5=archive-md5" + "md5=00000000000000000000000000000000" + ] +} +### +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" "hello" ] +url { + src: "archive.tgz" + checksum: [ "md5=00000000000000000000000000000000" ] +} +### +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" "hello" ] +url { + src: "archive.tgz" + checksum: [ + "md5=archive-md5" + "sha256=0000000000000000000000000000000000000000000000000000000000000000" + ] +} +### +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" "hello" ] +url { + src: "archive.tgz" + checksum: [ + "sha256=archive-sha256" + "md5=00000000000000000000000000000000" + ] +} +### +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" "hello" ] +url { + src: "archive.tgz" + checksum: [ + "md5=00000000000000000000000000000000" + "md5=11111111111111111111111111111111" + "md5=22222222222222222222222222222222" + "md5=33333333333333333333333333333333" + "md5=44444444444444444444444444444444" + "md5=archive-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" + ] +} +### +set -ue + +for p in `ls REPO/packages/*/*/opam`; do + sed -i.bak "s/archive-md5/$ARCHIVE_MD5/" $p + sed -i.bak "s/archive-sha256/$ARCHIVE_SHA256/" $p +done +### sh update-hashes.sh +### opam update + +<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><> +[default] synchronised from file://${BASEDIR}/REPO +Now run 'opam upgrade' to apply any package updates. +### ::: End setup ::: +### opam switch create robur --empty +### OPAMSTRICT=no +### ::::::::::::::::: +### :I: Url hashes +### ::::::::::::::::: +### :I:1: good md5 +### opam lint --package good-md5 +/good-md5.1: Passed. +### opam lint --package good-md5 --check-upstream +/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}/archive.tgz) +-> 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 +### test -f good-md5.1/hello +### opam clean --download-cache +Clearing cache of downloaded files +### :I:2: good sha256 +### opam lint --package good-sha256 +/good-sha256.1: Passed. +### opam lint --package good-sha256 --check-upstream +/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}/archive.tgz) +-> 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/hello +### opam clean --download-cache +Clearing cache of downloaded files +### :I:3: good md5 & sha256 +### opam lint --package good-md5-good-sha256 +/good-md5-good-sha256.1: Passed. +### opam lint --package good-md5-good-sha256 --check-upstream +/good-md5-good-sha256.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}/archive.tgz) +-> removed good-md5.1 +-> installed good-md5.1 +Done. +### sh check-cache.sh +MD5: archive, 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: archive, with matching checksum +SHA256: not found +### 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/hello +### opam clean --download-cache +Clearing cache of downloaded files +### :I:4: good sha256 & good md5 +### opam lint --package good-sha256-good-md5 +/good-sha256-good-md5.1: Passed. +### opam lint --package good-sha256-good-md5 --check-upstream +/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}/archive.tgz) +-> 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: archive, with matching checksum +SHA256: not found +### 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/hello +### opam clean --download-cache +Clearing cache of downloaded files +### :I:5: no checksum +### opam lint --package no-checksum +/no-checksum.1: Passed. +### opam lint --package no-checksum --check-upstream +/no-checksum.1: Warnings. + warning 59: url doesn't contain a checksum +### 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}/archive.tgz) +-> 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 <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +[ERROR] Failed to get sources of no-checksum.1: missing checksum + +OpamSolution.Fetch_fail("no-checksum.1: Missing checksum, and `--require-checksums` was set.") + + +<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> ++- The following actions failed +| - fetch no-checksum 1 ++- +- No changes have been performed +# Return code 40 # +### opam source no-checksum +Successfully extracted to ${BASEDIR}/no-checksum.1 +### test -f no-checksum.1/hello +### opam clean --download-cache +Clearing cache of downloaded files +### :I:6: multiple md5 +### opam lint --package multiple-md5 +/multiple-md5.1: Passed. +### opam lint --package multiple-md5 --check-upstream | '[0-9a-z]{32}' -> 'hash' +/multiple-md5.1: Errors. + error 60: Upstream check failed: "The archive doesn't match checksum: + - archive: md5=hash, in opam file: md5=hash + ." +# 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: Checksum mismatch for file://${BASEDIR}/archive.tgz: + expected md5=hash + got md5=hash +[ERROR] Failed to get sources 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: Checksum mismatch for file://${BASEDIR}/archive.tgz: + expected md5=hash + got md5=hash +[ERROR] Failed to get sources 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: Checksum mismatch for file://${BASEDIR}/archive.tgz: + expected md5=hash + got md5=hash +[ERROR] Download failed: Checksum mismatch +# Return code 40 # +### test -f multiple-md5.1/hello +# Return code 1 # +### opam clean --download-cache +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' +/bad-md5.1: Errors. + error 60: Upstream check failed: "The archive doesn't match checksum: + - archive: md5=hash, in opam file: md5=hash + ." +# Return code 1 # +### 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: Checksum mismatch for file://${BASEDIR}/archive.tgz: + expected md5=hash + got md5=hash +[ERROR] Failed to get sources 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: Checksum mismatch for file://${BASEDIR}/archive.tgz: + expected md5=hash + got md5=hash +[ERROR] Failed to get sources 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: Checksum mismatch for file://${BASEDIR}/archive.tgz: + expected md5=hash + got md5=hash +[ERROR] Download failed: Checksum mismatch +# Return code 40 # +### test -f bad-md5.1/hello +# 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 +/good-md5-bad-sha256.1: Passed. +### opam lint --package good-md5-bad-sha256 --check-upstream | '[0-9a-z]{64}' -> 'hash' +/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 + ." +# Return code 1 # +### 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}/archive.tgz) +-> removed good-md5.1 +-> installed good-md5.1 +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' +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: Checksum mismatch for file://${BASEDIR}/archive.tgz: + expected sha256=hash + got sha256=hash +[ERROR] Failed to get sources 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}/archive.tgz) +-> 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}/archive.tgz) +-> removed good-sha256.1 +-> installed good-sha256.1 +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' +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: Checksum mismatch for file://${BASEDIR}/archive.tgz: + expected sha256=hash + got sha256=hash +[ERROR] Failed to get sources 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: archive, 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: Checksum mismatch for file://${BASEDIR}/archive.tgz: + expected sha256=hash + got sha256=hash +[ERROR] Failed to get sources 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: Checksum mismatch for file://${BASEDIR}/archive.tgz: + expected sha256=md5 + got sha256=md5 +[ERROR] Download failed: Checksum mismatch +# Return code 40 # +### test -f good-md5-bad-sha256.1/hello +# 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 +/good-sha256-bad-md5.1: Passed. +### opam lint --package good-sha256-bad-md5 --check-upstream | '[0-9a-z]{32}' -> 'hash' +/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 + ." +# Return code 1 # +### 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: Checksum mismatch for file://${BASEDIR}/archive.tgz: + expected md5=hash + got md5=hash +[ERROR] Failed to get sources 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: Checksum mismatch for file://${BASEDIR}/archive.tgz: + expected md5=hash + got md5=hash +[ERROR] Failed to get sources 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: Checksum mismatch for file://${BASEDIR}/archive.tgz: + expected md5=hash + got md5=hash +[ERROR] Download failed: Checksum mismatch +# Return code 40 # +### test -f good-sha256-bad-md5.1/hello +# 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 +/clash-with-all-md5s.666: Passed. +### opam lint --package clash-with-all-md5s --check-upstream | '[0-9a-z]{32,64}' -> 'hash' +/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 + ." +# 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: Checksum mismatch for file://${BASEDIR}/archive.tgz: + expected md5=hash + got md5=hash +[ERROR] Failed to get sources 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}/archive.tgz) +-> 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}/archive.tgz) +-> removed good-sha256.1 +-> installed good-sha256.1 +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' +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) + +[ERROR] clash-with-all-md5s.666: Checksum mismatch for file://${BASEDIR}/archive.tgz: + expected md5=hash + got md5=hash +[ERROR] Failed to get sources 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: archive, 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: Checksum mismatch for file://${BASEDIR}/archive.tgz: + expected md5=hash + got md5=hash +[ERROR] Failed to get sources 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: Checksum mismatch for file://${BASEDIR}/archive.tgz: + expected md5=hash + got md5=hash +[ERROR] Download failed: Checksum mismatch +# Return code 40 # +### test -f clash-with-all-md5s.666/hello +# Return code 1 # +### opam clean --download-cache +Clearing cache of downloaded files +### ::::::::::::::::: +### :II: Cache manipulation +### ::::::::::::::::: +### :II:1: install with removed md5 frome cache, and kept sha256 +### 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 (file://${BASEDIR}/archive.tgz) +-> removed good-sha256-good-md5.1 +-> installed good-sha256-good-md5.1 +Done. +### sh check-cache.sh +MD5: link, to sha256 archive +SHA256: archive, with matching checksum +### rm "$ARCHIVE_MD5_PATH" +### 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. +### sh check-cache.sh +MD5: not found +SHA256: archive, with matching checksum +### 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: not found +SHA256: archive, with matching checksum +### opam clean --download-cache +Clearing cache of downloaded files +### :II:2: install with removed sha256 frome cache, and kept md5 +### 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 (file://${BASEDIR}/archive.tgz) +-> removed good-sha256-good-md5.1 +-> installed good-sha256-good-md5.1 +Done. +### sh check-cache.sh +MD5: link, to sha256 archive +SHA256: archive, with matching checksum +### rm "$ARCHIVE_SHA256_PATH" +### 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. +### sh check-cache.sh +MD5: link, to sha256 archive +SHA256: not found +### 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 (file://${BASEDIR}/archive.tgz) +-> installed good-sha256-good-md5.1 +Done. +### sh check-cache.sh +MD5: link, to sha256 archive +SHA256: archive, with matching checksum +### :II:3: corrupt md5 archive in cache +### sh check-cache.sh +MD5: link, to sha256 archive +SHA256: archive, 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 "$ARCHIVE_MD5_PATH" +### tar czf "$ARCHIVE_MD5_PATH" check-cache.sh +### sh check-cache.sh +MD5: archive, with mismatching checksum +SHA256: archive, with matching checksum +### # it's only sha256 that is checked, as it is good, it doesn't check other cache files +### 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: archive, with mismatching checksum +SHA256: archive, with matching checksum +### :II:4: corrupt sha256 archive in cache +### sh check-cache.sh +MD5: archive, with mismatching checksum +SHA256: archive, 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. +### cp archive.tgz "$ARCHIVE_MD5_PATH" +### rm "$ARCHIVE_SHA256_PATH" +### tar czf "$ARCHIVE_SHA256_PATH" check-cache.sh +### sh check-cache.sh +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' +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}/archive.tgz) +-> installed good-sha256-good-md5.1 +Done. +### sh check-cache.sh +MD5: link, to sha256 archive +SHA256: archive, with matching checksum +### :II: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 "$ARCHIVE_SHA256_PATH" +### tar czf "$ARCHIVE_SHA256_PATH" check-cache.sh +### rm "$ARCHIVE_MD5_PATH" +### tar czf "$ARCHIVE_MD5_PATH" check-cache.sh +### 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' +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}/archive.tgz) +-> installed good-sha256-good-md5.1 +Done. +### sh check-cache.sh +MD5: link, to sha256 archive +SHA256: archive, with matching checksum +### opam clean --download-cache +Clearing cache of downloaded files +### :II:6: Corrupt linked archive +### opam reinstall good-sha256-good-md5.1 +The following actions will be performed: +=== recompile 1 package + - recompile good-sha256-good-md5 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved good-sha256-good-md5.1 (file://${BASEDIR}/archive.tgz) +-> removed good-sha256-good-md5.1 +-> installed good-sha256-good-md5.1 +Done. +### sh check-cache.sh +MD5: link, to sha256 archive +SHA256: archive, with matching checksum +### opam remove good-sha256.1 +The following actions will be performed: +=== remove 1 package + - remove good-sha256 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> removed good-sha256.1 +Done. +### rm "$ARCHIVE_SHA256_PATH" +### opam install good-sha256.1 +The following actions will be performed: +=== install 1 package + - install good-sha256 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved good-sha256.1 (file://${BASEDIR}/archive.tgz) +-> installed good-sha256.1 +Done. +### sh check-cache.sh +MD5: link, to sha256 archive +SHA256: archive, with matching checksum +### opam remove good-sha256.1 +The following actions will be performed: +=== remove 1 package + - remove good-sha256 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> removed good-sha256.1 +Done. +### rm "$ARCHIVE_SHA256_PATH" +### tar czf "$ARCHIVE_SHA256_PATH" check-cache.sh +### 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' +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) + +-> retrieved good-sha256.1 (file://${BASEDIR}/archive.tgz) +-> installed good-sha256.1 +Done. +### sh check-cache.sh +MD5: link, to sha256 archive +SHA256: archive, with matching checksum diff --git a/tests/reftests/dune.inc b/tests/reftests/dune.inc index b6bc9bce24a..f2d47a3e02a 100644 --- a/tests/reftests/dune.inc +++ b/tests/reftests/dune.inc @@ -17,6 +17,24 @@ %{targets} (run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:admin.test} %{read-lines:testing-env})))) +(rule + (alias reftest-archive) + (action + (diff archive.test archive.out))) + +(alias + (name reftest) + (deps (alias reftest-archive))) + +(rule + (targets archive.out) + (deps root-N0REP0) + (package opam) + (action + (with-stdout-to + %{targets} + (run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:archive.test} %{read-lines:testing-env})))) + (rule (alias reftest-assume-built) (action @@ -488,6 +506,42 @@ %{targets} (run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:env.win32.test} %{read-lines:testing-env})))) +(rule + (alias reftest-extrafile) + (action + (diff extrafile.test extrafile.out))) + +(alias + (name reftest) + (deps (alias reftest-extrafile))) + +(rule + (targets extrafile.out) + (deps root-N0REP0) + (package opam) + (action + (with-stdout-to + %{targets} + (run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:extrafile.test} %{read-lines:testing-env})))) + +(rule + (alias reftest-extrasource) + (action + (diff extrasource.test extrasource.out))) + +(alias + (name reftest) + (deps (alias reftest-extrasource))) + +(rule + (targets extrasource.out) + (deps root-N0REP0) + (package opam) + (action + (with-stdout-to + %{targets} + (run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:extrasource.test} %{read-lines:testing-env})))) + (rule (alias reftest-init) (action @@ -692,24 +746,6 @@ %{targets} (run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:list.unix.test} %{read-lines:testing-env})))) -(rule - (alias reftest-local-cache) - (action - (diff local-cache.test local-cache.out))) - -(alias - (name reftest) - (deps (alias reftest-local-cache))) - -(rule - (targets local-cache.out) - (deps root-N0REP0) - (package opam) - (action - (with-stdout-to - %{targets} - (run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:local-cache.test} %{read-lines:testing-env})))) - (rule (alias reftest-lock) (action diff --git a/tests/reftests/extrafile.test b/tests/reftests/extrafile.test new file mode 100644 index 00000000000..bb30f20a6a4 --- /dev/null +++ b/tests/reftests/extrafile.test @@ -0,0 +1,570 @@ +N0REP0 +### ::: Setup ::: +### +Trust me, im' a patch! +### openssl md5 p.patch | '.*= ' -> '' >$ PATCH_MD5 +### openssl sha256 p.patch | '.*= ' -> '' >$ PATCH_SHA256 +### +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-file field ::: +### +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" "p.patch" ] +extra-files: [ + ["p.patch" "md5=patch-md5"] +] +### sh add-files.sh 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" "p.patch" ] +extra-files: [ + ["p.patch" "md5=patch-md5"] + ["p.patch" "sha256=patch-sha256"] +] +### sh add-files.sh 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" "p.patch" ] +extra-files: [ + ["p.patch" "md5=00000000000000000000000000000000"] +] +### sh add-files.sh 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" "p.patch" ] +extra-files: [ + ["p.patch" "md5=patch-md5"] + ["p.patch" "sha256=0000000000000000000000000000000000000000000000000000000000000000"] +] +### sh add-files.sh 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" "p.patch" ] +extra-files: [ + ["p.patch"] +] +### sh add-files.sh 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" "p.patch" ] +### sh add-files.sh 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" "p.patch" ] +extra-files: [ + ["p.patch" "md5=00000000000000000000000000000000"] +] +### +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-files: [ + ["/etc/passwdd" "md5=c316eacc19a12732bb894667a08e9c14"] +] +### +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" "p.patch" ] +extra-files: [ + ["../../../no-checksum/no-checksum.1/files/p.patch" "md5=patch-md5"] +] +### +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 +### ::::::::::::::::: +### sh -c "rm OPAM/repo/state-*.cache" +### OPAMDEBUGSECTIONS="opam-file" OPAMDEBUG=-2 opam list good-md5 -s | unordered +opam-file Missing expected extra files ../../../no-checksum/no-checksum.1/files/p.patch at ${BASEDIR}/OPAM/repo/default/packages/escape-good-md5/escape-good-md5.1/files +opam-file Missing extra-files field for p.patch for no-checksum.1, adding them. +opam-file Missing extra-files field for p.patch for not-mentioned.1, adding them. +opam-file Missing expected extra files p.patch at ${BASEDIR}/OPAM/repo/default/packages/not-present/not-present.1/files +opam-file Mismatching extra-files at ${BASEDIR}/OPAM/repo/default/packages/good-md5-good-sha256/good-md5-good-sha256.1: missing from 'files' directory (1) +opam-file Missing expected extra files /etc/passwdd at ${BASEDIR}/OPAM/repo/default/packages/escape-absolute/escape-absolute.1/files +opam-file Mismatching extra-files at ${BASEDIR}/OPAM/repo/default/packages/good-md5-bad-sha256/good-md5-bad-sha256.1: missing from 'files' directory (1) +opam-file Mismatching extra-files at ${BASEDIR}/OPAM/repo/default/packages/bad-md5/bad-md5.1: wrong checksum (1) +good-md5.1 +### :I:1: good md5 +### opam lint --package good-md5 +/good-md5.1: Passed. +### opam lint --package good-md5 --check-upstream +/good-md5.1: Passed. +### opam install good-md5 +The following actions will be performed: +=== install 1 package + - install good-md5 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> 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 <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed good-md5.1 +Done. +### opam source good-md5 +Successfully extracted to ${BASEDIR}/good-md5.1 +### test -f good-md5.1/p.patch +### opam clean --download-cache +Clearing cache of downloaded files +### :I:2: good md5 & sha256 +### opam lint --package good-md5-good-sha256 +/good-md5-good-sha256.1: Passed. +### opam lint --package good-md5-good-sha256 --check-upstream +/good-md5-good-sha256.1: Passed. +### opam install good-md5-good-sha256 +The following actions will be performed: +=== install 1 package + - install good-md5-good-sha256 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed good-md5-good-sha256.1 +Done. +### 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 <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> 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/p.patch +### opam clean --download-cache +Clearing cache of downloaded files +### :I:3: bad md5 +### opam lint --package bad-md5 +/bad-md5.1: Errors. + error 53: Mismatching 'extra-files:' field: "p.patch" +# Return code 1 # +### opam lint --package bad-md5 --check-upstream +/bad-md5.1: Errors. + error 53: Mismatching 'extra-files:' field: "p.patch" +# Return code 1 # +### opam install bad-md5 +The following actions will be performed: +=== install 1 package + - install bad-md5 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> + +Bad hash for - ${BASEDIR}/OPAM/repo/default/packages/bad-md5/bad-md5.1/files/p.patch + + + +<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> ++- The following actions failed +| - build bad-md5 1 ++- +- No changes have been performed +# Return code 31 # +### opam install bad-md5 --require-checksums +The following actions will be performed: +=== install 1 package + - install bad-md5 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> + +Bad hash for - ${BASEDIR}/OPAM/repo/default/packages/bad-md5/bad-md5.1/files/p.patch + + + +<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> ++- The following actions failed +| - build bad-md5 1 ++- +- No changes have been performed +# Return code 31 # +### opam source bad-md5 | '.n"' -> '"' +[WARNING] Some errors extracting to ${BASEDIR}/bad-md5.1: Failure("Bad hash for - ${BASEDIR}/OPAM/repo/default/packages/bad-md5/bad-md5.1/files/p.patch") + +### test -f bad-md5.1/p.patch +# Return code 1 # +### opam clean --download-cache +Clearing cache of downloaded files +### :I:4: 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 +/good-md5-bad-sha256.1: Passed. +### opam install good-md5-bad-sha256 +The following actions will be performed: +=== install 1 package + - install good-md5-bad-sha256 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> + +Bad hash for - ${BASEDIR}/OPAM/repo/default/packages/good-md5-bad-sha256/good-md5-bad-sha256.1/files/p.patch + + + +<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> ++- The following actions failed +| - build good-md5-bad-sha256 1 ++- +- No changes have been performed +# Return code 31 # +### opam install good-md5-bad-sha256 --require-checksums +The following actions will be performed: +=== install 1 package + - install good-md5-bad-sha256 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> + +Bad hash for - ${BASEDIR}/OPAM/repo/default/packages/good-md5-bad-sha256/good-md5-bad-sha256.1/files/p.patch + + + +<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> ++- The following actions failed +| - build good-md5-bad-sha256 1 ++- +- No changes have been performed +# Return code 31 # +### opam source good-md5-bad-sha256 | '.n"' -> '"' +[WARNING] Some errors extracting to ${BASEDIR}/good-md5-bad-sha256.1: Failure("Bad hash for - ${BASEDIR}/OPAM/repo/default/packages/good-md5-bad-sha256/good-md5-bad-sha256.1/files/p.patch") + +### test -f good-md5-bad-sha256.1/p.patch +### opam clean --download-cache +Clearing cache of downloaded files +### :I:5: no checksum +### opam lint --package no-checksum +/no-checksum.1: Errors. + error 3: File format error in 'extra-files' at line 11, column 2: expected [file checksum] +# Return code 1 # +### opam lint --package no-checksum --check-upstream +/no-checksum.1: Errors. + error 3: File format error in 'extra-files' at line 11, column 2: expected [file checksum] +# Return code 1 # +### # extra files is added with its checksum at repo loading +### opam install no-checksum +[ERROR] In the opam file for no-checksum.1: + - At ${BASEDIR}/OPAM/repo/default/packages/no-checksum/no-checksum.1/opam:11:2-11:13:: + expected [file checksum] + 'extra-files' has been ignored. +The following actions will be performed: +=== install 1 package + - install no-checksum 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed no-checksum.1 +Done. +### opam remove no-checksum +[ERROR] In the opam file for no-checksum.1: + - At ${BASEDIR}/OPAM/repo/default/packages/no-checksum/no-checksum.1/opam:11:2-11:13:: + expected [file checksum] + 'extra-files' has been ignored. +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 +[ERROR] In the opam file for no-checksum.1: + - At ${BASEDIR}/OPAM/repo/default/packages/no-checksum/no-checksum.1/opam:11:2-11:13:: + expected [file checksum] + 'extra-files' has been ignored. +The following actions will be performed: +=== install 1 package + - install no-checksum 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed no-checksum.1 +Done. +### opam source no-checksum +Successfully extracted to ${BASEDIR}/no-checksum.1 +### test -f no-checksum.1/p.patch +### opam clean --download-cache +Clearing cache of downloaded files +### ::::::::::::::::: +### :II: Presence +### ::::::::::::::::: +### :II:1: not mentioned +### opam lint --package not-mentioned +/not-mentioned.1: Passed. +### opam lint --package not-mentioned --check-upstream +/not-mentioned.1: Passed. +### opam install not-mentioned +The following actions will be performed: +=== install 1 package + - install not-mentioned 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed not-mentioned.1 +Done. +### opam remove not-mentioned +The following actions will be performed: +=== remove 1 package + - remove not-mentioned 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> removed not-mentioned.1 +Done. +### opam install not-mentioned --require-checksums +The following actions will be performed: +=== install 1 package + - install not-mentioned 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed not-mentioned.1 +Done. +### opam source not-mentioned +Successfully extracted to ${BASEDIR}/not-mentioned.1 +### test -f not-mentioned.1/p.patch +### opam clean --download-cache +Clearing cache of downloaded files +### :II:2: not present +### opam lint --package not-present +/not-present.1: Errors. + error 53: Mismatching 'extra-files:' field: "p.patch" +# Return code 1 # +### opam lint --package not-present --check-upstream +/not-present.1: Errors. + error 53: Mismatching 'extra-files:' field: "p.patch" +# Return code 1 # +### opam install not-present +The following actions will be performed: +=== install 1 package + - install not-present 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> + +Sys_error("${BASEDIR}/OPAM/repo/default/packages/not-present/not-present.1/files/p.patch: No such file or directory") + + +<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> ++- The following actions failed +| - build not-present 1 ++- +- No changes have been performed +# Return code 31 # +### opam install not-present --require-checksums +The following actions will be performed: +=== install 1 package + - install not-present 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> + +Sys_error("${BASEDIR}/OPAM/repo/default/packages/not-present/not-present.1/files/p.patch: No such file or directory") + + +<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> ++- The following actions failed +| - build not-present 1 ++- +- No changes have been performed +# Return code 31 # +### opam source not-present +Fatal error: +Sys_error("${BASEDIR}/OPAM/repo/default/packages/not-present/not-present.1/files/p.patch: No such file or directory") +# Return code 99 # +### test -f not-present.1/p.patch +# Return code 1 # +### opam clean --download-cache +Clearing cache of downloaded files +### ::::::::::::::::: +### :III: Escaping +### ::::::::::::::::: +### :III:1: absolute +### opam lint --package escape-absolute +/escape-absolute.1: Errors. + error 53: Mismatching 'extra-files:' field: "/etc/passwdd" +# Return code 1 # +### opam lint --package escape-absolute --check-upstream +/escape-absolute.1: Errors. + error 53: Mismatching 'extra-files:' field: "/etc/passwdd" +# Return code 1 # +### opam install escape-absolute +The following actions will be performed: +=== install 1 package + - install escape-absolute 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> + +Sys_error("${BASEDIR}/OPAM/repo/default/packages/escape-absolute/escape-absolute.1/files//etc/passwdd: No such file or directory") + + +<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> ++- The following actions failed +| - build escape-absolute 1 ++- +- No changes have been performed +# Return code 31 # +### opam install escape-absolute --require-checksums +The following actions will be performed: +=== install 1 package + - install escape-absolute 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> + +Sys_error("${BASEDIR}/OPAM/repo/default/packages/escape-absolute/escape-absolute.1/files//etc/passwdd: No such file or directory") + + +<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> ++- The following actions failed +| - build escape-absolute 1 ++- +- No changes have been performed +# Return code 31 # +### opam source escape-absolute +Fatal error: +Sys_error("${BASEDIR}/OPAM/repo/default/packages/escape-absolute/escape-absolute.1/files//etc/passwdd: No such file or directory") +# Return code 99 # +### test -f escape-absolute.1/p.patch +# Return code 1 # +### opam clean --download-cache +Clearing cache of downloaded files +### :III:2: good md5 +### opam lint --package escape-good-md5 +/escape-good-md5.1: Errors. + error 53: Mismatching 'extra-files:' field: "../../../no-checksum/no-checksum.1/files/p.patch" +# Return code 1 # +### opam lint --package escape-good-md5 --check-upstream +/escape-good-md5.1: Errors. + error 53: Mismatching 'extra-files:' field: "../../../no-checksum/no-checksum.1/files/p.patch" +# Return code 1 # +### # ERROR it copies it to build dir ^ relative path -> escape!!!! +### # currently writing in /tmp as a common it copies in +### # /tmp/build_d2b6ce_dune/opam-reftest-8f9413/escape-good-md5.1/../../../no-checksum/no-checksum.1/files +### # This is needed for test portability, windows doesn't check path before resolving it +### mkdir ${BASEDIR}/OPAM/repo/default/packages/escape-good-md5/escape-good-md5.1/files +### opam install escape-good-md5 +The following actions will be performed: +=== install 1 package + - install escape-good-md5 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +[ERROR] The compilation of escape-good-md5.1 failed at "test -f p.patch". + + + + +<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> ++- The following actions failed +| - build escape-good-md5 1 ++- +- No changes have been performed +# Return code 31 # +### opam install escape-good-md5 --require-checksums +The following actions will be performed: +=== install 1 package + - install escape-good-md5 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +[ERROR] The compilation of escape-good-md5.1 failed at "test -f p.patch". + + + + +<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> ++- The following actions failed +| - build escape-good-md5 1 ++- +- No changes have been performed +# Return code 31 # +### opam source escape-good-md5 +Successfully extracted to ${BASEDIR}/escape-good-md5.1 +### test -f escape-good-md5.1/p.patch +# Return code 1 # diff --git a/tests/reftests/extrasource.test b/tests/reftests/extrasource.test new file mode 100644 index 00000000000..f46207d1e0c --- /dev/null +++ b/tests/reftests/extrasource.test @@ -0,0 +1,1283 @@ +N0REP0 +### ::: Setup ::: +### +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 +### +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")" +### +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 ::: +### +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" ] +} +### +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" ] +} +### +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" + ] +} +### +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" + ] +} +### +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" +} +### +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" + ] +} +### +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" ] +} +### +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" + ] +} +### +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" + ] +} +### +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" + ] +} +### +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 +### +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" ] +} +### +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" +} +### +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" ] +} +### +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" ] +} +### +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 +/good-md5.1: Passed. +### opam lint --package good-md5 --check-upstream +/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 +/good-sha256.1: Passed. +### opam lint --package good-sha256 --check-upstream +/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 +/good-md5-good-sha256.1: Passed. +### opam lint --package good-md5-good-sha256 --check-upstream +/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: not found +### 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 +/good-sha256-good-md5.1: Passed. +### opam lint --package good-sha256-good-md5 --check-upstream +/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: not found +### 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 +/no-checksum.1: Passed. +### opam lint --package no-checksum --check-upstream +/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 +/multiple-md5.1: Passed. +### opam lint --package multiple-md5 --check-upstream +/multiple-md5.1: Passed. +### 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 +/bad-md5.1: Passed. +### opam lint --package bad-md5 --check-upstream +/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 +/good-md5-bad-sha256.1: Passed. +### opam lint --package good-md5-bad-sha256 --check-upstream +/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 +/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' +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 +/clash-with-all-md5s.666: Passed. +### opam lint --package clash-with-all-md5s --check-upstream +/clash-with-all-md5s.666: Passed. +### 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 +/not-mentioned.1: Passed. +### opam lint --package not-mentioned --check-upstream +/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 +/multiple.1: Errors. + error 3: File format error in 'extra-source': Duplicate section extra-source +# Return code 1 # +### opam lint --package multiple --check-upstream +/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: not found +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: not found +### :III:c: corrupt md5 patch in cache +### sh check-cache.sh +MD5: patch, with matching checksum +SHA256: not found +### 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: not found +### 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 +/escape-absolute.1: Passed. +### opam lint --package escape-absolute --check-upstream +/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 +/escape-build-good-md5.1: Passed. +### opam lint --package escape-build-good-md5 --check-upstream +/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 diff --git a/tests/reftests/local-cache.test b/tests/reftests/local-cache.test deleted file mode 100644 index 70885f29490..00000000000 --- a/tests/reftests/local-cache.test +++ /dev/null @@ -1,374 +0,0 @@ -N0REP0 -### ::: Setup ::: -### -Hi robur! -### tar czf archive.tgz hello -### -Trust me, im' a patch! -### openssl md5 archive.tgz | '.*= ' -> '' >$ ARCHIVE_MD5 -### openssl sha256 archive.tgz | '.*= ' -> '' >$ ARCHIVE_SHA256 -### openssl md5 p.patch | '.*= ' -> '' >$ PATCH_MD5 -### openssl sha256 p.patch | '.*= ' -> '' >$ PATCH_SHA256 -### sh -c "echo '$ARCHIVE_MD5' | cut -c 1-2" >$ PRE_MD5 -### echo "$OPAMROOT/download-cache/md5/$PRE_MD5/$ARCHIVE_MD5" >$ ARCHIVE_MD5_PATH -### sh -c "echo '$ARCHIVE_SHA256' | cut -c 1-2" >$ PRE_SHA256 -### echo "$OPAMROOT/download-cache/sha256/$PRE_SHA256/$ARCHIVE_SHA256" >$ ARCHIVE_SHA256_PATH -### -set -ue -eval "ARCHIVE_MD5_PATH=\"$ARCHIVE_MD5_PATH\"" -eval "ARCHIVE_SHA256_PATH=\"$ARCHIVE_SHA256_PATH\"" - -if command -v cygpath 2> /dev/null > /dev/null ; then - ARCHIVE_MD5_PATH=`cygpath -u "$ARCHIVE_MD5_PATH"` - ARCHIVE_SHA256_PATH=`cygpath -u "$ARCHIVE_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=`readlink -f "$path"` || true - if [ "$realpath" = "$ARCHIVE_MD5_PATH" ]; then - out="$out to md5 archive" - elif [ "$realpath" = "$ARCHIVE_SHA256_PATH" ]; then - out="$out to sha256 archive" - else - out="$out to unknown path $realpath" - fi - elif [ -f "$path" ] ; then - out="archive," - 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" -} - -md5=$(check "$ARCHIVE_MD5_PATH") -sha256=$(check "$ARCHIVE_SHA256_PATH") -echo "MD5: $md5" -echo "SHA256: $sha256" -### -set -ue -pkg=$1 -kind=$2 -hsh=$3 -case "$hsh-$kind" in - md5-archive) - HSH=$ARCHIVE_MD5 - break;; - sha256-archive) - HSH=$ARCHIVE_SHA256 - break;; - md5-patch) - HSH=$PATCH_MD5 - break;; - sha256-patch) - HSH=$PATCH_SHA256 - break;; -esac -pkgpath="REPO/packages/${pkg%.*}/$pkg" -sed -i.bak "s/good-$hsh/$HSH/" "$pkgpath/opam" -### -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" "hello" ] -url { - src: "archive.tgz" - checksum: [ - "sha256=good-sha256" - "md5=good-md5" - ] -} -### sh update-hash.sh good-sha256-good-md5.1 archive md5 -### sh update-hash.sh good-sha256-good-md5.1 archive sha256 -### opam update - -<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><> -[default] synchronised from file://${BASEDIR}/REPO -Now run 'opam upgrade' to apply any package updates. -### opam switch create default --empty -### :I:11: Change archive in cache -### :I:11:a: install with removed md5 frome cache, and kept sha256 -### 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 (file://${BASEDIR}/archive.tgz) --> installed good-sha256-good-md5.1 -Done. -### sh check-cache.sh -MD5: link, to sha256 archive -SHA256: archive, with matching checksum -### rm "$ARCHIVE_MD5_PATH" -### 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. -### sh check-cache.sh -MD5: not found -SHA256: archive, with matching checksum -### 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: not found -SHA256: archive, with matching checksum -### :I:11:b: install with removed sha256 frome cache, and kept md5 -### opam clean --download-cache -Clearing cache of downloaded files -### 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 (file://${BASEDIR}/archive.tgz) --> removed good-sha256-good-md5.1 --> installed good-sha256-good-md5.1 -Done. -### sh check-cache.sh -MD5: link, to sha256 archive -SHA256: archive, with matching checksum -### rm "$ARCHIVE_SHA256_PATH" -### 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. -### sh check-cache.sh -MD5: link, to sha256 archive -SHA256: not found -### 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 (file://${BASEDIR}/archive.tgz) --> installed good-sha256-good-md5.1 -Done. -### sh check-cache.sh -MD5: link, to sha256 archive -SHA256: archive, with matching checksum -### :I:11:c: corrupt md5 archive in cache -### sh check-cache.sh -MD5: link, to sha256 archive -SHA256: archive, 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 "$ARCHIVE_MD5_PATH" -### tar czf "$ARCHIVE_MD5_PATH" p.patch -### sh check-cache.sh -MD5: archive, with mismatching checksum -SHA256: archive, with matching checksum -### # it's only sha256 that is checked, as it is good, it doesn't check other cache files -### 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: archive, with mismatching checksum -SHA256: archive, with matching checksum -### :I:11:d: corrupt sha256 archive in cache -### sh check-cache.sh -MD5: archive, with mismatching checksum -SHA256: archive, 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. -### cp archive.tgz "$ARCHIVE_MD5_PATH" -### rm "$ARCHIVE_SHA256_PATH" -### tar czf "$ARCHIVE_SHA256_PATH" p.patch -### sh check-cache.sh -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' -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}/archive.tgz) --> installed good-sha256-good-md5.1 -Done. -### sh check-cache.sh -MD5: link, to sha256 archive -SHA256: archive, with matching checksum -### :I:11:e: 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 "$ARCHIVE_SHA256_PATH" -### tar czf "$ARCHIVE_SHA256_PATH" p.patch -### rm "$ARCHIVE_MD5_PATH" -### tar czf "$ARCHIVE_MD5_PATH" p.patch -### 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' -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}/archive.tgz) --> installed good-sha256-good-md5.1 -Done. -### sh check-cache.sh -MD5: link, to sha256 archive -SHA256: archive, with matching checksum -### -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" "hello" ] -url { - src: "archive.tgz" - checksum: [ - "sha256=good-sha256" - ] -} -### sh update-hash.sh good-sha256.1 archive sha256 -### opam update - -<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><> -[default] synchronised from file://${BASEDIR}/REPO -Now run 'opam upgrade' to apply any package updates. -### sh check-cache.sh -MD5: link, to sha256 archive -SHA256: archive, with matching checksum -### opam install good-sha256.1 -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. -### sh check-cache.sh -MD5: link, to sha256 archive -SHA256: archive, with matching checksum -### opam remove good-sha256.1 -The following actions will be performed: -=== remove 1 package - - remove good-sha256 1 - -<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> --> removed good-sha256.1 -Done. -### rm "$ARCHIVE_SHA256_PATH" -### opam install good-sha256.1 -The following actions will be performed: -=== install 1 package - - install good-sha256 1 - -<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> --> retrieved good-sha256.1 (file://${BASEDIR}/archive.tgz) --> installed good-sha256.1 -Done. -### sh check-cache.sh -MD5: link, to sha256 archive -SHA256: archive, with matching checksum -### opam remove good-sha256.1 -The following actions will be performed: -=== remove 1 package - - remove good-sha256 1 - -<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> --> removed good-sha256.1 -Done. -### rm "$ARCHIVE_SHA256_PATH" -### tar czf "$ARCHIVE_SHA256_PATH" p.patch -### 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' -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) - --> retrieved good-sha256.1 (file://${BASEDIR}/archive.tgz) --> installed good-sha256.1 -Done. -### sh check-cache.sh -MD5: link, to sha256 archive -SHA256: archive, with matching checksum