From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6756899790246641664 Date: Mon, 2 Dec 2019 21:33:11 -0800 (PST) From: vijai kumar To: isar-users Message-Id: <2f0e4ece-4ab7-4d5e-8db8-65d2fdb0ddc4@googlegroups.com> In-Reply-To: <20191108174735.9998-1-Vijaikumar_Kangarajan@mentor.com> References: <20191108174148.GA9643@oxygen> <20191108174735.9998-1-Vijaikumar_Kangarajan@mentor.com> Subject: Re: [PATCH v2] meta/classes: Make sure the files exists before copying MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_831_113223274.1575351191957" X-Google-Token: EJfnl-8F7WcxA5_cOm80 X-Google-IP: 139.181.36.34 X-TUID: /xxCBFE/lcQM ------=_Part_831_113223274.1575351191957 Content-Type: multipart/alternative; boundary="----=_Part_832_212150086.1575351191957" ------=_Part_832_212150086.1575351191957 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 > > 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 > --- > 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 > > ------=_Part_832_212150086.1575351191957 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Can this be merged to next??

Thanks,
Vijai Kumar K

On Friday, November 8, 2019 a= t 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:
=C2=A0 - Use -f in if condition instead of realpath -e to make code=20
more readable.

=C2=A0meta/classes/image.bbclass | 4 ++--
=C2=A01 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
=C2=A0do_copy_boot_files[dirs] =3D "${DEPLOY_DIR_IMAGE}"
=C2=A0do_copy_boot_files() {
=C2=A0 =C2=A0 =C2=A0kernel=3D"$(realpath -q '${IMAGE_ROOTFS}/$= {KERNEL_FILE}')"
- =C2=A0 =C2=A0if [ -n "$kernel" ]; then
+ =C2=A0 =C2=A0if [ -f "$kernel" ]; then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cp -f "$kernel" '${DEPL= OY_DIR_IMAGE}/${KERNEL_IMAGE}'
=C2=A0 =C2=A0 =C2=A0fi
=C2=A0
=C2=A0 =C2=A0 =C2=A0initrd=3D"$(realpath -q '${IMAGE_ROOTFS}/i= nitrd.img')"
- =C2=A0 =C2=A0if [ -n "$initrd" ]; then
+ =C2=A0 =C2=A0if [ -f "$initrd" ]; then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cp -f "$initrd" '${DEPL= OY_DIR_IMAGE}/${INITRD_IMAGE}'
=C2=A0 =C2=A0 =C2=A0fi
=C2=A0
--=20
2.17.1

------=_Part_832_212150086.1575351191957-- ------=_Part_831_113223274.1575351191957--