Skip to contentSkip to conversation

dm-verity-image-initramfs: Allow compressed image types

PATCH In review Stephan Wurm 2 participants 4 messages Jun 19, 2023 – Jul 21, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm-verity-image-initramfs: Allow compressed image types

Using <DM_VERITY_IMAGE_TYPE> in the depends variable does not work for compressed image types like squashfs-zst, as the resulting task dependency still contains the incompatible dash. Replacing the dash by an underscore resolves this issue.

---
 recipes-core/images/dm-verity-image-initramfs.bb | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
recipes-core/images/dm-verity-image-initramfs.bb +7 -1
index 187aeae..fc12ba0 100644
@@ -19,7 +19,13 @@ IMAGE_FEATURES = ""
 IMAGE_LINGUAS = ""
 
 # Can we somehow inspect reverse dependencies to avoid these variables?
-do_image[depends] += "${DM_VERITY_IMAGE}:do_image_${DM_VERITY_IMAGE_TYPE}"
+python __anonymous() {
+    verity_image = d.getVar('DM_VERITY_IMAGE')
+    verity_type = d.getVar('DM_VERITY_IMAGE_TYPE')
+
+    dep = ' %s:do_image_%s' % (verity_image, verity_type.replace('-', '_'))
+    d.appendVarFlag('do_image', 'depends', dep)
+}
 
 # Ensure dm-verity.env is updated also when rebuilding DM_VERITY_IMAGE
 do_image[nostamp] = "1"
Signature · 1 line
2.34.1
#1 lore raw

this fails to build:

The stack trace of python calls that resulted in this exception/failure was:
File: '<code>', lineno: 24, function: <module>
0020:__anon_70__home_akuster_oss_clean_poky_meta_classes_recipe_rootfs_postcommands_bbclass(d)
0021:__anon_125__home_akuster_oss_clean_poky_meta_classes_recipe_image_bbclass(d)
0022:__anon_181__home_akuster_oss_clean_poky_meta_classes_recipe_image_bbclass(d)
0023:__anon_518__home_akuster_oss_clean_poky_meta_classes_recipe_image_bbclass(d)
 *** 0024:__anon_28__home_akuster_oss_maint_meta_security_recipes_core_images_dm_verity_image_initramfs_bb(d)
File: '/home/akuster/oss/maint/meta-security/recipes-core/images/dm-verity-image-initramfs.bb', lineno: 26, function: __anon_28__home_akuster_oss_maint_meta_security_recipes_core_images_dm_verity_image_initramfs_bb 0022:python __anonymous() {
     0023:    verity_image = d.getVar('DM_VERITY_IMAGE')
     0024:    verity_type = d.getVar('DM_VERITY_IMAGE_TYPE')
     0025:
 *** 0026:    dep = ' %s:do_image_%s' % (verity_image, verity_type.replace('-', '_'))
     0027:    d.appendVarFlag('do_image', 'depends', dep)
     0028:}
     0029:
     0030:# Ensure dm-verity.env is updated also when rebuilding DM_VERITY_IMAGE
Exception: AttributeError: 'NoneType' object has no attribute 'replace

Quoted 38 lines · Stephan Wurm

Using <DM_VERITY_IMAGE_TYPE> in the depends variable does not work for compressed image types like squashfs-zst, as the resulting task dependency still contains the incompatible dash. Replacing the dash by an underscore resolves this issue.

---
  recipes-core/images/dm-verity-image-initramfs.bb | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
recipes-core/images/dm-verity-image-initramfs.bb +7 -2
index 187aeae..fc12ba0 100644
@@ -19,7 +19,13 @@ IMAGE_FEATURES = ""
  IMAGE_LINGUAS = ""
 
  # Can we somehow inspect reverse dependencies to avoid these variables?
