Updated for split package

This commit is contained in:
Dimitris Zlatanidis 2023-05-11 12:41:38 +03:00
parent 394ef51938
commit 3f67ef083f
9 changed files with 147 additions and 122 deletions

View file

@ -111,7 +111,7 @@ class Packages(Configs):
self.utils.remove_file_if_exists(self.tmp_slpkg, package)
else:
installed_package: str = self.utils.is_package_installed(pkg)
installed_version: str = self.utils.split_binary_pkg(installed_package)[1]
installed_version: str = self.utils.split_package(installed_package)['version']
self.view_message.view_skipping_packages(pkg, installed_version)
self.download_the_binary_packages(package_urls)
@ -141,7 +141,7 @@ class Packages(Configs):
def checksum_binary_packages(self) -> None:
md5 = Md5sum(self.flags)
for package in self.binary_packages:
name: str = self.utils.split_binary_pkg(Path(package).stem)[0]
name: str = self.utils.split_package(Path(package).stem)['name']
pkg_checksum: str = self.data[name][10]
md5.check(self.tmp_slpkg, package, pkg_checksum)
@ -161,7 +161,7 @@ class Packages(Configs):
self.multi_process(command, package, message)
if not self.option_for_resolve_off:
name: str = self.utils.split_binary_pkg(Path(package).stem)[0]
name: str = self.utils.split_package(Path(package).stem)['name']
self.logs_deps.logging(name)
def multi_process(self, command: str, filename: str, message: str) -> None:

View file

