Fixed check adn the build tag

This commit is contained in:
Dimitris Zlatanidis 2023-03-14 11:31:05 +02:00
parent 28e82b7c2f
commit df8b76d190

View file

@ -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: