From d7a17f324ee80ecd75985415909541946d0b9561 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Fri, 28 Oct 2022 17:40:42 -0300 Subject: [PATCH] [gems.debian] fix: not properly handling packages with names ending with :i386 --- CHANGELOG.md | 2 ++ bauh/gems/debian/aptitude.py | 2 +- tests/gems/debian/test_aptitude.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe11b10c..8f24fba0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - some desktop entries not being displayed on the desktop environment menu (requires the AppImage to be reinstalled) [#287](https://github.com/vinifmor/bauh/issues/287) - Arch - not detecting some package replacements when upgrading due to conflict information having logic operators (e.g: `at-spi2-core: 2.44.1 -> 2.46.0` should replace the installed `at-spi2-atk: 2.38`) +- Debian + - not properly handling packages with names ending with `:i386` [#298](https://github.com/vinifmor/bauh/issues/298) - GUI - management panel not fully maximizing diff --git a/bauh/gems/debian/aptitude.py b/bauh/gems/debian/aptitude.py index e94490cf..8a3f62f1 100644 --- a/bauh/gems/debian/aptitude.py +++ b/bauh/gems/debian/aptitude.py @@ -241,7 +241,7 @@ class Aptitude: @property def re_transaction_pkg(self) -> Pattern: if self._re_transaction_pkg is None: - self._re_transaction_pkg = re.compile(r'([a-zA-Z0-9\-_@~.+]+)({\w+})?\s*\[([a-zA-Z0-9\-_@~.+:]+)' + self._re_transaction_pkg = re.compile(r'([a-zA-Z0-9\-_@~.+:]+)({\w+})?\s*\[([a-zA-Z0-9\-_@~.+:]+)' r'(\s+->\s+([a-zA-Z0-9\-_@~.+:]+))?](\s*<([\-+]?[0-9.,]+\s+\w+)>)?') return self._re_transaction_pkg diff --git a/tests/gems/debian/test_aptitude.py b/tests/gems/debian/test_aptitude.py index 8015c4cb..05f775d2 100644 --- a/tests/gems/debian/test_aptitude.py +++ b/tests/gems/debian/test_aptitude.py @@ -166,3 +166,33 @@ Description: GNU C compiler ] self.assertEqual([p.__dict__ for p in expected], [p.__dict__ for p in returned]) + + def test_map_transaction_output__it_should_map_i386_packages(self): + output = "\nThe following NEW packages will be installed:\n" \ + " gcc-12-base:i386{a} [12.1.0-2distro~22.04] <+272 kB> glib-networking:i386{a} [2.72.0-1] <+242 kB>\n" \ + "\nThe following packages will be REMOVED:\n" \ + " celluloid{a} [0.21-linux+distro] <-1066 kB> libpcre3:i386{a} [2:8.39-13distro0.22.04.1] <-714 kB>" + + transaction = self.aptitude.map_transaction_output(output) + to_install = { + DebianPackage(name="gcc-12-base:i386", + version="12.1.0-2distro~22.04", + latest_version="12.1.0-2distro~22.04", + transaction_size=272000.0 + ), + DebianPackage(name="glib-networking:i386", version="2.72.0-1", + latest_version="2.72.0-1", transaction_size=242000.0) + } + self.assertEqual(to_install, {*transaction.to_install}) + + to_remove = { + DebianPackage(name="celluloid", + version="0.21-linux+distro", + latest_version="0.21-linux+distro", + transaction_size=-1066000.0 + ), + DebianPackage(name="libpcre3:i386", version="2:8.39-13distro0.22.04.1", + latest_version="2:8.39-13distro0.22.04.1", transaction_size=-714000.0) + } + + self.assertEqual(to_remove, {*transaction.to_remove})