@ -162,14 +162,15 @@ class InstallData(Configs):
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
package = line.replace(pkg_tag[0], '').strip()
name: str = self.utils.split_package(package)['name']
version: str = self.utils.split_package(package)['version']
cache.append(name)
cache.append(version)
cache.append(package)
cache.append(mirror)
try:
cache.append(checksums_dict[package_name])
cache.append(checksums_dict[package])
except KeyError:
cache.append('error checksum')
@ -252,14 +253,15 @@ class InstallData(Configs):
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
package = line.replace(pkg_tag[0], '').strip()
name: str = self.utils.split_package(package)['name']
version: str = self.utils.split_package(package)['version']
cache.append(name)
cache.append(version)
cache.append(package)
cache.append(mirror)
try:
cache.append(checksums_dict[package_name])
cache.append(checksums_dict[package])
except KeyError:
cache.append('error checksum')
@ -342,14 +344,15 @@ class InstallData(Configs):
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
package = line.replace(pkg_tag[0], '').strip()
name: str = self.utils.split_package(package)['name']
version: str = self.utils.split_package(package)['version']
cache.append(name)
cache.append(version)
cache.append(package)
cache.append(mirror)
try:
cache.append(checksums_dict[package_name])
cache.append(checksums_dict[package])
except KeyError:
cache.append('error checksum')
@ -433,14 +436,15 @@ class InstallData(Configs):
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
package = line.replace(pkg_tag[0], '').strip()
name: str = self.utils.split_package(package)['name']
version: str = self.utils.split_package(package)['version']
cache.append(name)
cache.append(version)
cache.append(package)
cache.append(mirror)
try:
cache.append(checksums_dict[package_name])
cache.append(checksums_dict[package])
except KeyError:
cache.append('error checksum')
@ -528,14 +532,15 @@ class InstallData(Configs):
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
package = line.replace(pkg_tag[0], '').strip()
name: str = self.utils.split_package(package)['name']
version: str = self.utils.split_package(package)['version']
cache.append(name) # package name
cache.append(version) # package version
cache.append(package)
cache.append(mirror)
try:
cache.append(checksums_dict[package_name])
cache.append(checksums_dict[package])
except KeyError:
cache.append('error checksum')
@ -618,14 +623,15 @@ class InstallData(Configs):
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
package = line.replace(pkg_tag[0], '').strip()
name: str = self.utils.split_package(package)['name']
version: str = self.utils.split_package(package)['version']
cache.append(name)
cache.append(version)
cache.append(package)
cache.append(mirror)
try:
cache.append(checksums_dict[package_name])
cache.append(checksums_dict[package])
except KeyError:
cache.append('error checksum')
@ -709,14 +715,15 @@ class InstallData(Configs):
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
package = line.replace(pkg_tag[0], '').strip()
name: str = self.utils.split_package(package)['name']
version: str = self.utils.split_package(package)['version']
cache.append(name)
cache.append(version)
cache.append(package)
cache.append(mirror)
try:
cache.append(checksums_dict[package_name])
cache.append(checksums_dict[package])
except KeyError:
cache.append('error checksum')
@ -799,14 +806,15 @@ class InstallData(Configs):
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
package = line.replace(pkg_tag[0], '').strip()
name: str = self.utils.split_package(package)['name']
version: str = self.utils.split_package(package)['version']
cache.append(name)
cache.append(version)
cache.append(package)
cache.append(mirror)
try:
cache.append(checksums_dict[package_name])
cache.append(checksums_dict[package])
except KeyError:
cache.append('error checksum')
@ -889,14 +897,15 @@ class InstallData(Configs):
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
package = line.replace(pkg_tag[0], '').strip()
name: str = self.utils.split_package(package)['name']
version: str = self.utils.split_package(package)['version']
cache.append(name)
cache.append(version)
cache.append(package)
cache.append(mirror)
try:
cache.append(checksums_dict[package_name])
cache.append(checksums_dict[package])
except KeyError:
cache.append('error checksum')
@ -980,14 +989,15 @@ class InstallData(Configs):
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name: str = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
package: str = line.replace(pkg_tag[0], '').strip()
name: str = self.utils.split_package(package)['name']
version: str = self.utils.split_package(package)['version']
cache.append(name)
cache.append(version)
cache.append(package)
cache.append(mirror)
try:
cache.append(checksums_dict[package_name])
cache.append(checksums_dict[package])
except KeyError:
cache.append('error checksum')
@ -1071,14 +1081,15 @@ class InstallData(Configs):
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
package = line.replace(pkg_tag[0], '').strip()
name: str = self.utils.split_package(package)['name']
version: str = self.utils.split_package(package)['version']
cache.append(name)
cache.append(version)
cache.append(package)
cache.append(mirror)
try:
cache.append(checksums_dict[package_name])
cache.append(checksums_dict[package])
except KeyError:
cache.append('error checksum')
@ -1167,14 +1178,15 @@ class InstallData(Configs):
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
package = line.replace(pkg_tag[0], '').strip()
name: str = self.utils.split_package(package)['name']
version: str = self.utils.split_package(package)['version']
cache.append(name)
cache.append(version)
cache.append(package)
cache.append(mirror)
try:
cache.append(checksums_dict[package_name])
cache.append(checksums_dict[package])
except KeyError:
cache.append('error checksum')
@ -1272,14 +1284,15 @@ class InstallData(Configs):
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
package = line.replace(pkg_tag[0], '').strip()
name: str = self.utils.split_package(package)['name']
version: str = self.utils.split_package(package)['version']
cache.append(name)
cache.append(version)
cache.append(package)
cache.append(mirror)
try:
cache.append(checksums_dict[package_name])
cache.append(checksums_dict[package])
except KeyError:
cache.append('error checksum')
@ -1377,14 +1390,15 @@ class InstallData(Configs):
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
package = line.replace(pkg_tag[0], '').strip()
name: str = self.utils.split_package(package)['name']
version: str = self.utils.split_package(package)['version']
cache.append(name)
cache.append(version)
cache.append(package)
cache.append(mirror)
try:
cache.append(checksums_dict[package_name])
cache.append(checksums_dict[package])
except KeyError:
cache.append('error checksum')
@ -1481,14 +1495,15 @@ class InstallData(Configs):
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
package = line.replace(pkg_tag[0], '').strip()
name: str = self.utils.split_package(package)['name']
version: str = self.utils.split_package(package)['version']
cache.append(name)
cache.append(version)
cache.append(package)
cache.append(mirror)
try:
cache.append(checksums_dict[package_name])
cache.append(checksums_dict[package])
except KeyError:
cache.append('error checksum')
@ -1585,14 +1600,15 @@ class InstallData(Configs):
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
package = line.replace(pkg_tag[0], '').strip()
name: str = self.utils.split_package(package)['name']
version: str = self.utils.split_package(package)['version']
cache.append(name) # package name
cache.append(version) # package version
cache.append(package)
cache.append(mirror)
try:
cache.append(checksums_dict[package_name])
cache.append(checksums_dict[package])
except KeyError:
cache.append('error checksum')

