From 8ea182da2a24190b99afc0cf33aea4fd476612a0 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Mon, 21 Oct 2019 12:11:06 -0300 Subject: [PATCH] [aur] fix -> update-checking for some scenarios described in Manjaro's forum --- CHANGELOG.md | 5 +++++ bauh/__init__.py | 2 +- bauh/gems/arch/mapper.py | 28 ++++++++++++++---------- tests/gems/arch/arch_data_mapper_test.py | 3 +++ 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee298e32..999dbc0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [0.7.1] 2019- +### Fixes +- AUR: + - update-checking for some scenarios + ## [0.7.0] 2019-10-18 ### Features - AppImage support ( see below ) diff --git a/bauh/__init__.py b/bauh/__init__.py index e1ab2566..3fdb7b7e 100644 --- a/bauh/__init__.py +++ b/bauh/__init__.py @@ -1,4 +1,4 @@ -__version__ = '0.7.0' +__version__ = '0.7.1' __app_name__ = 'bauh' import os diff --git a/bauh/gems/arch/mapper.py b/bauh/gems/arch/mapper.py index ffee5a99..d058d3c3 100644 --- a/bauh/gems/arch/mapper.py +++ b/bauh/gems/arch/mapper.py @@ -7,8 +7,7 @@ from bauh.gems.arch.model import ArchPackage URL_PKG_DOWNLOAD = 'https://aur.archlinux.org/{}' RE_LETTERS = re.compile(r'\.([a-zA-Z]+)-\d+$') -RE_ANY_LETTER = re.compile(r'[a-zA-Z]') -RE_VERSION_DELS = re.compile(r'[.:#@\-_]') +RE_VERSION_SPLIT = re.compile(r'[a-zA-Z]+|\d+|[\.\-_@#]+') RE_SFX = ('r', 're', 'release') GA_SFX = ('ga', 'ge') @@ -76,19 +75,18 @@ class ArchDataMapper: return nlatest > nversion - latest_split = RE_VERSION_DELS.split(latest_version) - version_split = RE_VERSION_DELS.split(version) + latest_split = RE_VERSION_SPLIT.findall(latest_version) + current_split = RE_VERSION_SPLIT.findall(version) for idx in range(len(latest_split)): - if idx < len(version_split): + if idx < len(current_split): latest_part = latest_split[idx] - version_part = version_split[idx] + current_part = current_split[idx] - if latest_part != version_part: - if RE_ANY_LETTER.findall(latest_part) or RE_ANY_LETTER.findall(version_part): - return latest_part > version_part - else: - dif = int(latest_part) - int(version_part) + if latest_part != current_part: + + try: + dif = int(latest_part) - int(current_part) if dif > 0: return True @@ -96,6 +94,14 @@ class ArchDataMapper: return False else: continue + + except ValueError: + if latest_part.isdigit(): + return True + elif current_part.isdigit(): + return False + else: + return latest_part > current_part return False def fill_package_build(self, pkg: ArchPackage): diff --git a/tests/gems/arch/arch_data_mapper_test.py b/tests/gems/arch/arch_data_mapper_test.py index 3aaf4a4a..6dfb42c8 100644 --- a/tests/gems/arch/arch_data_mapper_test.py +++ b/tests/gems/arch/arch_data_mapper_test.py @@ -24,6 +24,9 @@ class ArchDataMapperTest(TestCase): self.assertFalse(ArchDataMapper.check_update('77.0.3865.120-1', '77.0.3865.90-1')) self.assertTrue(ArchDataMapper.check_update('77.0.3865.a-1', '77.0.3865.b-1')) self.assertFalse(ArchDataMapper.check_update('77.0.b.0-1', '77.0.a.1-1')) + self.assertFalse(ArchDataMapper.check_update('r25.e22697c-1', 'r8.19fe011-1')) + self.assertFalse(ArchDataMapper.check_update('1.1.0.r11.caacf30-1', 'r65.4c7144a-1')) + self.assertFalse(ArchDataMapper.check_update('1.2.16.r688.8b2c199-1', 'r2105.e91f0e9-3')) def test_check_update_no_suffix_3_x_2_digits(self): self.assertTrue(ArchDataMapper.check_update('1.0.0-1', '1.1-1'))