new file mode 100644
@@ -0,0 +1,54 @@
+# Generates a json footprint file with the list of packages installed in the rootfs image,
+# with the following format:
+#
+# {
+# "package_name": "busybox-syslog",
+# "version": "1.37.0",
+# "total_size": 2824,
+# "installed_files": {
+# "/etc/init.d/syslog": 2104,
+# "/etc/syslog-startup.conf": 651,
+# "/etc/syslog.conf": 69
+# }
+# }
+#
+# Copyright (C) 2024 Wind River Systems, Inc.
+# Author: Beniamin Sandu <beniamin.sandu@windriver.com>
+#
+# SPDX-License-Identifier: GPL-2.0-only
+
+ROOTFS_POSTPROCESS_COMMAND:append = " create_rootfs_footprint; "
+ROOTFS_FOOTPRINT_FILE ?= "${IMGDEPLOYDIR}/${IMAGE_NAME}.footprint.json"
+
+python create_rootfs_footprint() {
+ from oe.rootfs import image_list_installed_packages
+ import oe.packagedata
+ import json
+
+ footprint_file = d.getVar('ROOTFS_FOOTPRINT_FILE')
+ pkg_info_dic = {}
+ pkg_dic = dict(package_name="", version="", total_size=0, installed_files="")
+ pkg_list = sorted(image_list_installed_packages(d))
+
+ pkg_data_list = []
+
+ for pkg in pkg_list:
+ pkg_info = os.path.join(d.getVar('PKGDATA_DIR'), 'runtime-reverse', pkg)
+ pkg_name = os.path.basename(os.readlink(pkg_info))
+ pkg_info_dic[pkg_name] = oe.packagedata.read_pkgdatafile(pkg_info)
+
+ pkg_dic["package_name"] = pkg_name
+ pkg_dic["version"] = pkg_info_dic[pkg_name]["PV"]
+ pkg_dic["total_size"] = int(pkg_info_dic[pkg_name]["PKGSIZE:" + pkg_name])
+ pkg_dic["installed_files"] = json.loads(pkg_info_dic[pkg_name]["FILES_INFO:" + pkg_name])
+
+ pkg_data_list.append(pkg_dic.copy())
+
+ with open(footprint_file, 'w') as f:
+ json.dump(pkg_data_list, f, indent=4)
+
+ footprint_link = os.path.join(d.getVar('IMGDEPLOYDIR'), "%s.footprint.json" % d.getVar('IMAGE_LINK_NAME'))
+ if os.path.lexists(footprint_link):
+ os.remove(footprint_link)
+ os.symlink(os.path.basename(footprint_file), footprint_link)
+}
The rootfs-footprint class can be inherited by image recipes to generate a .json footprint file. This file contains a list of all installed packages, with the following format: { "package_name": "busybox-udhcpc", "version": "1.37.0", "total_size": 2701, "installed_files": { "/etc/udhcpc.d/50default": 2652, "/usr/share/udhcpc/default.script": 49 } } The data can be used with other tools/scripts to generate detailed rootfs reports or perform relevant comparisons. Signed-off-by: Beniamin Sandu <beniamin.sandu@windriver.com> --- meta/classes/rootfs-footprint.bbclass | 54 +++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 meta/classes/rootfs-footprint.bbclass