Reproducible build - #240
Conversation
| @@ -0,0 +1,3 @@ | |||
| FILESEXTRAPATHS:prepend := "${THISDIR}/lshw:" | |||
|
|
|||
| SRC_URI:append = " file://0001-src-Makefile-Use-gzip-with-n-option.patch" | |||
There was a problem hiding this comment.
Is there no way to pass flags without patches?
There was a problem hiding this comment.
I tried EXTRA_OEMAKE += "GZIP='gzip -9 -n'", but got this:
| gzip -9 -n -c pci.ids > pci.ids.gz
| gzip -9 -n -c usb.ids > usb.ids.gz
| gzip -9 -n -c oui.txt > oui.txt.gz
| gzip -9 -n -c manuf.txt > manuf.txt.gz
| gzip: gzip: gzip: abort: cannot provide files in GZIP environment variableabort: cannot provide files in GZIP environment variableabort: cannot provide files in GZIP environment variable
There was a problem hiding this comment.
Try:
EXTRA_OEMAKE += "GZIP='-9 -n'"
| do_image_wic:prepend() { | ||
| WKS_FILE="${WORKDIR}/usb-stick-dts.wks" | ||
| UUID="${@'$(echo ${LAYER_COMMIT_SHA} | cut -c1-8)-$(echo ${LAYER_COMMIT_SHA} | cut -c9-12)-4$(echo ${LAYER_COMMIT_SHA} | cut -c13-15)-$(echo ${LAYER_COMMIT_SHA} | cut -c16-19)-$(echo ${LAYER_COMMIT_SHA} | cut -c20-31)'}" | ||
| sed -i "s/--use-uuid/--uuid $UUID/" $WKS_FILE |
There was a problem hiding this comment.
Don't we use: usb-stick-dts.wks.in?
You can use variables directly e.g. https://github.com/Dasharo/meta-dts/blob/uki/meta-dts-distro/wic/usb-stick-dts.wks.in#L3 (setting LABEL)
There was a problem hiding this comment.
The problem with this is the following:
We need to evaluate a bash command to create a uuid based on the commit SHA. I tried defining the UUIDs in this recipe and passing them to WICVARS
ROOT_UUID="${@'$(echo ${LAYER_COMMIT_SHA} | sha256sum | cut -c1-8)-$(echo ${LAYER_COMMIT_SHA} | sha256sum | cut -c9-12)-4$(echo ${LAYER_COMMIT_SHA} | sha256sum | cut -c13-15)-$(echo ${LAYER_COMMIT_SHA} | sha256sum | cut -c16-19)-$(echo ${LAYER_COMMIT_SHA} | sha256sum | cut -c20-31)'}"
BOOT_UUID="${@'$(echo "boot-${LAYER_COMMIT_SHA}" | sha256sum | cut -c1-8)-$(echo "boot-${LAYER_COMMIT_SHA}" | sha256sum | cut -c9-12)-4$(echo "boot-${LAYER_COMMIT_SHA}" | sha256sum | cut -c13-15)-$(echo "boot-${LAYER_COMMIT_SHA}" | sha256sum | cut -c16-19)-$(echo "boot-${LAYER_COMMIT_SHA}" | sha256sum | cut -c20-31)'}"
WICVARS += "ROOT_UUID BOOT_UUID "
but the commands were not evaluated, so the variables were passed to wks in the form of commands. I'm not sure how else I could pass them aside from the original idea. Unless we want to set fixed UUIDs, then it becomes a simple matter.
There was a problem hiding this comment.
Look at how every other recipe does this. Usually with python. I'm not sure if sh evaluation works:
https://docs.yoctoproject.org/bitbake/2.2/bitbake-user-manual/bitbake-user-manual-metadata.html#inline-python-variable-expansion
You could just define task and set value of this variable there: https://docs.yoctoproject.org/bitbake/2.2/bitbake-user-manual/bitbake-user-manual-metadata.html#exporting-variables-to-the-environment
You might write python task to begin with: https://docs.yoctoproject.org/bitbake/2.2/bitbake-user-manual/bitbake-user-manual-metadata.html#bitbake-style-python-functions
or just use this: https://docs.yoctoproject.org/bitbake/2.2/bitbake-user-manual/bitbake-user-manual-metadata.html#python-functions
BOOT_UUID="${@get_uuid('boot')}"
ROOT_UUID="${@get_uuid('root')}"
def get_uuid(string):
import hashlib, uuid
return str(uuid.UUID(hashlib.md5(f"{commit}{string}".encode()).hexdigest()))you need to somehow get commit in python func. Not tested so there probably are mistakes.
There was a problem hiding this comment.
I found do_rootfs_wicenv: https://git.yoctoproject.org/poky/plain/meta/classes-recipe/image_types_wic.bbclass
Maybe I can append the evaluated variables to the .env file there
There was a problem hiding this comment.
If this doesn't work you might have to use: https://docs.yoctoproject.org/bitbake/2.2/bitbake-user-manual/bitbake-user-manual-metadata.html#immediate-variable-expansion
There was a problem hiding this comment.
Maybe I can append the evaluated variables to the .env file there
why?
but the commands were not evaluated, so the variables were passed to wks in the form of commands
I think the problem was that you used wrong format. You can also use immediate variable expansion to make sure.
I think you tried to use bash script in python evaluation ('@'). Not only that but it's possible that it's because of ' in ${@'. It's possible that everything between '' was treated as string
There was a problem hiding this comment.
There was a problem hiding this comment.
You forgot to include commit sha. I think it should be something like:
BOOT_UUID="${@get_uuid('boot' + d.getVar('LAYER_COMMIT_SHA'))}"
ROOT_UUID="${@get_uuid('root' + d.getVar('LAYER_COMMIT_SHA'))}"
Check if it works (and check if LAYER_COMMIT_SHA is evaluated correctly)
There was a problem hiding this comment.
Working example:
- zarhus-base-image.inc#L12
- zarhus-uki.inc#L11
- zarhus-uki.wks#L3 - notice
--ptable gptin previous line, without it wic generates disk image with MBR which uses different UID format and will silently ignore--uuid, at least when it's in wrong format.
1fc2090 to
d66533a
Compare
d66533a to
6615c93
Compare
|
|
||
| ROOTFS_POSTPROCESS_COMMAND += "local_autologin; " | ||
|
|
||
| python do_rootfs_wicenv:append() { |
There was a problem hiding this comment.
My previous suggestions didn't work? Because it's way more complicated and error prone
There was a problem hiding this comment.
As I said, if done outside a task, they variables will not be evaluated before passed to the env
There was a problem hiding this comment.
ok, I didn't see your comment above. I will try that
6615c93 to
81be646
Compare
| lshw \ | ||
| " | ||
|
|
||
| LAYER_COMMIT_SHA := "`cd ${LAYERDIR} && git rev-parse HEAD`" |
There was a problem hiding this comment.
Don't use ` for shell evaluation
There was a problem hiding this comment.
81be646 to
1687659
Compare
Signed-off-by: Pawel Langowski <pawel.langowski@3mdeb.com>
Signed-off-by: Pawel Langowski <pawel.langowski@3mdeb.com>
1687659 to
6e7a12c
Compare
| BOOT_UUID="${@get_uuid('boot' + d.getVar('LAYER_COMMIT_SHA'))}" | ||
| ROOT_UUID="${@get_uuid('root' + d.getVar('LAYER_COMMIT_SHA'))}" | ||
|
|
||
| def get_uuid(string): |
There was a problem hiding this comment.
You need to use bootloader --ptable gpt in wks file if you want to use long form of UUID otherwise it'd likely be ignored. MBR uses short UUID.
827816f to
31eb3fa
Compare
No description provided.