* [PATCH] meta: image: detect broken symlinks @ 2018-02-27 17:23 Henning Schild 2018-03-02 12:20 ` Jan Kiszka ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: Henning Schild @ 2018-02-27 17:23 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. 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index 2c255f4..46d3560 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass @@ -8,7 +8,7 @@ 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)) return "" -- 2.16.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] meta: image: detect broken symlinks 2018-02-27 17:23 [PATCH] meta: image: detect broken symlinks Henning Schild @ 2018-03-02 12:20 ` Jan Kiszka 2018-03-02 16:30 ` Alexander Smirnov 2018-03-09 15:26 ` [PATCH v3] " Henning Schild 2 siblings, 0 replies; 9+ messages in thread From: Jan Kiszka @ 2018-03-02 12:20 UTC (permalink / raw) To: [ext] Henning Schild, isar-users On 2018-02-27 18:23, [ext] Henning Schild wrote: > Switch get_image_name from os.path.lexists to os.path.exists because the > latter detects broken symlinks correctly. > > 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 | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass > index 2c255f4..46d3560 100644 > --- a/meta/classes/image.bbclass > +++ b/meta/classes/image.bbclass > @@ -8,7 +8,7 @@ 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)) > return "" > Makes sense. Wondering if the original commit didn't already want to do this, just accidentally picked the wrong function. Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] meta: image: detect broken symlinks 2018-02-27 17:23 [PATCH] meta: image: detect broken symlinks Henning Schild 2018-03-02 12:20 ` Jan Kiszka @ 2018-03-02 16:30 ` Alexander Smirnov 2018-03-04 19:28 ` Alexander Smirnov 2018-03-09 15:26 ` [PATCH v3] " Henning Schild 2 siblings, 1 reply; 9+ messages in thread From: Alexander Smirnov @ 2018-03-02 16:30 UTC (permalink / raw) To: Henning Schild, isar-users On 02/27/2018 08:23 PM, Henning Schild wrote: > Switch get_image_name from os.path.lexists to os.path.exists because the > latter detects broken symlinks correctly. > > 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. > Applied, thanks. P.S.: fixed to upper case after semicolon in patch topic. Alex ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] meta: image: detect broken symlinks 2018-03-02 16:30 ` Alexander Smirnov @ 2018-03-04 19:28 ` Alexander Smirnov 2018-03-04 19:49 ` Jan Kiszka 2018-03-05 18:49 ` Henning Schild 0 siblings, 2 replies; 9+ messages in thread From: Alexander Smirnov @ 2018-03-04 19:28 UTC (permalink / raw) To: isar-users On 03/02/2018 07:30 PM, Alexander Smirnov wrote: > On 02/27/2018 08:23 PM, Henning Schild wrote: >> Switch get_image_name from os.path.lexists to os.path.exists because the >> latter detects broken symlinks correctly. >> >> 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. >> > > Applied, thanks. > > P.S.: fixed to upper case after semicolon in patch topic. Dropped from the next branch. The patch breaks 'start_vm' script, $INITRD_IMAGE variable is no more valid with it. Alex ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] meta: image: detect broken symlinks 2018-03-04 19:28 ` Alexander Smirnov @ 2018-03-04 19:49 ` Jan Kiszka 2018-03-05 18:49 ` Henning Schild 1 sibling, 0 replies; 9+ messages in thread From: Jan Kiszka @ 2018-03-04 19:49 UTC (permalink / raw) To: Alexander Smirnov, isar-users On 2018-03-04 20:28, Alexander Smirnov wrote: > On 03/02/2018 07:30 PM, Alexander Smirnov wrote: >> On 02/27/2018 08:23 PM, Henning Schild wrote: >>> Switch get_image_name from os.path.lexists to os.path.exists because the >>> latter detects broken symlinks correctly. >>> >>> 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. >>> >> >> Applied, thanks. >> >> P.S.: fixed to upper case after semicolon in patch topic. > > Dropped from the next branch. The patch breaks 'start_vm' script, > $INITRD_IMAGE variable is no more valid with it. That smells fishy. Maybe the broken link test is papering over another issue. Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] meta: image: detect broken symlinks 2018-03-04 19:28 ` Alexander Smirnov 2018-03-04 19:49 ` Jan Kiszka @ 2018-03-05 18:49 ` Henning Schild 1 sibling, 0 replies; 9+ messages in thread From: Henning Schild @ 2018-03-05 18:49 UTC (permalink / raw) To: Alexander Smirnov; +Cc: isar-users Am Sun, 4 Mar 2018 22:28:36 +0300 schrieb Alexander Smirnov <asmirnov@ilbers.de>: > On 03/02/2018 07:30 PM, Alexander Smirnov wrote: > > On 02/27/2018 08:23 PM, Henning Schild wrote: > >> Switch get_image_name from os.path.lexists to os.path.exists > >> because the latter detects broken symlinks correctly. > >> > >> 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. > >> > > > > Applied, thanks. > > > > P.S.: fixed to upper case after semicolon in patch topic. > > Dropped from the next branch. The patch breaks 'start_vm' script, > $INITRD_IMAGE variable is no more valid with it. Ok, that is a bug in the script since it can not handle the valid case that the variable is not set. Anyways, i updated the script along with my patch and your jenkins is currently testing that. Will send an updated version of that patch soon. Henning > Alex > ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3] meta: image: detect broken symlinks 2018-02-27 17:23 [PATCH] meta: image: detect broken symlinks Henning Schild 2018-03-02 12:20 ` Jan Kiszka 2018-03-02 16:30 ` Alexander Smirnov @ 2018-03-09 15:26 ` Henning Schild 2018-03-20 13:42 ` Henning Schild 2 siblings, 1 reply; 9+ messages in thread From: Henning Schild @ 2018-03-09 15:26 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 | 5 ++++- scripts/start_vm | 11 +++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index 2c255f4..6a705fc 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass @@ -8,8 +8,11 @@ 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 get_image_name(d, os.path.relpath(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] 9+ messages in thread
* Re: [PATCH v3] meta: image: detect broken symlinks 2018-03-09 15:26 ` [PATCH v3] " Henning Schild @ 2018-03-20 13:42 ` Henning Schild 2018-03-27 13:50 ` Alexander Smirnov 0 siblings, 1 reply; 9+ messages in thread From: Henning Schild @ 2018-03-20 13:42 UTC (permalink / raw) To: isar-users, Alexander Smirnov ping Am Fri, 9 Mar 2018 16:26:01 +0100 schrieb Henning Schild <henning.schild@siemens.com>: > 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 | 5 ++++- > scripts/start_vm | 11 +++++++---- > 2 files changed, 11 insertions(+), 5 deletions(-) > > diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass > index 2c255f4..6a705fc 100644 > --- a/meta/classes/image.bbclass > +++ b/meta/classes/image.bbclass > @@ -8,8 +8,11 @@ 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 get_image_name(d, > os.path.relpath(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")"/.. > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] meta: image: detect broken symlinks 2018-03-20 13:42 ` Henning Schild @ 2018-03-27 13:50 ` Alexander Smirnov 0 siblings, 0 replies; 9+ messages in thread From: Alexander Smirnov @ 2018-03-27 13:50 UTC (permalink / raw) To: Henning Schild, isar-users Hi, On 03/20/2018 04:42 PM, Henning Schild wrote: > ping Applied to next, thanks! Alex > > Am Fri, 9 Mar 2018 16:26:01 +0100 > schrieb Henning Schild <henning.schild@siemens.com>: > >> 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 | 5 ++++- >> scripts/start_vm | 11 +++++++---- >> 2 files changed, 11 insertions(+), 5 deletions(-) >> >> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass >> index 2c255f4..6a705fc 100644 >> --- a/meta/classes/image.bbclass >> +++ b/meta/classes/image.bbclass >> @@ -8,8 +8,11 @@ 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 get_image_name(d, >> os.path.relpath(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")"/.. >> > -- With best regards, Alexander Smirnov ilbers GmbH Baierbrunner Str. 28c D-81379 Munich +49 (89) 122 67 24-0 http://ilbers.de/ Commercial register Munich, HRB 214197 General manager: Baurzhan Ismagulov ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-03-27 13:50 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-02-27 17:23 [PATCH] meta: image: detect broken symlinks Henning Schild 2018-03-02 12:20 ` Jan Kiszka 2018-03-02 16:30 ` Alexander Smirnov 2018-03-04 19:28 ` Alexander Smirnov 2018-03-04 19:49 ` Jan Kiszka 2018-03-05 18:49 ` Henning Schild 2018-03-09 15:26 ` [PATCH v3] " Henning Schild 2018-03-20 13:42 ` Henning Schild 2018-03-27 13:50 ` Alexander Smirnov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox