From 1f8a639a67a192fa06cef15018a5cd5f7f94a602 Mon Sep 17 00:00:00 2001 From: Charlie Johnston Date: Mon, 27 Nov 2023 06:11:47 -0700 Subject: bitbake: fetch2: Ensure GCP fetcher checks if file exists before download. The GCP fetcher was calling bb.fetch2.check_network_access with "gsutil stat" as the command, but then never actually ran that command to check if the file exists. In cases where the file did not exist in a gs:// premirror, this would lead to an unhandled exception from do_fetch when the GCP python API tried to perform the download. This change resolves that issue by adding a runfetchcmd to call gsutil. (Bitbake rev: 1ab1d36c0af6fc58a974106b61ff4d37da6cb229) Signed-off-by: Charlie Johnston Signed-off-by: Richard Purdie --- bitbake/lib/bb/fetch2/gcp.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'bitbake/lib/bb/fetch2') diff --git a/bitbake/lib/bb/fetch2/gcp.py b/bitbake/lib/bb/fetch2/gcp.py index f42c81fda8..f40ce2eaa5 100644 --- a/bitbake/lib/bb/fetch2/gcp.py +++ b/bitbake/lib/bb/fetch2/gcp.py @@ -47,6 +47,7 @@ class GCP(FetchMethod): ud.basename = os.path.basename(ud.path) ud.localfile = d.expand(urllib.parse.unquote(ud.basename)) + ud.basecmd = "gsutil stat" def get_gcp_client(self): from google.cloud import storage @@ -61,7 +62,8 @@ class GCP(FetchMethod): if self.gcp_client is None: self.get_gcp_client() - bb.fetch2.check_network_access(d, "gsutil stat", ud.url) + bb.fetch2.check_network_access(d, ud.basecmd, f"gs://{ud.host}{ud.path}") + runfetchcmd("%s %s" % (ud.basecmd, f"gs://{ud.host}{ud.path}"), d) # Path sometimes has leading slash, so strip it path = ud.path.lstrip("/") @@ -88,7 +90,8 @@ class GCP(FetchMethod): if self.gcp_client is None: self.get_gcp_client() - bb.fetch2.check_network_access(d, "gsutil stat", ud.url) + bb.fetch2.check_network_access(d, ud.basecmd, f"gs://{ud.host}{ud.path}") + runfetchcmd("%s %s" % (ud.basecmd, f"gs://{ud.host}{ud.path}"), d) # Path sometimes has leading slash, so strip it path = ud.path.lstrip("/") -- cgit v1.2.3-54-g00ecf