Skip to contentSkip to conversation

qemuboot: don't fail when QB_DEFAULT_KERNEL isn't symlink

PATCH In review Martin Jansa 2 participants 4 messages Sep 28, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemuboot: don't fail when QB_DEFAULT_KERNEL isn't symlink

* in some cases we might set QB_DEFAULT_KERNEL to the real filename instead of symlink and then this whole readlink work around actually breaks the build, because os.readlink fails on normal files:

Quoted 1 line
Quoted 1 line
Quoted 1 line

os.readlink('deploy/images/qemux86/bzImage-linux-yocto-qemux86-master-20160927084848.bin')

'bzImage-linux-yocto-qemux86.bin'

Quoted 1 line
Quoted 1 line
Quoted 1 line

os.readlink('deploy/images/qemux86/bzImage-linux-yocto-qemux86.bin')

Traceback (most recent call last):

    File "<stdin>", line 1, in <module>

OSError: [Errno 22] Invalid argument: '/jenkins/mjansa/build-starfish-master-mcf/BUILD/deploy/images/qemux86/bzImage-linux-yocto-qemux86.bin'

---
 meta/classes/qemuboot.bbclass | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meta/classes/qemuboot.bbclass +5 -1
index 97a2357..a3a05ba 100644
@@ -69,7 +69,11 @@ python write_qemuboot_conf() {
     # to the kernel file, which hinders relocatability of the qb conf.
     # Read the link and replace it with the full filename of the target.
     kernel_link = os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), d.getVar('QB_DEFAULT_KERNEL', True))
-    kernel = os.readlink(kernel_link)
+    try:
+        kernel = os.readlink(kernel_link)
+    except OSError as e:
+        # we assume it failed, because QB_DEFAULT_KERNEL is already real file or hardlink, not symlink
+        kernel = kernel_link
     cf.set('config_bsp', 'QB_DEFAULT_KERNEL', kernel)
 
     bb.utils.mkdirhier(os.path.dirname(qemuboot))
Signature · 1 line
2.10.0
#1 lore raw
Quoted 21 lines · Martin Jansa

* in some cases we might set QB_DEFAULT_KERNEL to the real filename instead of symlink and then this whole readlink work around actually breaks the build, because os.readlink fails on normal files:

Quoted 1 line
Quoted 1 line
Quoted 1 line

os.readlink('deploy/images/qemux86/bzImage-linux-yocto-qemux86-master-20160927084848.bin')

'bzImage-linux-yocto-qemux86.bin'

Quoted 1 line
Quoted 1 line
Quoted 1 line

os.readlink('deploy/images/qemux86/bzImage-linux-yocto-qemux86.bin')

Traceback (most recent call last):

    File "<stdin>", line 1, in <module>

OSError: [Errno 22] Invalid argument: '/jenkins/mjansa/build-starfish-master-mcf/BUILD/deploy/images/qemux86/bzImage-linux-yocto-qemux86.bin'

---
 meta/classes/qemuboot.bbclass | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meta/classes/qemuboot.bbclass +0 -0
index 97a2357..a3a05ba 100644

meta/classes/qemuboot.bbclass python write_qemuboot_conf() { · line 72

Quoted 4 lines
meta/classes/qemuboot.bbclass +0 -1
@@ -69,7 +69,11 @@ python write_qemuboot_conf() {
     # to the kernel file, which hinders relocatability of the qb conf.
     # Read the link and replace it with the full filename of the target.
     kernel_link = os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), d.getVar('QB_DEFAULT_KERNEL', True))
-    kernel = os.readlink(kernel_link)

os.path.realpath(kernel_link) should work for regular file or symlink.

// Robert

Quoted 9 lines
meta/classes/qemuboot.bbclass +5 -0
+    try:
+        kernel = os.readlink(kernel_link)
+    except OSError as e:
+        # we assume it failed, because QB_DEFAULT_KERNEL is already real file or hardlink, not symlink
+        kernel = kernel_link
     cf.set('config_bsp', 'QB_DEFAULT_KERNEL', kernel)
 
     bb.utils.mkdirhier(os.path.dirname(qemuboot))
#2 lore raw

PATCH 1/1 qemuboot: don't fail when QB_DEFAULT_KERNEL isn't symlink

* in some cases we might set QB_DEFAULT_KERNEL to the real filename instead of symlink and then this whole readlink work around actually breaks the build, because os.readlink fails on normal files:

Quoted 1 line
Quoted 1 line
Quoted 1 line

os.readlink('deploy/images/qemux86/bzImage-linux-yocto-qemux86-master-20160927084848.bin')

'bzImage-linux-yocto-qemux86.bin'

Quoted 1 line
Quoted 1 line
Quoted 1 line

os.readlink('deploy/images/qemux86/bzImage-linux-yocto-qemux86.bin')

Traceback (most recent call last):

    File "<stdin>", line 1, in <module>

OSError: [Errno 22] Invalid argument: '/jenkins/mjansa/build-starfish-master-mcf/BUILD/deploy/images/qemux86/bzImage-linux-yocto-qemux86.bin'

---
 meta/classes/qemuboot.bbclass | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meta/classes/qemuboot.bbclass +5 -1
index 97a2357..a3a05ba 100644
@@ -69,7 +69,11 @@ python write_qemuboot_conf() {
     # to the kernel file, which hinders relocatability of the qb conf.
     # Read the link and replace it with the full filename of the target.
     kernel_link = os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), d.getVar('QB_DEFAULT_KERNEL', True))
-    kernel = os.readlink(kernel_link)
+    try:
+        kernel = os.readlink(kernel_link)
+    except OSError as e:
+        # we assume it failed, because QB_DEFAULT_KERNEL is already real file or hardlink, not symlink
+        kernel = kernel_link
     cf.set('config_bsp', 'QB_DEFAULT_KERNEL', kernel)
 
     bb.utils.mkdirhier(os.path.dirname(qemuboot))
Signature · 1 line
2.10.0
#3 lore raw

PATCH v2 1/1 qemuboot: don't fail when QB_DEFAULT_KERNEL isn't symlink

In reply to Robert Yang

* in some cases we might set QB_DEFAULT_KERNEL to the real filename instead of symlink and then this whole readlink work around actually breaks the build, because os.readlink fails on normal files:

Quoted 1 line
Quoted 1 line
Quoted 1 line

os.readlink('deploy/images/qemux86/bzImage-linux-yocto-qemux86-master-20160927084848.bin')

'bzImage-linux-yocto-qemux86.bin'

Quoted 1 line
Quoted 1 line
Quoted 1 line

os.readlink('deploy/images/qemux86/bzImage-linux-yocto-qemux86.bin')

Traceback (most recent call last):

    File "<stdin>", line 1, in <module>

OSError: [Errno 22] Invalid argument: '/jenkins/mjansa/build-starfish-master-mcf/BUILD/deploy/images/qemux86/bzImage-linux-yocto-qemux86.bin'

---
 meta/classes/qemuboot.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/qemuboot.bbclass +1 -1
index 97a2357..ef9a128 100644
@@ -69,7 +69,7 @@ python write_qemuboot_conf() {
     # to the kernel file, which hinders relocatability of the qb conf.
     # Read the link and replace it with the full filename of the target.
     kernel_link = os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), d.getVar('QB_DEFAULT_KERNEL', True))
-    kernel = os.readlink(kernel_link)
+    kernel = os.path.realpath(kernel_link)
     cf.set('config_bsp', 'QB_DEFAULT_KERNEL', kernel)
 
     bb.utils.mkdirhier(os.path.dirname(qemuboot))
Signature · 1 line
2.10.0