Skip to contentSkip to conversation

license: add package URLs to license.manifest

PATCH New [email protected] 1 participant 1 message Dec 12, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 license: add package URLs to license.manifest

Manufacturers of embedded systems are obliged to publish information to the used open-source software components. Additionally the URLs for accessing these software components are a useful or even necessary information. Therefore these URLs are added to the package information listed in the license.manifest file.

---
meta/classes/license.bbclass       |  2 ++ meta/classes/license_image.bbclass | 23 ++++++++++++++++++++++-

2 files changed, 24 insertions(+), 1 deletion(-)
meta/classes/license.bbclass +0 -0
index 0d0faa28d7..83bf1da41f 100644
@@ -50,6 +50,8 @@ def get_recipe_info(d):

info["PV"] = d.getVar("PV")
info["PR"] = d.getVar("PR")
info["LICENSE"] = d.getVar("LICENSE")
+    info["SRC_URI"] = d.getVar("SRC_URI")
+    info["LIC_FILES_CHKSUM"] = d.getVar("LIC_FILES_CHKSUM") return info

def add_package_and_files(d):

meta/classes/license_image.bbclass +0 -0
index 73cebb4d55..16a39fce3d 100644
@@ -72,7 +72,28 @@ def write_license_files(d, license_manifest, pkg_dic, rootfs=True):

license_file.write("PACKAGE NAME: %s\n" % pkg)
license_file.write("PACKAGE VERSION: %s\n" % pkg_dic[pkg]["PV"]) license_file.write("RECIPE NAME: %s\n" % pkg_dic[pkg]["PN"])
-                license_file.write("LICENSE: %s\n\n" % pkg_dic[pkg]["LICENSE"])
+                license_file.write("LICENSE: %s\n" % pkg_dic[pkg]["LICENSE"])
+
+                # Add SRC_URIs to license.manifest from recipeinfo files
+                pkg_dic[pkg]["SRC_URI"] = ""
+                licdir = os.path.join(d.getVar('LICENSE_DIRECTORY'), pkg_dic[pkg]["PN"]) +                if os.path.exists(licdir):
+                    with open(os.path.join(licdir, "recipeinfo"), "r") as f:
+                        for line in f.readlines():
+                            key,val = line.split(": ", 1)
+                            if key == "SRC_URI":
+                                uri = val.split()
+                                if len(uri) > 0:
+                                    if "file://" not in uri[0]:
+                                        pkg_dic[pkg]["SRC_URI"] = uri[0]
+                                    else:
+                                        bb.warn("No source URL available for %s" % (pkg_dic[pkg]["PN"])) +                                else:
+                                    bb.warn("No source URL available for %s" % (pkg_dic[pkg]["PN"])) +                else:
+                    bb.note("No license information available for %s" % (pkg_dic[pkg]["PN"])) +
+                license_file.write("SRC_URI: %s\n\n" % pkg_dic[pkg]["SRC_URI"])

# If the package doesn't contain any file, that is, its size is 0, the license # isn't relevant as far as the final image is concerned. So doing license check --
2.17.1