pkglib: put real pkg-build-arg-hash into pkg hash#4176
pkglib: put real pkg-build-arg-hash into pkg hash#4176christoph-zededa wants to merge 1 commit intolinuxkit:masterfrom
Conversation
when using ``` buildArgs: - REL_HASH_%=@lkt:pkgs:../* ``` then exactly this string is put into the pkg hash, but if one of these packages are updated, the pkg hash is not updated, as the string is static. Instead put in the real pkg-build-arg-hash so that even if a pkg is updated, it's descendants end up with a new hash. Signed-off-by: Christoph Ostarek <christoph@zededa.com>
0b575eb to
6e329b9
Compare
|
|
||
| buildArgKey := fmt.Sprintf("buildArg=%s", buildArg) | ||
| pkgHash += fmt.Sprintf("%x", sha1.Sum([]byte(buildArgKey))) | ||
| pkgHash = fmt.Sprintf("%x", sha1.Sum([]byte(pkgHash))) |
There was a problem hiding this comment.
IMO this should be optimized, f.e. filter out duplicates if needed and sort alphabetically.
|
Can you explain the logic here a bit, using words (as opposed to code)? The way it works now, the logic for determining the tag is here, where it basically gets the tree hash. If the files are dirty, then it appends dirty and also calculates the content hash. The builds args themselves are not included directly, only by virtue of being in a file in the directory. What does this change in that process? |
Ideally I would also have put these changes around https://github.com/linuxkit/linuxkit/blob/master/src/cmd/linuxkit/pkglib/pkglib.go#L243-L265, but Finally it does this template thing that was originally here: https://github.com/linuxkit/linuxkit/blob/master/src/cmd/linuxkit/pkglib/pkglib.go#L243-L265 |
|
The implementation is a bit off (it only runs the template if buildArgs are not nil), but it looks like you are changing the More fundamentally, you are including the build args as part of the hash, whereas currently it is just the This whol |
this is the code: if the buildArgs are nil, then only is not running, the rest, i.e.: still is executed. |
the struct is code - I do not understand, can you elaborate a bit more? |
This might be the last one ;-) Does it help if I ask ChatGPT to create an even cuter animal image?
Even in the past you could not, because if there is an |
No, I am commenting on how it was done, not on whether or not it was good. |
Nah, make it something interesting and not believable. "ChatGPT" give me an image of an animal that might appear in the Halo video game franchise. |
I would argue that you should use I need to think about this for a while. We are changing the definition of the hash, which is not something to be taken lightly. Sure, the tools all will get it, like |
when using
then exactly this string is put into the pkg hash, but if one of these packages are updated, the pkg hash is not updated, as the string is static.
Instead put in the real pkg-build-arg-hash so that even if a pkg is updated, it's descendants end up with a new hash.
- What I did
Include "real" build-args hashes in to pkg hash.
- How I did it
- How to verify it
Change a pkg and then build a pkg (with
REL_HASH_%=@lkt:pkgs:../*); check that it really gets built again.- Description for the changelog
Include "real" build-args hashes in to pkg hash.
- A picture of a cute animal (not mandatory but encouraged)
