Updated for kernel version

This commit is contained in:
Dimitris Zlatanidis 2024-04-15 19:43:49 +03:00
parent 55ed84b475
commit 9c7ff2172c
6 changed files with 21 additions and 4 deletions

View file

@ -6,6 +6,7 @@
- Added:
* Added to support custom repositories
* Added KERNEL_VERSION config to handle custom slackbuild version
### 5.0.5 - 12/04/2024
- Added:

View file

@ -52,6 +52,12 @@ ASCII_CHARACTERS = true
# not work. Default is true. [true/false].
ASK_QUESTION = true
# This config removes the kernel version from some slackbuilds custom
# version build, like nvidia-kernel and virtualbox-kernel slackbuild packages.
# It helps to compare install and repository versions.
# Default is true. [true/false].
KERNEL_VERSION = true
# Download sources in parallel. Default is false. [true/false]
# Alternatively, you can use the option '--parallel'.
PARALLEL_DOWNLOADS = false

View file

@ -81,6 +81,7 @@ class Configs:
os_arch: str = config['os_arch']
download_only_path: Path = Path(config['download_only_path'])
ask_question: bool = config['ask_question']
kernel_version: str = config['kernel_version']
installpkg: str = config['installpkg']
reinstall: str = config['reinstall']
removepkg: str = config['removepkg']

View file

@ -38,7 +38,7 @@ class FormConfigs(Configs):
title: str = ' Configuration File '
# Creating the elements for the dialog form.
for i, (key, value) in enumerate(self.configs['CONFIGS'].items(), start=1):
for i, (key, value) in enumerate(self.configs['configs'].items(), start=1):
if value is True:
value: str = 'true'
elif value is False:
@ -76,6 +76,7 @@ class FormConfigs(Configs):
'SILENT_MODE',
'ASCII_CHARACTERS',
'ASK_QUESTION',
'KERNEL_VERSION',
'PARALLEL_DOWNLOADS',
'PROGRESS_BAR',
'SPINNING_BAR',
@ -90,7 +91,7 @@ class FormConfigs(Configs):
]
values: list = ['true', 'false']
for key, value in zip(self.configs['CONFIGS'].keys(), tags):
for key, value in zip(self.configs['configs'].keys(), tags):
if key in keys and value not in values:
self.dialogbox.msgbox(f"\nError: Value for '{key}', it must be 'true' or 'false.'\n",
@ -115,7 +116,7 @@ class FormConfigs(Configs):
with open(self.config_file, 'w') as patch_toml:
for line in self.orig_configs:
for key, value in zip(self.configs['CONFIGS'].keys(), tags):
for key, value in zip(self.configs['configs'].keys(), tags):
if line.lstrip().startswith(f'{key} ='):
line = f' {key} = "{value}"\n'
@ -127,6 +128,7 @@ class FormConfigs(Configs):
'SILENT_MODE =',
'ASCII_CHARACTERS =',
'ASK_QUESTION =',
'KERNEL_VERSION =',
'PARALLEL_DOWNLOADS =',
'MAXIMUM_PARALLEL = ',
'PROGRESS_BAR =',

View file

@ -2,9 +2,10 @@
# -*- coding: utf-8 -*-
import shutil
import platform
from pathlib import Path
from typing import Generator
from packaging.version import parse, InvalidVersion
from pathlib import Path
from slpkg.configs import Configs
from slpkg.utilities import Utilities
@ -31,6 +32,7 @@ class Upgrade(Configs):
self.installed_names: list = []
self.installed_packages: list = []
self.kernel_ver: str = platform.uname()[2]
self.columns, self.rows = shutil.get_terminal_size()
def load_installed_packages(self, repository: str) -> None:
@ -89,7 +91,11 @@ class Upgrade(Configs):
if self.data.get(inst_name):
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']
if self.kernel_version and self.repository in [self.repos.sbo_repo_name, self.repos.ponce_repo_name]:
inst_version: str = inst_version.replace(f'_{self.kernel_ver}', '')
inst_build: str = self.utils.split_package(installed)['build']
try:
if parse(repo_version) > parse(inst_version):

View file

@ -42,6 +42,7 @@ class TestConfigs(unittest.TestCase):
self.assertEqual('-c mirror --parallel=100 --only-newer --delete', self.configs.lftp_mirror_options)
self.assertEqual(True, self.configs.ascii_characters)
self.assertEqual(True, self.configs.ask_question)
self.assertEqual(True, self.configs.kernel_version)
self.assertEqual(False, self.configs.parallel_downloads)
self.assertEqual(5, self.configs.maximum_parallel)
self.assertEqual(True, self.configs.progress_bar)