diff --git a/master_changes.md b/master_changes.md index 313b5b7dd60..7559b4e15fe 100644 --- a/master_changes.md +++ b/master_changes.md @@ -50,6 +50,7 @@ users) ## Source ## Lint + * [BUG] fix lint W59 with local urls that are not archives [#6219 @rjbou - fix #6218] ## Repository @@ -107,6 +108,7 @@ users) ## Reftests ### Tests + * Add more tests for lint W59 [#6219 @rjbou] ### Engine diff --git a/src/state/opamFileTools.ml b/src/state/opamFileTools.ml index 804a54c6a17..0833f74e34c 100644 --- a/src/state/opamFileTools.ml +++ b/src/state/opamFileTools.ml @@ -396,9 +396,15 @@ let t_lint ?check_extra_files ?(check_upstream=false) ?(all=false) t = | #OpamUrl.version_control -> true | _ -> false) in + let url_archive = + let open OpamStd.Option.Op in + t.url >>| OpamFile.URL.url >>| (fun u -> + OpamSystem.is_archive u.OpamUrl.path) + in let is_url_archive = - not (OpamFile.OPAM.has_flag Pkgflag_Conf t) && - url_vcs = Some false + not (OpamFile.OPAM.has_flag Pkgflag_Conf t) + && url_vcs = Some false + && url_archive = Some true in let check_upstream = check_upstream && is_url_archive in let check_double compare to_str lst = @@ -1001,7 +1007,7 @@ let t_lint ?check_extra_files ?(check_upstream=false) ?(all=false) t = |> List.map OpamHash.to_string |> OpamStd.Format.pretty_list)]) t.url) - (url_vcs = Some true + (url_vcs = Some true && url_archive = Some false && OpamStd.Option.Op.(t.url >>| fun u -> OpamFile.URL.checksum u <> []) = Some true); cond 68 `Warning diff --git a/tests/reftests/lint.test b/tests/reftests/lint.test index f9528eeecc2..916a23da081 100644 --- a/tests/reftests/lint.test +++ b/tests/reftests/lint.test @@ -852,6 +852,7 @@ ${BASEDIR}/lint.opam: Warnings. ### opam lint ./lint.opam --check-upstream ${BASEDIR}/lint.opam: Warnings. warning 59: url doesn't contain a checksum +### # package with conf flag ### opam-version: "2.0" synopsis: "A word" @@ -864,7 +865,6 @@ dev-repo: "hg+https://to@li.nt" bug-reports: "https://nobug" url { src:"an-archive.tgz" } flags: conf -### # package with conf flag ### opam lint ./lint.opam ${BASEDIR}/lint.opam: Errors. error 46: Package is flagged "conf" but has source, install or remove instructions @@ -873,6 +873,7 @@ ${BASEDIR}/lint.opam: Errors. ${BASEDIR}/lint.opam: Errors. error 46: Package is flagged "conf" but has source, install or remove instructions # Return code 1 # +### # package with git url ### opam-version: "2.0" synopsis: "A word" @@ -884,7 +885,53 @@ license: "ISC" dev-repo: "hg+https://to@li.nt" bug-reports: "https://nobug" url { src:"git+https://a/repo" } -### # package with git url +### opam lint ./lint.opam +${BASEDIR}/lint.opam: Passed. +### opam lint ./lint.opam --check-upstream +${BASEDIR}/lint.opam: Passed. +### # package with local url +### +something +### +opam-version: "2.0" +synopsis: "A word" +description: "Two words." +authors: "the testing team" +homepage: "egapemoh" +maintainer: "maint@tain.er" +license: "ISC" +dev-repo: "hg+https://to@li.nt" +bug-reports: "https://nobug" +### +basedir=$(echo "$BASEDIR" | sed "s/\\\\\\\\/\\\\\\\\\\\\\\\\/g") +cat << EOF >> lint.opam +url { src:"file://$basedir/an-archive" } +EOF +### sh add-url.sh +### opam lint ./lint.opam +${BASEDIR}/lint.opam: Passed. +### opam lint ./lint.opam --check-upstream +${BASEDIR}/lint.opam: Passed. +### # package with local archive url +### +opam-version: "2.0" +synopsis: "A word" +description: "Two words." +authors: "the testing team" +homepage: "egapemoh" +maintainer: "maint@tain.er" +license: "ISC" +dev-repo: "hg+https://to@li.nt" +bug-reports: "https://nobug" +### +basedir=$(echo "$BASEDIR" | sed "s/\\\\\\\\/\\\\\\\\\\\\\\\\/g") +cat << EOF >> lint.opam +url { + src:"file://$basedir/an-archive.tgz" + checksum: "md5=$(openssl md5 an-archive.tgz | cut -f2 -d' ')" + } +EOF +### sh add-url.sh ### opam lint ./lint.opam ${BASEDIR}/lint.opam: Passed. ### opam lint ./lint.opam --check-upstream