From e91c4a114b652d0644913d087c6767fbaeee7689 Mon Sep 17 00:00:00 2001 From: Tomas Hozza Date: Thu, 2 Sep 2021 18:10:12 +0200 Subject: [PATCH] image-info: check not installed documentation Extend the report to list also all documentation files, which are normally part of the installed RPM packages, but were not installed on the system. This can happen e.g. when '--excludedocs' option is used when installing packages using rpm. Signed-off-by: Tomas Hozza --- tools/image-info | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tools/image-info b/tools/image-info index c8d65c00f..4037fc419 100755 --- a/tools/image-info +++ b/tools/image-info @@ -390,6 +390,38 @@ def rpm_verify(tree): } +def rpm_not_installed_docs(tree, is_ostree): + """ + Gathers information on documentation, which is part of RPM packages, + but was not installed. + + Returns: list of documentation files, which are normally a part of + the installed RPM packages, but were not installed (e.g. due to using + '--excludedocs' option when executing 'rpm' command). + + An example return value: + [ + "/usr/share/man/man1/sdiff.1.gz", + "/usr/share/man/man1/seapplet.1.gz", + "/usr/share/man/man1/secon.1.gz", + "/usr/share/man/man1/secret-tool.1.gz", + "/usr/share/man/man1/sed.1.gz", + "/usr/share/man/man1/seq.1.gz" + ] + """ + # check not installed Docs (e.g. when RPMs are installed with --excludedocs) + not_installed_docs = [] + cmd = ["rpm", "--root", tree, "-qad", "--state"] + if is_ostree: + cmd += ["--dbpath", "/usr/share/rpm"] + output = subprocess_check_output(cmd) + for line in output.splitlines(): + if line.startswith("not installed"): + not_installed_docs.append(line.split()[-1]) + + return sorted(not_installed_docs) + + def rpm_packages(tree, is_ostree): """ Read NVRs of RPM packages installed on the system. @@ -1953,6 +1985,10 @@ def append_filesystem(report, tree, *, is_ostree=False): if not is_ostree: report["rpm-verify"] = rpm_verify(tree) + not_installed_docs = rpm_not_installed_docs(tree, is_ostree) + if not_installed_docs: + report["rpm_not_installed_docs"] = not_installed_docs + with open(f"{tree}/etc/os-release") as f: report["os-release"] = parse_environment_vars(f.read())