Skip to contentSkip to conversation

classes/kernel: fix symlink creation in DEPLOYDIR for bundled initramfs

PATCH New André Draszik 1 participant 3 messages Jun 24, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 classes/kernel: fix symlink creation in DEPLOYDIR for bundled initramfs

From: André Draszik <[email protected]>

If multiple kernel image types have been specified, only the very first one would receive a symlink in DEPLOYDIR.

The reason is that we're looping over the list of image types and check if a bundled initramfs images exists using a relative path. As part of the loop we're changing the current directory, hence all additional iterations fail to see the files we're looking for, and hence no symlinks are being created.

Fix by not changing the directory and adjusting the ln invocation instead.

---
 meta/classes/kernel.bbclass | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
meta/classes/kernel.bbclass +1 -2
index 59bbbe8..3127590 100644
@@ -586,8 +586,7 @@ kernel_do_deploy() {
 			initramfs_base_name=${type}-${INITRAMFS_BASE_NAME}
 			initramfs_symlink_name=${type}-initramfs-${MACHINE}
 			install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs ${DEPLOYDIR}/${initramfs_base_name}.bin
-			cd ${DEPLOYDIR}
-			ln -sf ${initramfs_base_name}.bin ${initramfs_symlink_name}.bin
+			ln -sf ${initramfs_base_name}.bin ${DEPLOYDIR}/${initramfs_symlink_name}.bin
 		fi
 	done
 }
Signature · 1 line
2.8.1
#1 lore raw

PATCH 2/2 classes/kernel: fix symlink logic when bundling initramfs images

From: André Draszik <[email protected]>

If linkpath points to the a file in KERNEL_OUTPUT_DIR, rather than outside, then symlink creation for the bundled initramfs image files fails.

This is because in that case $linkpath.initramfs and $realpath.initramfs are in the same directory, KERNEL_OUTPUT_DIR, and hence are the same. Since we just created $realpath.initramfs, creating a symlink with the same name will fail.

Given that $linkpath is not necessarily the same as the kernel image type, just removing this symlink creation is not the right thing to do, as in that case kernel_do_deploy() wouldn't find the bundled file.

What we really want is a symlink from the name of the initramfs-bundled kernel image type to the real initramfs-bundled kernel image, as that is what is actually used later in do_deploy().

This brings the code path for when $KERNEL_OUTPUT_DIR/$type is a symlink in line with when it is not.

---
 meta/classes/kernel.bbclass | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
meta/classes/kernel.bbclass +1 -2
index 3127590..c6d06b5 100644
@@ -232,8 +232,7 @@ do_bundle_initramfs () {
 			if [ -n "$realpath" ]; then
 				mv -f $realpath $realpath.initramfs
 				mv -f $realpath.bak $realpath
-				cd ${B}/${KERNEL_OUTPUT_DIR}
-				ln -sf $linkpath.initramfs
+				ln -s $linkpath.initramfs ${B}/${KERNEL_OUTPUT_DIR}/$type.initramfs
 			else
 				mv -f ${KERNEL_OUTPUT_DIR}/$type ${KERNEL_OUTPUT_DIR}/$type.initramfs
 				mv -f ${KERNEL_OUTPUT_DIR}/$type.bak ${KERNEL_OUTPUT_DIR}/$type
Signature · 1 line
2.8.1
#2 lore raw

PATCH v2 1/1 classes/kernel: fix symlink logic when bundling initramfs images

From: André Draszik <[email protected]>

If linkpath points to the a file in KERNEL_OUTPUT_DIR, rather than outside, then symlink creation for the bundled initramfs image files fails.

This is because in that case $linkpath.initramfs and $realpath.initramfs are in the same directory, KERNEL_OUTPUT_DIR, and hence are the same. Since we just created $realpath.initramfs, creating a symlink with the same name will fail.

Given that $linkpath is not necessarily the same as the kernel image type, just removing this symlink creation is not the right thing to do, as in that case kernel_do_deploy() wouldn't find the bundled file.

What we really want is a symlink from the name of the initramfs-bundled kernel image type to the real initramfs-bundled kernel image, as that is what is actually used later in do_deploy().

This brings the code path for when $KERNEL_OUTPUT_DIR/$type is a symlink in line with when it is not.

---
 meta/classes/kernel.bbclass | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
meta/classes/kernel.bbclass +1 -2
index 3127590..a56b66b 100644
@@ -232,8 +232,7 @@ do_bundle_initramfs () {
 			if [ -n "$realpath" ]; then
 				mv -f $realpath $realpath.initramfs
 				mv -f $realpath.bak $realpath
-				cd ${B}/${KERNEL_OUTPUT_DIR}
-				ln -sf $linkpath.initramfs
+				ln -sf $linkpath.initramfs ${B}/${KERNEL_OUTPUT_DIR}/$type.initramfs
 			else
 				mv -f ${KERNEL_OUTPUT_DIR}/$type ${KERNEL_OUTPUT_DIR}/$type.initramfs
 				mv -f ${KERNEL_OUTPUT_DIR}/$type.bak ${KERNEL_OUTPUT_DIR}/$type
Signature · 1 line
2.8.1