-do_image[depends] += "${DM_VERITY_IMAGE}:do_image_${DM_VERITY_IMAGE_TYPE}"
+python __anonymous() {
+    verity_image = d.getVar('DM_VERITY_IMAGE')
+    verity_type = d.getVar('DM_VERITY_IMAGE_TYPE')
+
+    dep = ' %s:do_image_%s' % (verity_image, verity_type.replace('-', '_'))
+    d.appendVarFlag('do_image', 'depends', dep)
+}
 
  # Ensure dm-verity.env is updated also when rebuilding DM_VERITY_IMAGE
  do_image[nostamp] = "1"
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#60337): https://lists.yoctoproject.org/g/yocto/message/60337
Mute This Topic: https://lists.yoctoproject.org/mt/99618767/3616698
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw

Hello akuster808,

Am Mittwoch, dem 21.06.2023 um 19:16 -0400 schrieb akuster808:

Quoted 27 lines

this fails to build:

The stack trace of python calls that resulted in this exception/failure was:
File: '<code>', lineno: 24, function: <module> 0020:__anon_70__home_akuster_oss_clean_poky_meta_classes_recipe_rootf s_postcommands_bbclass(d) 0021:__anon_125__home_akuster_oss_clean_poky_meta_classes_recipe_imag e_bbclass(d) 0022:__anon_181__home_akuster_oss_clean_poky_meta_classes_recipe_imag e_bbclass(d) 0023:__anon_518__home_akuster_oss_clean_poky_meta_classes_recipe_imag e_bbclass(d)
  ***
0024:__anon_28__home_akuster_oss_maint_meta_security_recipes_core_ima ges_dm_verity_image_initramfs_bb(d)
File:
'/home/akuster/oss/maint/meta-security/recipes-core/images/dm-verity- image-initramfs.bb',
lineno: 26, function:
__anon_28__home_akuster_oss_maint_meta_security_recipes_core_images_d m_verity_image_initramfs_bb
      0022:python __anonymous() {
      0023:    verity_image = d.getVar('DM_VERITY_IMAGE') 0024:    verity_type = d.getVar('DM_VERITY_IMAGE_TYPE') 0025:
  *** 0026:    dep = ' %s:do_image_%s' % (verity_image,

Quoted 8 lines

verity_type.replace('-', '_'))
      0027:    d.appendVarFlag('do_image', 'depends', dep) 0028:}
      0029:
      0030:# Ensure dm-verity.env is updated also when rebuilding DM_VERITY_IMAGE
Exception: AttributeError: 'NoneType' object has no attribute 'replace

this looks like DM_VERITY_IMAGE_TYPE was never set or is empty, hence the replace operation cannot work.

I tested this on kirkstone with DM_VERITY_IMAGE_TYPE set to squashfs or squashfs-zst, while DM_VERITY_IMAGE was configured to reflect my normal rootfs image.

Best regards
Stephan

#3 lore raw

PATCH 1/1 dm-verity-image-initramfs: Allow compressed image types

In reply to Stephan Wurm

Using <DM_VERITY_IMAGE_TYPE> in the depends variable does not work for compressed image types like squashfs-zst, as the resulting task dependency still contains the incompatible dash. Replacing the dash by an underscore resolves this issue.

---
 recipes-core/images/dm-verity-image-initramfs.bb | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
recipes-core/images/dm-verity-image-initramfs.bb +8 -1
index 187aeae..78f7b49 100644
@@ -19,7 +19,14 @@ IMAGE_FEATURES = ""
 IMAGE_LINGUAS = ""
 
 # Can we somehow inspect reverse dependencies to avoid these variables?
-do_image[depends] += "${DM_VERITY_IMAGE}:do_image_${DM_VERITY_IMAGE_TYPE}"
+python __anonymous() {
+    verity_image = d.getVar('DM_VERITY_IMAGE')
+    verity_type = d.getVar('DM_VERITY_IMAGE_TYPE')
+
+    if verity_image and verity_type:
+        dep = ' %s:do_image_%s' % (verity_image, verity_type.replace('-', '_'))
+        d.appendVarFlag('do_image', 'depends', dep)
+}
 
 # Ensure dm-verity.env is updated also when rebuilding DM_VERITY_IMAGE
 do_image[nostamp] = "1"
Signature · 1 line
2.34.1