wic: bootimg-partition: Add directory copy support to bootimage creation
PATCH 1/1 wic: bootimg-partition: Add directory copy support to bootimage creation
Hi,
this patch allows to create directories inside the boot partition when using WIC. Without the patch the build process will abort with an error when a recipe tries to not only copy files but to also create a directory inside the boot partition.
Recipe content:
inherit deploy
do_deploy() {
install -d ${DEPLOYDIR}/${BOOTFILES_DIR_NAME}/mydirectory touch ${DEPLOYDIR}/${BOOTFILES_DIR_NAME}/mydirectory/${PN}-${PV}.stamp }
addtask deploy before do_build after do_install do_deploy[dirs] += "${DEPLOYDIR}/${BOOTFILES_DIR_NAME}/mydirectory"
The task do_image_wic will then complain (paths reduced and anonymized):
| ERROR: _exec_cmd: install -m 0644 -D /my/home/dir/yocto/rpi-build/tmp/deploy/images/raspberrypi4/bootfiles/mydirectory /my/home/dir/yocot/rpi-build/tmp/work/raspberrypi4-poky-linux-gnueabi/my-image/1.0-r0/tmp-wic/boot.1/mydirectory returned '1' instead of 0
| output: install: omitting directory '/my/home/dir/yocto/rpi-build/tmp/deploy/images/raspberrypi4/bootfiles/mydirectory'
As can be seen it uses "install -D" instead of creating the directory with "install -d". This patch fixes this.
Best regards
Sven
Quoted 1 line
From
360775581a573a62032155fc6968175125e9c1dbMon Sep 17 00:00:00 2001
From: Sven Bachmann <[email protected]>
Date: Tue, 25 Jan 2022 20:47:17 +0100
Subject: [PATCH 1/1] wic: bootimg-partition: add directory copy support to bootimage creation
---
.../lib/wic/plugins/source/bootimg-partition.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
(quoted diff) +0 -0
b/scripts/lib/wic/plugins/source/bootimg-partition.py index 5dbe2558d2..6348050bd5 100644
scripts/lib/wic/plugins/source/bootimg-partition.py +0 -0
@@ -184,9 +184,17 @@ class BootimgPartitionPlugin(SourcePlugin):
for task in cls.install_task:
src_path, dst_path = task
logger.debug('Install %s as %s', src_path, dst_path)
- install_cmd = "install -m 0644 -D %s %s" \
- % (os.path.join(kernel_dir, src_path),
- os.path.join(hdddir, dst_path))
+ if os.path.isfile(src_path):
+ install_cmd = "install -m 0644 -D %s %s" \
+ % (os.path.join(kernel_dir, src_path), + os.path.join(hdddir, dst_path))
+ elif os.path.isdir:
+ install_cmd = "install -m 0755 -d %s" \
+ % (os.path.join(hdddir, dst_path))
+ else:
+ logger.error("Path is neither file nor directory: %s", src_path) + raise WicError("Type of path unknown, exiting")
+
exec_cmd(install_cmd)
logger.debug('Prepare boot partition using rootfs in %s', hdddir)
Signature · 1 line
2.34.1
Quoted 65 lines · Sven Bachmann
Hi,
this patch allows to create directories inside the boot partition when using WIC. Without the patch the build process will abort with an error when a recipe tries to not only copy files but to also create a directory inside the boot partition.
Recipe content:
inherit deploy
do_deploy(){
install -d ${DEPLOYDIR}/${BOOTFILES_DIR_NAME}/mydirectory touch ${DEPLOYDIR}/${BOOTFILES_DIR_NAME}/mydirectory/${PN}-${PV}.stamp }
addtask deploy beforedo_buildafterdo_installdo_deploy[dirs] += "${DEPLOYDIR}/${BOOTFILES_DIR_NAME}/mydirectory"The task
do_image_wicwill then complain (paths reduced and anonymized):| ERROR:
_exec_cmd: install -m 0644 -D /my/home/dir/yocto/rpi-build/tmp/deploy/images/raspberrypi4/bootfiles/mydirectory /my/home/dir/yocot/rpi-build/tmp/work/raspberrypi4-poky-linux-gnueabi/my-image/1.0-r0/tmp-wic/boot.1/mydirectory returned '1' instead of 0
| output: install: omitting directory '/my/home/dir/yocto/rpi-build/tmp/deploy/images/raspberrypi4/bootfiles/mydirectory'As can be seen it uses "install -D" instead of creating the directory with "install -d". This patch fixes this.
Best regards
SvenFrom
360775581a573a62032155fc6968175125e9c1dbMon Sep 17 00:00:00 2001
From: Sven Bachmann <[email protected]>
Date: Tue, 25 Jan 2022 20:47:17 +0100
Subject: [PATCH 1/1] wic: bootimg-partition: add directory copy support to bootimage creationSigned-off-by Sven Bachmann <[email protected]>---
.../lib/wic/plugins/source/bootimg-partition.py | 14 +++++++++++---1 file changed, 11 insertions(+), 3 deletions(-)scripts/lib/wic/plugins/source/bootimg-partition.py +0
-0@@ -184,9 +184,17 @@ class BootimgPartitionPlugin(SourcePlugin):for task in cls.install_task:
src_path,dst_path= tasklogger.debug('Install %s as %s', src_path, dst_path)-install_cmd= "install -m 0644 -D %s %s" \
- % (os.path.join(kernel_dir, src_path), -os.path.join(hdddir, dst_path)) + ifos.path.isfile(src_path):
+install_cmd= "install -m 0644 -D %s %s" \
+ % (os.path.join(kernel_dir, src_path), +os.path.join(hdddir, dst_path)) + elif os.path.isdir:
+install_cmd= "install -m 0755 -d %s" \
Quoted 8 lines
+ % (
os.path.join(hdddir, dst_path))
+ else:
+logger.error("Path is neither file nor directory: %s", src_path)+ raiseWicError("Type of path unknown, exiting")
+
exec_cmd(install_cmd)
logger.debug('Prepare boot partition using rootfs in %s', hdddir)
I'm afraid the patch within the email has been line wrapped and even with that fixed, the whitespace is corrupted making it hard to apply. I do also wonder if there are extra tests we should be adding to the test suite to cover this issue (see "oe-selftest -r wic")?
Cheers,
Richard
Quoted 11 lines · Richard Purdie
Quoted 1 line · Sven Bachmann
[Defective Patch]
I'm afraid the patch within the email has been line wrapped and even with that fixed, the whitespace is corrupted making it hard to apply. I do also wonder if there are extra tests we should be adding to the test suite to cover this issue (see "oe-selftest -r wic")?
Cheers,
Richard
Hi Richard,
I'm very sorry about this. I thought I'd configured Thunderbird correctly. Before resubmitting I'll configure "git send-mail" and use this for sending. I'll also try to understand the selftest and add a test.
Bye
Sven