public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH 1/2] meta: image: detect broken symlinks
@ 2018-03-09  8:21 Henning Schild
  2018-03-09  8:21 ` [PATCH 2/2] scripts: return errors for CI Henning Schild
  2018-03-09  8:30 ` [PATCH 1/2] meta: image: detect broken symlinks Henning Schild
  0 siblings, 2 replies; 4+ messages in thread
From: Henning Schild @ 2018-03-09  8:21 UTC (permalink / raw)
  To: isar-users; +Cc: Henning Schild

Switch get_image_name from os.path.lexists to os.path.exists because the
latter detects broken symlinks correctly. Also support older debian
versions where the symlinks in the rootfs are absolute
Also change scripts/start_vm to handle the case where no initrd is
present.

Issue:
If you build a kernel without CONFIG_BLK_DEV_INITRD the postinst hook will
still call "linux-update-symlinks" and create a broken symlink. After
that os.path.lexists will return True and "sudo cp" in do_copy_boot_files
will fail.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 meta/classes/image.bbclass |  4 +++-
 scripts/start_vm           | 11 +++++++----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 2c255f4..6753aed 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -8,8 +8,10 @@ IMAGE_ROOTFS   = "${WORKDIR}/rootfs"
 def get_image_name(d, name_link):
     S = d.getVar("IMAGE_ROOTFS", True)
     path_link = os.path.join(S, name_link)
-    if os.path.lexists(path_link):
+    if os.path.exists(path_link):
         return os.path.basename(os.path.realpath(path_link))
+    if os.path.islink(path_link):
+        return os.path.basename(os.path.join(S, os.path.realpath(path_link)))
     return ""
 
 # These variables are used by wic and start_vm
diff --git a/scripts/start_vm b/scripts/start_vm
index b7b5e17..0d1d554 100755
--- a/scripts/start_vm
+++ b/scripts/start_vm
@@ -25,8 +25,8 @@ qemu-system-$QEMU_ARCH \\\\\n\
     -M $QEMU_MACHINE \\\\\n\
     $QCPU\\\\\n\
     -nographic \\\\\n\
-    -kernel \$IMAGE_DIR/$KERNEL_IMAGE \\\\\n\
-    -initrd \$IMAGE_DIR/$INITRD_IMAGE \\\\\n\
+    -kernel \$QKERNEL \\\\\n\
+    -initrd \$QINITRD \\\\\n\
     -append \"console=$MACHINE_SERIAL root=/dev/$ROOTFS_DEV rw\" \\\\\n\
     $EXTRA_ARGS \\\\\n\
     $root1"
@@ -38,8 +38,8 @@ qemu-system-$QEMU_ARCH \\\\\n\
 	-M $QEMU_MACHINE \
 	$QCPU \
 	-nographic \
-	-kernel $IMAGE_DIR/$KERNEL_IMAGE \
-	-initrd $IMAGE_DIR/$INITRD_IMAGE \
+	-kernel $QKERNEL \
+	-initrd $QINITRD \
 	-append "console=$MACHINE_SERIAL root=/dev/$ROOTFS_DEV rw" \
 	$EXTRA_ARGS \
 	$root2
@@ -118,6 +118,9 @@ readonly ROOTFS_IMAGE=isar-image-base-debian-$DISTRO-qemu$ARCH.ext4.img
 
 eval $(bitbake -e multiconfig:qemu$ARCH-$DISTRO:isar-image-base | grep "^KERNEL_IMAGE=")
 eval $(bitbake -e multiconfig:qemu$ARCH-$DISTRO:isar-image-base | grep "^INITRD_IMAGE=")
+QKERNEL=$IMAGE_DIR/$KERNEL_IMAGE
+QINITRD=/dev/null
+[ -n "$INITRD_IMAGE" ] && QINITRD=$IMAGE_DIR/$INITRD_IMAGE
 
 readonly ISARROOT="$(dirname "$0")"/..
 
-- 
2.16.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-09  8:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-09  8:21 [PATCH 1/2] meta: image: detect broken symlinks Henning Schild
2018-03-09  8:21 ` [PATCH 2/2] scripts: return errors for CI Henning Schild
2018-03-09  8:30   ` Henning Schild
2018-03-09  8:30 ` [PATCH 1/2] meta: image: detect broken symlinks Henning Schild

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox