Skip to contentSkip to conversation

[2.0][PATCH] fetch2: add Google Cloud Platform (GCP) fetcher

bitbake-devel [email protected] 1 participant 1 message Aug 17, 2023

lore
Share & tools
lore
#0 lore raw

From: Emil Ekmečić <[email protected]>

Requesting a backport of this patch to BitBake 2.0 to support use of the GCP fetcher internally at our company, which is on Kirkstone.

This fetcher allows BitBake to fetch from a Google Cloud Storage bucket. The fetcher expects a gs:// URI of the following form:

SSTATE_MIRRORS = "file://.* gs://<bucket name>/PATH"

The fetcher uses the Google Cloud Storage Python Client, and expects it to be installed, configured, and authenticated prior to use. There is also documentation for the fetcher added to the User Manual.

If accepted, this patch should merge in with the corresponding oe-core backport request titled "Add GCP fetcher to list of supported protocols".

Some comments on the patch:

---
 .../bitbake-user-manual-fetching.rst          | 36 +++++++
 lib/bb/fetch2/__init__.py                     |  4 +-
 lib/bb/fetch2/gcp.py                          | 98 +++++++++++++++++++
 3 files changed, 137 insertions(+), 1 deletion(-)
 create mode 100644 lib/bb/fetch2/gcp.py
doc/bitbake-user-manual/bitbake-user-manual-fetching.rst +36 -0
index 519aec9a..bf3abd1c 100644
@@ -688,6 +688,40 @@ Here is an example URL::
 
 It can also be used when setting mirrors definitions using the :term:`PREMIRRORS` variable.
 
+.. _gcp-fetcher:
+
+GCP Fetcher (``gs://``)
+--------------------------
+
+This submodule fetches data from a
+`Google Cloud Storage Bucket <https://cloud.google.com/storage/docs/buckets>`__.
+It uses the `Google Cloud Storage Python Client <https://cloud.google.com/python/docs/reference/storage/latest>`__
+to check the status of objects in the bucket and download them.
+The use of the Python client makes it substantially faster than using command
+line tools such as gsutil.
+
+The fetcher requires the Google Cloud Storage Python Client to be installed, along
+with the gsutil tool.
+
+The fetcher requires that the machine has valid credentials for accessing the
+chosen bucket. Instructions for authentication can be found in the
+`Google Cloud documentation <https://cloud.google.com/docs/authentication/provide-credentials-adc#local-dev>`__.
+
+The fetcher can be used for fetching sstate artifacts from a GCS bucket by
+specifying the :term:`SSTATE_MIRRORS` variable as shown below::
+
+   SSTATE_MIRRORS ?= "\
+       file://.* gs://<bucket name>/PATH \
+   "
+
+The fetcher can also be used in recipes::
+
+   SRC_URI = "gs://<bucket name>/<foo_container>/<bar_file>"
+
+However, the checksum of the file should be also be provided::
+
+   SRC_URI[sha256sum] = "<sha256 string>"
+
 .. _crate-fetcher:
 
 Crate Fetcher (``crate://``)
@@ -791,6 +825,8 @@ Fetch submodules also exist for the following:
 
 -  OSC (``osc://``)
 
+-  S3 (``s3://``)
+
 -  Secure FTP (``sftp://``)
 
 -  Secure Shell (``ssh://``)
lib/bb/fetch2/__init__.py +3 -1
index a3140626..4176ff4c 100644
@@ -1285,7 +1285,7 @@ class FetchData(object):
 
             if checksum_name in self.parm:
                 checksum_expected = self.parm[checksum_name]
-            elif self.type not in ["http", "https", "ftp", "ftps", "sftp", "s3", "az"]:
+            elif self.type not in ["http", "https", "ftp", "ftps", "sftp", "s3", "az", "gs"]:
                 checksum_expected = None
             else:
                 checksum_expected = d.getVarFlag("SRC_URI", checksum_name)
@@ -1961,6 +1961,7 @@ from . import npm
 from . import npmsw
 from . import az
 from . import crate
+from . import gcp
 
 methods.append(local.Local())
 methods.append(wget.Wget())
@@ -1982,3 +1983,4 @@ methods.append(npm.Npm())
 methods.append(npmsw.NpmShrinkWrap())
 methods.append(az.Az())
 methods.append(crate.Crate())
+methods.append(gcp.GCP())
lib/bb/fetch2/gcp.py new file +98 -0

98 lines not on this page · raw message

Signature · 1 line
2.41.0