* [PATCH] meta/classes: Make sure the files exists before copying
@ 2019-11-08 11:41 vijaikumar.kanagarajan
2019-11-08 17:10 ` Henning Schild
0 siblings, 1 reply; 7+ messages in thread
From: vijaikumar.kanagarajan @ 2019-11-08 11:41 UTC (permalink / raw)
To: isar-users; +Cc: Vijai Kumar K
From: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
By default realpath doesnot check if the file exists and hence
might return an invalid path. Use -e to check if the file actually
exists.
Signed-off-by: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
---
meta/classes/image.bbclass | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 8384b71..5b2eee0 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -128,12 +128,12 @@ EOF
do_copy_boot_files[dirs] = "${DEPLOY_DIR_IMAGE}"
do_copy_boot_files() {
- kernel="$(realpath -q '${IMAGE_ROOTFS}/${KERNEL_FILE}')"
+ kernel="$(realpath -eq '${IMAGE_ROOTFS}/${KERNEL_FILE}')"
if [ -n "$kernel" ]; then
cp -f "$kernel" '${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}'
fi
- initrd="$(realpath -q '${IMAGE_ROOTFS}/initrd.img')"
+ initrd="$(realpath -eq '${IMAGE_ROOTFS}/initrd.img')"
if [ -n "$initrd" ]; then
cp -f "$initrd" '${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}'
fi
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] meta/classes: Make sure the files exists before copying
2019-11-08 11:41 [PATCH] meta/classes: Make sure the files exists before copying vijaikumar.kanagarajan
@ 2019-11-08 17:10 ` Henning Schild
2019-11-08 17:41 ` Vijai Kumar K
0 siblings, 1 reply; 7+ messages in thread
From: Henning Schild @ 2019-11-08 17:10 UTC (permalink / raw)
To: vijaikumar.kanagarajan; +Cc: isar-users, Vijai Kumar K
Am Fri, 8 Nov 2019 17:11:58 +0530
schrieb <vijaikumar.kanagarajan@gmail.com>:
> From: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
>
> By default realpath doesnot check if the file exists and hence
> might return an invalid path. Use -e to check if the file actually
> exists.
>
> Signed-off-by: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
> ---
> meta/classes/image.bbclass | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 8384b71..5b2eee0 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -128,12 +128,12 @@ EOF
>
> do_copy_boot_files[dirs] = "${DEPLOY_DIR_IMAGE}"
> do_copy_boot_files() {
> - kernel="$(realpath -q '${IMAGE_ROOTFS}/${KERNEL_FILE}')"
> + kernel="$(realpath -eq '${IMAGE_ROOTFS}/${KERNEL_FILE}')"
> if [ -n "$kernel" ]; then
> cp -f "$kernel" '${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}'
> fi
>
> - initrd="$(realpath -q '${IMAGE_ROOTFS}/initrd.img')"
> + initrd="$(realpath -eq '${IMAGE_ROOTFS}/initrd.img')"
> if [ -n "$initrd" ]; then
> cp -f "$initrd" '${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}'
> fi
I would rather convert the "-n" checks into "-f". It is the same but i
think more readable. People are more likely to know test -f than
realpath -q ... i guess.
Henning
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] meta/classes: Make sure the files exists before copying
2019-11-08 17:10 ` Henning Schild
@ 2019-11-08 17:41 ` Vijai Kumar K
2019-11-08 17:47 ` [PATCH v2] " vijaikumar.kanagarajan
0 siblings, 1 reply; 7+ messages in thread
From: Vijai Kumar K @ 2019-11-08 17:41 UTC (permalink / raw)
To: Henning Schild; +Cc: vijaikumar.kanagarajan, isar-users
On Fri, Nov 08, 2019 at 06:10:55PM +0100, Henning Schild wrote:
> Am Fri, 8 Nov 2019 17:11:58 +0530
> schrieb <vijaikumar.kanagarajan@gmail.com>:
>
> > From: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
> >
> > By default realpath doesnot check if the file exists and hence
> > might return an invalid path. Use -e to check if the file actually
> > exists.
> >
> > Signed-off-by: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
> > ---
> > meta/classes/image.bbclass | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> > index 8384b71..5b2eee0 100644
> > --- a/meta/classes/image.bbclass
> > +++ b/meta/classes/image.bbclass
> > @@ -128,12 +128,12 @@ EOF
> >
> > do_copy_boot_files[dirs] = "${DEPLOY_DIR_IMAGE}"
> > do_copy_boot_files() {
> > - kernel="$(realpath -q '${IMAGE_ROOTFS}/${KERNEL_FILE}')"
> > + kernel="$(realpath -eq '${IMAGE_ROOTFS}/${KERNEL_FILE}')"
> > if [ -n "$kernel" ]; then
> > cp -f "$kernel" '${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}'
> > fi
> >
> > - initrd="$(realpath -q '${IMAGE_ROOTFS}/initrd.img')"
> > + initrd="$(realpath -eq '${IMAGE_ROOTFS}/initrd.img')"
> > if [ -n "$initrd" ]; then
> > cp -f "$initrd" '${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}'
> > fi
>
> I would rather convert the "-n" checks into "-f". It is the same but i
> think more readable. People are more likely to know test -f than
> realpath -q ... i guess.
I had that dilemma. Decided to go with -e since realpath had that
provision. We could use -f as well, if that makes code more readable.
Will send a v2.
Thanks,
Vijai Kumar K
>
> Henning
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] meta/classes: Make sure the files exists before copying
2019-11-08 17:41 ` Vijai Kumar K
@ 2019-11-08 17:47 ` vijaikumar.kanagarajan
2019-12-03 5:33 ` vijai kumar
2019-12-05 12:55 ` Baurzhan Ismagulov
0 siblings, 2 replies; 7+ messages in thread
From: vijaikumar.kanagarajan @ 2019-11-08 17:47 UTC (permalink / raw)
To: isar-users, henning.schild; +Cc: Vijai Kumar K
From: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
By default realpath doesnot check if the file exists and hence
might return an invalid path.
Check if file exists before copying.
Signed-off-by: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
---
Changes in v2:
- Use -f in if condition instead of realpath -e to make code
more readable.
meta/classes/image.bbclass | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 8384b71..c845eab 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -129,12 +129,12 @@ EOF
do_copy_boot_files[dirs] = "${DEPLOY_DIR_IMAGE}"
do_copy_boot_files() {
kernel="$(realpath -q '${IMAGE_ROOTFS}/${KERNEL_FILE}')"
- if [ -n "$kernel" ]; then
+ if [ -f "$kernel" ]; then
cp -f "$kernel" '${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}'
fi
initrd="$(realpath -q '${IMAGE_ROOTFS}/initrd.img')"
- if [ -n "$initrd" ]; then
+ if [ -f "$initrd" ]; then
cp -f "$initrd" '${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}'
fi
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] meta/classes: Make sure the files exists before copying
2019-11-08 17:47 ` [PATCH v2] " vijaikumar.kanagarajan
@ 2019-12-03 5:33 ` vijai kumar
2019-12-05 9:36 ` Henning Schild
2019-12-05 12:55 ` Baurzhan Ismagulov
1 sibling, 1 reply; 7+ messages in thread
From: vijai kumar @ 2019-12-03 5:33 UTC (permalink / raw)
To: isar-users
[-- Attachment #1.1: Type: text/plain, Size: 1335 bytes --]
Can this be merged to next??
Thanks,
Vijai Kumar K
On Friday, November 8, 2019 at 11:17:45 PM UTC+5:30, vijai kumar wrote:
>
> From: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
>
> By default realpath doesnot check if the file exists and hence
> might return an invalid path.
>
> Check if file exists before copying.
>
> Signed-off-by: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
> ---
> Changes in v2:
> - Use -f in if condition instead of realpath -e to make code
> more readable.
>
> meta/classes/image.bbclass | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 8384b71..c845eab 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -129,12 +129,12 @@ EOF
> do_copy_boot_files[dirs] = "${DEPLOY_DIR_IMAGE}"
> do_copy_boot_files() {
> kernel="$(realpath -q '${IMAGE_ROOTFS}/${KERNEL_FILE}')"
> - if [ -n "$kernel" ]; then
> + if [ -f "$kernel" ]; then
> cp -f "$kernel" '${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}'
> fi
>
> initrd="$(realpath -q '${IMAGE_ROOTFS}/initrd.img')"
> - if [ -n "$initrd" ]; then
> + if [ -f "$initrd" ]; then
> cp -f "$initrd" '${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}'
> fi
>
> --
> 2.17.1
>
>
[-- Attachment #1.2: Type: text/html, Size: 2334 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] meta/classes: Make sure the files exists before copying
2019-12-03 5:33 ` vijai kumar
@ 2019-12-05 9:36 ` Henning Schild
0 siblings, 0 replies; 7+ messages in thread
From: Henning Schild @ 2019-12-05 9:36 UTC (permalink / raw)
To: vijai kumar; +Cc: isar-users
i would say so
Henning
On Mon, 2 Dec 2019 21:33:11 -0800
vijai kumar <vijaikumar.kanagarajan@gmail.com> wrote:
> Can this be merged to next??
>
> Thanks,
> Vijai Kumar K
>
> On Friday, November 8, 2019 at 11:17:45 PM UTC+5:30, vijai kumar
> wrote:
> >
> > From: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
> >
> > By default realpath doesnot check if the file exists and hence
> > might return an invalid path.
> >
> > Check if file exists before copying.
> >
> > Signed-off-by: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
> > ---
> > Changes in v2:
> > - Use -f in if condition instead of realpath -e to make code
> > more readable.
> >
> > meta/classes/image.bbclass | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/meta/classes/image.bbclass
> > b/meta/classes/image.bbclass index 8384b71..c845eab 100644
> > --- a/meta/classes/image.bbclass
> > +++ b/meta/classes/image.bbclass
> > @@ -129,12 +129,12 @@ EOF
> > do_copy_boot_files[dirs] = "${DEPLOY_DIR_IMAGE}"
> > do_copy_boot_files() {
> > kernel="$(realpath -q '${IMAGE_ROOTFS}/${KERNEL_FILE}')"
> > - if [ -n "$kernel" ]; then
> > + if [ -f "$kernel" ]; then
> > cp -f "$kernel" '${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}'
> > fi
> >
> > initrd="$(realpath -q '${IMAGE_ROOTFS}/initrd.img')"
> > - if [ -n "$initrd" ]; then
> > + if [ -f "$initrd" ]; then
> > cp -f "$initrd" '${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}'
> > fi
> >
> > --
> > 2.17.1
> >
> >
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] meta/classes: Make sure the files exists before copying
2019-11-08 17:47 ` [PATCH v2] " vijaikumar.kanagarajan
2019-12-03 5:33 ` vijai kumar
@ 2019-12-05 12:55 ` Baurzhan Ismagulov
1 sibling, 0 replies; 7+ messages in thread
From: Baurzhan Ismagulov @ 2019-12-05 12:55 UTC (permalink / raw)
To: isar-users
On Fri, Nov 08, 2019 at 11:17:35PM +0530, vijaikumar.kanagarajan@gmail.com wrote:
> By default realpath doesnot check if the file exists and hence
> might return an invalid path.
>
> Check if file exists before copying.
Applied to next, thanks.
With kind regards,
Baurzhan.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-12-05 12:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-08 11:41 [PATCH] meta/classes: Make sure the files exists before copying vijaikumar.kanagarajan
2019-11-08 17:10 ` Henning Schild
2019-11-08 17:41 ` Vijai Kumar K
2019-11-08 17:47 ` [PATCH v2] " vijaikumar.kanagarajan
2019-12-03 5:33 ` vijai kumar
2019-12-05 9:36 ` Henning Schild
2019-12-05 12:55 ` Baurzhan Ismagulov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox