From df8b76d190acf0b930412665a20f24ba1191c699 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 14 Mar 2023 11:31:05 +0200 Subject: [PATCH] Fixed check adn the build tag --- slpkg/utilities.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/slpkg/utilities.py b/slpkg/utilities.py index 137eb710..fcb23ca3 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- +import re import time import shutil from pathlib import Path @@ -100,13 +101,30 @@ class Utilities: installed = self.is_package_installed(package, file_pattern) repository_version = str(SBoQueries(package).version()) + repo_build_tag = self.read_build_tag(package) + inst_build_tag = self.split_installed_pkg(installed)[3] + if not repository_version: repository_version: str = '0' if installed: installed_version: str = self.split_installed_pkg(installed)[1] - return str(LooseVersion(repository_version)) > str(LooseVersion(installed_version)) + return (str(LooseVersion(repository_version + repo_build_tag)) > + str(LooseVersion(installed_version + inst_build_tag))) + + def read_build_tag(self, sbo: str) -> str: + """ Patching SBo TAG from the configuration file. """ + location: str = SBoQueries(sbo).location() + sbo_script = Path(self.configs.sbo_repo_path, location, sbo, f'{sbo}.SlackBuild') + + if sbo_script.is_file(): + with open(sbo_script, 'r', encoding='utf-8') as f: + lines = f.readlines() + + for line in lines: + if line.startswith('BUILD=$'): + return ''.join(re.findall(r'\d+', line)) @staticmethod def is_option(flag: list, flags: list) -> Any: