mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-02-06 08:46:21 +01:00
Added split package method
Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
parent
bf45160027
commit
478b5ab8fa
3 changed files with 20 additions and 9 deletions
|
@ -14,6 +14,7 @@ class Check:
|
|||
|
||||
def __init__(self):
|
||||
self.configs = Configs
|
||||
self.utils = Utilities()
|
||||
|
||||
@staticmethod
|
||||
def exists(slackbuilds: list):
|
||||
|
@ -37,16 +38,14 @@ class Check:
|
|||
if 'UNSUPPORTED' in sources:
|
||||
raise SystemExit(f"\nPackage '{sbo}' unsupported by arch.\n")
|
||||
|
||||
@staticmethod
|
||||
def installed(slackbuilds: list):
|
||||
def installed(self, slackbuilds: list):
|
||||
""" Checking for installed packages. """
|
||||
found, not_found = [], []
|
||||
utils = Utilities()
|
||||
|
||||
for sbo in slackbuilds:
|
||||
package = utils.is_installed(sbo)
|
||||
package = self.utils.is_installed(sbo)
|
||||
if package:
|
||||
pkg = '-'.join(package.split('-')[:-3])
|
||||
pkg = self.utils.split_installed_pkg(package)[0]
|
||||
found.append(pkg)
|
||||
else:
|
||||
not_found.append(sbo)
|
||||
|
|
|
@ -6,6 +6,7 @@ from distutils.version import LooseVersion
|
|||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.queries import SBoQueries
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.blacklist import Blacklist
|
||||
|
||||
|
||||
|
@ -14,6 +15,7 @@ class Upgrade:
|
|||
|
||||
def __init__(self):
|
||||
self.configs = Configs
|
||||
self.utils = Utilities()
|
||||
|
||||
def packages(self):
|
||||
""" Compares version of packages and returns the maximum. """
|
||||
|
@ -23,13 +25,14 @@ class Upgrade:
|
|||
black = Blacklist().get()
|
||||
|
||||
for pkg in os.listdir(self.configs.log_packages):
|
||||
inst_pkg_name = '-'.join(pkg.split('-')[:-3])
|
||||
inst_pkg_name = self.utils.split_installed_pkg(pkg)[0]
|
||||
|
||||
if (pkg.endswith(self.configs.sbo_repo_tag)
|
||||
and inst_pkg_name not in black):
|
||||
|
||||
if inst_pkg_name in repo_packages:
|
||||
installed_ver = pkg.replace(f'{inst_pkg_name}-', '').split('-')[0]
|
||||
installed_ver = self.utils.split_installed_pkg(pkg)[1]
|
||||
repo_ver = SBoQueries(inst_pkg_name).version()
|
||||
|
||||
if LooseVersion(repo_ver) > LooseVersion(installed_ver):
|
||||
yield inst_pkg_name
|
||||
yield inst_pkg_name
|
|
@ -6,7 +6,6 @@ import os
|
|||
import shutil
|
||||
import tarfile
|
||||
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.blacklist import Blacklist
|
||||
|
||||
|
@ -52,3 +51,13 @@ class Utilities:
|
|||
directory = f'{path}/{folder}'
|
||||
if not os.path.isdir(directory):
|
||||
os.makedirs(directory)
|
||||
|
||||
def split_installed_pkg(self, package):
|
||||
""" Split the package by the name, version, arch, build and tag. """
|
||||
name = '-'.join(package.split('-')[:-3])
|
||||
version = ''.join(package[len(name):].split('-')[:-2])
|
||||
arch = ''.join(package[len(name + version) + 2:].split('-')[:-1])
|
||||
build = ''.join(package[len(name + version + arch) + 3:].split('-')).replace(self.configs.sbo_repo_tag, '')
|
||||
tag = ''.join(package[len(name + version + arch + build) + 4:].split('-'))
|
||||
|
||||
return [name, version, arch, build, tag]
|
||||
|
|
Loading…
Add table
Reference in a new issue