summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2
diff options
context:
space:
mode:
authorCharlie Johnston <charlie.johnston@loftorbital.com>2023-11-27 06:11:47 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-12-02 18:04:23 +0000
commit1f8a639a67a192fa06cef15018a5cd5f7f94a602 (patch)
tree2cff0441ec242f660285ca5d00c7cd3478ef7b27 /bitbake/lib/bb/fetch2
parent64725a9c324d709e633ad31a79266a62a6d10f34 (diff)
downloadpoky-1f8a639a67a192fa06cef15018a5cd5f7f94a602.tar.gz
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 <charlie.johnston@loftorbital.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2')
-rw-r--r--bitbake/lib/bb/fetch2/gcp.py7
1 files changed, 5 insertions, 2 deletions
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):
47 ud.basename = os.path.basename(ud.path) 47 ud.basename = os.path.basename(ud.path)
48 48
49 ud.localfile = d.expand(urllib.parse.unquote(ud.basename)) 49 ud.localfile = d.expand(urllib.parse.unquote(ud.basename))
50 ud.basecmd = "gsutil stat"
50 51
51 def get_gcp_client(self): 52 def get_gcp_client(self):
52 from google.cloud import storage 53 from google.cloud import storage
@@ -61,7 +62,8 @@ class GCP(FetchMethod):
61 if self.gcp_client is None: 62 if self.gcp_client is None:
62 self.get_gcp_client() 63 self.get_gcp_client()
63 64
64 bb.fetch2.check_network_access(d, "gsutil stat", ud.url) 65 bb.fetch2.check_network_access(d, ud.basecmd, f"gs://{ud.host}{ud.path}")
66 runfetchcmd("%s %s" % (ud.basecmd, f"gs://{ud.host}{ud.path}"), d)
65 67
66 # Path sometimes has leading slash, so strip it 68 # Path sometimes has leading slash, so strip it
67 path = ud.path.lstrip("/") 69 path = ud.path.lstrip("/")
@@ -88,7 +90,8 @@ class GCP(FetchMethod):
88 if self.gcp_client is None: 90 if self.gcp_client is None:
89 self.get_gcp_client() 91 self.get_gcp_client()
90 92
91 bb.fetch2.check_network_access(d, "gsutil stat", ud.url) 93 bb.fetch2.check_network_access(d, ud.basecmd, f"gs://{ud.host}{ud.path}")
94 runfetchcmd("%s %s" % (ud.basecmd, f"gs://{ud.host}{ud.path}"), d)
92 95
93 # Path sometimes has leading slash, so strip it 96 # Path sometimes has leading slash, so strip it
94 path = ud.path.lstrip("/") 97 path = ud.path.lstrip("/")