Updated for upgrade packages

This commit is contained in:
Dimitris Zlatanidis 2024-03-29 22:48:18 +02:00
parent 5f872f0ea1
commit ca1934be26
2 changed files with 21 additions and 9 deletions

View file

@ -1,9 +1,12 @@
## slpkg - ChangeLog
### 5.0.1 - 28/03/2024
### 5.0.1 - 29/03/2024
- Updated:
* Updated to check upgrade packages against all repositories (slpkg upgrade --repository='*' --check)
- Bugfixes:
* Upgrade packages for -current version (Thanks to Marav)
### 5.0.0 - 24/03/2024
- Updated:
* Blacklist using regex pattern

View file

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
from typing import Generator
from pkg_resources import parse_version
from packaging.version import parse
from pathlib import Path
from slpkg.configs import Configs
@ -62,31 +62,40 @@ class Upgrade(Configs):
def is_package_upgradeable(self, installed: str) -> bool:
inst_name: str = self.utils.split_package(installed)['name']
if self.data.get(inst_name):
repo_package: str = self.data[inst_name]['package'][:-4]
repo_version: str = self.data[inst_name]['version']
repo_build: str = self.data[inst_name]['build']
inst_version: str = self.utils.split_package(installed)['version']
inst_build: str = self.utils.split_package(installed)['build']
try:
if parse_version(repo_package) > parse_version(installed):
if parse(repo_version) > parse(inst_version):
return True
if parse(repo_version) == parse(inst_version):
if repo_build > inst_build:
return True
except ValueError:
return False
return False
def check_packages(self) -> None:
repo_data: dict = {}
found_packages: dict = {}
if self.repository == '*':
repo_data: dict = self.data
self.installed_packages: list = list(self.log_packages.glob('*'))
else:
self.load_installed_packages()
self.data[self.repository] = self.data
for repo, data in self.data.items():
repo_data[self.repository] = self.data
for repo, data in repo_data.items():
for installed in self.installed_packages:
name: str = self.utils.split_package(installed.name)['name']
if data.get(name):
repo_package: str = data[name]['package'][:-4]
self.data: dict = data
if parse_version(repo_package) > parse_version(installed.name):
if self.is_package_upgradeable(installed.name):
self.id += 1
self.sum_upgrade += 1
inst_version: str = self.utils.split_package(installed.name)['version']