-
Notifications
You must be signed in to change notification settings - Fork 8
Reproducible build #240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there no way to pass flags without patches?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My previous suggestions didn't work? Because it's way more complicated and error prone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use ` for shell evaluation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
81be646 to
1687659
Compare
Signed-off-by: Pawel Langowski <[email protected]>
Signed-off-by: Pawel Langowski <[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.