diff mbox series

[RFC,06/21] fetch2: introduce common package manager metadata

Message ID 20241220112613.22647-7-stefan.herbrechtsmeier-oss@weidmueller.com
State New
Headers show
Series Concept for tightly coupled package manager (Node.js, Go, Rust) | expand

Commit Message

Stefan Herbrechtsmeier Dec. 20, 2024, 11:25 a.m. UTC
From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

Downloads from package manager repositories are identified via registry,
name, and version. The fetchers use individual styles to define the
download metadata:

npm://<REGISTRY>;package=<NAME>;version=<VERSION>

crate://<REGISTRY>/<NAME>/<VERSION>

GO_MOD_PROXY = “<REGISTRY>”
gomod://<NAME>;version=<VERSION>
gomodgit://<NAME>;version=<VERSION>;repo= <REPOSITORY>

The name and version are important for the SBOM to add usable name,
version, and CPE to the SBOM entries for the downloaded dependencies.
Introduce a common style and check the existence of the parameters:

<TYPE>://<REGISTRY | REPOSITORY>;dn=<NAME>;dv=<VERSION>

The style clearly separates the metadata and supports slashes and @
in the name.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
---

 lib/bb/fetch2/__init__.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index d2a30c18f..4b7c01d6a 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -1356,6 +1356,12 @@  class FetchData(object):
         if hasattr(self.method, "urldata_init"):
             self.method.urldata_init(self, d)
 
+        if self.method.require_download_metadata():
+            if "dn" not in self.parm:
+                raise MissingParameterError("dn", self.url)
+            if "dv" not in self.parm:
+                raise MissingParameterError("dv", self.url)
+
         for checksum_id in CHECKSUM_LIST:
             configure_checksum(checksum_id)
 
@@ -1711,6 +1717,12 @@  class FetchMethod(object):
         """
         return []
 
+    def require_download_metadata(self):
+        """
+        The fetcher requires download name (dn) und version (dv) parameter.
+        """
+        return False
+
 
 class DummyUnpackTracer(object):
     """