From 40ccfeb2796754586e2171f9fa957be101922e4f Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 6 Jun 2024 12:01:40 +0300 Subject: [PATCH] Added for package type Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 1 + configs/slpkg.toml | 3 +++ slpkg/configs.py | 2 ++ slpkg/dialog_configs.py | 5 ++++- slpkg/install_data.py | 2 +- slpkg/multi_process.py | 2 +- tests/test_configs.py | 1 + 7 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 299e013b..fc0288a5 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -5,6 +5,7 @@ - Added: * Added PACKAGE_METHOD config to choose the upgrade method * Added DOWNGRADE_PACKAGES config to allow to downgrade packages (Thanks to marav) + * Added PACKAGE_TYPE config if you prefer to add your own binary type - Updated: * Updated message for invalid package version diff --git a/configs/slpkg.toml b/configs/slpkg.toml index dfc88724..e9744416 100644 --- a/configs/slpkg.toml +++ b/configs/slpkg.toml @@ -15,6 +15,9 @@ DOWNLOAD_ONLY_PATH = "/tmp/slpkg/" # Change here if you are going to use '.sqf' files. FILE_LIST_SUFFIX = ".pkgs" +# List of suffixes for binary packages. +PACKAGE_TYPE = [".tgz", ".txz"] + # Configs for displaying colorful menu. Default is true. [true/false] COLORS = true diff --git a/slpkg/configs.py b/slpkg/configs.py index ee0b06ad..54c5eb3d 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -36,6 +36,7 @@ class Configs: # pylint: disable=[R0902] os_arch: str = platform.machine() file_list_suffix: str = '.pkgs' + package_type = [".tgz", ".txz"] installpkg: str = 'upgradepkg --install-new' reinstall: str = 'upgradepkg --reinstall' removepkg: str = 'removepkg' @@ -86,6 +87,7 @@ class Configs: # pylint: disable=[R0902] os_arch: str = config['os_arch'] file_list_suffix: str = config['file_list_suffix'] + package_type = config['package_type'] installpkg: str = config['installpkg'] reinstall: str = config['reinstall'] removepkg: str = config['removepkg'] diff --git a/slpkg/dialog_configs.py b/slpkg/dialog_configs.py index 72768dbe..2c4f2f57 100644 --- a/slpkg/dialog_configs.py +++ b/slpkg/dialog_configs.py @@ -150,5 +150,8 @@ class FormConfigs(Configs): 'CHECKSUM_MD5 =') ): line: str = line.replace('"', '') - + elif line.lstrip().startswith('PACKAGE_TYPE ='): + line: str = line.replace('"[', '[') + line: str = line.replace(']"', ']') + line: str = line.replace("'", '"') patch_toml.write(line) diff --git a/slpkg/install_data.py b/slpkg/install_data.py index 52a3b232..bb6287f7 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -175,7 +175,7 @@ class InstallData(Configs): for line in checksums_md5: line = line.strip() - if line.endswith(('.txz', '.tgz')): + if line.endswith(tuple(self.package_type)): file: str = line.split('./')[1].split('/')[-1].strip() checksum: str = line.split('./')[0].strip() checksums_dict[file] = checksum diff --git a/slpkg/multi_process.py b/slpkg/multi_process.py index f9749656..9415cffa 100644 --- a/slpkg/multi_process.py +++ b/slpkg/multi_process.py @@ -53,7 +53,7 @@ class MultiProcess(Configs): # pylint: disable=[R0902] failed: str = f'{self.bred}{self.ascii.failed}{self.endc}' installed: str = '' - if filename.endswith(('.tgz', 'txz')) and not self.option_for_reinstall: + if filename.endswith(tuple(self.package_type)) and not self.option_for_reinstall: installed_package = self.log_packages.glob(filename[:-4]) for inst in installed_package: if inst.name == filename[:-4]: diff --git a/tests/test_configs.py b/tests/test_configs.py index 72d10f33..085d8b45 100644 --- a/tests/test_configs.py +++ b/tests/test_configs.py @@ -28,6 +28,7 @@ class TestConfigs(unittest.TestCase): self.assertEqual(Path('/var/log/slpkg/upgrade.log'), self.configs.upgrade_log_file) self.assertEqual('.pkgs', self.configs.file_list_suffix) + self.assertEqual(['.tgz', '.txz'], self.configs.package_type) self.assertEqual('upgradepkg --install-new', self.configs.installpkg) self.assertEqual('upgradepkg --reinstall', self.configs.reinstall) self.assertEqual('removepkg', self.configs.removepkg)