diff mbox series

[meta-swupdate] Check for fetched URLs before adding to SWU

Message ID 20191210104936.13745-1-sbabic@denx.de
State Accepted
Headers show
Series [meta-swupdate] Check for fetched URLs before adding to SWU | expand

Commit Message

Stefano Babic Dec. 10, 2019, 10:49 a.m. UTC
There are cases where the fetched URLs are retrieved from a repo. Files
cannot be copied as they are and must be evaluated in the recipe. IOne
use case is if the sw-description is fetched from a git repo instead of
beeing stored on a local file. The check vrifies that the fetched URL is
a file before copying it.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 classes/swupdate.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Vincent Prince Dec. 16, 2019, 9:52 a.m. UTC | #1
Hi Stefano, 

os.path.isfile should have absolute path as argument and filename isn't for 
local files, so SWU is broken with this patch.

Best regards,
Vincent

Le mardi 10 décembre 2019 11:49:42 UTC+1, Stefano Babic a écrit :
>
> There are cases where the fetched URLs are retrieved from a repo. Files 
> cannot be copied as they are and must be evaluated in the recipe. IOne 
> use case is if the sw-description is fetched from a git repo instead of 
> beeing stored on a local file. The check vrifies that the fetched URL is 
> a file before copying it. 
>
> Signed-off-by: Stefano Babic <sba...@denx.de <javascript:>> 
> --- 
>  classes/swupdate.bbclass | 2 +- 
>  1 file changed, 1 insertion(+), 1 deletion(-) 
>
> diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass 
> index 1d74eef..b39b773 100644 
> --- a/classes/swupdate.bbclass 
> +++ b/classes/swupdate.bbclass 
> @@ -77,7 +77,7 @@ python do_swuimage () { 
>      for url in fetch.urls: 
>          local = fetch.localpath(url) 
>          filename = os.path.basename(local) 
> -        if (filename != 'sw-description'): 
> +        if (filename != 'sw-description') and (os.path.isfile(filename)): 
>              shutil.copyfile(local, os.path.join(s, "%s" % filename )) 
>              list_for_cpio.append(filename) 
>   
> -- 
> 2.17.1 
>
>
Stefano Babic Dec. 16, 2019, 10:16 a.m. UTC | #2
Hi Vincent,

On 16/12/19 10:52, Vincent Prince wrote:
> Hi Stefano, 
> 
> os.path.isfile should have absolute path as argument and filename isn't
> for local files, so SWU is broken with this patch.
> 

mmhhh...mabe should this set in this way (I have already merged this, so
I need a new patch to fix it) ?

diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
index 9fce1ea..4cd4fd2 100644
--- a/classes/swupdate.bbclass
+++ b/classes/swupdate.bbclass
@@ -98,7 +98,7 @@ python do_swuimage () {
     for url in fetch.urls:
         local = fetch.localpath(url)
         filename = os.path.basename(local)
-        if (filename != 'sw-description') and (os.path.isfile(filename)):
+        if (filename != 'sw-description') and (os.path.isfile(local)):
             shutil.copyfile(local, os.path.join(s, "%s" % filename ))
             list_for_cpio.append(filename)

Best regards,
Stefano

> Best regards,
> Vincent
> 
> Le mardi 10 décembre 2019 11:49:42 UTC+1, Stefano Babic a écrit :
> 
>     There are cases where the fetched URLs are retrieved from a repo. Files
>     cannot be copied as they are and must be evaluated in the recipe. IOne
>     use case is if the sw-description is fetched from a git repo instead of
>     beeing stored on a local file. The check vrifies that the fetched
>     URL is
>     a file before copying it.
> 
>     Signed-off-by: Stefano Babic <sba...@denx.de <javascript:>>
>     ---
>      classes/swupdate.bbclass | 2 +-
>      1 file changed, 1 insertion(+), 1 deletion(-)
> 
>     diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
>     index 1d74eef..b39b773 100644
>     --- a/classes/swupdate.bbclass
>     +++ b/classes/swupdate.bbclass
>     @@ -77,7 +77,7 @@ python do_swuimage () {
>          for url in fetch.urls:
>              local = fetch.localpath(url)
>              filename = os.path.basename(local)
>     -        if (filename != 'sw-description'):
>     +        if (filename != 'sw-description') and
>     (os.path.isfile(filename)):
>                  shutil.copyfile(local, os.path.join(s, "%s" % filename ))
>                  list_for_cpio.append(filename)
>      
>     -- 
>     2.17.1
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "swupdate" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swupdate+unsubscribe@googlegroups.com
> <mailto:swupdate+unsubscribe@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/swupdate/8c5b619c-824e-49e8-bc0c-d6e0f80b9ace%40googlegroups.com
> <https://groups.google.com/d/msgid/swupdate/8c5b619c-824e-49e8-bc0c-d6e0f80b9ace%40googlegroups.com?utm_medium=email&utm_source=footer>.
Vincent Prince Dec. 16, 2019, 10:46 a.m. UTC | #3
-        if (filename != 'sw-description') and (os.path.isfile(filename)):
+        if (filename != 'sw-description') and (os.path.isfile(local)):

This patch fixes it indeed.

Le lundi 16 décembre 2019 11:16:24 UTC+1, Stefano Babic a écrit :
>
> Hi Vincent, 
>
> On 16/12/19 10:52, Vincent Prince wrote: 
> > Hi Stefano,  
> > 
> > os.path.isfile should have absolute path as argument and filename isn't 
> > for local files, so SWU is broken with this patch. 
> > 
>
> mmhhh...mabe should this set in this way (I have already merged this, so 
> I need a new patch to fix it) ? 
>
> diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass 
> index 9fce1ea..4cd4fd2 100644 
> --- a/classes/swupdate.bbclass 
> +++ b/classes/swupdate.bbclass 
> @@ -98,7 +98,7 @@ python do_swuimage () { 
>      for url in fetch.urls: 
>          local = fetch.localpath(url) 
>          filename = os.path.basename(local) 
> -        if (filename != 'sw-description') and (os.path.isfile(filename)): 
> +        if (filename != 'sw-description') and (os.path.isfile(local)): 
>              shutil.copyfile(local, os.path.join(s, "%s" % filename )) 
>              list_for_cpio.append(filename) 
>
> Best regards, 
> Stefano 
>
> > Best regards, 
> > Vincent 
> > 
> > Le mardi 10 décembre 2019 11:49:42 UTC+1, Stefano Babic a écrit : 
> > 
> >     There are cases where the fetched URLs are retrieved from a repo. 
> Files 
> >     cannot be copied as they are and must be evaluated in the recipe. 
> IOne 
> >     use case is if the sw-description is fetched from a git repo instead 
> of 
> >     beeing stored on a local file. The check vrifies that the fetched 
> >     URL is 
> >     a file before copying it. 
> > 
> >     Signed-off-by: Stefano Babic <sba...@denx.de <javascript:>> 
> >     --- 
> >      classes/swupdate.bbclass | 2 +- 
> >      1 file changed, 1 insertion(+), 1 deletion(-) 
> > 
> >     diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass 
> >     index 1d74eef..b39b773 100644 
> >     --- a/classes/swupdate.bbclass 
> >     +++ b/classes/swupdate.bbclass 
> >     @@ -77,7 +77,7 @@ python do_swuimage () { 
> >          for url in fetch.urls: 
> >              local = fetch.localpath(url) 
> >              filename = os.path.basename(local) 
> >     -        if (filename != 'sw-description'): 
> >     +        if (filename != 'sw-description') and 
> >     (os.path.isfile(filename)): 
> >                  shutil.copyfile(local, os.path.join(s, "%s" % filename 
> )) 
> >                  list_for_cpio.append(filename) 
> >       
> >     -- 
> >     2.17.1 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "swupdate" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> > an email to swup...@googlegroups.com <javascript:> 
> > <mailto:swup...@googlegroups.com <javascript:>>. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/swupdate/8c5b619c-824e-49e8-bc0c-d6e0f80b9ace%40googlegroups.com 
> > <
> https://groups.google.com/d/msgid/swupdate/8c5b619c-824e-49e8-bc0c-d6e0f80b9ace%40googlegroups.com?utm_medium=email&utm_source=footer>. 
>
>
>
> -- 
> ===================================================================== 
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk 
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany 
> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de 
> <javascript:> 
> ===================================================================== 
>
Vincent Prince Dec. 16, 2019, 10:48 a.m. UTC | #4
More precisely, it works fine for my use-case with local files, but I 
didn't test with remote files as bugfix was intended in first place, 
Maybe you can check if it is ok for your use-case also?

Le lundi 16 décembre 2019 11:46:41 UTC+1, Vincent Prince a écrit :
>
> -        if (filename != 'sw-description') and (os.path.isfile(filename)):
> +        if (filename != 'sw-description') and (os.path.isfile(local)):
>
> This patch fixes it indeed.
>
> Le lundi 16 décembre 2019 11:16:24 UTC+1, Stefano Babic a écrit :
>>
>> Hi Vincent, 
>>
>> On 16/12/19 10:52, Vincent Prince wrote: 
>> > Hi Stefano,  
>> > 
>> > os.path.isfile should have absolute path as argument and filename isn't 
>> > for local files, so SWU is broken with this patch. 
>> > 
>>
>> mmhhh...mabe should this set in this way (I have already merged this, so 
>> I need a new patch to fix it) ? 
>>
>> diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass 
>> index 9fce1ea..4cd4fd2 100644 
>> --- a/classes/swupdate.bbclass 
>> +++ b/classes/swupdate.bbclass 
>> @@ -98,7 +98,7 @@ python do_swuimage () { 
>>      for url in fetch.urls: 
>>          local = fetch.localpath(url) 
>>          filename = os.path.basename(local) 
>> -        if (filename != 'sw-description') and 
>> (os.path.isfile(filename)): 
>> +        if (filename != 'sw-description') and (os.path.isfile(local)): 
>>              shutil.copyfile(local, os.path.join(s, "%s" % filename )) 
>>              list_for_cpio.append(filename) 
>>
>> Best regards, 
>> Stefano 
>>
>> > Best regards, 
>> > Vincent 
>> > 
>> > Le mardi 10 décembre 2019 11:49:42 UTC+1, Stefano Babic a écrit : 
>> > 
>> >     There are cases where the fetched URLs are retrieved from a repo. 
>> Files 
>> >     cannot be copied as they are and must be evaluated in the recipe. 
>> IOne 
>> >     use case is if the sw-description is fetched from a git repo 
>> instead of 
>> >     beeing stored on a local file. The check vrifies that the fetched 
>> >     URL is 
>> >     a file before copying it. 
>> > 
>> >     Signed-off-by: Stefano Babic <sba...@denx.de <javascript:>> 
>> >     --- 
>> >      classes/swupdate.bbclass | 2 +- 
>> >      1 file changed, 1 insertion(+), 1 deletion(-) 
>> > 
>> >     diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass 
>> >     index 1d74eef..b39b773 100644 
>> >     --- a/classes/swupdate.bbclass 
>> >     +++ b/classes/swupdate.bbclass 
>> >     @@ -77,7 +77,7 @@ python do_swuimage () { 
>> >          for url in fetch.urls: 
>> >              local = fetch.localpath(url) 
>> >              filename = os.path.basename(local) 
>> >     -        if (filename != 'sw-description'): 
>> >     +        if (filename != 'sw-description') and 
>> >     (os.path.isfile(filename)): 
>> >                  shutil.copyfile(local, os.path.join(s, "%s" % filename 
>> )) 
>> >                  list_for_cpio.append(filename) 
>> >       
>> >     -- 
>> >     2.17.1 
>> > 
>> > -- 
>> > You received this message because you are subscribed to the Google 
>> > Groups "swupdate" group. 
>> > To unsubscribe from this group and stop receiving emails from it, send 
>> > an email to swup...@googlegroups.com 
>> > <mailto:swup...@googlegroups.com>. 
>> > To view this discussion on the web visit 
>> > 
>> https://groups.google.com/d/msgid/swupdate/8c5b619c-824e-49e8-bc0c-d6e0f80b9ace%40googlegroups.com 
>> > <
>> https://groups.google.com/d/msgid/swupdate/8c5b619c-824e-49e8-bc0c-d6e0f80b9ace%40googlegroups.com?utm_medium=email&utm_source=footer>. 
>>
>>
>>
>> -- 
>> ===================================================================== 
>> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk 
>> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany 
>> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de 
>> ===================================================================== 
>>
>
Stefano Babic Dec. 16, 2019, 1:17 p.m. UTC | #5
On 16/12/19 11:48, Vincent Prince wrote:
> More precisely, it works fine for my use-case with local files, but I
> didn't test with remote files as bugfix was intended in first place, 
> Maybe you can check if it is ok for your use-case also?

Tested, it works with my use case, too. I sent a patch.

Best regards,
Stefano

> 
> Le lundi 16 décembre 2019 11:46:41 UTC+1, Vincent Prince a écrit :
> 
>     -        if (filename != 'sw-description') and
>     (os.path.isfile(filename)):
>     +        if (filename != 'sw-description') and (os.path.isfile(local)):
> 
>     This patch fixes it indeed.
> 
>     Le lundi 16 décembre 2019 11:16:24 UTC+1, Stefano Babic a écrit :
> 
>         Hi Vincent,
> 
>         On 16/12/19 10:52, Vincent Prince wrote:
>         > Hi Stefano, 
>         >
>         > os.path.isfile should have absolute path as argument and
>         filename isn't
>         > for local files, so SWU is broken with this patch.
>         >
> 
>         mmhhh...mabe should this set in this way (I have already merged
>         this, so
>         I need a new patch to fix it) ?
> 
>         diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
>         index 9fce1ea..4cd4fd2 100644
>         --- a/classes/swupdate.bbclass
>         +++ b/classes/swupdate.bbclass
>         @@ -98,7 +98,7 @@ python do_swuimage () {
>              for url in fetch.urls:
>                  local = fetch.localpath(url)
>                  filename = os.path.basename(local)
>         -        if (filename != 'sw-description') and
>         (os.path.isfile(filename)):
>         +        if (filename != 'sw-description') and
>         (os.path.isfile(local)):
>                      shutil.copyfile(local, os.path.join(s, "%s" %
>         filename ))
>                      list_for_cpio.append(filename)
> 
>         Best regards,
>         Stefano
> 
>         > Best regards,
>         > Vincent
>         >
>         > Le mardi 10 décembre 2019 11:49:42 UTC+1, Stefano Babic a écrit :
>         >
>         >     There are cases where the fetched URLs are retrieved from
>         a repo. Files
>         >     cannot be copied as they are and must be evaluated in the
>         recipe. IOne
>         >     use case is if the sw-description is fetched from a git
>         repo instead of
>         >     beeing stored on a local file. The check vrifies that the
>         fetched
>         >     URL is
>         >     a file before copying it.
>         >
>         >     Signed-off-by: Stefano Babic <sba...@denx.de <javascript:>>
>         >     ---
>         >      classes/swupdate.bbclass | 2 +-
>         >      1 file changed, 1 insertion(+), 1 deletion(-)
>         >
>         >     diff --git a/classes/swupdate.bbclass
>         b/classes/swupdate.bbclass
>         >     index 1d74eef..b39b773 100644
>         >     --- a/classes/swupdate.bbclass
>         >     +++ b/classes/swupdate.bbclass
>         >     @@ -77,7 +77,7 @@ python do_swuimage () {
>         >          for url in fetch.urls:
>         >              local = fetch.localpath(url)
>         >              filename = os.path.basename(local)
>         >     -        if (filename != 'sw-description'):
>         >     +        if (filename != 'sw-description') and
>         >     (os.path.isfile(filename)):
>         >                  shutil.copyfile(local, os.path.join(s, "%s" %
>         filename ))
>         >                  list_for_cpio.append(filename)
>         >      
>         >     --
>         >     2.17.1
>         >
>         > --
>         > You received this message because you are subscribed to the
>         Google
>         > Groups "swupdate" group.
>         > To unsubscribe from this group and stop receiving emails from
>         it, send
>         > an email to swup...@googlegroups.com
>         > <mailto:swup...@googlegroups.com>.
>         > To view this discussion on the web visit
>         >
>         https://groups.google.com/d/msgid/swupdate/8c5b619c-824e-49e8-bc0c-d6e0f80b9ace%40googlegroups.com
>         <https://groups.google.com/d/msgid/swupdate/8c5b619c-824e-49e8-bc0c-d6e0f80b9ace%40googlegroups.com>
> 
>         >
>         <https://groups.google.com/d/msgid/swupdate/8c5b619c-824e-49e8-bc0c-d6e0f80b9ace%40googlegroups.com?utm_medium=email&utm_source=footer
>         <https://groups.google.com/d/msgid/swupdate/8c5b619c-824e-49e8-bc0c-d6e0f80b9ace%40googlegroups.com?utm_medium=email&utm_source=footer>>.
> 
> 
> 
>         -- 
>         =====================================================================
> 
>         DENX Software Engineering GmbH,      Managing Director: Wolfgang
>         Denk
>         HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell,
>         Germany
>         Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email:
>         sba...@denx.de
>         =====================================================================
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "swupdate" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swupdate+unsubscribe@googlegroups.com
> <mailto:swupdate+unsubscribe@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/swupdate/a935e8d1-682b-4690-96dc-f23a8b0507b8%40googlegroups.com
> <https://groups.google.com/d/msgid/swupdate/a935e8d1-682b-4690-96dc-f23a8b0507b8%40googlegroups.com?utm_medium=email&utm_source=footer>.
diff mbox series

Patch

diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
index 1d74eef..b39b773 100644
--- a/classes/swupdate.bbclass
+++ b/classes/swupdate.bbclass
@@ -77,7 +77,7 @@  python do_swuimage () {
     for url in fetch.urls:
         local = fetch.localpath(url)
         filename = os.path.basename(local)
-        if (filename != 'sw-description'):
+        if (filename != 'sw-description') and (os.path.isfile(filename)):
             shutil.copyfile(local, os.path.join(s, "%s" % filename ))
             list_for_cpio.append(filename)