From e242261270cc3f9d70c9b31f1a3a999c986f90db Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 13 May 2023 23:24:00 +0300 Subject: [PATCH] Updated for naming --- slpkg/binaries/install.py | 4 ++-- slpkg/checksum.py | 10 ++++------ slpkg/sbos/slackbuild.py | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/slpkg/binaries/install.py b/slpkg/binaries/install.py index df68db6e..d69ee247 100644 --- a/slpkg/binaries/install.py +++ b/slpkg/binaries/install.py @@ -35,6 +35,7 @@ class Packages(Configs): self.logs_deps = LoggingDeps(repository, data) self.upgrade = Upgrade(repository, data) self.view_message = ViewMessage(flags, repository, data) + self.check_md5 = Md5sum(flags) self.dependencies: list = [] self.install_order: list = [] @@ -141,11 +142,10 @@ class Packages(Configs): return False def checksum_binary_packages(self) -> None: - md5 = Md5sum(self.flags) for package in self.binary_packages: name: str = self.utils.split_package(Path(package).stem)['name'] pkg_checksum: str = self.data[name]['checksum'] - md5.check(self.tmp_slpkg, package, pkg_checksum) + self.check_md5.md5sum(self.tmp_slpkg, package, pkg_checksum) def install_packages(self) -> None: for package in self.binary_packages: diff --git a/slpkg/checksum.py b/slpkg/checksum.py index 3e100ce5..9c6dd4ca 100644 --- a/slpkg/checksum.py +++ b/slpkg/checksum.py @@ -18,31 +18,29 @@ class Md5sum: """ Checksum the sources. """ def __init__(self, flags: list): - self.flags: list = flags - self.ascii = AsciiBox() self.errors = Errors() self.utils = Utilities() + self.view = ViewMessage(flags) logging.basicConfig(filename=LoggingConfig.log_file, filemode=LoggingConfig.filemode, encoding=LoggingConfig.encoding, level=LoggingConfig.level) - def check(self, path: Union[str, Path], source: str, checksum: str) -> None: + def md5sum(self, path: Union[str, Path], source: str, checksum: str) -> None: """ Checksum the source. """ source_file = unquote(source) filename = source_file.split('/')[-1] source_path = Path(path, filename) md5 = self.read_file(source_path) - file_check = hashlib.md5(md5).hexdigest() + file_check: str = hashlib.md5(md5).hexdigest() checksum = "".join(checksum) if file_check != checksum: self.ascii.draw_checksum_error_box(filename, checksum, file_check) - view = ViewMessage(self.flags) - view.question() + self.view.question() def read_file(self, filename: Union[str, Path]) -> bytes: """ Reads the file. """ diff --git a/slpkg/sbos/slackbuild.py b/slpkg/sbos/slackbuild.py index 9bdf629e..a9176252 100644 --- a/slpkg/sbos/slackbuild.py +++ b/slpkg/sbos/slackbuild.py @@ -44,6 +44,7 @@ class Slackbuilds(Configs): self.logs_deps = LoggingDeps(repository, data) self.upgrade = Upgrade(repository, data) self.view_message = ViewMessage(flags, repository, data) + self.check_md5 = Md5sum(self.flags) self.sources: dict = {} self.install_order: list = [] @@ -186,8 +187,7 @@ class Slackbuilds(Configs): sources: list = self.data[sbo]['download'].split() for source, checksum in zip(sources, checksums): - md5sum = Md5sum(self.flags) - md5sum.check(path, source, checksum) + self.check_md5.md5sum(path, source, checksum) def build_and_install_the_slackbuilds(self) -> None: for sbo in self.install_order: