From 7061252688089a1f42503a67915e01e26bfbaf5a Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 19 Oct 2022 19:55:45 +0300 Subject: [PATCH] Update configs for sbo repository Signed-off-by: Dimitris Zlatanidis --- configs/slpkg.yml | 6 +++--- slpkg/checks.py | 4 ++-- slpkg/configs.py | 12 ++++++------ slpkg/download_only.py | 4 ++-- slpkg/find_installed.py | 4 ++-- slpkg/slackbuild.py | 6 ++---- slpkg/upgrade.py | 4 ++-- slpkg/views/views.py | 4 ++-- tests/test_configs.py | 12 ++++++------ 9 files changed, 27 insertions(+), 29 deletions(-) diff --git a/configs/slpkg.yml b/configs/slpkg.yml index de2c1d61..27632e2d 100644 --- a/configs/slpkg.yml +++ b/configs/slpkg.yml @@ -13,9 +13,9 @@ configs: repo_version: 15.0 sbo_url: http://slackbuilds.org/slackbuilds/15.0 sbo_txt: SLACKBUILDS.TXT - tar_suffix: .tar.gz - pkg_suffix: .tgz - repo_tag: _SBo + sbo_tar_suffix: .tar.gz + sbo_pkg_suffix: .tgz + sbo_repo_tag: _SBo installpkg: upgradepkg --install-new reinstall: upgradepkg --reinstall removepkg: removepkg diff --git a/slpkg/checks.py b/slpkg/checks.py index 53b95a5f..4a701292 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -13,7 +13,7 @@ from slpkg.blacklist import Blacklist class Check: ''' Some checks before proceed. ''' log_packages: str = Configs.log_packages - repo_tag: str = Configs.repo_tag + sbo_repo_tag: str = Configs.sbo_repo_tag def exists(self, slackbuilds: list): ''' Checking if the slackbuild exists in the repository. ''' @@ -42,7 +42,7 @@ class Check: for package in os.listdir(self.log_packages): for sbo in slackbuilds: - if sbo + '-' in package and self.repo_tag in package: + if sbo + '-' in package and self.sbo_repo_tag in package: return raise SystemExit('\nNot found installed packages.\n') diff --git a/slpkg/configs.py b/slpkg/configs.py index 6bf64405..b8e59759 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -36,9 +36,9 @@ class Configs: repo_version: str = '15.0' sbo_url: str = f'http://slackbuilds.org/slackbuilds/{repo_version}' sbo_txt: str = 'SLACKBUILDS.TXT' - tar_suffix: str = '.tar.gz' - pkg_suffix: str = '.tgz' - repo_tag: str = '_SBo' + sbo_tar_suffix: str = '.tar.gz' + sbo_pkg_suffix: str = '.tgz' + sbo_repo_tag: str = '_SBo' # Slackware commands installpkg: str = 'upgradepkg --install-new' @@ -83,9 +83,9 @@ class Configs: repo_version: str = config['repo_version'] sbo_url: str = config['sbo_url'] sbo_txt: str = config['sbo_txt'] - tar_suffix: str = config['tar_suffix'] - pkg_suffix: str = config['pkg_suffix'] - repo_tag: str = config['repo_tag'] + sbo_tar_suffix: str = config['tar_suffix'] + sbo_pkg_suffix: str = config['pkg_suffix'] + sbo_repo_tag: str = config['repo_tag'] # Slackware commands installpkg: str = config['installpkg'] diff --git a/slpkg/download_only.py b/slpkg/download_only.py index 38f7492b..b0c865dc 100644 --- a/slpkg/download_only.py +++ b/slpkg/download_only.py @@ -17,7 +17,7 @@ class Download: session: str = Session download_only = Configs.download_only sbo_url: str = Configs.sbo_url - tar_suffix: str = Configs.tar_suffix + sbo_tar_suffix: str = Configs.sbo_tar_suffix def packages(self, slackbuilds: list): @@ -27,7 +27,7 @@ class Download: wget = Wget() for sbo in slackbuilds: - file = f'{sbo}{self.tar_suffix}' + file = f'{sbo}{self.sbo_tar_suffix}' location = SBoQueries(sbo).location() url = f'{self.sbo_url}/{location}/{file}' diff --git a/slpkg/find_installed.py b/slpkg/find_installed.py index 7e41e345..f3ea255c 100644 --- a/slpkg/find_installed.py +++ b/slpkg/find_installed.py @@ -11,13 +11,13 @@ from slpkg.configs import Configs class FindInstalled: log_packages: str = Configs.log_packages colors: dict = Configs.colour - repo_tag: str = Configs.repo_tag + sbo_repo_tag: str = Configs.sbo_repo_tag def find(self, packages: list): matching = [] for pkg in packages: for package in os.listdir(self.log_packages): - if pkg in package and self.repo_tag in package: + if pkg in package and self.sbo_repo_tag in package: matching.append(package) self.matched(matching) diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py index 00c04553..09697251 100644 --- a/slpkg/slackbuild.py +++ b/slpkg/slackbuild.py @@ -32,9 +32,7 @@ class Slackbuilds: build_path: str = Configs.build_path tmp_slpkg: str = Configs.tmp_slpkg tmp_path: str = Configs.tmp_path - tar_suffix: str = Configs.tar_suffix - repo_tag: str = Configs.repo_tag - pkg_suffix: str = Configs.pkg_suffix + sbo_tar_suffix: str = Configs.sbo_tar_suffix installpkg: str = Configs.installpkg reinstall: str = Configs.reinstall @@ -98,7 +96,7 @@ class Slackbuilds: wget = Wget() for sbo in self.install_order: - file = f'{sbo}{self.tar_suffix}' + file = f'{sbo}{self.sbo_tar_suffix}' self.utils.remove_file_if_exists(self.tmp_slpkg, file) self.utils.remove_folder_if_exists(self.build_path, sbo) diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index c6b112d0..9045bda7 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -12,12 +12,12 @@ from slpkg.queries import SBoQueries @dataclass class Upgrade: log_packages: str = Configs.log_packages - repo_tag: str = Configs.repo_tag + sbo_repo_tag: str = Configs.sbo_repo_tag def packages(self): ''' Compares version of packages and returns the maximum. ''' for pkg in os.listdir(self.log_packages): - if pkg.endswith(self.repo_tag): + if pkg.endswith(self.sbo_repo_tag): name = '-'.join(pkg.split('-')[:-3]) installed_ver = pkg.replace(name + '-', '').split('-')[0] repo_ver = SBoQueries(name).version() diff --git a/slpkg/views/views.py b/slpkg/views/views.py index 90e3741a..6b0f7f39 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -17,7 +17,7 @@ class ViewMessage: flags: list colors: dict = Configs.colour log_packages: str = Configs.log_packages - repo_tag: str = Configs.repo_tag + sbo_repo_tag: str = Configs.sbo_repo_tag arch: str = Configs.os_arch session: str = Session utils: str = Utilities() @@ -131,7 +131,7 @@ class ViewMessage: for package in installed: black = package.split('-')[0] - if (package.startswith(name) and self.repo_tag in package and + if (package.startswith(name) and self.sbo_repo_tag in package and black not in self.black.get()): self.installed_packages.append(package) print(f'[{color["RED"]} delete {color["ENDC"]}] -> {package}') diff --git a/tests/test_configs.py b/tests/test_configs.py index 0f35d22c..9b3fc51a 100644 --- a/tests/test_configs.py +++ b/tests/test_configs.py @@ -7,9 +7,9 @@ class TestConfigs(unittest.TestCase): def setUp(self): self.repo_version = Configs.repo_version self.sbo_txt = Configs.sbo_txt - self.tar_suffix = Configs.tar_suffix - self.pkg_suffix = Configs.pkg_suffix - self.repo_tag = Configs.repo_tag + self.sbo_tar_suffix = Configs.sbo_tar_suffix + self.sbo_pkg_suffix = Configs.sbo_pkg_suffix + self.sbo_repo_tag = Configs.sbo_repo_tag self.os_arch = Configs.os_arch def test_repo_version(self): @@ -19,13 +19,13 @@ class TestConfigs(unittest.TestCase): self.assertEqual('SLACKBUILDS.TXT', self.sbo_txt) def test_tar_suffix(self): - self.assertEqual('.tar.gz', self.tar_suffix) + self.assertEqual('.tar.gz', self.sbo_tar_suffix) def test_pkg_suffix(self): - self.assertEqual('.tgz', self.pkg_suffix) + self.assertEqual('.tgz', self.sbo_pkg_suffix) def test_repo_tag(self): - self.assertEqual('_SBo', self.repo_tag) + self.assertEqual('_SBo', self.sbo_repo_tag) def test_os_arch(self): self.assertEqual('x86_64', self.os_arch)