[elbe-devel] [PATCH] elbepack: group installed packages by origin

Thomas Weißschuh thomas.weissschuh at linutronix.de
Fri Mar 15 12:54:40 CET 2024


This makes it easier to validate from where packages are coming from.
Non-Debian origins are shown first as those are of most interest.

Example for examples/x86_64-docker-elbe.xml:

Before:

    Installed Packages List
    -----------------------

    |adduser|3.134|deb.debian.org stable main
    |apt|2.6.1|deb.debian.org stable main
    |apt-utils|2.6.1|deb.debian.org stable main
    |base-files|12.4+deb12u5|deb.debian.org stable main
    ...

Ater:

    Installed Packages List
    -----------------------

    debian.linutronix.de
    ~~~~~~~~~~~~~~~~~~~~

    |elbe|14.9.3+deb12+build1311|debian.linutronix.de bookworm main
    |elbe-schema|14.9.3+deb12+build1311|debian.linutronix.de bookworm main
    |python3-elbe-bin|14.9.3+deb12+build1311|debian.linutronix.de bookworm main
    |python3-elbe-common|14.9.3+deb12+build1311|debian.linutronix.de bookworm main
    |python3-elbe-control|14.9.3+deb12+build1311|debian.linutronix.de bookworm main

    Debian
    ~~~~~~

    |adduser|3.134|deb.debian.org stable main
    |apt|2.6.1|deb.debian.org stable main
    |apt-utils|2.6.1|deb.debian.org stable main
    |base-files|12.4+deb12u5|deb.debian.org stable main
    ....

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/dump.py | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/elbepack/dump.py b/elbepack/dump.py
index b99b6b14ddac..234d1f890b63 100644
--- a/elbepack/dump.py
+++ b/elbepack/dump.py
@@ -2,6 +2,7 @@
 # SPDX-License-Identifier: GPL-3.0-or-later
 # SPDX-FileCopyrightText: 2014-2017 Linutronix GmbH
 
+import collections
 import logging
 from datetime import datetime
 from fnmatch import fnmatchcase
@@ -203,11 +204,27 @@ def elbe_report(xml, buildenv, cache, targetfs):
     report.info('')
     report.info('Installed Packages List')
     report.info('-----------------------')
-    report.info('')
 
     instpkgs = cache.get_installed_pkgs()
+
+    groups = collections.defaultdict(list)
     for p in instpkgs:
-        report.info('|%s|%s|%s', p.name, p.installed_version, p.origin)
+        o, _, _ = p.origin.split(' ')
+        if o.endswith('.debian.org'):
+            # Group upstream packages together.
+            o = 'Debian'
+
+        groups[o].append(p)
+
+    # Sort alphabetically, 'Debian' last.
+    for origin, pkgs in sorted(groups.items(), key=lambda x: (x[0] == 'Debian', x[0])):
+        report.info('')
+        report.info('%s', origin)
+        report.info('~' * len(origin))
+        report.info('')
+
+        for p in pkgs:
+            report.info('|%s|%s|%s', p.name, p.installed_version, p.origin)
 
     index = cache.get_fileindex(removeprefix='/usr')
     mt_index = targetfs.mtime_snap()

---
base-commit: ef9eeca734b372faba47b88df94950d5b465751d
change-id: 20240315-pkg-report-b03329be15d4

Best regards,
-- 
Thomas Weißschuh <thomas.weissschuh at linutronix.de>



More information about the elbe-devel mailing list