Skip to contentSkip to conversation

image_types.bbclass: Don't try to create ubi symlink twice

PATCH New Mike Looijmans 1 participant 1 message Sep 15, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 image_types.bbclass: Don't try to create ubi symlink twice

Fixes b6e64de541b37 "Restore compatibility with previous UBI filesystems"

The multivolume UBI code creates symlinks for each volume. If the volume name is empty, it will create a symlink that the rootfs code will attempt to create again later, resulting in a crash like this (unless IMAGE_LINK_NAME is blank):
ERROR: Error executing a python function in .../recipes-core/images/my-image.bb:
File: '.../oe-core/meta/lib/oe/image.py', lineno: 203, function: _create_symlinks
*** 0203: os.symlink(src, dst)
Exception: OSError: [Errno 17] File exists

To prevent this from happening, only create symlinks to volumes that have a name, and let the rootfs script create the default symlink later.

---
 meta/classes/image_types.bbclass | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
meta/classes/image_types.bbclass +12 -10
index 306403e..afa2e8e 100644
@@ -139,17 +139,19 @@ multiubi_mkfs() {
 	# Cleanup cfg file
 	mv ubinize${vname}.cfg ${DEPLOY_DIR_IMAGE}/
 
-	# Create own symlink
-	cd ${DEPLOY_DIR_IMAGE}
-	if [ -e ${IMAGE_NAME}${vname}.rootfs.ubifs ]; then
-		ln -sf ${IMAGE_NAME}${vname}.rootfs.ubifs \
-		${IMAGE_LINK_NAME}${vname}.ubifs
-	fi
-	if [ -e ${IMAGE_NAME}${vname}.rootfs.ubi ]; then
-		ln -sf ${IMAGE_NAME}${vname}.rootfs.ubi \
-		${IMAGE_LINK_NAME}${vname}.ubi
+	# Create own symlinks for 'named' volumes
+	if [ -n "$vname" ]; then
+		cd ${DEPLOY_DIR_IMAGE}
+		if [ -e ${IMAGE_NAME}${vname}.rootfs.ubifs ]; then
+			ln -sf ${IMAGE_NAME}${vname}.rootfs.ubifs \
+			${IMAGE_LINK_NAME}${vname}.ubifs
+		fi
+		if [ -e ${IMAGE_NAME}${vname}.rootfs.ubi ]; then
+			ln -sf ${IMAGE_NAME}${vname}.rootfs.ubi \
+			${IMAGE_LINK_NAME}${vname}.ubi
+		fi
+		cd -
 	fi
-	cd -
 }
 
 IMAGE_CMD_multiubi () {
Signature · 1 line
1.9.1