diff --git a/src/state/opamFileTools.ml b/src/state/opamFileTools.ml index 7e5fe9d0ee5..f6286aec7b9 100644 --- a/src/state/opamFileTools.ml +++ b/src/state/opamFileTools.ml @@ -298,11 +298,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 @@ -698,7 +698,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/lint.test b/tests/reftests/lint.test index 72a23291e88..bdbf33e51ad 100644 --- a/tests/reftests/lint.test +++ b/tests/reftests/lint.test @@ -690,7 +690,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" diff --git a/tests/reftests/url-section-checks.test b/tests/reftests/url-section-checks.test index 427d75a1bcd..4bb97970d58 100644 --- a/tests/reftests/url-section-checks.test +++ b/tests/reftests/url-section-checks.test @@ -431,7 +431,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