diff mbox series

npmsw fetcher: Avoid instantiating Fetch class if url list is empty

Message ID 20230417211228.1838-1-public@smn.dk
State Accepted, archived
Commit e602963dfd505eef08702366383358d29ee20c4d
Headers show
Series npmsw fetcher: Avoid instantiating Fetch class if url list is empty | expand

Commit Message

Svend Meyland Nicolaisen April 17, 2023, 9:12 p.m. UTC
Recipes containing both git and npmsw sources in the SRC_URI fail
during fetch from the shrinkwrap. It seems that when the fetcher is
fetching from the shrinkwrap, the SRCREV variable has been deleted but it
till ends up fetching from the git source resulting in an error because
SRCREV is undefined. The root cause of this is that the Fetch class defaults
to urls from the SRC_URI when the urls parameter contains an empty list. This
patch will ensure that Fetch is not instantiated if the urls list is empty.
---
 lib/bb/fetch2/npmsw.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Luca Ceresoli April 18, 2023, 10:24 a.m. UTC | #1
Hello Svend,

On Mon, 17 Apr 2023 23:12:28 +0200
"Svend Meyland Nicolaisen" <public@smn.dk> wrote:

> Recipes containing both git and npmsw sources in the SRC_URI fail
> during fetch from the shrinkwrap. It seems that when the fetcher is
> fetching from the shrinkwrap, the SRCREV variable has been deleted but it
> till ends up fetching from the git source resulting in an error because
> SRCREV is undefined. The root cause of this is that the Fetch class defaults
> to urls from the SRC_URI when the urls parameter contains an empty list. This
> patch will ensure that Fetch is not instantiated if the urls list is empty.

Thank you, looks much better now! I have sent the e-mail in appropriate
ASCII so it can be applied with 'git am' here as Michael told you, and
you fixed the commit title.

There are still a couple things you should improve (good news: those
are easier).

From
https://www.openembedded.org/wiki/How_to_submit_a_patch_to_OpenEmbedded:

 * All commit messages must include Signed-off-by (git commit -s)
 * Please substitute "PATCH" with "PATCH v2" if you are submitting a
   revised version after addressing feedback (or v3, v4 etc.) 
   (git commit -v<NUMBER>)

Can you resend with those fixed please?

Best regards,
Luca
Svend Meyland Nicolaisen April 18, 2023, 8:56 p.m. UTC | #2
Hi Luca,

Thank you for your mail. I am sorry that I forgot the sign-off option the second time around. I have now sent the patch again including sign-off and tagged as PATCH v2.

I could however not get the -v option on git commit to work. As far as I can see the -v option means verbose. I used --subject-prefix on git send-email instead. I hope everything is OK now.

Kind regards,
Svend
Luca Ceresoli April 19, 2023, 7:46 a.m. UTC | #3
Hi Svend,

On Tue, 18 Apr 2023 13:56:19 -0700
"Svend Meyland Nicolaisen" <public@smn.dk> wrote:

> Hi Luca,
> 
> Thank you for your mail. I am sorry that I forgot the sign-off option the second time around. I have now sent the patch again including sign-off and tagged as PATCH v2.
> 
> I could however not get the -v option on git commit to work. As far as I can see the -v option means verbose. I used --subject-prefix on git send-email instead. I hope everything is OK now.

Ah, sure, my mistake: the -v<N> option is for git format-patch, not git
commit. Apologies.

Best regards,
Luca
diff mbox series

Patch

diff --git a/lib/bb/fetch2/npmsw.py b/lib/bb/fetch2/npmsw.py
index 36fcbfba..cc81100b 100644
--- a/lib/bb/fetch2/npmsw.py
+++ b/lib/bb/fetch2/npmsw.py
@@ -205,7 +205,9 @@  class NpmShrinkWrap(FetchMethod):
         # This fetcher resolves multiple URIs from a shrinkwrap file and then
         # forwards it to a proxy fetcher. The management of the donestamp file,
         # the lockfile and the checksums are forwarded to the proxy fetcher.
-        ud.proxy = Fetch([dep["url"] for dep in ud.deps if dep["url"]], data)
+        shrinkwrap_urls = [dep["url"] for dep in ud.deps if dep["url"]]
+        if shrinkwrap_urls:
+            ud.proxy = Fetch(shrinkwrap_urls, data)
         ud.needdonestamp = False
 
     @staticmethod