From c5cca86a45986bb8c1cae4955046656ee2cc9bf2 Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Wed, 8 Mar 2023 19:54:24 +0100 Subject: [PATCH] lint: update W59 (no checksum on url) to always display a warning, no more tied to --check-upstream option --- master_changes.md | 1 + src/state/opamFileTools.ml | 6 +++--- tests/reftests/archive.test | 3 ++- tests/reftests/lint.test | 8 ++++++-- tests/reftests/show.test | 27 +++++++++++++++------------ 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/master_changes.md b/master_changes.md index 36814f91023..aedcc254713 100644 --- a/master_changes.md +++ b/master_changes.md @@ -73,6 +73,7 @@ users) * Add E71 to check if the same checksum algorithm is used several times for a given url in `url` section [#5561 @rjbou] * Add E72 to check if the same checksum algorithm is used several times for a given url in `extra-sources` section [#5561 @rjbou] * Add E73 to check that paths in `extra-files:` are not escapable [#5561 @rjbou] + * Update W59 (no checksum in `url`) to always display a warning, untie it from `--check-upstream` option [#5561 @rjbou] ## Repository * Mitigate curl/curl#13845 by falling back from --write-out to --fail if exit code 43 is returned by curl [#6168 @dra27 - fix #6120] diff --git a/src/state/opamFileTools.ml b/src/state/opamFileTools.ml index ced443f74a8..49e79e2f618 100644 --- a/src/state/opamFileTools.ml +++ b/src/state/opamFileTools.ml @@ -396,11 +396,11 @@ let t_lint ?check_extra_files ?(check_upstream=false) ?(all=false) t = | #OpamUrl.version_control -> true | _ -> false) in - let check_upstream = - check_upstream && + let is_url_archive = not (OpamFile.OPAM.has_flag Pkgflag_Conf t) && url_vcs = Some false in + let check_upstream = check_upstream && is_url_archive in let check_double compare to_str lst = let double = List.sort compare lst @@ -811,7 +811,7 @@ let t_lint ?check_extra_files ?(check_upstream=false) ?(all=false) t = Printf.sprintf "Found %s variable%s, predefined one%s" var s_ nvar) (rem_test || rem_doc)); cond 59 `Warning "url doesn't contain a checksum" - (check_upstream && + (is_url_archive && OpamStd.Option.map OpamFile.URL.checksum t.url = Some []); (let upstream_error = if not check_upstream then None else diff --git a/tests/reftests/archive.test b/tests/reftests/archive.test index 60d43572c68..cea652b2ac6 100644 --- a/tests/reftests/archive.test +++ b/tests/reftests/archive.test @@ -430,7 +430,8 @@ Successfully extracted to ${BASEDIR}/good-sha256-good-md5.1 Clearing cache of downloaded files ### :I:5: no checksum ### opam lint --package no-checksum -/no-checksum.1: Passed. +/no-checksum.1: Warnings. + warning 59: url doesn't contain a checksum ### opam lint --package no-checksum --check-upstream /no-checksum.1: Warnings. warning 59: url doesn't contain a checksum diff --git a/tests/reftests/lint.test b/tests/reftests/lint.test index 35d2e56bd03..06e2ae6f48d 100644 --- a/tests/reftests/lint.test +++ b/tests/reftests/lint.test @@ -352,7 +352,10 @@ homepage: "egapemoh" maintainer: "maint@tain.er" license: "ISC" bug-reports: "https://nobug" -url { src:"https://u.rl" } +url { + src:"an-archive.tgz" + checksum: "md5=00000000000000000000000000000000" +} ### opam lint ./lint.opam ${BASEDIR}/lint.opam: Warnings. warning 37: Missing field 'dev-repo' @@ -852,7 +855,8 @@ dev-repo: "hg+https://to@li.nt" bug-reports: "https://nobug" url { src:"an-archive.tgz" } ### opam lint ./lint.opam -${BASEDIR}/lint.opam: Passed. +${BASEDIR}/lint.opam: Warnings. + warning 59: url doesn't contain a checksum ### opam lint ./lint.opam --check-upstream ${BASEDIR}/lint.opam: Warnings. warning 59: url doesn't contain a checksum diff --git a/tests/reftests/show.test b/tests/reftests/show.test index 7662c4741b6..13650c4ad7f 100644 --- a/tests/reftests/show.test +++ b/tests/reftests/show.test @@ -353,6 +353,7 @@ depexts devel/llvm10 llvm-10-dev opam-version: "2.0" url { src:"https://an.arch/i/ve.tgz" + checksum: "md5=00000000000000000000000000000000" mirrors: [ "https://a.mi/rror" "http://swhid.opam.ocaml.org/swh:1:dir:309cf2674ee7a0749978cf8265ab91a60aea0f7d" ] @@ -364,18 +365,19 @@ name swhid all-versions dev <><> Version-specific details <><><><><><><><><><><><><><><><><><><><><><><><><> -version dev -pin https://an.arch/i/ve.tgz -url.src "https://an.arch/i/ve.tgz" -url.swhid "swh:1:dir:309cf2674ee7a0749978cf8265ab91a60aea0f7d" -homepage "egapemoh" -bug-reports "https://nobug" -dev-repo "hg+https://pkg@op.am" -authors "the testing team" -maintainer "maint@tain.er" -license "MIT" -synopsis A word -description Two words. +version dev +pin https://an.arch/i/ve.tgz +url.src "https://an.arch/i/ve.tgz" +url.swhid "swh:1:dir:309cf2674ee7a0749978cf8265ab91a60aea0f7d" +url.checksum "md5=00000000000000000000000000000000" +homepage "egapemoh" +bug-reports "https://nobug" +dev-repo "hg+https://pkg@op.am" +authors "the testing team" +maintainer "maint@tain.er" +license "MIT" +synopsis A word +description Two words. ### opam show ./swhid.opam --raw opam-version: "2.0" name: "swhid" @@ -390,6 +392,7 @@ bug-reports: "https://nobug" dev-repo: "hg+https://pkg@op.am" url { src: "https://an.arch/i/ve.tgz" + checksum: "md5=00000000000000000000000000000000" mirrors: [ "https://swhid.opam.ocaml.org/swh:1:dir:309cf2674ee7a0749978cf8265ab91a60aea0f7d" "https://a.mi/rror"