View file

@ -444,11 +444,12 @@ class Argparse(Configs):
installed: list = list(self.utils.installed_packages.values())
for package in installed:
split_package: list = self.utils.split_binary_pkg(package)
package_name: str = self.utils.split_package(package)['name']
package_version: str = self.utils.split_package(package)['version']
for pkg in packages:
if pkg in package or pkg == '*':
choices.extend([(split_package[0], split_package[1], False, f'Package: {package}')])
choices.extend([(package_name, package_version, False, f'Package: {package}')])
elif method == 'upgrade':
for pkg in packages:
@ -456,12 +457,13 @@ class Argparse(Configs):
if pkg == package:
inst_pkg: str = self.utils.is_package_installed(package)
split_inst_pkg: list = self.utils.split_binary_pkg(inst_pkg)
inst_package_version: str = self.utils.split_package(inst_pkg)['version']
inst_package_build: str = self.utils.split_package(inst_pkg)['build']
if self.is_binary:
repo_ver: str = self.data[package][0]
bin_pkg: str = self.data[package][1]
repo_build_tag: str = self.utils.split_binary_pkg(bin_pkg[:-4])[3]
repo_build_tag: str = self.utils.split_package(bin_pkg[:-4])['build']
else:
repo_ver: str = self.data[package][2]
repo_location: str = self.data[package][0]
@ -469,8 +471,8 @@ class Argparse(Configs):
package, repo_location, self.repository
)
choices.extend([(package, f'{split_inst_pkg[1]} -> {repo_ver}', True,
f'Installed: {package}-{split_inst_pkg[1]} Build: {split_inst_pkg[3]} -> '
choices.extend([(package, f'{inst_package_version} -> {repo_ver}', True,
f'Installed: {package}-{inst_package_version} Build: {inst_package_build} -> '
f'Available: {repo_ver} Build: {repo_build_tag}')])
else:
for pkg in packages:

View file

@ -92,7 +92,7 @@ class RemovePackages(Configs):
def remove_packages(self) -> None:
for package in self.installed_packages:
command: str = f'{self.removepkg} {package}'
name: str = self.utils.split_binary_pkg(package)[0]
name: str = self.utils.split_package(package)['name']
self.process_message: str = f"package '{name}' to remove"
dependencies: list = self.is_dependency(name)
@ -147,7 +147,7 @@ class RemovePackages(Configs):
for package in self.dependencies:
inst_pkg: str = self.utils.is_package_installed(package)
inst_ver: str = self.utils.split_binary_pkg(inst_pkg)[1]
inst_ver: str = self.utils.split_package(inst_pkg)['version']
choices.extend([(package, inst_ver, True, f'Package: {inst_pkg}')])
text: str = f'There are {len(choices)} dependencies:'

View file

@ -211,7 +211,7 @@ class Slackbuilds(Configs):
self.logs_deps.logging(sbo)
else:
installed_package: str = self.utils.is_package_installed(sbo)
installed_version: str = self.utils.split_binary_pkg(installed_package)[1]
installed_version: str = self.utils.split_package(installed_package)['version']
self.view_message.view_skipping_packages(sbo, installed_version)
def patch_slackbuild_tag(self, sbo: str) -> None:

View file

@ -46,13 +46,13 @@ class Upgrade(Configs):
inst_package: str = self.utils.is_package_installed(name)
if inst_package and inst_package.endswith(self.repos.repositories[self.repository][6]):
inst_package_version: str = self.utils.split_binary_pkg(inst_package)[1]
inst_package_build: str = self.utils.split_binary_pkg(inst_package)[3]
inst_package_version: str = self.utils.split_package(inst_package)['version']
inst_package_build: str = self.utils.split_package(inst_package)['build']
if self.is_binary and self.data.get(name):
repo_package_version: str = self.data[name][0]
repo_package: str = self.data[name][1]
repo_package_build: str = self.utils.split_binary_pkg(repo_package)[3]
repo_package_build: str = self.utils.split_package(repo_package)['build']
else:
repo_package_version: str = self.data[name][2]
repo_location: str = self.data[name][0]

View file

@ -44,7 +44,7 @@ class Utilities(Configs):
def all_installed(self) -> dict:
""" Return all installed packages from /val/log/packages folder. """
for file in self.log_packages.glob(self.file_pattern):
name: str = self.split_binary_pkg(file.name)[0]
name: str = self.split_package(file.name)[0]
if not name.startswith('.') and not self.blacklist_pattern(name):
yield name, file.name
@ -69,7 +69,7 @@ class Utilities(Configs):
directory.mkdir(parents=True, exist_ok=True)
@staticmethod
def split_binary_pkg(package: str) -> list:
def split_package(package: str) -> dict:
""" Split the package by the name, version, arch, build and tag. """
name: str = '-'.join(package.split('-')[:-3])
version: str = ''.join(package[len(name):].split('-')[:-2])
@ -78,7 +78,15 @@ class Utilities(Configs):
build: str = ''.join(re.findall(r'\d+', build_tag[:2]))
pkg_tag: str = build_tag[len(build):]
return [name, version, arch, build, pkg_tag]
split: dict = {
'name': name,
'version': version,
'arch': arch,
'build': build,
'tag': pkg_tag
}
return split
# return [name, version, arch, build, pkg_tag]
def finished_time(self, elapsed_time: float) -> None:
""" Printing the elapsed time. """

View file

@ -165,9 +165,8 @@ class ViewMessage(Configs):
def view_remove_package(self, package: str) -> None:
installed = self.utils.is_package_installed(package)
pkg: list = self.utils.split_binary_pkg(installed)
version: str = pkg[1]
repo_tag: str = pkg[4]
version: str = self.utils.split_package(installed)['version']
repo_tag: str = self.utils.split_package(installed)['tag']
size: str = self.utils.get_file_size(Path(self.log_packages, installed))
repository = repo_tag.lower().replace('_', '')
@ -245,7 +244,7 @@ class ViewMessage(Configs):
def build_package_and_version(self, package: str) -> str:
installed_package: str = self.utils.is_package_installed(package)
version: str = self.utils.split_binary_pkg(installed_package)[1]
version: str = self.utils.split_package(installed_package)['version']
return f'{package}-{version}'
def view_skipping_packages(self, package: str, version: str) -> None:

View file

@ -19,16 +19,16 @@ class TestUtilities(unittest.TestCase):
self.assertEqual(self.package, self.utils.is_package_installed('aaa_base'))
def test_split_name(self):
self.assertEqual('aaa_base', self.utils.split_binary_pkg(self.package)[0])
self.assertEqual('aaa_base', self.utils.split_package(self.package)['name'])
def test_split_version(self):
self.assertEqual('15.0', self.utils.split_binary_pkg(self.package)[1])
self.assertEqual('15.0', self.utils.split_package(self.package)['version'])
def test_split_arch(self):
self.assertEqual('x86_64', self.utils.split_binary_pkg(self.package)[2])
self.assertEqual('x86_64', self.utils.split_package(self.package)['arch'])
def test_split_build(self):
self.assertEqual('4', self.utils.split_binary_pkg(self.package)[3])
self.assertEqual('4', self.utils.split_package(self.package)['build'])
def test_is_installed(self):
self.assertEqual(self.package, self.utils.is_package_installed('aaa_base'))