if f.type == "file":
continue
- uri = f.type
- proto = getattr(f, "proto", None)
- if proto is not None:
- uri = uri + "+" + proto
- uri = uri + "://" + f.host + f.path
-
- if f.method.supports_srcrev():
- uri = uri + "@" + f.revisions[name]
-
if f.method.supports_checksum(f):
for checksum_id in CHECKSUM_LIST:
if checksum_id.upper() not in oe.spdx.SPDXPackage.ALLOWED_CHECKSUMS:
c.checksumValue = expected_checksum
package.checksums.append(c)
- package.downloadLocation = uri
+ package.downloadLocation = oe.spdx_common.fetch_data_to_uri(f, name)
doc.packages.append(package)
doc.add_relationship(doc, "DESCRIBES", package)
# In the future, we might be able to do more fancy dependencies,
inputs.add(file)
else:
- uri = fd.type
- proto = getattr(fd, "proto", None)
- if proto is not None:
- uri = uri + "+" + proto
- uri = uri + "://" + fd.host + fd.path
-
- if fd.method.supports_srcrev():
- uri = uri + "@" + fd.revisions[name]
-
dl = objset.add(
oe.spdx30.software_Package(
_id=objset.new_spdxid("source", str(download_idx + 1)),
creationInfo=objset.doc.creationInfo,
name=file_name,
software_primaryPurpose=primary_purpose,
- software_downloadLocation=uri,
+ software_downloadLocation=oe.spdx_common.fetch_data_to_uri(
+ fd, name
+ ),
)
)
def load_spdx_license_data(d):
-
with open(d.getVar("SPDX_LICENSES"), "r") as f:
data = json.load(f)
# Transform the license array to a dictionary
bb.utils.mkdirhier(spdx_workdir)
finally:
d.setVar("WORKDIR", workdir)
+
+
+def fetch_data_to_uri(fd, name):
+ """
+ Translates a bitbake FetchData to a string URI
+ """
+ uri = fd.type
+ # Map gitsm to git, since gitsm:// is not a valid URI protocol
+ if uri == "gitsm":
+ uri = "git"
+ proto = getattr(fd, "proto", None)
+ if proto is not None:
+ uri = uri + "+" + proto
+ uri = uri + "://" + fd.host + fd.path
+
+ if fd.method.supports_srcrev():
+ uri = uri + "@" + fd.revisions[name]
+
+ return uri