public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: vijaikumar.kanagarajan@gmail.com
To: isar-users@googlegroups.com, henning.schild@siemens.com
Cc: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
Subject: [PATCH v2] meta/classes: Make sure the files exists before copying
Date: Fri,  8 Nov 2019 23:17:35 +0530	[thread overview]
Message-ID: <20191108174735.9998-1-Vijaikumar_Kangarajan@mentor.com> (raw)
In-Reply-To: <20191108174148.GA9643@oxygen>

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


  reply	other threads:[~2019-11-08 17:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-08 11:41 [PATCH] " vijaikumar.kanagarajan
2019-11-08 17:10 ` Henning Schild
2019-11-08 17:41   ` Vijai Kumar K
2019-11-08 17:47     ` vijaikumar.kanagarajan [this message]
2019-12-03  5:33       ` [PATCH v2] " vijai kumar
2019-12-05  9:36         ` Henning Schild
2019-12-05 12:55       ` Baurzhan Ismagulov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191108174735.9998-1-Vijaikumar_Kangarajan@mentor.com \
    --to=vijaikumar.kanagarajan@gmail.com \
    --cc=Vijaikumar_Kanagarajan@mentor.com \
    --cc=henning.schild@siemens.com \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox