From patchwork Sun Apr 16 20:07:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Svend Meyland Nicolaisen X-Patchwork-Id: 22662 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D210C77B61 for ; Sun, 16 Apr 2023 20:07:18 +0000 (UTC) Subject: [PATCH] npmsw fetcher: Avoid instantiating Fetch class if url list is empty To: bitbake-devel@lists.openembedded.org From: public@smn.dk X-Originating-Location: =?unknown-8bit?b?Qmlya2Vyw7hkLCBDYXBpdGFsIFJlZ2lv?= =?unknown-8bit?b?biwgREsgKDEzMC4yMjguMjkuMzgp?= X-Originating-Platform: Windows Chrome 112 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Sun, 16 Apr 2023 13:07:15 -0700 Message-ID: List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sun, 16 Apr 2023 20:07:18 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/14706 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 still 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. Signed-off-by: Svend Meyland Nicolaisen --- lib/bb/fetch2/npmsw.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.39.2.windows.1 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