mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-24 19:58:31 +01:00
93a0059757
Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
32 lines
969 B
Python
32 lines
969 B
Python
#!/usr/bin/python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import os
|
|
from dataclasses import dataclass
|
|
from distutils.version import LooseVersion
|
|
|
|
from slpkg.configs import Configs
|
|
from slpkg.queries import SBoQueries
|
|
|
|
|
|
@dataclass
|
|
class Upgrade:
|
|
log_packages: str = Configs.log_packages
|
|
sbo_repo_tag: str = Configs.sbo_repo_tag
|
|
|
|
def packages(self):
|
|
''' Compares version of packages and returns the maximum. '''
|
|
print("Do not forget to run 'slpkg update' before.")
|
|
|
|
repo_packages = SBoQueries('').names()
|
|
|
|
for pkg in os.listdir(self.log_packages):
|
|
if pkg.endswith(self.sbo_repo_tag):
|
|
name = '-'.join(pkg.split('-')[:-3])
|
|
|
|
if name in repo_packages:
|
|
installed_ver = pkg.replace(name + '-', '').split('-')[0]
|
|
repo_ver = SBoQueries(name).version()
|
|
|
|
if LooseVersion(repo_ver) > LooseVersion(installed_ver):
|
|
yield name
|