Updated for gpg

This commit is contained in:
Dimitris Zlatanidis 2024-03-20 23:50:21 +02:00
parent 7b5a1983c6
commit 0c4c40781c
3 changed files with 14 additions and 3 deletions

View file

@ -12,6 +12,7 @@ from slpkg.upgrade import Upgrade
from slpkg.views.views import View
from slpkg.utilities import Utilities
from slpkg.dialog_box import DialogBox
from slpkg.gpg_verify import GPGVerify
from slpkg.downloader import Downloader
from slpkg.views.asciibox import AsciiBox
from slpkg.repositories import Repositories
@ -23,6 +24,7 @@ class Packages(Configs):
def __init__(self, repository: str, data: dict, packages: list, flags: list, mode: str):
super(Configs, self).__init__()
self.repository = repository
self.data: dict = data
self.packages: list = packages
self.flags: list = flags
@ -37,6 +39,7 @@ class Packages(Configs):
self.check_md5 = Md5sum(flags)
self.download = Downloader(flags)
self.ascii = AsciiBox()
self.gpg = GPGVerify()
self.dependencies: list = []
self.install_order: list = []
@ -53,7 +56,6 @@ class Packages(Configs):
self.packages: list = self.utils.apply_package_pattern(data, packages)
def execute(self) -> None:
# self.creating_dependencies_list()
self.creating_dependencies_list()
self.choose_package_dependencies()
self.add_dependencies_to_install_order()
@ -97,6 +99,7 @@ class Packages(Configs):
def crating_the_package_urls_list(self) -> None:
packages: dict = {}
asc_files: list = []
for pkg in self.install_order:
if self.continue_to_install(pkg):
@ -104,8 +107,13 @@ class Packages(Configs):
mirror: str = self.data[pkg]['mirror']
location: str = self.data[pkg]['location']
url: list = [f'{mirror}{location}/{package}']
asc_url: list = [f'{mirror}{location}/{package}.asc']
asc_file: Path = Path(self.tmp_slpkg, f'{package}.asc')
packages[pkg] = (url, self.tmp_slpkg)
if self.gpg_verification:
packages[f'{pkg}.asc'] = (asc_url, self.tmp_slpkg)
asc_files.append(asc_file)
self.binary_packages.append(package)
self.utils.remove_file_if_exists(self.tmp_slpkg, package)
@ -114,6 +122,9 @@ class Packages(Configs):
self.view.skipping_packages(installed_package)
self.download_the_binary_packages(packages)
if self.gpg_verification:
self.gpg.verify(asc_files)
print()
def download_the_binary_packages(self, packages: dict) -> None:
if packages:

View file

@ -32,7 +32,7 @@ class GPGVerify(Configs):
exit_code: int = process.returncode
if i == 0:
print(f'{self.bred}FAILED!{self.endc}')
print(f"{'':>2}Error {process.returncode}: file '{file.name}' not found.")
print(f"{'':>2}Error {process.returncode}: {file.name}")
if exit_code == 0:
print(f'{self.yellow}{self.ascii.done}{self.endc}')

View file

@ -99,7 +99,7 @@ class Slackbuilds(Configs):
self.install_order.extend(self.dependencies)
def gpg_verifying(self):
if self.repository == self.repos.sbo_repo_name:
if self.gpg_verification and self.repository == self.repos.sbo_repo_name:
asc_files: list = []
for file in self.slackbuilds + self.dependencies:
location: str = self.data[file]['location']