conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.29k stars 982 forks source link

[question] sha256 checksum not checked #17307

Closed gouriano closed 1 week ago

gouriano commented 1 week ago

What is your question?

Hi. I have noticed that the SHA256 checksum is not working in my local builds. I build a package.. in conandata.yml there is an entry like this

sources:
  "8.0.10":
    url: "https://github.com/.../release-8.0.10.tar.gz"
    sha256: "aaaaaaaaaaaaaaa"

it seems everything is correct, isn't it? Then the build says

getting mypackage sources...
from url: https://github.com/.../release-8.0.10.tar.gz
mypackage/8.0.10: WARN: Cannot cache download() without sha256 checksum

and the build proceeds. What am I doing wrong? I do not know where to start. Any advice? Thanks

Have you read the CONTRIBUTING guide?

gouriano commented 1 week ago

I mean SHA256 is intentionally wrong

AbrilRBS commented 1 week ago

Hi @gouriano thanks for your question.

Without having the code for your conanfile I can't confirm, but it's probable that you are not properly passing the sha256 from the conandata.yml to the get() call.

In fact, in https://github.com/ncbi/ncbi-cxx-toolkit-conan/blob/master/conanfile.py#L226, which might be the origin of your issue, you would also need to get the sha256 to pass it to the get function, something like:

        tk_url = self.conan_data["sources"][self.version]["url"] if "url" in self.conan_data["sources"][self.version].keys() else ""
+       tk_checksum = self.conan_data["sources"][self.version].get("sha256", None)
        tk_git = self.conan_data["sources"][self.version]["git"] if "git" in self.conan_data["sources"][self.version].keys() else ""
        tk_branch = self.conan_data["sources"][self.version]["branch"] if "branch" in self.conan_data["sources"][self.version].keys() else "main"

        if tk_url != None and tk_url != "":
            print("from url: " + tk_url)
            try:
-               get(self, tk_url, strip_root = True)
+               get(self, tk_url, sha256 = tk_checksum, strip_root = True)

(Although I'd recommend making the sha non-optional)

Let me know if this helps :)

gouriano commented 1 week ago

I see. I was under impression that it all works automatically. My fault. Thank you very much