Skip to contentSkip to conversation

Checksum of an external file

DISCUSSION Anton Gerasimov 2 participants 3 messages Dec 11, 2017

lore
Share & tools
lore
#0 lore raw

Hi,

my recipe takes a path to a file on user's file system as an input, processes it and stores on the device. Sometimes user wants to update this file and I'd like the recipe to be rebuilt every time the file itself changes, even if the file path didn't.

So I had an illusion to understand how sstate cache works and wrote the following code:

    def calculate_file_sha256(bb, d):
        return bb.utils.sha256_file(d.getVar("PATH_TO_FILE"))

    PATH_TO_FILE[vardepvalue] = "${@calculate_file_sha256(bb, d)}"

Unfortunately this doesn't work as expected (the recipe doesn't get rebuilt when the file changes, looks like calculate_file_sha256 doesn't run unless PATH_TO_FILE has changed) and at the same time if I 'cleanall' the recipe and change the file before rebuilding I get a lot of "metadata is not deterministic" errors.

Is there a proper way to do that with bitbake?

Thanks,
Anton Gerasimov

#1 lore raw
Quoted 7 lines · Anton Gerasimov

Unfortunately this doesn't work as expected (the recipe doesn't get rebuilt when the file changes, looks like calculate_file_sha256 doesn't run unless PATH_TO_FILE has changed) and at the same time if I 'cleanall' the recipe and change the file before rebuilding I get a lot of "metadata is not deterministic" errors.

Is there a proper way to do that with bitbake?

I don't think so. You need to write an external script that copies the file into the layer, then runs bitbake. The recipe should simply refer to the file via SRC_URI file fetcher.

Alex

#2 lore raw
Quoted 4 lines

I don't think so. You need to write an external script that copies the file into the layer, then runs bitbake. The recipe should simply refer to the file via SRC_URI file fetcher.

Thank you a lot, that actually works without copying: SRC_URI works with absolute pathes as well. Such a straightworward solution has never occured to me for some reason.

- Anton