From 37c008dbb2670943a796491eb64a5c062ecb1ec9 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 29 Mar 2023 23:11:27 +0300 Subject: [PATCH 01/74] Fixed for cancel --- slpkg/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/slpkg/main.py b/slpkg/main.py index 24862c20..c09694dc 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -453,9 +453,11 @@ class Argparse(Configs): text: str = f'There are {len(choices)} packages:' code, tags = self.dialogbox.checklist(text, packages, title, height, width, list_height, choices) - os.system('clear') + if code == 'cancel': + raise SystemExit() + if not tags: return packages From 6b404ae9921f59f1f1243be7268cafa98c082304 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 29 Mar 2023 23:36:59 +0300 Subject: [PATCH 02/74] Fixed for search --- slpkg/binaries/queries.py | 4 ++-- slpkg/main.py | 3 ++- slpkg/repositories.py | 4 ++-- slpkg/search.py | 38 +++++++++++++++++++++++++++----------- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/slpkg/binaries/queries.py b/slpkg/binaries/queries.py index a87b5d6b..3b5a52d4 100644 --- a/slpkg/binaries/queries.py +++ b/slpkg/binaries/queries.py @@ -40,11 +40,11 @@ class BinQueries(Configs): return [pkg[0] for pkg in pkgs] - def all_package_name_with_repo(self) -> tuple: + def package_names_from_all_repositories(self) -> tuple: """ Returns the package name with the repo. """ pkgs: tuple = self.session.query( BinariesTable.name, BinariesTable.repo).where( - BinariesTable.repo == self.repo).all() + BinariesTable.repo.in_(self.repos.bin_enabled_repos)).all() if pkgs: return pkgs diff --git a/slpkg/main.py b/slpkg/main.py index c09694dc..beb2bba4 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -287,7 +287,8 @@ class Argparse(Configs): and not self.utils.is_option(self.flag_binaries, self.flags)): self.usage.help_minimal(f"{self.prog_name}: invalid options '{', '.join(self.flags)}'") - if self.binary_repo not in self.repos.binaries_repositories_dict.keys(): + if self.binary_repo not in self.repos.binaries_repositories_dict.keys() \ + and self.binary_repo == '*' and not self.utils.is_option(['-s', 'search'], self.args): self.usage.help_minimal(f"{self.prog_name}: invalid binary repository '{self.binary_repo}'") def invalid_options(self) -> None: diff --git a/slpkg/repositories.py b/slpkg/repositories.py index 5985a93e..313244a3 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -22,7 +22,7 @@ class Repositories: repos = {} binaries_repositories_dict = {} - bin_enabled_repositories = [] + bin_enabled_repos = [] sbo_enabled: bool = True sbo_repo_name: str = 'sbo' @@ -146,7 +146,7 @@ class Repositories: # All enabled binaries repositories. for repo, enable in binaries_repositories_dict.items(): if enable: - bin_enabled_repositories.append(repo) + bin_enabled_repos.append(repo) if ponce_repo: sbo_enabled_repository: str = ponce_repo_name diff --git a/slpkg/search.py b/slpkg/search.py index 2c5f8e2a..84e0fabf 100644 --- a/slpkg/search.py +++ b/slpkg/search.py @@ -37,22 +37,38 @@ class SearchPackage(Configs): # Searching for binaries. if self.utils.is_option(self.flag_bin_repository, self.flags): - pkg_repo: tuple = BinQueries('', repo).all_package_name_with_repo() + if repo == '*': + pkg_repo: tuple = BinQueries('', repo).package_names_from_all_repositories() - for pkg in packages: - for pr in pkg_repo: + for pkg in packages: + for pr in pkg_repo: - if pkg in pr[0] or pkg == '*': - matching += 1 + if pkg in pr[0] or pkg == '*': + matching += 1 - desc: str = BinQueries(pr[0], pr[1]).description() - version: str = BinQueries(pr[0], pr[1]).version() + desc: str = BinQueries(pr[0], pr[1]).description() + version: str = BinQueries(pr[0], pr[1]).version() - if repo == '*': - repository: str = f'{pr[1]}: ' + if repo == '*': + repository: str = f'{pr[1]}: ' + + print(f'{repository}{self.cyan}{pr[0]}{self.endc}-{self.yellow}{version}{self.endc}' + f'{self.green}{desc}{self.endc}') + else: + pkg_repo: list = BinQueries('', repo).all_package_names() + + for pkg in packages: + for pr in pkg_repo: + + if pkg in pr: + matching += 1 + + desc: str = BinQueries(pr, repo).description() + version: str = BinQueries(pr, repo).version() + + print(f'{repository}{self.cyan}{pr}{self.endc}-{self.yellow}{version}{self.endc}' + f'{self.green}{desc}{self.endc}') - print(f'{repository}{self.cyan}{pr[0]}{self.endc}-{self.yellow}{version}{self.endc}' - f'{self.green}{desc}{self.endc}') else: # Searching for slackbuilds. names: list = SBoQueries('').sbos() From 92717ea575e6193534deb16527b07c8145819d92 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 29 Mar 2023 23:39:37 +0300 Subject: [PATCH 03/74] Fixed for update --- slpkg/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/main.py b/slpkg/main.py index beb2bba4..e8bcede9 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -288,7 +288,7 @@ class Argparse(Configs): self.usage.help_minimal(f"{self.prog_name}: invalid options '{', '.join(self.flags)}'") if self.binary_repo not in self.repos.binaries_repositories_dict.keys() \ - and self.binary_repo == '*' and not self.utils.is_option(['-s', 'search'], self.args): + and self.binary_repo == '*' and not self.utils.is_option(['-s', 'search', '-u', 'update'], self.args): self.usage.help_minimal(f"{self.prog_name}: invalid binary repository '{self.binary_repo}'") def invalid_options(self) -> None: From 0f299a56ed43ba0856df184816e05983b66812e3 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 29 Mar 2023 23:41:20 +0300 Subject: [PATCH 04/74] Updated for coding style --- slpkg/binaries/queries.py | 4 ++-- slpkg/binaries/required.py | 2 +- slpkg/main.py | 2 +- slpkg/repo_info.py | 8 ++++---- slpkg/search.py | 2 +- slpkg/upgrade.py | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/slpkg/binaries/queries.py b/slpkg/binaries/queries.py index 3b5a52d4..031beb92 100644 --- a/slpkg/binaries/queries.py +++ b/slpkg/binaries/queries.py @@ -24,7 +24,7 @@ class BinQueries(Configs): if self.name in self.black.packages(): self.name: str = '' - def all_package_names(self) -> list: + def all_package_names_by_repo(self) -> list: """ Returns all the names of the binaries packages. """ pkgs: tuple = self.session.query( BinariesTable.name).where( @@ -32,7 +32,7 @@ class BinQueries(Configs): return [pkg[0] for pkg in pkgs] - def all_binaries_packages(self) -> list: + def all_binaries_packages_by_repo(self) -> list: """ Returns all the binaries packages. """ pkgs: tuple = self.session.query( BinariesTable.package).where( diff --git a/slpkg/binaries/required.py b/slpkg/binaries/required.py index 6e2af441..32964516 100644 --- a/slpkg/binaries/required.py +++ b/slpkg/binaries/required.py @@ -11,7 +11,7 @@ class Required: def __init__(self, name: str, repo: str): self.name: str = name self.repo: str = repo - self.repo_package_names: list = BinQueries(name, self.repo).all_package_names() + self.repo_package_names: list = BinQueries(name, self.repo).all_package_names_by_repo() def resolve(self) -> list: """ Resolve the dependencies. """ diff --git a/slpkg/main.py b/slpkg/main.py index e8bcede9..182539d0 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -402,7 +402,7 @@ class Argparse(Configs): repo_packages: list = SBoQueries('').sbos() if self.utils.is_option(self.flag_binaries, self.flags): - repo_packages: list = BinQueries('', self.binary_repo).all_package_names() + repo_packages: list = BinQueries('', self.binary_repo).all_package_names_by_repo() installed: list = self.utils.installed_packages diff --git a/slpkg/repo_info.py b/slpkg/repo_info.py index 34f1cdab..c78cf17c 100644 --- a/slpkg/repo_info.py +++ b/slpkg/repo_info.py @@ -53,10 +53,10 @@ class RepoInfo(Configs): packages: dict = { self.repos.sbo_repo_name: len(SBoQueries('').sbos()), self.repos.ponce_repo_name: len(SBoQueries('').sbos()), - self.repos.alien_repo_name: len(BinQueries('', repo).all_package_names()), - self.repos.gnome_repo_name: len(BinQueries('', repo).all_package_names()), - self.repos.conraid_repo_name: len(BinQueries('', repo).all_package_names()), - self.repos.slackonly_repo_name: len(BinQueries('', repo).all_package_names()) + self.repos.alien_repo_name: len(BinQueries('', repo).all_package_names_by_repo()), + self.repos.gnome_repo_name: len(BinQueries('', repo).all_package_names_by_repo()), + self.repos.conraid_repo_name: len(BinQueries('', repo).all_package_names_by_repo()), + self.repos.slackonly_repo_name: len(BinQueries('', repo).all_package_names_by_repo()) } if value[0]: diff --git a/slpkg/search.py b/slpkg/search.py index 84e0fabf..27f84fe8 100644 --- a/slpkg/search.py +++ b/slpkg/search.py @@ -55,7 +55,7 @@ class SearchPackage(Configs): print(f'{repository}{self.cyan}{pr[0]}{self.endc}-{self.yellow}{version}{self.endc}' f'{self.green}{desc}{self.endc}') else: - pkg_repo: list = BinQueries('', repo).all_package_names() + pkg_repo: list = BinQueries('', repo).all_package_names_by_repo() for pkg in packages: for pr in pkg_repo: diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index 4d46584c..3b390356 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -25,7 +25,7 @@ class Upgrade(Configs): def packages(self) -> Generator[str, None, None]: """ Compares version of packages and returns the maximum. """ if self.utils.is_option(self.flag_bin_repository, self.flags): - repo_packages: list = BinQueries('', self.repo).all_package_names() + repo_packages: list = BinQueries('', self.repo).all_package_names_by_repo() else: repo_packages: list = SBoQueries('').sbos() From 332dc855685d7e4397d662af1fb38b016ab48ebc Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 29 Mar 2023 23:41:53 +0300 Subject: [PATCH 05/74] Updated for coding style --- slpkg/binaries/queries.py | 2 +- slpkg/search.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/slpkg/binaries/queries.py b/slpkg/binaries/queries.py index 031beb92..cc462def 100644 --- a/slpkg/binaries/queries.py +++ b/slpkg/binaries/queries.py @@ -40,7 +40,7 @@ class BinQueries(Configs): return [pkg[0] for pkg in pkgs] - def package_names_from_all_repositories(self) -> tuple: + def all_package_names_from_repositories(self) -> tuple: """ Returns the package name with the repo. """ pkgs: tuple = self.session.query( BinariesTable.name, BinariesTable.repo).where( diff --git a/slpkg/search.py b/slpkg/search.py index 27f84fe8..48958701 100644 --- a/slpkg/search.py +++ b/slpkg/search.py @@ -38,7 +38,7 @@ class SearchPackage(Configs): # Searching for binaries. if self.utils.is_option(self.flag_bin_repository, self.flags): if repo == '*': - pkg_repo: tuple = BinQueries('', repo).package_names_from_all_repositories() + pkg_repo: tuple = BinQueries('', repo).all_package_names_from_repositories() for pkg in packages: for pr in pkg_repo: From 33125895bba5bfbcfcac6b45fa4b6dcc3e427d3f Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 29 Mar 2023 23:50:53 +0300 Subject: [PATCH 06/74] Updated for upgrade --- slpkg/upgrade.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index 3b390356..913d1f2b 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -45,7 +45,8 @@ class Upgrade(Configs): if self.utils.is_option(self.flag_bin_repository, self.flags): repo_package: str = BinQueries(package, self.repo).package_bin() - return parse(repo_package[:-4]) > parse(inst_package) + repo_version: str = BinQueries(package, self.repo).version() + repo_build: str = self.utils.split_binary_pkg(repo_package)[3] else: repo_version: str = SBoQueries(package).version() From 8a0e5891b4e6e0729cb00f719ba852d430ab362c Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 00:10:54 +0300 Subject: [PATCH 07/74] Fixed for repo --- slpkg/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/main.py b/slpkg/main.py index 182539d0..07ba3ba5 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -718,7 +718,7 @@ class Argparse(Configs): if self.utils.is_option(self.flag_searches, self.flags): packages: list = self.choose_packages(packages, command) - self.check.exists_in_the_database(packages) + self.check.exists_in_the_database(packages, self.binary_repo) tracking = Tracking(self.flags) tracking.packages(packages, self.binary_repo) From 3fa38556f0ad72fb6a16e23ae7631c6dbca97a29 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 00:11:41 +0300 Subject: [PATCH 08/74] Fixed for repo --- slpkg/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/main.py b/slpkg/main.py index 07ba3ba5..f67141c5 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -700,7 +700,7 @@ class Argparse(Configs): if self.utils.is_option(self.flag_searches, self.flags): packages: list = self.choose_packages(packages, command) - self.check.exists_in_the_database(packages) + self.check.exists_in_the_database(packages, self.binary_repo) dependees = Dependees(packages, self.flags) dependees.find(self.binary_repo) From e07a1170cf661195adc210790cb93a685753edd0 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 00:13:07 +0300 Subject: [PATCH 09/74] Updated for coding style --- slpkg/upgrade.py | 1 - 1 file changed, 1 deletion(-) diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index 913d1f2b..0a7b3b2e 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -47,7 +47,6 @@ class Upgrade(Configs): repo_package: str = BinQueries(package, self.repo).package_bin() repo_version: str = BinQueries(package, self.repo).version() repo_build: str = self.utils.split_binary_pkg(repo_package)[3] - else: repo_version: str = SBoQueries(package).version() repo_build: str = self.utils.read_sbo_build_tag(package) From 7b9d3614f175332242192a906e2f906c785eaf7d Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 00:13:51 +0300 Subject: [PATCH 10/74] Updated for coding style --- slpkg/binaries/queries.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/slpkg/binaries/queries.py b/slpkg/binaries/queries.py index cc462def..97eaa36c 100644 --- a/slpkg/binaries/queries.py +++ b/slpkg/binaries/queries.py @@ -51,6 +51,14 @@ class BinQueries(Configs): return () + def all_pkg_and_required(self) -> list: + """ Returns all package with the dependencies. """ + required: list = self.session.query( + BinariesTable.name, BinariesTable.required).where( + BinariesTable.repo == self.repo).all() + + return required + def repository(self) -> str: """ Return the repository name fo the package. """ repository: tuple = self.session.query( @@ -197,11 +205,3 @@ class BinQueries(Configs): if desc: return desc[0] return '' - - def all_pkg_and_required(self) -> list: - """ Returns all package with the dependencies. """ - required: list = self.session.query( - BinariesTable.name, BinariesTable.required).where( - BinariesTable.repo == self.repo).all() - - return required From 51e488ea7f489610ad091449ae338c185f7c9373 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 00:15:06 +0300 Subject: [PATCH 11/74] Updated for coding style --- slpkg/binaries/queries.py | 2 +- slpkg/dependees.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/slpkg/binaries/queries.py b/slpkg/binaries/queries.py index 97eaa36c..44261ea9 100644 --- a/slpkg/binaries/queries.py +++ b/slpkg/binaries/queries.py @@ -51,7 +51,7 @@ class BinQueries(Configs): return () - def all_pkg_and_required(self) -> list: + def all_package_names_with_required(self) -> list: """ Returns all package with the dependencies. """ required: list = self.session.query( BinariesTable.name, BinariesTable.required).where( diff --git a/slpkg/dependees.py b/slpkg/dependees.py index a5752c0b..b041219d 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -92,7 +92,7 @@ class Dependees(Configs): def find_requires(self, pkg: str, repo) -> Generator[str, None, None]: """ Find requires that slackbuild dependees. """ if self.utils.is_option(self.flag_bin_repository, self.flags): - requires: list = BinQueries(pkg, repo).all_pkg_and_required() + requires: list = BinQueries(pkg, repo).all_package_names_with_required() else: requires: list = SBoQueries('').all_sbo_and_requires() From dd1ac1bf7041b16b6360d0bc62bc6b16fb103724 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 09:06:14 +0300 Subject: [PATCH 12/74] Updated for repo info --- slpkg/binaries/queries.py | 8 ++++++++ slpkg/install_data.py | 40 ++++++++++++++++++++++++++++++++++++-- slpkg/main.py | 8 ++++---- slpkg/models/models.py | 11 +++++++++++ slpkg/repo_info.py | 38 ++++++++++++++++++------------------ slpkg/sbos/queries.py | 7 +++++++ slpkg/update_repository.py | 17 ++++++++++++++-- 7 files changed, 102 insertions(+), 27 deletions(-) diff --git a/slpkg/binaries/queries.py b/slpkg/binaries/queries.py index 44261ea9..dad4c852 100644 --- a/slpkg/binaries/queries.py +++ b/slpkg/binaries/queries.py @@ -24,6 +24,14 @@ class BinQueries(Configs): if self.name in self.black.packages(): self.name: str = '' + def count_packages(self): + """ Counts the number of the packages. """ + count = self.session.query( + BinariesTable.id).where( + BinariesTable.repo == self.repo).count() + + return count + def all_package_names_by_repo(self) -> list: """ Returns all the names of the binaries packages. """ pkgs: tuple = self.session.query( diff --git a/slpkg/install_data.py b/slpkg/install_data.py index 6068a0a9..d3a9b71d 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -7,7 +7,8 @@ from slpkg.configs import Configs from slpkg.utilities import Utilities from slpkg.repositories import Repositories from slpkg.models.models import session as Session -from slpkg.models.models import SBoTable, PonceTable, BinariesTable +from slpkg.models.models import (SBoTable, PonceTable, + BinariesTable, LastRepoUpdated) class InstallData(Configs): @@ -24,6 +25,14 @@ class InstallData(Configs): self.byellow: str = f'{self.bold}{self.yellow}' self.endc: str = self.color['endc'] + def last_updated(self, repo_file: Path) -> str: + """ Reads the first date of the changelog file.""" + lines: list = self.utils.read_file(repo_file) + days = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun') + for line in lines: + if line.startswith(days): + return line.replace('\n', '') + def install_sbos_data(self) -> None: """ Install the data for SBo repository. """ sbo_tags = [ @@ -39,10 +48,13 @@ class InstallData(Configs): 'SLACKBUILD SHORT DESCRIPTION:' ] sbo_table = SBoTable - path = Path(self.repos.sbo_repo_path, self.repos.sbo_repo_slackbuilds) + sbo_name: str = self.repos.sbo_repo_name + path: Path = Path(self.repos.sbo_repo_path, self.repos.sbo_repo_slackbuilds) + path_changelog: Path = Path(self.repos.sbo_repo_path, self.repos.sbo_repo_changelog) if self.repos.ponce_repo: sbo_table = PonceTable + sbo_name: str = self.repos.ponce_repo_name path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_slackbuilds) slackbuilds_txt: list = self.utils.read_file(path) @@ -68,6 +80,10 @@ class InstallData(Configs): cache: list = [] # reset cache after 11 lines + last_updated: str = self.last_updated(path_changelog) + date: str = LastRepoUpdated(repo=sbo_name, date=last_updated) + self.session.add(date) + print(f'{self.byellow}Done{self.endc}') self.session.commit() @@ -85,6 +101,7 @@ class InstallData(Configs): ] path_packages: Path = Path(self.repos.alien_repo_path, self.repos.alien_repo_packages) path_checksums: Path = Path(self.repos.alien_repo_path, self.repos.alien_repo_checksums) + path_changelog: Path = Path(self.repos.alien_repo_path, self.repos.alien_repo_changelog) packages_txt: list = self.utils.read_file(path_packages) checksums_md5: list = self.utils.read_file(path_checksums) @@ -154,6 +171,10 @@ class InstallData(Configs): cache: list = [] # reset cache + last_updated: str = self.last_updated(path_changelog) + date: str = LastRepoUpdated(repo=self.repos.alien_repo_name, date=last_updated) + self.session.add(date) + print(f'{self.byellow}Done{self.endc}') self.session.commit() @@ -171,6 +192,7 @@ class InstallData(Configs): ] path_packages: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_packages) path_checksums: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_checksums) + path_changelog: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_changelog) packages_txt: list = self.utils.read_file(path_packages) checksums_md5: list = self.utils.read_file(path_checksums) @@ -239,6 +261,10 @@ class InstallData(Configs): cache: list = [] # reset cache + last_updated: str = self.last_updated(path_changelog) + date: str = LastRepoUpdated(repo=self.repos.gnome_repo_name, date=last_updated) + self.session.add(date) + print(f'{self.byellow}Done{self.endc}') self.session.commit() @@ -256,6 +282,7 @@ class InstallData(Configs): ] path_packages: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_packages) path_checksums: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_checksums) + path_changelog: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_changelog) checksums_md5: list = self.utils.read_file(path_checksums) packages_txt: list = self.utils.read_file(path_packages) @@ -325,6 +352,10 @@ class InstallData(Configs): cache: list = [] # reset cache + last_updated: str = self.last_updated(path_changelog) + date: str = LastRepoUpdated(repo=self.repos.conraid_repo_name, date=last_updated) + self.session.add(date) + print(f'{self.byellow}Done{self.endc}') self.session.commit() @@ -342,6 +373,7 @@ class InstallData(Configs): ] path_packages: Path = Path(self.repos.slackonly_repo_path, self.repos.slackonly_repo_packages) path_checksums: Path = Path(self.repos.slackonly_repo_path, self.repos.slackonly_repo_checksums) + path_changelog: Path = Path(self.repos.slackonly_repo_path, self.repos.slackonly_repo_changelog) packages_txt: list = self.utils.read_file(path_packages) checksums_md5: list = self.utils.read_file(path_checksums) @@ -411,6 +443,10 @@ class InstallData(Configs): cache: list = [] # reset cache + last_updated: str = self.last_updated(path_changelog) + date: str = LastRepoUpdated(repo=self.repos.slackonly_repo_name, date=last_updated) + self.session.add(date) + print(f'{self.byellow}Done{self.endc}') self.session.commit() diff --git a/slpkg/main.py b/slpkg/main.py index f67141c5..8754d650 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -783,10 +783,10 @@ def main(): '-t': argparse.tracking } - try: - arguments[args[0]]() - except (KeyError, IndexError): - usage.help_short(1) + # try: + arguments[args[0]]() + # except (KeyError, IndexError): + usage.help_short(1) if __name__ == '__main__': diff --git a/slpkg/models/models.py b/slpkg/models/models.py index 213746f7..d0fcd882 100644 --- a/slpkg/models/models.py +++ b/slpkg/models/models.py @@ -90,4 +90,15 @@ class LogsDependencies(Base): requires: str = Column(Text) +@dataclass +class LastRepoUpdated(Base): + """ The table that saves the last updated date. """ + + __tablename__ = 'lastupdated' + + id: int = Column(Integer, primary_key=True) + repo: str = Column(Text) + date: str = Column(Text) + + Base.metadata.create_all(engine) diff --git a/slpkg/repo_info.py b/slpkg/repo_info.py index c78cf17c..e3705875 100644 --- a/slpkg/repo_info.py +++ b/slpkg/repo_info.py @@ -2,13 +2,14 @@ # -*- coding: utf-8 -*- import shutil -from pathlib import Path from slpkg.configs import Configs from slpkg.utilities import Utilities from slpkg.sbos.queries import SBoQueries from slpkg.repositories import Repositories from slpkg.binaries.queries import BinQueries +from slpkg.models.models import LastRepoUpdated +from slpkg.models.models import session as Session class RepoInfo(Configs): @@ -20,6 +21,7 @@ class RepoInfo(Configs): self.repos = Repositories() self.color = self.colour() self.columns, self.rows = shutil.get_terminal_size() + self.session = Session self.bold: str = self.color['bold'] self.green: str = self.color['green'] @@ -32,13 +34,14 @@ class RepoInfo(Configs): def info(self): """ Prints information about repositories. """ + total_packages: int = 0 + enabled: int = 0 + print('Repositories Information:') print('=' * self.columns) print(f"{'Name:':<18}{'Status:':<15}{'Last Updated:':<35}{'Packages:':>12}") print('=' * self.columns) - total_packages: int = 0 - enabled: int = 0 for repo, value in self.repos.repos_dict.items(): count: int = 0 status: str = 'Disabled' @@ -48,15 +51,20 @@ class RepoInfo(Configs): status: str = 'Enabled' color: str = self.green - last: str = self.last_update(Path(value[1], value[2])) + last: str = self.session.query( + LastRepoUpdated.date).where( + LastRepoUpdated.repo == repo).first() + + if last is None: + last: tuple = ('',) packages: dict = { - self.repos.sbo_repo_name: len(SBoQueries('').sbos()), - self.repos.ponce_repo_name: len(SBoQueries('').sbos()), - self.repos.alien_repo_name: len(BinQueries('', repo).all_package_names_by_repo()), - self.repos.gnome_repo_name: len(BinQueries('', repo).all_package_names_by_repo()), - self.repos.conraid_repo_name: len(BinQueries('', repo).all_package_names_by_repo()), - self.repos.slackonly_repo_name: len(BinQueries('', repo).all_package_names_by_repo()) + self.repos.sbo_repo_name: SBoQueries('').count_packages(), + self.repos.ponce_repo_name: SBoQueries('').count_packages(), + self.repos.alien_repo_name: BinQueries('', repo).count_packages(), + self.repos.gnome_repo_name: BinQueries('', repo).count_packages(), + self.repos.conraid_repo_name: BinQueries('', repo).count_packages(), + self.repos.slackonly_repo_name: BinQueries('', repo).count_packages() } if value[0]: @@ -64,16 +72,8 @@ class RepoInfo(Configs): total_packages += count - print(f"{self.cyan}{repo:<18}{self.endc}{color}{status:<15}{self.endc}{last:<35}" + print(f"{self.cyan}{repo:<18}{self.endc}{color}{status:<15}{self.endc}{last[0]:<35}" f"{self.yellow}{count:>12}{self.endc}") print('=' * self.columns) print(f"{self.grey}Total of {enabled} repositories are enabled with {total_packages} packages available.") - - def last_update(self, repo_file: Path) -> str: - """ Reads the first date of the changelog file.""" - lines: list = self.utils.read_file(repo_file) - days = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun') - for line in lines: - if line.startswith(days): - return line.replace('\n', '') diff --git a/slpkg/sbos/queries.py b/slpkg/sbos/queries.py index 7e5ce76a..fe20d2fc 100644 --- a/slpkg/sbos/queries.py +++ b/slpkg/sbos/queries.py @@ -29,6 +29,13 @@ class SBoQueries(Configs): if self.repos.ponce_repo: self.sbo_table = PonceTable + def count_packages(self): + """ Counts the number of the packages. """ + count = self.session.query( + self.sbo_table.id).count() + + return count + def repo_name(self): """ Returns the repo name by the table. """ table = inspect(self.sbo_table) diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index 59d4bab8..4d358c1e 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -15,7 +15,8 @@ from slpkg.repositories import Repositories from slpkg.check_updates import CheckUpdates from slpkg.models.models import session as Session from slpkg.models.models import (Base, engine, SBoTable, - PonceTable, BinariesTable) + PonceTable, BinariesTable, + LastRepoUpdated) class UpdateRepository(Configs): @@ -87,6 +88,7 @@ class UpdateRepository(Configs): print() self.delete_binaries_data(self.repos.alien_repo_name) + self.delete_last_updated(self.repos.alien_repo_name) self.data.install_alien_data() print() else: @@ -112,6 +114,7 @@ class UpdateRepository(Configs): print() self.delete_binaries_data(self.repos.gnome_repo_name) + self.delete_last_updated(self.repos.gnome_repo_name) self.data.install_gnome_data() print() else: @@ -138,6 +141,7 @@ class UpdateRepository(Configs): print() self.delete_binaries_data(self.repos.conraid_repo_name) + self.delete_last_updated(self.repos.conraid_repo_name) self.data.install_conraid_data() print() else: @@ -164,6 +168,7 @@ class UpdateRepository(Configs): print() self.delete_binaries_data(self.repos.slackonly_repo_name) + self.delete_last_updated(self.repos.slackonly_repo_name) self.data.install_slackonly_data() print() else: @@ -192,6 +197,7 @@ class UpdateRepository(Configs): os.chdir(self.repos.ponce_repo_path) gen_command: str = f'./gen_sbo_txt.sh > {self.repos.ponce_repo_slackbuilds}' self.utils.process(gen_command) + self.delete_last_updated(self.repos.ponce_repo_name) print('\n') else: @@ -205,6 +211,7 @@ class UpdateRepository(Configs): lftp_command: str = (f'lftp {self.lftp_mirror_options} {self.repos.sbo_repo_mirror} ' f'{self.repos.sbo_repo_path}') self.utils.process(lftp_command) + self.delete_last_updated(self.repos.sbo_repo_name) self.delete_sbo_data() self.data.install_sbos_data() @@ -277,6 +284,11 @@ class UpdateRepository(Configs): self.session.query(BinariesTable).where(BinariesTable.repo == repo).delete() self.session.commit() + def delete_last_updated(self, repo) -> None: + """ Deletes the last updated date. """ + self.session.query(LastRepoUpdated).where(LastRepoUpdated.repo == repo).delete() + self.session.commit() + def drop_the_tables(self): """ Drop all the tables from the database. """ print(f'\n{self.prog_name}: {self.bred}WARNING{self.endc}: All the data from the database will be deleted!') @@ -285,7 +297,8 @@ class UpdateRepository(Configs): tables: list = [ PonceTable.__table__, SBoTable.__table__, - BinariesTable.__table__ + BinariesTable.__table__, + LastRepoUpdated.__table__ ] Base.metadata.drop_all(bind=engine, tables=tables) From c86a0a627145b691528548e050a831db32fa7b85 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 09:16:31 +0300 Subject: [PATCH 13/74] Updated for file not found --- slpkg/checksum.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/slpkg/checksum.py b/slpkg/checksum.py index eda55172..eb3eb2ee 100644 --- a/slpkg/checksum.py +++ b/slpkg/checksum.py @@ -8,6 +8,7 @@ from urllib.parse import unquote from slpkg.views.ascii import Ascii from slpkg.views.views import ViewMessage +from slpkg.utilities import Utilities class Md5sum: @@ -16,6 +17,7 @@ class Md5sum: def __init__(self, flags: list): self.flags: list = flags self.ascii = Ascii() + self.utils = Utilities() def check(self, path: Union[str, Path], source: str, checksum: str) -> None: """ Checksum the source. """ @@ -34,8 +36,10 @@ class Md5sum: view = ViewMessage(self.flags) view.question() - @staticmethod - def read_file(filename: Union[str, Path]) -> bytes: + def read_file(self, filename: Union[str, Path]) -> bytes: """ Reads the text file. """ - with open(filename, 'rb') as f: - return f.read() + try: + with open(filename, 'rb') as f: + return f.read() + except FileNotFoundError: + self.utils.raise_error_message(f"No such file or directory: '{filename}'") From 0afd7d4fad7ba099e7703006670b75ceeba8a2bc Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 09:19:50 +0300 Subject: [PATCH 14/74] Updated for file not found --- slpkg/utilities.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slpkg/utilities.py b/slpkg/utilities.py index a86a9502..8cc998e4 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -140,8 +140,8 @@ class Utilities: yield package - except FileNotFoundError as err: - self.raise_error_message(str(err)) + except FileNotFoundError: + self.raise_error_message(f"No such file or directory: '{file}'") @staticmethod def read_file(file: Union[str, Path]) -> list: From 276f26e21a58ceb9e640e0a4b13c7794502ed2a1 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 09:46:59 +0300 Subject: [PATCH 15/74] Updated for mirror --- configs/repositories.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/repositories.toml b/configs/repositories.toml index e765c01b..37d54b31 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -35,7 +35,7 @@ GNOME_REPO_NAME = "gnome" GNOME_REPO = false - GNOME_REPO_MIRROR = "https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/" + GNOME_REPO_MIRROR = "http://slackware.uk/gfs/current/43.3/x86_64/" GNOME_REPO_PACKAGES = "PACKAGES.TXT" GNOME_REPO_CHECKSUMS = "CHECKSUMS.md5" GNOME_REPO_CHANGELOG = "ChangeLog.txt" From 11f0b369278105b0c3c5055ca55de0288b54423e Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 10:00:37 +0300 Subject: [PATCH 16/74] Updated for mirror --- slpkg/install_data.py | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/slpkg/install_data.py b/slpkg/install_data.py index d3a9b71d..fcd3d879 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -216,17 +216,12 @@ class InstallData(Configs): cache.append(split_package[0]) # package name cache.append(split_package[1]) # package version cache.append(package_name) + cache.append(self.repos.gnome_repo_mirror) try: cache.append(checksums_dict[package_name]) except KeyError: cache.append('error checksum') - if line.startswith(pkg_tag[1]): - package_mirror = line.replace(pkg_tag[1], '').strip() - if not package_mirror.endswith('/'): - package_mirror: str = f'{package_mirror}/' - cache.append(package_mirror) - if line.startswith(pkg_tag[2]): package_location = line.replace(pkg_tag[2], '').strip() cache.append(package_location[1:]) # Do not install (.) dot @@ -249,8 +244,8 @@ class InstallData(Configs): name=cache[0], version=cache[1], package=cache[2], - checksum=cache[3], - mirror=cache[4], + mirror=cache[3], + checksum=cache[4], location=cache[5], size_comp=cache[6], size_uncomp=cache[7], @@ -307,17 +302,12 @@ class InstallData(Configs): cache.append(split_package[0]) # package name cache.append(split_package[1]) # package version cache.append(package_name) + cache.append(self.repos.conraid_repo_mirror) try: cache.append(checksums_dict[package_name]) except KeyError: cache.append('error checksum') - if line.startswith(pkg_tag[1]): - package_mirror: str = line.replace(pkg_tag[1], '').strip() - if not package_mirror.endswith('/'): - package_mirror: str = f'{package_mirror}/' - cache.append(package_mirror) - if line.startswith(pkg_tag[2]): package_location: str = line.replace(pkg_tag[2], '').strip() cache.append(package_location[2:]) # Do not install (./) dot @@ -340,8 +330,8 @@ class InstallData(Configs): name=cache[0], version=cache[1], package=cache[2], - checksum=cache[3], - mirror=cache[4], + mirror=cache[3], + checksum=cache[4], location=cache[5], size_comp=cache[6], size_uncomp=cache[7], From 339559372ff43a7d819d2762788f43af8f4ab302 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 10:17:47 +0300 Subject: [PATCH 17/74] Updated for check db --- slpkg/checks.py | 5 +++-- slpkg/main.py | 1 - slpkg/views/views.py | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/slpkg/checks.py b/slpkg/checks.py index 151dd799..35fc4b78 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -84,5 +84,6 @@ class Check(Configs): """ Checking for empty table and database file. """ db = Path(self.db_path, self.database_name) if not self.session.query(self.repo_table).first() or not db.is_file(): - self.utils.raise_error_message("You need to update the package lists first.\n" - " Please run 'slpkg update'") + self.utils.raise_error_message("You need to update the package lists first, run:\n\n" + " $ 'slpkg update'\n" + " $ 'slpkg update --bin-repo='*' for binaries") diff --git a/slpkg/main.py b/slpkg/main.py index 8754d650..ac501266 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -626,7 +626,6 @@ class Argparse(Configs): if len(self.args) >= 2: - self.check.is_empty_database() packages: list = self.is_file_list_packages() if self.utils.is_option(self.flag_searches, self.flags): diff --git a/slpkg/views/views.py b/slpkg/views/views.py index 6b5ecba5..82014f2c 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -207,7 +207,10 @@ class ViewMessage(Configs): for pkg in packages: - upgradeable: bool = self.upgrade.is_package_upgradeable(pkg) + upgradeable: bool = False + if option != 'remove': + upgradeable: bool = self.upgrade.is_package_upgradeable(pkg) + installed: str = self.utils.is_package_installed(pkg) if not installed: From 01d07a68f5abda0adf21946133472db0c93efd6e Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 10:46:20 +0300 Subject: [PATCH 18/74] Updated for bool --- slpkg/utilities.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/slpkg/utilities.py b/slpkg/utilities.py index 8cc998e4..a793b246 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -6,7 +6,7 @@ import time import shutil import subprocess from pathlib import Path -from typing import Generator, Any, Union +from typing import Generator, Union from slpkg.configs import Configs from slpkg.blacklist import Blacklist @@ -122,9 +122,11 @@ class Utilities: return ''.join(re.findall(r'\d+', line)) @staticmethod - def is_option(flag: list, flags: list) -> Any: + def is_option(flag: list, flags: list) -> bool: """ Checking for flags. """ - return [f for f in flag if f in flags] + for f in flag: + if f in flags: + return True def read_packages_from_file(self, file: Path) -> Generator: """ Reads packages from file and split these to list. """ From c1d877bab71146fad95ab037dd77de938042bfc9 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 10:48:07 +0300 Subject: [PATCH 19/74] Fixed check bin repos --- slpkg/main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/slpkg/main.py b/slpkg/main.py index ac501266..2be8dc84 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -283,13 +283,13 @@ class Argparse(Configs): def check_for_bin_repositories(self) -> None: """ Checks combination for binaries use repositories only and if repository exists. """ - if (self.utils.is_option(self.flag_binaries, self.flags) - and not self.utils.is_option(self.flag_binaries, self.flags)): - self.usage.help_minimal(f"{self.prog_name}: invalid options '{', '.join(self.flags)}'") + if self.utils.is_option(self.flag_binaries, self.flags): - if self.binary_repo not in self.repos.binaries_repositories_dict.keys() \ - and self.binary_repo == '*' and not self.utils.is_option(['-s', 'search', '-u', 'update'], self.args): - self.usage.help_minimal(f"{self.prog_name}: invalid binary repository '{self.binary_repo}'") + if self.binary_repo == '*' and not self.utils.is_option(['-s', 'search', '-u', 'update'], self.args): + self.usage.help_minimal(f"{self.prog_name}: invalid binary repository '{self.binary_repo}'") + + elif self.binary_repo not in self.repos.binaries_repositories_dict.keys() and self.binary_repo != '*': + self.usage.help_minimal(f"{self.prog_name}: invalid binary repository '{self.binary_repo}'") def invalid_options(self) -> None: """ Checks for invalid options. """ From cdd28f019742d952da25803c23f336db088f6a58 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 16:27:42 +0300 Subject: [PATCH 20/74] Fixed for install --- slpkg/binaries/install.py | 18 +++++++----------- slpkg/upgrade.py | 12 ++++++------ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/slpkg/binaries/install.py b/slpkg/binaries/install.py index 6d3be84a..78589f0b 100644 --- a/slpkg/binaries/install.py +++ b/slpkg/binaries/install.py @@ -100,10 +100,7 @@ class Packages(Configs): for pkg in self.install_order: - skip_package: str = self.skip_installed_package(pkg) - - if not skip_package: - + if self.is_for_install(pkg): mirror: str = BinQueries(pkg, self.repo).mirror() location: str = BinQueries(pkg, self.repo).location() package: str = BinQueries(pkg, self.repo).package_bin() @@ -111,9 +108,8 @@ class Packages(Configs): pkg_urls.append(f'{mirror}{location}/{package}') self.binary_packages.append(package) self.utils.remove_file_if_exists(self.tmp_slpkg, package) - else: - version: str = self.utils.split_binary_pkg(skip_package)[1] + version: str = BinQueries(pkg, self.repo).version() self.view_message.view_skipping_packages(pkg, version) if pkg_urls: @@ -121,13 +117,13 @@ class Packages(Configs): down.download() print() - def skip_installed_package(self, package) -> str: + def is_for_install(self, name) -> bool: """ Skip installed package when the option --skip-installed is applied. """ - installed_package: str = self.utils.is_package_installed(package) + if self.utils.is_option(self.flag_skip_installed, self.flags): + return False - if (installed_package and self.mode == 'upgrade' and not self.upgrade.is_package_upgradeable(package) - or self.mode == 'install' and not self.utils.is_option(self.flag_reinstall, self.flags)): - return installed_package + if self.upgrade.is_package_upgradeable(name) or self.utils.is_option(self.flag_reinstall, self.flags): + return True def checksum(self) -> None: """ Packages checksums. """ diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index 0a7b3b2e..e610e291 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -37,18 +37,18 @@ class Upgrade(Configs): if self.is_package_upgradeable(inst_package): yield inst_package - def is_package_upgradeable(self, package: str) -> bool: + def is_package_upgradeable(self, name: str) -> bool: """ Checks for installed and upgradeable packages. """ - inst_package: str = self.utils.is_package_installed(package) + inst_package: str = self.utils.is_package_installed(name) inst_version: str = self.utils.split_binary_pkg(inst_package)[1] inst_build: str = self.utils.split_binary_pkg(inst_package)[3] if self.utils.is_option(self.flag_bin_repository, self.flags): - repo_package: str = BinQueries(package, self.repo).package_bin() - repo_version: str = BinQueries(package, self.repo).version() + repo_package: str = BinQueries(name, self.repo).package_bin() + repo_version: str = BinQueries(name, self.repo).version() repo_build: str = self.utils.split_binary_pkg(repo_package)[3] else: - repo_version: str = SBoQueries(package).version() - repo_build: str = self.utils.read_sbo_build_tag(package) + repo_version: str = SBoQueries(name).version() + repo_build: str = self.utils.read_sbo_build_tag(name) return parse(repo_version + repo_build) > parse(inst_version + inst_build) From 02fd803fd068ec3fff5544bb5d2764c2b8808114 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 16:56:43 +0300 Subject: [PATCH 21/74] Updated for comments --- slpkg/binaries/install.py | 9 ++++++--- slpkg/sbos/slackbuild.py | 24 +++++++++++++++--------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/slpkg/binaries/install.py b/slpkg/binaries/install.py index 78589f0b..7a1a3efd 100644 --- a/slpkg/binaries/install.py +++ b/slpkg/binaries/install.py @@ -100,7 +100,7 @@ class Packages(Configs): for pkg in self.install_order: - if self.is_for_install(pkg): + if self.continue_install(pkg): mirror: str = BinQueries(pkg, self.repo).mirror() location: str = BinQueries(pkg, self.repo).location() package: str = BinQueries(pkg, self.repo).package_bin() @@ -117,8 +117,11 @@ class Packages(Configs): down.download() print() - def is_for_install(self, name) -> bool: - """ Skip installed package when the option --skip-installed is applied. """ + def continue_install(self, name) -> bool: + """ Skip installed package when the option --skip-installed is applied + and continue to install if the package is upgradable or the --reinstall option + applied. + """ if self.utils.is_option(self.flag_skip_installed, self.flags): return False diff --git a/slpkg/sbos/slackbuild.py b/slpkg/sbos/slackbuild.py index ebc99841..2b522725 100644 --- a/slpkg/sbos/slackbuild.py +++ b/slpkg/sbos/slackbuild.py @@ -7,7 +7,6 @@ import shutil import subprocess from pathlib import Path -from typing import Literal from collections import OrderedDict from multiprocessing import Process, cpu_count @@ -136,12 +135,19 @@ class Slackbuilds(Configs): self.view_message.question() - def is_not_for_skipped(self, sbo: str) -> Literal[True]: - """ Condition to check if slackbuild is for skipped. """ - return (not self.utils.is_package_installed(sbo) or - self.upgrade.is_package_upgradeable(sbo) or - self.mode == 'build' or - self.utils.is_option(self.flag_reinstall, self.flags)) + def continue_build_or_install(self, name) -> bool: + """ Skip installed package when the option --skip-installed is applied + and continue to install if the package is upgradable or the --reinstall option + applied. + """ + if self.mode == 'build': + return True + + if self.utils.is_option(self.flag_skip_installed, self.flags): + return False + + if self.upgrade.is_package_upgradeable(name) or self.utils.is_option(self.flag_reinstall, self.flags): + return True def prepare_slackbuilds_for_build(self) -> None: """ Downloads files and sources. """ @@ -150,7 +156,7 @@ class Slackbuilds(Configs): for sbo in self.install_order: - if self.is_not_for_skipped(sbo): + if self.continue_build_or_install(sbo): build_path: Path = Path(self.build_path, sbo) @@ -203,7 +209,7 @@ class Slackbuilds(Configs): """ Build the slackbuilds and install. """ for sbo in self.install_order: - if self.is_not_for_skipped(sbo): + if self.continue_build_or_install(sbo): self.build_the_script(self.build_path, sbo) if not self.mode == 'build': From 463187608964f08bde4536336e48a398236aa27a Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 17:11:23 +0300 Subject: [PATCH 22/74] Updated for deps logs --- slpkg/binaries/install.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/slpkg/binaries/install.py b/slpkg/binaries/install.py index 7a1a3efd..c5a37a61 100644 --- a/slpkg/binaries/install.py +++ b/slpkg/binaries/install.py @@ -151,7 +151,9 @@ class Packages(Configs): if not self.utils.is_option(self.flag_resolve_off, self.flags): name: str = self.utils.split_binary_pkg(package[:-4])[0] - self.logging_installed_dependencies(name) + + if not self.utils.is_option(self.flag_resolve_off, self.flags): + self.logging_installed_dependencies(name) def logging_installed_dependencies(self, name: str) -> None: """ Logging installed dependencies and used for remove. """ From e7d4bb8d25915012b8abc0ba1d938843bbb9c058 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 17:11:31 +0300 Subject: [PATCH 23/74] Updated for coding style --- slpkg/sbos/slackbuild.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/slpkg/sbos/slackbuild.py b/slpkg/sbos/slackbuild.py index 2b522725..2973f49a 100644 --- a/slpkg/sbos/slackbuild.py +++ b/slpkg/sbos/slackbuild.py @@ -212,9 +212,9 @@ class Slackbuilds(Configs): if self.continue_build_or_install(sbo): self.build_the_script(self.build_path, sbo) - if not self.mode == 'build': + if self.mode in ['install', 'upgrade']: - pkg: str = self.creating_package_for_install(sbo) + pkg: str = self.package_for_install(sbo) self.install_package(pkg) if not self.utils.is_option(self.flag_resolve_off, self.flags): @@ -277,9 +277,8 @@ class Slackbuilds(Configs): self.multi_process(command, package, message) - def creating_package_for_install(self, name: str) -> str: - """ Creating a list with all the finished packages for - installation. """ + def package_for_install(self, name: str) -> str: + """ Returns the package for install. """ version: str = SBoQueries(name).version() pattern: str = f'{name}-{version}*{self.repos.repo_tag}*' From fb91e151d939c411ead45f72575ebe9b94eef25f Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 17:25:37 +0300 Subject: [PATCH 24/74] Fixed for except options --- slpkg/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/slpkg/main.py b/slpkg/main.py index 2be8dc84..efe002f9 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -285,7 +285,9 @@ class Argparse(Configs): """ Checks combination for binaries use repositories only and if repository exists. """ if self.utils.is_option(self.flag_binaries, self.flags): - if self.binary_repo == '*' and not self.utils.is_option(['-s', 'search', '-u', 'update'], self.args): + except_options: list = ['-s', 'search', '-u', 'update', '-c', 'check-updates'] + + if self.binary_repo == '*' and not self.utils.is_option(except_options, self.args): self.usage.help_minimal(f"{self.prog_name}: invalid binary repository '{self.binary_repo}'") elif self.binary_repo not in self.repos.binaries_repositories_dict.keys() and self.binary_repo != '*': From 312d1d0c4626c98f20939b71af4941b8b2f5bdef Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 17:25:55 +0300 Subject: [PATCH 25/74] Updated for version rc1 --- setup.cfg | 2 +- slpkg/views/version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 925bfc8c..8e03a5a5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = slpkg -version = 4.6.2 +version = r.c.1 license_file = LICENSE author = Dimitris Zlatanidis author_email = d.zlatanidis@gmail.com diff --git a/slpkg/views/version.py b/slpkg/views/version.py index b74cd685..30086c6f 100644 --- a/slpkg/views/version.py +++ b/slpkg/views/version.py @@ -5,7 +5,7 @@ class Version: """ Print the version. """ def __init__(self): - self.version_info: tuple = (4, 6, 2) + self.version_info: tuple = ('r', 'c', 1) self.version: str = '{0}.{1}.{2}'.format(*self.version_info) self.license: str = 'MIT License' self.author: str = 'Dimitris Zlatanidis (dslackw)' From fa0c9ea17a0e61e98f229eb982541adcd7ce5810 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 17:51:40 +0300 Subject: [PATCH 26/74] Updated man page --- man/slpkg.1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/man/slpkg.1 b/man/slpkg.1 index 22cb076f..5e4bd934 100644 --- a/man/slpkg.1 +++ b/man/slpkg.1 @@ -34,7 +34,7 @@ Upgrade all the installed packages if the newer version exists in the repository .P .B -c, check-updates .RS -Check if there is any news on the SlackBuild's ChangeLog.txt file. +Check if there is any news on the repositories ChangeLog.txt file. .RE .P .B -I, repo-info @@ -181,7 +181,8 @@ Download files in parallel to speed up the process. .BI "-B," "" " \-\-bin-repo=[" REPO "] .RS Switch to binaries repositories and select a repository. -Example: '\fIslpkg -i audacity --bin=repo=alien\fR'. +Example: '\fIslpkg -i audacity --bin-repo=alien\fR'. Options update, check, and search support the asterisk '*' to apply +it in all repositories, like search a package to all binaries repositories '\fIslpkg -s libreoffice --bin-repo='*'\fR'. (to be used with: -u, update, -U, upgrade, -i, install, -d, download, -s, search, -t, tracking, -e, dependees) .RE .P From 343b15d884705c565564835553b715b98b2148a5 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 18:17:10 +0300 Subject: [PATCH 27/74] Fixed for tracking version --- slpkg/tracking.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/slpkg/tracking.py b/slpkg/tracking.py index 60ac3ee5..b7f8cf36 100644 --- a/slpkg/tracking.py +++ b/slpkg/tracking.py @@ -37,12 +37,13 @@ class Tracking(Configs): char: str = f' {self.llc}{self.hl}' sp: str = ' ' * 4 + for package in packages: pkg = f'{self.yellow}{package}{self.endc}' if self.utils.is_option(self.flag_pkg_version, self.flags): - version: str = SBoQueries(package).version() + version: str = SBoQueries(package).version() if self.utils.is_option(self.flag_bin_repository, self.flags): version: str = BinQueries(package, repo).version() @@ -55,25 +56,26 @@ class Tracking(Configs): how_many: int = len(requires) - if not requires: - requires: list = ['No dependencies'] - print(pkg) print(char, end='') - for i, req in enumerate(requires, start=1): - require: str = f'{self.cyan}{req}{self.endc}' - if self.utils.is_option(self.flag_pkg_version, self.flags): - version: str = f"-{self.yellow}{SBoQueries(req).version()}{self.endc}" + if not requires: + print(f' {self.cyan}No dependencies{self.endc}') + else: + for i, req in enumerate(requires, start=1): + require: str = f'{self.cyan}{req}{self.endc}' - if self.utils.is_option(self.flag_bin_repository, self.flags): - version: str = f"-{self.yellow}{BinQueries(req, repo).version()}{self.endc}" + if self.utils.is_option(self.flag_pkg_version, self.flags): - require: str = f'{self.cyan}{req}{self.endc}{version}' + version: str = f"-{self.yellow}{SBoQueries(req).version()}{self.endc}" + if self.utils.is_option(self.flag_bin_repository, self.flags): + version: str = f"-{self.yellow}{BinQueries(req, repo).version()}{self.endc}" - if i == 1: - print(f' {self.cyan}{requires[0]}{self.endc}') - else: - print(f'{sp}{require}') + require: str = f'{self.cyan}{req}{self.endc}{version}' + + if i == 1: + print(f' {require}') + else: + print(f'{sp}{require}') print(f'\n{self.grey}{how_many} dependencies for {package}{self.endc}\n') From 06e87927e7ca61dd07e2cd19055c34cd358c3839 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 20:23:22 +0300 Subject: [PATCH 28/74] Fixed for changelog date --- slpkg/install_data.py | 1 + 1 file changed, 1 insertion(+) diff --git a/slpkg/install_data.py b/slpkg/install_data.py index fcd3d879..0fc81193 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -56,6 +56,7 @@ class InstallData(Configs): sbo_table = PonceTable sbo_name: str = self.repos.ponce_repo_name path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_slackbuilds) + path_changelog: Path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_changelog) slackbuilds_txt: list = self.utils.read_file(path) From dd9955d457ac83f337b1ebd370d2c6a118b13ef5 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 21:21:29 +0300 Subject: [PATCH 29/74] Added repo ponce_bin --- configs/repositories.toml | 16 ++++++- slpkg/check_updates.py | 5 +++ slpkg/install_data.py | 85 ++++++++++++++++++++++++++++++++++++++ slpkg/repo_info.py | 3 +- slpkg/repositories.py | 29 ++++++++++--- slpkg/update_repository.py | 30 ++++++++++++++ 6 files changed, 160 insertions(+), 8 deletions(-) diff --git a/configs/repositories.toml b/configs/repositories.toml index 37d54b31..0e0b8fd3 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -11,6 +11,7 @@ [REPOSITORIES] + # Repository for slackware 15.0 stable. SBO_REPO_NAME = "sbo" SBO_REPO_MIRROR = "https://slackbuilds.org/slackbuilds/15.0/" SBO_REPO_SLACKBUILDS = "SLACKBUILDS.TXT" @@ -18,6 +19,7 @@ SBO_REPO_TAR_SUFFIX = ".tar.gz" SBO_REPO_TAG = "_SBo" + # Repository for slackware -current. PONCE_REPO_NAME = "ponce" PONCE_REPO = false PONCE_REPO_MIRROR = "https://cgit.ponce.cc/slackbuilds/plain/" @@ -25,6 +27,7 @@ PONCE_REPO_CHANGELOG = "ChangeLog.txt" PONCE_REPO_TAG = "_SBo" + # Repository for slackware 15.0 stable. ALIEN_REPO_NAME = "alien" ALIEN_REPO = false ALIEN_REPO_MIRROR = "http://slackware.uk/people/alien/sbrepos/15.0/x86_64/" @@ -33,13 +36,15 @@ ALIEN_REPO_CHECKSUMS = "CHECKSUMS.md5" ALIEN_REPO_CHANGELOG = "ChangeLog.txt" + # Repository for slackware -current. GNOME_REPO_NAME = "gnome" GNOME_REPO = false - GNOME_REPO_MIRROR = "http://slackware.uk/gfs/current/43.3/x86_64/" + GNOME_REPO_MIRROR = "https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/" GNOME_REPO_PACKAGES = "PACKAGES.TXT" GNOME_REPO_CHECKSUMS = "CHECKSUMS.md5" GNOME_REPO_CHANGELOG = "ChangeLog.txt" + # Repository for slackware -current. CONRAID_REPO_NAME = "conraid" CONRAID_REPO = false CONRAID_REPO_MIRROR = "https://slack.conraid.net/repository/slackware64-current/" @@ -47,9 +52,18 @@ CONRAID_REPO_CHECKSUMS = "CHECKSUMS.md5" CONRAID_REPO_CHANGELOG = "ChangeLog.txt" + # Repository for slackware 15.0 stable. SLACKONLY_REPO_NAME = "slackonly" SLACKONLY_REPO = false SLACKONLY_REPO_MIRROR = "https://packages.slackonly.com/pub/packages/15.0-x86_64/" SLACKONLY_REPO_PACKAGES = "PACKAGES.TXT" SLACKONLY_REPO_CHECKSUMS = "CHECKSUMS.md5" SLACKONLY_REPO_CHANGELOG = "ChangeLog.txt" + + # Repository for slackware 15.0 stable. + PONCE_BIN_REPO_NAME = "ponce_bin" + PONCE_BIN_REPO = false + PONCE_BIN_REPO_MIRROR = "https://ponce.cc/slackware/slackware64-15.0/packages/" + PONCE_BIN_REPO_PACKAGES = "PACKAGES.TXT" + PONCE_BIN_REPO_CHECKSUMS = "CHECKSUMS.md5" + PONCE_BIN_REPO_CHANGELOG = "ChangeLog.txt" diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index be7b121e..e7c3a3c9 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -59,6 +59,11 @@ class CheckUpdates(Configs): self.repo_chg_txt: str = f'{self.repos.slackonly_repo_mirror}{self.repos.slackonly_repo_changelog}' compare[self.repos.slackonly_repo_name] = self.compare_dates() + if self.repos.ponce_bin_repo and self.repo == self.repos.ponce_bin_repo_name or self.repo == '*': + self.local_chg_txt: Path = Path(self.repos.ponce_bin_repo_path, self.repos.ponce_bin_repo_changelog) + self.repo_chg_txt: str = f'{self.repos.ponce_bin_repo_mirror}{self.repos.ponce_bin_repo_changelog}' + compare[self.repos.ponce_bin_repo_name] = self.compare_dates() + else: if self.repos.ponce_repo: self.local_chg_txt: Path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_changelog) diff --git a/slpkg/install_data.py b/slpkg/install_data.py index 0fc81193..63264bcd 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -441,3 +441,88 @@ class InstallData(Configs): print(f'{self.byellow}Done{self.endc}') self.session.commit() + + def install_ponce_bin_data(self) -> None: + """ Install the data for ponce_bin repository. """ + checksums_dict: dict = {} + pkg_tag = [ + 'PACKAGE NAME:', + 'PACKAGE MIRROR:', + 'PACKAGE LOCATION:', + 'PACKAGE SIZE (compressed):', + 'PACKAGE SIZE (uncompressed):', + 'PACKAGE DESCRIPTION:' + ] + path_packages: Path = Path(self.repos.ponce_bin_repo_path, self.repos.ponce_bin_repo_packages) + path_checksums: Path = Path(self.repos.ponce_bin_repo_path, self.repos.ponce_bin_repo_checksums) + path_changelog: Path = Path(self.repos.ponce_bin_repo_path, self.repos.ponce_bin_repo_changelog) + packages_txt: list = self.utils.read_file(path_packages) + checksums_md5: list = self.utils.read_file(path_checksums) + + for line in checksums_md5: + line = line.strip() + + if line.endswith(('.txz', '.tgz')): + file: str = line.split('./')[1].strip() + checksum: str = line.split('./')[0].strip() + checksums_dict[file] = checksum + + cache: list = [] # init cache + + print('Creating the database... ', end='', flush=True) + + 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) + cache.append(self.repos.ponce_bin_repo_mirror) + try: + cache.append(checksums_dict[package_name]) + except KeyError: + cache.append('error checksum') + + if line.startswith(pkg_tag[2]): + package_location = line.replace(pkg_tag[2], '').strip() + cache.append(package_location[1:]) # Do not install (.) dot + + if line.startswith(pkg_tag[3]): + package_size_comp = line.replace(pkg_tag[3], '').strip() + cache.append(f'{package_size_comp}B') + + if line.startswith(pkg_tag[4]): + package_size_uncomp = line.replace(pkg_tag[4], '').strip() + cache.append(f'{package_size_uncomp}B') + + if line.startswith(pkg_tag[5]): + package_description = line.replace(pkg_tag[5], '').strip() + cache.append(package_description) + + if len(cache) == 9: + data: str = BinariesTable( + repo=self.repos.ponce_bin_repo_name, + name=cache[0], + version=cache[1], + package=cache[2], + mirror=cache[3], + checksum=cache[4], + location=cache[5], + size_comp=cache[6], + size_uncomp=cache[7], + description=cache[8] + ) + + self.session.add(data) + + cache: list = [] # reset cache + + last_updated: str = self.last_updated(path_changelog) + date: str = LastRepoUpdated(repo=self.repos.ponce_bin_repo_name, date=last_updated) + self.session.add(date) + + print(f'{self.byellow}Done{self.endc}') + + self.session.commit() diff --git a/slpkg/repo_info.py b/slpkg/repo_info.py index e3705875..3e269c44 100644 --- a/slpkg/repo_info.py +++ b/slpkg/repo_info.py @@ -64,7 +64,8 @@ class RepoInfo(Configs): self.repos.alien_repo_name: BinQueries('', repo).count_packages(), self.repos.gnome_repo_name: BinQueries('', repo).count_packages(), self.repos.conraid_repo_name: BinQueries('', repo).count_packages(), - self.repos.slackonly_repo_name: BinQueries('', repo).count_packages() + self.repos.slackonly_repo_name: BinQueries('', repo).count_packages(), + self.repos.ponce_bin_repo_name: BinQueries('', repo).count_packages() } if value[0]: diff --git a/slpkg/repositories.py b/slpkg/repositories.py index 313244a3..3c7ba1f4 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -42,7 +42,7 @@ class Repositories: ponce_repo_tag: str = "_SBo" alien_repo_name: str = 'alien' - alien_repo: bool = True + alien_repo: bool = False alien_repo_path: Path = Path(config.lib_path, 'repositories', alien_repo_name) alien_repo_mirror: str = "http://slackware.uk/people/alien/sbrepos/15.0/x86_64/" alien_repo_changelog_mirror: str = "http://slackware.uk/people/alien/sbrepos/" @@ -51,7 +51,7 @@ class Repositories: alien_repo_changelog: str = "ChangeLog.txt" gnome_repo_name: str = 'gnome' - gnome_repo: bool = True + gnome_repo: bool = False gnome_repo_path: Path = Path(config.lib_path, 'repositories', gnome_repo_name) gnome_repo_mirror: str = "https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/" gnome_repo_packages: str = "PACKAGES.TXT" @@ -59,7 +59,7 @@ class Repositories: gnome_repo_changelog: str = "ChangeLog.txt" conraid_repo_name: str = 'conraid' - conraid_repo: bool = True + conraid_repo: bool = False conraid_repo_path: Path = Path(config.lib_path, 'repositories', conraid_repo_name) conraid_repo_mirror: str = "https://reddoglinux.ddns.net/linux/conraid_43.x/x86_64/" conraid_repo_packages: str = "PACKAGES.TXT" @@ -67,13 +67,21 @@ class Repositories: conraid_repo_changelog: str = "ChangeLog.txt" slackonly_repo_name: str = 'slackonly' - slackonly_repo: bool = True + slackonly_repo: bool = False slackonly_repo_path: Path = Path(config.lib_path, 'repositories', slackonly_repo_name) slackonly_repo_mirror: str = "https://packages.slackonly.com/pub/packages/15.0-x86_64/" slackonly_repo_packages: str = "PACKAGES.TXT" slackonly_repo_checksums: str = "CHECKSUMS.md5" slackonly_repo_changelog: str = "ChangeLog.txt" + ponce_bin_repo_name: str = 'ponce_bin' + ponce_bin_repo: bool = False + ponce_bin_repo_path: Path = Path(config.lib_path, 'repositories', ponce_bin_repo_name) + ponce_bin_repo_mirror: str = "https://ponce.cc/slackware/slackware64-15.0/packages/" + ponce_bin_repo_packages: str = "PACKAGES.TXT" + ponce_bin_repo_checksums: str = "CHECKSUMS.md5" + ponce_bin_repo_changelog: str = "ChangeLog.txt" + # Default repository tag. repo_tag: str = sbo_repo_tag @@ -128,6 +136,13 @@ class Repositories: slackonly_repo_checksums: str = repos['SLACKONLY_REPO_CHECKSUMS'] slackonly_repo_changelog: str = repos['SLACKONLY_REPO_CHANGELOG'] + ponce_bin_repo_name: str = repos['PONCE_BIN_REPO_NAME'] + ponce_bin_repo: bool = repos['PONCE_BIN_REPO'] + ponce_bin_repo_mirror: str = repos['PONCE_BIN_REPO_MIRROR'] + ponce_bin_repo_packages: str = repos['PONCE_BIN_REPO_PACKAGES'] + ponce_bin_repo_checksums: str = repos['PONCE_BIN_REPO_CHECKSUMS'] + ponce_bin_repo_changelog: str = repos['PONCE_BIN_REPO_CHANGELOG'] + except (tomli.TOMLDecodeError, KeyError) as error: raise SystemExit(f"\n{config.prog_name} {bred}Error{endc}: {error}: in the configuration file " f"'{repositories_file_toml}'.\n" @@ -140,7 +155,8 @@ class Repositories: alien_repo_name: alien_repo, gnome_repo_name: gnome_repo, conraid_repo_name: conraid_repo, - slackonly_repo_name: slackonly_repo + slackonly_repo_name: slackonly_repo, + ponce_bin_repo_name: ponce_bin_repo } # All enabled binaries repositories. @@ -160,5 +176,6 @@ class Repositories: alien_repo_name: [alien_repo, alien_repo_path, alien_repo_changelog], gnome_repo_name: [gnome_repo, gnome_repo_path, gnome_repo_changelog], conraid_repo_name: [conraid_repo, conraid_repo_path, conraid_repo_changelog], - slackonly_repo_name: [slackonly_repo, slackonly_repo_path, slackonly_repo_changelog] + slackonly_repo_name: [slackonly_repo, slackonly_repo_path, slackonly_repo_changelog], + ponce_bin_repo_name: [ponce_bin_repo, ponce_bin_repo_path, ponce_bin_repo_changelog] } diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index 4d358c1e..d2d4c47c 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -65,6 +65,9 @@ class UpdateRepository(Configs): if self.repo == self.repos.slackonly_repo_name or self.repo == '*': self.slackonly_repository() + + if self.repo == self.repos.ponce_bin_repo_name or self.repo == '*': + self.ponce_bin_repository() else: self.slackbuild_repositories() @@ -174,6 +177,33 @@ class UpdateRepository(Configs): else: self.not_enabled_message(self.repos.slackonly_repo_name) + def ponce_bin_repository(self): + if self.repos.ponce_bin_repo: + urls: list = [] + print('Updating the packages list...\n') + print(f"Downloading the '{self.green}{self.repos.ponce_bin_repo_name}{self.endc}' " + f"repository, please wait...\n") + self.make_dirs(self.repos.ponce_bin_repo_name) + + urls.append(f'{self.repos.ponce_bin_repo_mirror}{self.repos.ponce_bin_repo_packages}') + urls.append(f'{self.repos.ponce_bin_repo_mirror}{self.repos.ponce_bin_repo_changelog}') + urls.append(f'{self.repos.ponce_bin_repo_mirror}{self.repos.ponce_bin_repo_checksums}') + + self.utils.remove_file_if_exists(self.repos.ponce_bin_repo_path, self.repos.ponce_bin_repo_packages) + self.utils.remove_file_if_exists(self.repos.ponce_bin_repo_path, self.repos.ponce_bin_repo_changelog) + self.utils.remove_file_if_exists(self.repos.ponce_bin_repo_path, self.repos.ponce_bin_repo_checksums) + + down = Downloader(self.repos.ponce_bin_repo_path, urls, self.flags) + down.download() + print() + + self.delete_binaries_data(self.repos.ponce_bin_repo_name) + self.delete_last_updated(self.repos.ponce_bin_repo_name) + self.data.install_ponce_bin_data() + print() + else: + self.not_enabled_message(self.repos.ponce_bin_repo_name) + def slackbuild_repositories(self): """ Update the slackbuild repositories. """ if self.repos.ponce_repo: From 7fa5381448e624182ac9b9f0d1e91a24dbce5b1d Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 21:34:53 +0300 Subject: [PATCH 30/74] Fixed for requires --- slpkg/install_data.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/slpkg/install_data.py b/slpkg/install_data.py index 63264bcd..bf8e9566 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -250,7 +250,8 @@ class InstallData(Configs): location=cache[5], size_comp=cache[6], size_uncomp=cache[7], - description=cache[8] + description=cache[8], + required='' ) self.session.add(data) @@ -336,7 +337,8 @@ class InstallData(Configs): location=cache[5], size_comp=cache[6], size_uncomp=cache[7], - description=cache[8] + description=cache[8], + required='', ) self.session.add(data) @@ -512,7 +514,8 @@ class InstallData(Configs): location=cache[5], size_comp=cache[6], size_uncomp=cache[7], - description=cache[8] + description=cache[8], + required='' ) self.session.add(data) From 7b212704ba0952f4e7c534ff4d588297f25aa96b Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 21:39:00 +0300 Subject: [PATCH 31/74] Updated for mirrors --- configs/repositories.toml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/configs/repositories.toml b/configs/repositories.toml index 0e0b8fd3..a1e42490 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -5,8 +5,9 @@ # Default is the 'sbo' repository. ######################################################################## -# Note: Before using the repository, make sure you have read about it, # -# some repositories are for -current only. # +# Note: Before using the repository, make sure you have read about it. # +# Some repositories are for -current only. Change the mirror if # +# it is necessary. # ######################################################################## [REPOSITORIES] @@ -28,6 +29,7 @@ PONCE_REPO_TAG = "_SBo" # Repository for slackware 15.0 stable. + # Mirror for -current: http://slackware.uk/people/alien/sbrepos/current/x86_64/ ALIEN_REPO_NAME = "alien" ALIEN_REPO = false ALIEN_REPO_MIRROR = "http://slackware.uk/people/alien/sbrepos/15.0/x86_64/" @@ -53,6 +55,7 @@ CONRAID_REPO_CHANGELOG = "ChangeLog.txt" # Repository for slackware 15.0 stable. + # Mirror for -current: https://packages.slackonly.com/pub/packages/current-x86_64/ SLACKONLY_REPO_NAME = "slackonly" SLACKONLY_REPO = false SLACKONLY_REPO_MIRROR = "https://packages.slackonly.com/pub/packages/15.0-x86_64/" @@ -61,6 +64,7 @@ SLACKONLY_REPO_CHANGELOG = "ChangeLog.txt" # Repository for slackware 15.0 stable. + # Mirror for -current: https://ponce.cc/slackware/slackware64-current/packages/ PONCE_BIN_REPO_NAME = "ponce_bin" PONCE_BIN_REPO = false PONCE_BIN_REPO_MIRROR = "https://ponce.cc/slackware/slackware64-15.0/packages/" From 6f0806e1b2546dc46e77c19dc4663cb293212524 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 21:49:03 +0300 Subject: [PATCH 32/74] Updated for summary --- slpkg/repo_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/slpkg/repo_info.py b/slpkg/repo_info.py index 3e269c44..edd126ed 100644 --- a/slpkg/repo_info.py +++ b/slpkg/repo_info.py @@ -77,4 +77,5 @@ class RepoInfo(Configs): f"{self.yellow}{count:>12}{self.endc}") print('=' * self.columns) - print(f"{self.grey}Total of {enabled} repositories are enabled with {total_packages} packages available.") + print(f"{self.grey}Total of {enabled}/{len(self.repos.repos_dict)} " + f"repositories are enabled with {total_packages} packages available.") From eeaf06ea60e2b185cc1c57ad473e87b6fd5afb68 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 22:44:40 +0300 Subject: [PATCH 33/74] Added multilib repo --- configs/repositories.toml | 10 +++++ slpkg/check_updates.py | 6 +++ slpkg/install_data.py | 86 ++++++++++++++++++++++++++++++++++++++ slpkg/repo_info.py | 1 + slpkg/repositories.py | 19 +++++++++ slpkg/update_repository.py | 30 +++++++++++++ 6 files changed, 152 insertions(+) diff --git a/configs/repositories.toml b/configs/repositories.toml index a1e42490..bd006cdd 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -38,6 +38,16 @@ ALIEN_REPO_CHECKSUMS = "CHECKSUMS.md5" ALIEN_REPO_CHANGELOG = "ChangeLog.txt" + # Repository for slackware 15.0 stable. + # Mirror for -current: https://slackware.nl/people/alien/multilib/current/ + MULTILIB_REPO_NAME = "multilib" + MULTILIB_REPO = false + MULTILIB_REPO_MIRROR = "https://slackware.nl/people/alien/multilib/15.0/" + MULTILIB_REPO_CHANGELOG_MIRROR = "https://slackware.nl/people/alien/multilib/" + MULTILIB_REPO_PACKAGES = "PACKAGES.TXT" + MULTILIB_REPO_CHECKSUMS = "CHECKSUMS.md5" + MULTILIB_REPO_CHANGELOG = "ChangeLog.txt" + # Repository for slackware -current. GNOME_REPO_NAME = "gnome" GNOME_REPO = false diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index e7c3a3c9..c46a117d 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -44,6 +44,12 @@ class CheckUpdates(Configs): self.repo_chg_txt: str = f'{self.repos.alien_repo_changelog_mirror}{self.repos.alien_repo_changelog}' compare[self.repos.alien_repo_name] = self.compare_dates() + if self.repos.multilib_repo and self.repo == self.repos.multilib_repo_name or self.repo == '*': + self.local_chg_txt: Path = Path(self.repos.multilib_repo_path, self.repos.multilib_repo_changelog) + self.repo_chg_txt: str = (f'{self.repos.multilib_repo_changelog_mirror}' + f'{self.repos.multilib_repo_changelog}') + compare[self.repos.multilib_repo_name] = self.compare_dates() + if self.repos.gnome_repo and self.repo == self.repos.gnome_repo_name or self.repo == '*': self.local_chg_txt: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_changelog) self.repo_chg_txt: str = f'{self.repos.gnome_repo_mirror}{self.repos.gnome_repo_changelog}' diff --git a/slpkg/install_data.py b/slpkg/install_data.py index bf8e9566..4e0b21ab 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -180,6 +180,92 @@ class InstallData(Configs): self.session.commit() + def install_multilib_data(self) -> None: + """ Install the data for multilib repository. """ + checksums_dict: dict = {} + pkg_tag = [ + 'PACKAGE NAME:', + 'PACKAGE LOCATION:', + 'PACKAGE SIZE (compressed):', + 'PACKAGE SIZE (uncompressed):', + 'PACKAGE DESCRIPTION:' + ] + path_packages: Path = Path(self.repos.multilib_repo_path, self.repos.multilib_repo_packages) + path_checksums: Path = Path(self.repos.multilib_repo_path, self.repos.multilib_repo_checksums) + path_changelog: Path = Path(self.repos.multilib_repo_path, self.repos.multilib_repo_changelog) + packages_txt: list = self.utils.read_file(path_packages) + checksums_md5: list = self.utils.read_file(path_checksums) + + for line in checksums_md5: + line = line.strip() + + if line.endswith(('.txz', '.tgz')): + file: str = line.split('./')[1].split('/')[-1].strip() + checksum: str = line.split('./')[0].strip() + checksums_dict[file] = checksum + + cache: list = [] # init cache + + print('Creating the database... ', end='', flush=True) + + 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) + cache.append(self.repos.multilib_repo_mirror) + try: + cache.append(checksums_dict[package_name]) + except KeyError: + cache.append('error checksum') + + if line.startswith(pkg_tag[1]): + package_location = line.replace(pkg_tag[1], '').strip() + cache.append(package_location[1:]) # Do not install (.) dot + + if line.startswith(pkg_tag[2]): + package_size_comp = line.replace(pkg_tag[2], '').strip() + cache.append(f'{package_size_comp}B') + + if line.startswith(pkg_tag[3]): + package_size_uncomp = line.replace(pkg_tag[3], '').strip() + cache.append(f'{package_size_uncomp}B') + + if line.startswith(pkg_tag[4]): + package_description = line.replace(pkg_tag[4], '').strip() + cache.append(package_description) + + if len(cache) == 9: + data: str = BinariesTable( + repo=self.repos.multilib_repo_name, + name=cache[0], + version=cache[1], + package=cache[2], + mirror=cache[3], + checksum=cache[4], + location=cache[5], + size_comp=cache[6], + size_uncomp=cache[7], + description=cache[8], + required='' + + ) + + self.session.add(data) + + cache: list = [] # reset cache + + last_updated: str = self.last_updated(path_changelog) + date: str = LastRepoUpdated(repo=self.repos.multilib_repo_name, date=last_updated) + self.session.add(date) + + print(f'{self.byellow}Done{self.endc}') + + self.session.commit() + def install_gnome_data(self) -> None: """ Install the data for gnome repository. """ checksums_dict: dict = {} diff --git a/slpkg/repo_info.py b/slpkg/repo_info.py index edd126ed..c791b6f5 100644 --- a/slpkg/repo_info.py +++ b/slpkg/repo_info.py @@ -62,6 +62,7 @@ class RepoInfo(Configs): self.repos.sbo_repo_name: SBoQueries('').count_packages(), self.repos.ponce_repo_name: SBoQueries('').count_packages(), self.repos.alien_repo_name: BinQueries('', repo).count_packages(), + self.repos.multilib_repo_name: BinQueries('', repo).count_packages(), self.repos.gnome_repo_name: BinQueries('', repo).count_packages(), self.repos.conraid_repo_name: BinQueries('', repo).count_packages(), self.repos.slackonly_repo_name: BinQueries('', repo).count_packages(), diff --git a/slpkg/repositories.py b/slpkg/repositories.py index 3c7ba1f4..aa9a3f54 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -50,6 +50,15 @@ class Repositories: alien_repo_checksums: str = "CHECKSUMS.md5" alien_repo_changelog: str = "ChangeLog.txt" + multilib_repo_name: str = 'multilib' + multilib_repo: bool = False + multilib_repo_path: Path = Path(config.lib_path, 'repositories', multilib_repo_name) + multilib_repo_mirror: str = "https://slackware.nl/people/alien/multilib/15.0/" + multilib_repo_changelog_mirror: str = "https://slackware.nl/people/alien/multilib/" + multilib_repo_packages: str = "PACKAGES.TXT" + multilib_repo_checksums: str = "CHECKSUMS.md5" + multilib_repo_changelog: str = "ChangeLog.txt" + gnome_repo_name: str = 'gnome' gnome_repo: bool = False gnome_repo_path: Path = Path(config.lib_path, 'repositories', gnome_repo_name) @@ -115,6 +124,14 @@ class Repositories: alien_repo_checksums: str = repos['ALIEN_REPO_CHECKSUMS'] alien_repo_changelog: str = repos['ALIEN_REPO_CHANGELOG'] + multilib_repo_name: str = repos['MULTILIB_REPO_NAME'] + multilib_repo: bool = repos['MULTILIB_REPO'] + multilib_repo_mirror: str = repos['MULTILIB_REPO_MIRROR'] + multilib_repo_changelog_mirror: str = repos['MULTILIB_REPO_CHANGELOG_MIRROR'] + multilib_repo_packages: str = repos['MULTILIB_REPO_PACKAGES'] + multilib_repo_checksums: str = repos['MULTILIB_REPO_CHECKSUMS'] + multilib_repo_changelog: str = repos['MULTILIB_REPO_CHANGELOG'] + gnome_repo_name: str = repos['GNOME_REPO_NAME'] gnome_repo: bool = repos['GNOME_REPO'] gnome_repo_mirror: str = repos['GNOME_REPO_MIRROR'] @@ -153,6 +170,7 @@ class Repositories: # Dictionary with the binaries repositories. binaries_repositories_dict = { alien_repo_name: alien_repo, + multilib_repo_name: multilib_repo, gnome_repo_name: gnome_repo, conraid_repo_name: conraid_repo, slackonly_repo_name: slackonly_repo, @@ -174,6 +192,7 @@ class Repositories: sbo_repo_name: [sbo_enabled, sbo_repo_path, sbo_repo_changelog], ponce_repo_name: [ponce_repo, ponce_repo_path, ponce_repo_changelog], alien_repo_name: [alien_repo, alien_repo_path, alien_repo_changelog], + multilib_repo_name: [multilib_repo, multilib_repo_path, multilib_repo_changelog], gnome_repo_name: [gnome_repo, gnome_repo_path, gnome_repo_changelog], conraid_repo_name: [conraid_repo, conraid_repo_path, conraid_repo_changelog], slackonly_repo_name: [slackonly_repo, slackonly_repo_path, slackonly_repo_changelog], diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index d2d4c47c..6b00187a 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -68,6 +68,9 @@ class UpdateRepository(Configs): if self.repo == self.repos.ponce_bin_repo_name or self.repo == '*': self.ponce_bin_repository() + + if self.repo == self.repos.multilib_repo_name or self.repo == '*': + self.multilib_repository() else: self.slackbuild_repositories() @@ -97,6 +100,33 @@ class UpdateRepository(Configs): else: self.not_enabled_message(self.repos.alien_repo_name) + def multilib_repository(self): + if self.repos.multilib_repo: + urls: list = [] + print('Updating the packages list...\n') + print(f"Downloading the '{self.green}{self.repos.multilib_repo_name}{self.endc}' " + f"repository, please wait...\n") + self.make_dirs(self.repos.multilib_repo_name) + + urls.append(f'{self.repos.multilib_repo_mirror}{self.repos.multilib_repo_packages}') + urls.append(f'{self.repos.multilib_repo_changelog_mirror}{self.repos.multilib_repo_changelog}') + urls.append(f'{self.repos.multilib_repo_mirror}{self.repos.multilib_repo_checksums}') + + self.utils.remove_file_if_exists(self.repos.multilib_repo_path, self.repos.multilib_repo_packages) + self.utils.remove_file_if_exists(self.repos.multilib_repo_path, self.repos.multilib_repo_changelog) + self.utils.remove_file_if_exists(self.repos.multilib_repo_path, self.repos.multilib_repo_checksums) + + down = Downloader(self.repos.multilib_repo_path, urls, self.flags) + down.download() + print() + + self.delete_binaries_data(self.repos.multilib_repo_name) + self.delete_last_updated(self.repos.multilib_repo_name) + self.data.install_multilib_data() + print() + else: + self.not_enabled_message(self.repos.multilib_repo_name) + def gnome_repository(self): if self.repos.gnome_repo: urls: list = [] From 5fd2dad816c54cfa44b7bb4cbc831b047ad982ad Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 22:48:46 +0300 Subject: [PATCH 34/74] Fixed pkg pattern search --- slpkg/search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/search.py b/slpkg/search.py index 48958701..6629c468 100644 --- a/slpkg/search.py +++ b/slpkg/search.py @@ -60,7 +60,7 @@ class SearchPackage(Configs): for pkg in packages: for pr in pkg_repo: - if pkg in pr: + if pkg in pr or pkg == '*': matching += 1 desc: str = BinQueries(pr, repo).description() From 232385fe63e36098ba349cad791396ed4820523d Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 22:54:17 +0300 Subject: [PATCH 35/74] Fixed typo --- man/slpkg.1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/man/slpkg.1 b/man/slpkg.1 index 5e4bd934..b9e697ce 100644 --- a/man/slpkg.1 +++ b/man/slpkg.1 @@ -11,7 +11,7 @@ slpkg [-h|-v] [-u, update] [-U, upgrade] [-c, check-updates] [-I, repo-info] [-g [-D, clean-tmp] [-T, clean-data] [-b, build] [-i, install] [-d, download] [-R, remove] [-f, find] [-w, view] [-s, search] [-e, dependees] [-t, tracking] -y, --yes, -j, --jobs, -o, --resolve-off, -r, --reinstall, -k, --skip-installed, -E, --full-reverse, -S, --search, -n, --no-silent, -p, --pkg-version, -z, --G, --generate-only, -P, --parallel, -B, --bin-repo=[\fIPATH\fR], -z, --directory=[\fIPATH\fR] +-G, --generate-only, -P, --parallel, -B, --bin-repo=[\fIREPO\fR], -z, --directory=[\fIPATH\fR] .SH DESCRIPTION .P Slpkg is a software package manager that installs, updates, and removes packages on Slackware based systems. @@ -131,7 +131,7 @@ Turns off dependency resolving. (to be used with: -U, upgrade, -b, build, -i, in .B -r, --reinstall .RS Use this option if you want to upgrade all packages even if the same version is already installed. -Do not skip installed packages. (to be used with: upgrade, -i, install) +Do not skip installed packages. (to be used with: -U, upgrade, -i, install) .RE .P .B -k, --skip-installed From b97424c835c4b5ed0f9769d54986cd8e747a3562 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 22:54:33 +0300 Subject: [PATCH 36/74] Updated comments --- slpkg/search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/search.py b/slpkg/search.py index 6629c468..be64d646 100644 --- a/slpkg/search.py +++ b/slpkg/search.py @@ -28,7 +28,7 @@ class SearchPackage(Configs): self.flag_bin_repository: list = ['-B=', '--bin-repo='] def package(self, packages: list, repo=None) -> None: - """ Searching and print the matched slackbuilds. """ + """ Searching and print the matched packages. """ matching: int = 0 repository: str = '' From 34262069422a482d4c15ec80c453e328fc62175f Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 22:57:17 +0300 Subject: [PATCH 37/74] Fixed for keyerror --- slpkg/main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/slpkg/main.py b/slpkg/main.py index efe002f9..02daf377 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -729,8 +729,11 @@ class Argparse(Configs): def help_for_commands(self) -> None: """ Extra help information for commands. """ if len(self.args) == 2: - flags = self.commands[self.args[1]] - Help(self.args[1], flags).view() + try: + flags = self.commands[self.args[1]] + Help(self.args[1], flags).view() + except KeyError: + self.usage.help_short(1) else: self.usage.help_short(1) From 1b4b388442632a664e0d1a9a7e0f72a632486fae Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 23:04:51 +0300 Subject: [PATCH 38/74] Updated for help --- man/slpkg.1 | 3 ++- slpkg/views/help_commands.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/man/slpkg.1 b/man/slpkg.1 index b9e697ce..b73d9215 100644 --- a/man/slpkg.1 +++ b/man/slpkg.1 @@ -39,7 +39,8 @@ Check if there is any news on the repositories ChangeLog.txt file. .P .B -I, repo-info .RS -Prints the repositories information. +View information related to repositories, such as which repositories are active, when they were upgraded, +and how many packages they contain. .RE .P .B -L, clean-logs diff --git a/slpkg/views/help_commands.py b/slpkg/views/help_commands.py index 5281c000..e689fd30 100644 --- a/slpkg/views/help_commands.py +++ b/slpkg/views/help_commands.py @@ -26,6 +26,8 @@ class Help(Configs): 'update': "Updates the package list and the database.", 'upgrade': "Upgrade all the installed packages if the newer version exists in the repository.", 'check-updates': "Check if there is any news on the SlackBuild's ChangeLog.txt file.", + 'repo-info': "View information related to repositories, such as which repositories are active, " + "when they were upgraded, and how many packages they contain.", 'configs': "Edit the configuration '/etc/slpkg/slpkg.toml' file.", 'clean-logs': "Cleans dependencies log tracking. After that procedure you should remove dependencies " "by hand.", @@ -49,6 +51,7 @@ class Help(Configs): help_commands['-u'] = help_commands['update'] help_commands['-U'] = help_commands['upgrade'] help_commands['-c'] = help_commands['check-updates'] + help_commands['-I'] = help_commands['repo-info'] help_commands['-g'] = help_commands['configs'] help_commands['-L'] = help_commands['clean-logs'] help_commands['-D'] = help_commands['clean-tmp'] From 49cf129c60c4e752ac250a9324553813430f485b Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 23:08:43 +0300 Subject: [PATCH 39/74] Updated for error msg --- slpkg/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/main.py b/slpkg/main.py index 02daf377..126f8753 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -733,7 +733,7 @@ class Argparse(Configs): flags = self.commands[self.args[1]] Help(self.args[1], flags).view() except KeyError: - self.usage.help_short(1) + self.usage.help_minimal(f"{self.prog_name}: invalid argument '{''.join(self.args[1])}'") else: self.usage.help_short(1) From 186f86d6e8a3fe8e375b98ff3b333d297b0e8c2d Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 23:08:58 +0300 Subject: [PATCH 40/74] Updated for check-updates --- slpkg/views/help_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/views/help_commands.py b/slpkg/views/help_commands.py index e689fd30..8f662f1b 100644 --- a/slpkg/views/help_commands.py +++ b/slpkg/views/help_commands.py @@ -25,7 +25,7 @@ class Help(Configs): help_commands: dict = { 'update': "Updates the package list and the database.", 'upgrade': "Upgrade all the installed packages if the newer version exists in the repository.", - 'check-updates': "Check if there is any news on the SlackBuild's ChangeLog.txt file.", + 'check-updates': "Check if there is any news on the repositories ChangeLog.txt file.", 'repo-info': "View information related to repositories, such as which repositories are active, " "when they were upgraded, and how many packages they contain.", 'configs': "Edit the configuration '/etc/slpkg/slpkg.toml' file.", From 5b4e03de9f16351a24d058fdeafb495b8f28b57c Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 23:10:26 +0300 Subject: [PATCH 41/74] Updated for commands --- slpkg/views/cli_menu.py | 2 +- slpkg/views/help_commands.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index 5cb5cae2..fb528fd9 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -70,7 +70,7 @@ class Usage(Configs): f' {self.cyan}-f, find{self.endc} [packages...] Find installed packages.\n' f' {self.cyan}-w, view{self.endc} [packages...] View packages from the repository.\n' f' {self.cyan}-s, search{self.endc} [packages...] Search packages from the repository.\n' - f' {self.cyan}-e, dependees{self.endc} [packages...] Show which packages depend.\n' + f' {self.cyan}-e, dependees{self.endc} [packages...] Show which packages depend on.\n' f' {self.cyan}-t, tracking{self.endc} [packages...] Tracking the packages dependencies.\n' f'\n{self.bold}OPTIONS:{self.endc}\n' f' {self.yellow}-y, --yes{self.endc} Answer Yes to all questions.\n' diff --git a/slpkg/views/help_commands.py b/slpkg/views/help_commands.py index 8f662f1b..fd19366e 100644 --- a/slpkg/views/help_commands.py +++ b/slpkg/views/help_commands.py @@ -44,7 +44,7 @@ class Help(Configs): 'find': "Find your installed packages on your system.", 'view': "View information packages from the repository and get everything in your terminal.", 'search': "Search and match packages from the repository.", - 'dependees': "Show which SlackBuilds depend on.", + 'dependees': "Show which packages depend on.", 'tracking': "Tracking the packages dependencies." } From be75c741d238ea205d6000fdf76e7bf9769d90c7 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 23:41:29 +0300 Subject: [PATCH 42/74] Added restricted repo --- configs/repositories.toml | 10 +++++ slpkg/check_updates.py | 6 +++ slpkg/install_data.py | 86 ++++++++++++++++++++++++++++++++++++++ slpkg/repo_info.py | 1 + slpkg/repositories.py | 19 +++++++++ slpkg/update_repository.py | 30 +++++++++++++ 6 files changed, 152 insertions(+) diff --git a/configs/repositories.toml b/configs/repositories.toml index bd006cdd..f1ab5778 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -48,6 +48,16 @@ MULTILIB_REPO_CHECKSUMS = "CHECKSUMS.md5" MULTILIB_REPO_CHANGELOG = "ChangeLog.txt" + # Repository for slackware 15.0 stable. + # Mirror for -current: https://slackware.nl/people/alien/restricted_sbrepos/current/x86_64/ + RESTRICTED_REPO_NAME = "restricted" + RESTRICTED_REPO = false + RESTRICTED_REPO_MIRROR = "https://slackware.nl/people/alien/restricted_sbrepos/15.0/x86_64/" + RESTRICTED_REPO_CHANGELOG_MIRROR = "https://slackware.nl/people/alien/restricted_sbrepos/" + RESTRICTED_REPO_PACKAGES = "PACKAGES.TXT" + RESTRICTED_REPO_CHECKSUMS = "CHECKSUMS.md5" + RESTRICTED_REPO_CHANGELOG = "ChangeLog.txt" + # Repository for slackware -current. GNOME_REPO_NAME = "gnome" GNOME_REPO = false diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index c46a117d..5465fbe6 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -50,6 +50,12 @@ class CheckUpdates(Configs): f'{self.repos.multilib_repo_changelog}') compare[self.repos.multilib_repo_name] = self.compare_dates() + if self.repos.restricted_repo and self.repo == self.repos.restricted_repo_name or self.repo == '*': + self.local_chg_txt: Path = Path(self.repos.restricted_repo_path, self.repos.restricted_repo_changelog) + self.repo_chg_txt: str = (f'{self.repos.restricted_repo_changelog_mirror}' + f'{self.repos.restricted_repo_changelog}') + compare[self.repos.restricted_repo_name] = self.compare_dates() + if self.repos.gnome_repo and self.repo == self.repos.gnome_repo_name or self.repo == '*': self.local_chg_txt: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_changelog) self.repo_chg_txt: str = f'{self.repos.gnome_repo_mirror}{self.repos.gnome_repo_changelog}' diff --git a/slpkg/install_data.py b/slpkg/install_data.py index 4e0b21ab..1671383d 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -266,6 +266,92 @@ class InstallData(Configs): self.session.commit() + def install_restricted_data(self) -> None: + """ Install the data for multilib repository. """ + checksums_dict: dict = {} + pkg_tag = [ + 'PACKAGE NAME:', + 'PACKAGE LOCATION:', + 'PACKAGE SIZE (compressed):', + 'PACKAGE SIZE (uncompressed):', + 'PACKAGE DESCRIPTION:' + ] + path_packages: Path = Path(self.repos.restricted_repo_path, self.repos.restricted_repo_packages) + path_checksums: Path = Path(self.repos.restricted_repo_path, self.repos.restricted_repo_checksums) + path_changelog: Path = Path(self.repos.restricted_repo_path, self.repos.restricted_repo_changelog) + packages_txt: list = self.utils.read_file(path_packages) + checksums_md5: list = self.utils.read_file(path_checksums) + + for line in checksums_md5: + line = line.strip() + + if line.endswith(('.txz', '.tgz')): + file: str = line.split('./')[1].split('/')[-1].strip() + checksum: str = line.split('./')[0].strip() + checksums_dict[file] = checksum + + cache: list = [] # init cache + + print('Creating the database... ', end='', flush=True) + + 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) + cache.append(self.repos.restricted_repo_mirror) + try: + cache.append(checksums_dict[package_name]) + except KeyError: + cache.append('error checksum') + + if line.startswith(pkg_tag[1]): + package_location = line.replace(pkg_tag[1], '').strip() + cache.append(package_location[1:]) # Do not install (.) dot + + if line.startswith(pkg_tag[2]): + package_size_comp = line.replace(pkg_tag[2], '').strip() + cache.append(f'{package_size_comp}B') + + if line.startswith(pkg_tag[3]): + package_size_uncomp = line.replace(pkg_tag[3], '').strip() + cache.append(f'{package_size_uncomp}B') + + if line.startswith(pkg_tag[4]): + package_description = line.replace(pkg_tag[4], '').strip() + cache.append(package_description) + + if len(cache) == 9: + data: str = BinariesTable( + repo=self.repos.restricted_repo_name, + name=cache[0], + version=cache[1], + package=cache[2], + mirror=cache[3], + checksum=cache[4], + location=cache[5], + size_comp=cache[6], + size_uncomp=cache[7], + description=cache[8], + required='' + + ) + + self.session.add(data) + + cache: list = [] # reset cache + + last_updated: str = self.last_updated(path_changelog) + date: str = LastRepoUpdated(repo=self.repos.restricted_repo_name, date=last_updated) + self.session.add(date) + + print(f'{self.byellow}Done{self.endc}') + + self.session.commit() + def install_gnome_data(self) -> None: """ Install the data for gnome repository. """ checksums_dict: dict = {} diff --git a/slpkg/repo_info.py b/slpkg/repo_info.py index c791b6f5..92ba90be 100644 --- a/slpkg/repo_info.py +++ b/slpkg/repo_info.py @@ -63,6 +63,7 @@ class RepoInfo(Configs): self.repos.ponce_repo_name: SBoQueries('').count_packages(), self.repos.alien_repo_name: BinQueries('', repo).count_packages(), self.repos.multilib_repo_name: BinQueries('', repo).count_packages(), + self.repos.restricted_repo_name: BinQueries('', repo).count_packages(), self.repos.gnome_repo_name: BinQueries('', repo).count_packages(), self.repos.conraid_repo_name: BinQueries('', repo).count_packages(), self.repos.slackonly_repo_name: BinQueries('', repo).count_packages(), diff --git a/slpkg/repositories.py b/slpkg/repositories.py index aa9a3f54..7178bea1 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -59,6 +59,15 @@ class Repositories: multilib_repo_checksums: str = "CHECKSUMS.md5" multilib_repo_changelog: str = "ChangeLog.txt" + restricted_repo_name: str = 'restricted' + restricted_repo: bool = False + restricted_repo_path: Path = Path(config.lib_path, 'repositories', restricted_repo_name) + restricted_repo_mirror: str = "https://slackware.nl/people/alien/restricted_sbrepos/15.0/x86_64/" + restricted_repo_changelog_mirror: str = "https://slackware.nl/people/alien/restricted_sbrepos/" + restricted_repo_packages: str = "PACKAGES.TXT" + restricted_repo_checksums: str = "CHECKSUMS.md5" + restricted_repo_changelog: str = "ChangeLog.txt" + gnome_repo_name: str = 'gnome' gnome_repo: bool = False gnome_repo_path: Path = Path(config.lib_path, 'repositories', gnome_repo_name) @@ -132,6 +141,14 @@ class Repositories: multilib_repo_checksums: str = repos['MULTILIB_REPO_CHECKSUMS'] multilib_repo_changelog: str = repos['MULTILIB_REPO_CHANGELOG'] + restricted_repo_name: str = repos['RESTRICTED_REPO_NAME'] + restricted_repo: bool = repos['RESTRICTED_REPO'] + restricted_repo_mirror: str = repos['RESTRICTED_REPO_MIRROR'] + restricted_repo_changelog_mirror: str = repos['RESTRICTED_REPO_CHANGELOG_MIRROR'] + restricted_repo_packages: str = repos['RESTRICTED_REPO_PACKAGES'] + restricted_repo_checksums: str = repos['RESTRICTED_REPO_CHECKSUMS'] + restricted_repo_changelog: str = repos['RESTRICTED_REPO_CHANGELOG'] + gnome_repo_name: str = repos['GNOME_REPO_NAME'] gnome_repo: bool = repos['GNOME_REPO'] gnome_repo_mirror: str = repos['GNOME_REPO_MIRROR'] @@ -171,6 +188,7 @@ class Repositories: binaries_repositories_dict = { alien_repo_name: alien_repo, multilib_repo_name: multilib_repo, + restricted_repo_name: restricted_repo, gnome_repo_name: gnome_repo, conraid_repo_name: conraid_repo, slackonly_repo_name: slackonly_repo, @@ -193,6 +211,7 @@ class Repositories: ponce_repo_name: [ponce_repo, ponce_repo_path, ponce_repo_changelog], alien_repo_name: [alien_repo, alien_repo_path, alien_repo_changelog], multilib_repo_name: [multilib_repo, multilib_repo_path, multilib_repo_changelog], + restricted_repo_name: [restricted_repo, restricted_repo_path, restricted_repo_changelog], gnome_repo_name: [gnome_repo, gnome_repo_path, gnome_repo_changelog], conraid_repo_name: [conraid_repo, conraid_repo_path, conraid_repo_changelog], slackonly_repo_name: [slackonly_repo, slackonly_repo_path, slackonly_repo_changelog], diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index 6b00187a..3be2c07e 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -71,6 +71,9 @@ class UpdateRepository(Configs): if self.repo == self.repos.multilib_repo_name or self.repo == '*': self.multilib_repository() + + if self.repo == self.repos.restricted_repo_name or self.repo == '*': + self.restricted_repository() else: self.slackbuild_repositories() @@ -127,6 +130,33 @@ class UpdateRepository(Configs): else: self.not_enabled_message(self.repos.multilib_repo_name) + def restricted_repository(self): + if self.repos.restricted_repo: + urls: list = [] + print('Updating the packages list...\n') + print(f"Downloading the '{self.green}{self.repos.restricted_repo_name}{self.endc}' " + f"repository, please wait...\n") + self.make_dirs(self.repos.restricted_repo_name) + + urls.append(f'{self.repos.restricted_repo_mirror}{self.repos.restricted_repo_packages}') + urls.append(f'{self.repos.restricted_repo_changelog_mirror}{self.repos.restricted_repo_changelog}') + urls.append(f'{self.repos.restricted_repo_mirror}{self.repos.restricted_repo_checksums}') + + self.utils.remove_file_if_exists(self.repos.restricted_repo_path, self.repos.restricted_repo_packages) + self.utils.remove_file_if_exists(self.repos.restricted_repo_path, self.repos.restricted_repo_changelog) + self.utils.remove_file_if_exists(self.repos.restricted_repo_path, self.repos.restricted_repo_checksums) + + down = Downloader(self.repos.restricted_repo_path, urls, self.flags) + down.download() + print() + + self.delete_binaries_data(self.repos.restricted_repo_name) + self.delete_last_updated(self.repos.restricted_repo_name) + self.data.install_restricted_data() + print() + else: + self.not_enabled_message(self.repos.restricted_repo_name) + def gnome_repository(self): if self.repos.gnome_repo: urls: list = [] From 8d789304727ff6e1d5f2cd2d018a75beae5aa682 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 23:42:48 +0300 Subject: [PATCH 43/74] Removed no-silent --- man/slpkg.1 | 2 +- slpkg/main.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/man/slpkg.1 b/man/slpkg.1 index b73d9215..56b277a5 100644 --- a/man/slpkg.1 +++ b/man/slpkg.1 @@ -158,7 +158,7 @@ Example try: '\fIslpkg install python3 --search\fR' or '\fIslpkg download python .B -n, --no-silent .RS Disable silent mode, if it is enabled in the configuration file. (to be used with: -u, update, -U, upgrade, -b, build, --i, install, -d, download, -R, remove) +-i, install, -R, remove) .RE .P .B -p, --pkg-version diff --git a/slpkg/main.py b/slpkg/main.py index 126f8753..d0933b6b 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -199,8 +199,6 @@ class Argparse(Configs): self.flag_short_yes, self.flag_search, self.flag_short_search, - self.flag_no_silent, - self.flag_short_no_silent, self.flag_directory, self.flag_short_directory, self.flag_bin_repository, From 68c1fff43dc8f57141c5d7e3b39ca679f0b46e38 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 23:45:07 +0300 Subject: [PATCH 44/74] Updated title alignment --- slpkg/views/ascii.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/views/ascii.py b/slpkg/views/ascii.py index d5a2bb5f..9cc9d462 100644 --- a/slpkg/views/ascii.py +++ b/slpkg/views/ascii.py @@ -51,7 +51,7 @@ class Ascii(Configs): def draw_package_title_box(self, message: str, title: str) -> None: """ Drawing package title box. """ - middle_title: int = int((self.columns / 2) - len(title) + 6) + middle_title: int = int((self.columns / 2) - len(title) + 10) print(f'{self.bgreen}{self.upper_left_corner}' + f'{self.horizontal_line}' * (self.columns - 2) + f'{self.upper_right_corner}') From af250c20a3a027f1e1549ac05858a8a2e6c3af3a Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 23:52:27 +0300 Subject: [PATCH 45/74] Set for production --- slpkg/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/slpkg/main.py b/slpkg/main.py index d0933b6b..09159c14 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -785,10 +785,10 @@ def main(): '-t': argparse.tracking } - # try: - arguments[args[0]]() - # except (KeyError, IndexError): - usage.help_short(1) + try: + arguments[args[0]]() + except (KeyError, IndexError): + usage.help_short(1) if __name__ == '__main__': From 13480d60d68e2818b478b003b1b842022ddde346 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 23:53:23 +0300 Subject: [PATCH 46/74] Added new line --- slpkg/repo_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/repo_info.py b/slpkg/repo_info.py index 92ba90be..1985269d 100644 --- a/slpkg/repo_info.py +++ b/slpkg/repo_info.py @@ -80,4 +80,4 @@ class RepoInfo(Configs): print('=' * self.columns) print(f"{self.grey}Total of {enabled}/{len(self.repos.repos_dict)} " - f"repositories are enabled with {total_packages} packages available.") + f"repositories are enabled with {total_packages} packages available.\n") From 873f742848c2cedbd803ca0e930f6fe316830946 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 31 Mar 2023 12:16:18 +0300 Subject: [PATCH 47/74] Added salixos repo --- configs/repositories.toml | 8 ++++ slpkg/check_updates.py | 5 ++ slpkg/install_data.py | 95 ++++++++++++++++++++++++++++++++++++++ slpkg/repo_info.py | 3 +- slpkg/repositories.py | 21 ++++++++- slpkg/update_repository.py | 40 ++++++++++++++-- 6 files changed, 164 insertions(+), 8 deletions(-) diff --git a/configs/repositories.toml b/configs/repositories.toml index f1ab5778..dc2bbfdc 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -91,3 +91,11 @@ PONCE_BIN_REPO_PACKAGES = "PACKAGES.TXT" PONCE_BIN_REPO_CHECKSUMS = "CHECKSUMS.md5" PONCE_BIN_REPO_CHANGELOG = "ChangeLog.txt" + + # Repository for slackware 15.0 stable. + SALIXOS_REPO_NAME = "salixos" + SALIXOS_REPO = false + SALIXOS_REPO_MIRROR = "https://download.salixos.org/x86_64/slackware-15.0/" + SALIXOS_REPO_PACKAGES = "PACKAGES.TXT" + SALIXOS_REPO_CHECKSUMS = "CHECKSUMS.md5" + SALIXOS_REPO_CHANGELOG = "ChangeLog.txt" diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 5465fbe6..c51a4b19 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -76,6 +76,11 @@ class CheckUpdates(Configs): self.repo_chg_txt: str = f'{self.repos.ponce_bin_repo_mirror}{self.repos.ponce_bin_repo_changelog}' compare[self.repos.ponce_bin_repo_name] = self.compare_dates() + if self.repos.salixos_repo and self.repo == self.repos.salixos_repo_name or self.repo == '*': + self.local_chg_txt: Path = Path(self.repos.salixos_repo_path, self.repos.salixos_repo_changelog) + self.repo_chg_txt: str = f'{self.repos.salixos_repo_mirror}{self.repos.salixos_repo_changelog}' + compare[self.repos.salixos_repo_name] = self.compare_dates() + else: if self.repos.ponce_repo: self.local_chg_txt: Path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_changelog) diff --git a/slpkg/install_data.py b/slpkg/install_data.py index 1671383d..d0effc9d 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -701,3 +701,98 @@ class InstallData(Configs): print(f'{self.byellow}Done{self.endc}') self.session.commit() + + def install_salixos_data(self) -> None: + """ Install the data for slackonly repository. """ + checksums_dict: dict = {} + pkg_tag = [ + 'PACKAGE NAME:', + 'PACKAGE LOCATION:', + 'PACKAGE SIZE (compressed):', + 'PACKAGE SIZE (uncompressed):', + 'PACKAGE REQUIRED:', + 'PACKAGE DESCRIPTION:' + ] + path_packages: Path = Path(self.repos.salixos_repo_path, self.repos.salixos_repo_packages) + path_checksums: Path = Path(self.repos.salixos_repo_path, self.repos.salixos_repo_checksums) + path_changelog: Path = Path(self.repos.salixos_repo_path, self.repos.salixos_repo_changelog) + packages_txt: list = self.utils.read_file(path_packages) + checksums_md5: list = self.utils.read_file(path_checksums) + + for line in checksums_md5: + line = line.strip() + + if line.endswith(('.txz', '.tgz')): + file: str = line.split('./')[1].split('/')[-1].strip() + checksum: str = line.split('./')[0].strip() + checksums_dict[file] = checksum + + cache: list = [] # init cache + + print('Creating the database... ', end='', flush=True) + + 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) + cache.append(self.repos.salixos_repo_mirror) + try: + cache.append(checksums_dict[package_name]) + except KeyError: + cache.append('error checksum') + + if line.startswith(pkg_tag[1]): + package_location = line.replace(pkg_tag[1], '').strip() + cache.append(package_location[1:]) # Do not install (.) dot + + if line.startswith(pkg_tag[2]): + package_size_comp = line.replace(pkg_tag[2], '').strip() + cache.append(f'{package_size_comp}B') + + if line.startswith(pkg_tag[3]): + package_size_uncomp = line.replace(pkg_tag[3], '').strip() + cache.append(f'{package_size_uncomp}B') + + if line.startswith(pkg_tag[4]): + required = line.replace( + pkg_tag[4], '').replace( + ',', ' ').replace( + '|', ' ').strip() + list_required: list = required.split(' ') + package_required: str = ' '.join(list(set(list_required))) + cache.append(package_required) + + if line.startswith(pkg_tag[5]): + package_description = line.replace(pkg_tag[5], '').strip() + cache.append(package_description) + + if len(cache) == 10: + data: str = BinariesTable( + repo=self.repos.salixos_repo_name, + name=cache[0], + version=cache[1], + package=cache[2], + mirror=cache[3], + checksum=cache[4], + location=cache[5], + size_comp=cache[6], + size_uncomp=cache[7], + required=cache[8], + description=cache[9] + ) + + self.session.add(data) + + cache: list = [] # reset cache + + last_updated: str = self.last_updated(path_changelog) + date: str = LastRepoUpdated(repo=self.repos.salixos_repo_name, date=last_updated) + self.session.add(date) + + print(f'{self.byellow}Done{self.endc}') + + self.session.commit() diff --git a/slpkg/repo_info.py b/slpkg/repo_info.py index 1985269d..d7f15901 100644 --- a/slpkg/repo_info.py +++ b/slpkg/repo_info.py @@ -67,7 +67,8 @@ class RepoInfo(Configs): self.repos.gnome_repo_name: BinQueries('', repo).count_packages(), self.repos.conraid_repo_name: BinQueries('', repo).count_packages(), self.repos.slackonly_repo_name: BinQueries('', repo).count_packages(), - self.repos.ponce_bin_repo_name: BinQueries('', repo).count_packages() + self.repos.ponce_bin_repo_name: BinQueries('', repo).count_packages(), + self.repos.salixos_repo_name: BinQueries('', repo).count_packages() } if value[0]: diff --git a/slpkg/repositories.py b/slpkg/repositories.py index 7178bea1..d4efb5b6 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -100,6 +100,14 @@ class Repositories: ponce_bin_repo_checksums: str = "CHECKSUMS.md5" ponce_bin_repo_changelog: str = "ChangeLog.txt" + salixos_repo_name: str = 'salixos' + salixos_repo: bool = False + salixos_repo_path: Path = Path(config.lib_path, 'repositories', salixos_repo_name) + salixos_repo_mirror: str = "https://download.salixos.org/x86_64/slackware-15.0/" + salixos_repo_packages: str = "PACKAGES.TXT" + salixos_repo_checksums: str = "CHECKSUMS.md5" + salixos_repo_changelog: str = "ChangeLog.txt" + # Default repository tag. repo_tag: str = sbo_repo_tag @@ -177,6 +185,13 @@ class Repositories: ponce_bin_repo_checksums: str = repos['PONCE_BIN_REPO_CHECKSUMS'] ponce_bin_repo_changelog: str = repos['PONCE_BIN_REPO_CHANGELOG'] + salixos_repo_name: str = repos['SALIXOS_REPO_NAME'] + salixos_repo: bool = repos['SALIXOS_REPO'] + salixos_repo_mirror: str = repos['SALIXOS_REPO_MIRROR'] + salixos_repo_packages: str = repos['SALIXOS_REPO_PACKAGES'] + salixos_repo_checksums: str = repos['SALIXOS_REPO_CHECKSUMS'] + salixos_repo_changelog: str = repos['SALIXOS_REPO_CHANGELOG'] + except (tomli.TOMLDecodeError, KeyError) as error: raise SystemExit(f"\n{config.prog_name} {bred}Error{endc}: {error}: in the configuration file " f"'{repositories_file_toml}'.\n" @@ -192,7 +207,8 @@ class Repositories: gnome_repo_name: gnome_repo, conraid_repo_name: conraid_repo, slackonly_repo_name: slackonly_repo, - ponce_bin_repo_name: ponce_bin_repo + ponce_bin_repo_name: ponce_bin_repo, + salixos_repo_name:salixos_repo } # All enabled binaries repositories. @@ -215,5 +231,6 @@ class Repositories: gnome_repo_name: [gnome_repo, gnome_repo_path, gnome_repo_changelog], conraid_repo_name: [conraid_repo, conraid_repo_path, conraid_repo_changelog], slackonly_repo_name: [slackonly_repo, slackonly_repo_path, slackonly_repo_changelog], - ponce_bin_repo_name: [ponce_bin_repo, ponce_bin_repo_path, ponce_bin_repo_changelog] + ponce_bin_repo_name: [ponce_bin_repo, ponce_bin_repo_path, ponce_bin_repo_changelog], + salixos_repo_name: [salixos_repo, salixos_repo_path, salixos_repo_changelog] } diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index 3be2c07e..7c9752ad 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -57,6 +57,12 @@ class UpdateRepository(Configs): if self.repo == self.repos.alien_repo_name or self.repo == '*': self.alien_repository() + if self.repo == self.repos.multilib_repo_name or self.repo == '*': + self.multilib_repository() + + if self.repo == self.repos.restricted_repo_name or self.repo == '*': + self.restricted_repository() + if self.repo == self.repos.gnome_repo_name or self.repo == '*': self.gnome_repository() @@ -69,11 +75,8 @@ class UpdateRepository(Configs): if self.repo == self.repos.ponce_bin_repo_name or self.repo == '*': self.ponce_bin_repository() - if self.repo == self.repos.multilib_repo_name or self.repo == '*': - self.multilib_repository() - - if self.repo == self.repos.restricted_repo_name or self.repo == '*': - self.restricted_repository() + if self.repo == self.repos.salixos_repo_name or self.repo == '*': + self.salixos_repository() else: self.slackbuild_repositories() @@ -264,6 +267,33 @@ class UpdateRepository(Configs): else: self.not_enabled_message(self.repos.ponce_bin_repo_name) + def salixos_repository(self): + if self.repos.salixos_repo: + urls: list = [] + print('Updating the packages list...\n') + print(f"Downloading the '{self.green}{self.repos.salixos_repo_name}{self.endc}' " + f"repository, please wait...\n") + self.make_dirs(self.repos.salixos_repo_name) + + urls.append(f'{self.repos.salixos_repo_mirror}{self.repos.salixos_repo_packages}') + urls.append(f'{self.repos.salixos_repo_mirror}{self.repos.salixos_repo_changelog}') + urls.append(f'{self.repos.salixos_repo_mirror}{self.repos.salixos_repo_checksums}') + + self.utils.remove_file_if_exists(self.repos.salixos_repo_path, self.repos.salixos_repo_packages) + self.utils.remove_file_if_exists(self.repos.salixos_repo_path, self.repos.salixos_repo_changelog) + self.utils.remove_file_if_exists(self.repos.salixos_repo_path, self.repos.salixos_repo_checksums) + + down = Downloader(self.repos.salixos_repo_path, urls, self.flags) + down.download() + print() + + self.delete_binaries_data(self.repos.salixos_repo_name) + self.delete_last_updated(self.repos.salixos_repo_name) + self.data.install_salixos_data() + print() + else: + self.not_enabled_message(self.repos.salixos_repo_name) + def slackbuild_repositories(self): """ Update the slackbuild repositories. """ if self.repos.ponce_repo: From ab62b41612ccee6a8b8145f89fed63ca80ca16ed Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 31 Mar 2023 19:08:12 +0300 Subject: [PATCH 48/74] Fixed for salixos required --- slpkg/binaries/required.py | 5 +++++ slpkg/install_data.py | 18 +++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/slpkg/binaries/required.py b/slpkg/binaries/required.py index 32964516..785f41e2 100644 --- a/slpkg/binaries/required.py +++ b/slpkg/binaries/required.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- +from slpkg.repositories import Repositories from slpkg.binaries.queries import BinQueries @@ -11,12 +12,16 @@ class Required: def __init__(self, name: str, repo: str): self.name: str = name self.repo: str = repo + self.repos = Repositories() self.repo_package_names: list = BinQueries(name, self.repo).all_package_names_by_repo() def resolve(self) -> list: """ Resolve the dependencies. """ requires: list[str] = BinQueries(self.name, self.repo).required() + if self.repos.salixos_repo_name: + return requires + for req in requires: if req: sub: list[str] = BinQueries(req, self.repo).required() diff --git a/slpkg/install_data.py b/slpkg/install_data.py index d0effc9d..13eddc28 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -758,13 +758,17 @@ class InstallData(Configs): cache.append(f'{package_size_uncomp}B') if line.startswith(pkg_tag[4]): - required = line.replace( - pkg_tag[4], '').replace( - ',', ' ').replace( - '|', ' ').strip() - list_required: list = required.split(' ') - package_required: str = ' '.join(list(set(list_required))) - cache.append(package_required) + deps: list = [] + required = line.replace(pkg_tag[4], '').strip() + + for req in required.split(','): + dep = req.split('|') + if len(dep) > 1: + deps.append(dep[1]) + else: + deps += dep + + cache.append(' '.join(deps)) if line.startswith(pkg_tag[5]): package_description = line.replace(pkg_tag[5], '').strip() From 5360c65bf2387821fa8d0e293d0dd30a43b8933e Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 31 Mar 2023 19:11:31 +0300 Subject: [PATCH 49/74] Updated for coding style --- slpkg/binaries/required.py | 20 ++++++++++---------- slpkg/sbos/dependencies.py | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/slpkg/binaries/required.py b/slpkg/binaries/required.py index 785f41e2..2783ede3 100644 --- a/slpkg/binaries/required.py +++ b/slpkg/binaries/required.py @@ -17,23 +17,23 @@ class Required: def resolve(self) -> list: """ Resolve the dependencies. """ - requires: list[str] = BinQueries(self.name, self.repo).required() + required: list[str] = BinQueries(self.name, self.repo).required() if self.repos.salixos_repo_name: - return requires + return required - for req in requires: + for req in required: if req: - sub: list[str] = BinQueries(req, self.repo).required() + sub_required: list[str] = BinQueries(req, self.repo).required() - for s in sub: - requires.append(s) + for sub in sub_required: + required.append(sub) # Clean for dependencies not in the repository. - for dep in requires: + for dep in required: if dep not in self.repo_package_names: - requires.remove(dep) + required.remove(dep) - requires.reverse() + required.reverse() - return list(dict.fromkeys(requires)) + return list(dict.fromkeys(required)) diff --git a/slpkg/sbos/dependencies.py b/slpkg/sbos/dependencies.py index 6e911d99..74795e20 100644 --- a/slpkg/sbos/dependencies.py +++ b/slpkg/sbos/dependencies.py @@ -16,9 +16,9 @@ class Requires: requires: list[str] = SBoQueries(self.name).requires() # type: ignore for req in requires: if req: - sub: list[str] = SBoQueries(req).requires() # type: ignore - for s in sub: - requires.append(s) + sub_requires: list[str] = SBoQueries(req).requires() # type: ignore + for sub in sub_requires: + requires.append(sub) requires.reverse() From cf8fc5cf31056a45948f3bcba3615eb14a3e1335 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 31 Mar 2023 19:12:17 +0300 Subject: [PATCH 50/74] Fixed typo --- slpkg/binaries/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/binaries/install.py b/slpkg/binaries/install.py index c5a37a61..eba653c8 100644 --- a/slpkg/binaries/install.py +++ b/slpkg/binaries/install.py @@ -74,7 +74,7 @@ class Packages(Configs): self.utils.finished_time(elapsed_time) def dependencies(self): - """ Creating te dependencies list and the order for install. """ + """ Creating the dependencies list and the order for install. """ requires: list = [] if not self.utils.is_option(self.flag_resolve_off, self.flags): From 46168397aa94c87afe021b74f950c19d68b68504 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 31 Mar 2023 20:08:39 +0300 Subject: [PATCH 51/74] Added slackel repo --- configs/repositories.toml | 8 +++ slpkg/check_updates.py | 5 ++ slpkg/install_data.py | 101 ++++++++++++++++++++++++++++++++- slpkg/repo_info.py | 3 +- slpkg/repositories.py | 111 +++++++++++++++++++++---------------- slpkg/update_repository.py | 30 ++++++++++ 6 files changed, 209 insertions(+), 49 deletions(-) diff --git a/configs/repositories.toml b/configs/repositories.toml index dc2bbfdc..f9eb037f 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -99,3 +99,11 @@ SALIXOS_REPO_PACKAGES = "PACKAGES.TXT" SALIXOS_REPO_CHECKSUMS = "CHECKSUMS.md5" SALIXOS_REPO_CHANGELOG = "ChangeLog.txt" + + # Repository for slackware -current. + SLACKEL_REPO_NAME = "slackel" + SLACKEL_REPO = false + SLACKEL_REPO_MIRROR = "http://www.slackel.gr/repo/x86_64/slackware-current/" + SLACKEL_REPO_PACKAGES = "PACKAGES.TXT" + SLACKEL_REPO_CHECKSUMS = "CHECKSUMS.md5" + SLACKEL_REPO_CHANGELOG = "ChangeLog.txt" diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index c51a4b19..68e004d6 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -81,6 +81,11 @@ class CheckUpdates(Configs): self.repo_chg_txt: str = f'{self.repos.salixos_repo_mirror}{self.repos.salixos_repo_changelog}' compare[self.repos.salixos_repo_name] = self.compare_dates() + if self.repos.slackel_repo and self.repo == self.repos.slackel_repo_name or self.repo == '*': + self.local_chg_txt: Path = Path(self.repos.slackel_repo_path, self.repos.slackel_repo_changelog) + self.repo_chg_txt: str = f'{self.repos.slackel_repo_mirror}{self.repos.slackel_repo_changelog}' + compare[self.repos.slackel_repo_name] = self.compare_dates() + else: if self.repos.ponce_repo: self.local_chg_txt: Path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_changelog) diff --git a/slpkg/install_data.py b/slpkg/install_data.py index 13eddc28..7eff12a1 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -703,7 +703,7 @@ class InstallData(Configs): self.session.commit() def install_salixos_data(self) -> None: - """ Install the data for slackonly repository. """ + """ Install the data for salixos repository. """ checksums_dict: dict = {} pkg_tag = [ 'PACKAGE NAME:', @@ -800,3 +800,102 @@ class InstallData(Configs): print(f'{self.byellow}Done{self.endc}') self.session.commit() + + def install_slackel_data(self) -> None: + """ Install the data for slackel repository. """ + checksums_dict: dict = {} + pkg_tag = [ + 'PACKAGE NAME:', + 'PACKAGE LOCATION:', + 'PACKAGE SIZE (compressed):', + 'PACKAGE SIZE (uncompressed):', + 'PACKAGE REQUIRED:', + 'PACKAGE DESCRIPTION:' + ] + path_packages: Path = Path(self.repos.slackel_repo_path, self.repos.slackel_repo_packages) + path_checksums: Path = Path(self.repos.slackel_repo_path, self.repos.slackel_repo_checksums) + path_changelog: Path = Path(self.repos.slackel_repo_path, self.repos.slackel_repo_changelog) + packages_txt: list = self.utils.read_file(path_packages) + checksums_md5: list = self.utils.read_file(path_checksums) + + for line in checksums_md5: + line = line.strip() + + if line.endswith(('.txz', '.tgz')): + file: str = line.split('./')[1].split('/')[-1].strip() + checksum: str = line.split('./')[0].strip() + checksums_dict[file] = checksum + + cache: list = [] # init cache + + print('Creating the database... ', end='', flush=True) + + 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) + cache.append(self.repos.slackel_repo_mirror) + try: + cache.append(checksums_dict[package_name]) + except KeyError: + cache.append('error checksum') + + if line.startswith(pkg_tag[1]): + package_location = line.replace(pkg_tag[1], '').strip() + cache.append(package_location[1:]) # Do not install (.) dot + + if line.startswith(pkg_tag[2]): + package_size_comp = line.replace(pkg_tag[2], '').strip() + cache.append(f'{package_size_comp}B') + + if line.startswith(pkg_tag[3]): + package_size_uncomp = line.replace(pkg_tag[3], '').strip() + cache.append(f'{package_size_uncomp}B') + + if line.startswith(pkg_tag[4]): + deps: list = [] + required = line.replace(pkg_tag[4], '').strip() + + for req in required.split(','): + dep = req.split('|') + if len(dep) > 1: + deps.append(dep[1]) + else: + deps += dep + + cache.append(' '.join(deps)) + + if line.startswith(pkg_tag[5]): + package_description = line.replace(pkg_tag[5], '').strip() + cache.append(package_description) + + if len(cache) == 10: + data: str = BinariesTable( + repo=self.repos.slackel_repo_name, + name=cache[0], + version=cache[1], + package=cache[2], + mirror=cache[3], + checksum=cache[4], + location=cache[5], + size_comp=cache[6], + size_uncomp=cache[7], + required=cache[8], + description=cache[9] + ) + + self.session.add(data) + + cache: list = [] # reset cache + + last_updated: str = self.last_updated(path_changelog) + date: str = LastRepoUpdated(repo=self.repos.slackel_repo_name, date=last_updated) + self.session.add(date) + + print(f'{self.byellow}Done{self.endc}') + + self.session.commit() diff --git a/slpkg/repo_info.py b/slpkg/repo_info.py index d7f15901..2736ac47 100644 --- a/slpkg/repo_info.py +++ b/slpkg/repo_info.py @@ -68,7 +68,8 @@ class RepoInfo(Configs): self.repos.conraid_repo_name: BinQueries('', repo).count_packages(), self.repos.slackonly_repo_name: BinQueries('', repo).count_packages(), self.repos.ponce_bin_repo_name: BinQueries('', repo).count_packages(), - self.repos.salixos_repo_name: BinQueries('', repo).count_packages() + self.repos.salixos_repo_name: BinQueries('', repo).count_packages(), + self.repos.slackel_repo_name: BinQueries('', repo).count_packages() } if value[0]: diff --git a/slpkg/repositories.py b/slpkg/repositories.py index d4efb5b6..4e86fb7a 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -27,86 +27,94 @@ class Repositories: sbo_repo_name: str = 'sbo' sbo_repo_path: Path = Path(config.lib_path, 'repositories', sbo_repo_name) - sbo_repo_mirror: str = "https://slackbuilds.org/slackbuilds/15.0/" - sbo_repo_slackbuilds: str = "SLACKBUILDS.TXT" - sbo_repo_changelog: str = "ChangeLog.txt" - sbo_repo_tar_suffix: str = ".tar.gz" - sbo_repo_tag: str = "_SBo" + sbo_repo_mirror: str = 'https://slackbuilds.org/slackbuilds/15.0/' + sbo_repo_slackbuilds: str = 'SLACKBUILDS.TXT' + sbo_repo_changelog: str = 'ChangeLog.txt' + sbo_repo_tar_suffix: str = '.tar.gz' + sbo_repo_tag: str = '_SBo' ponce_repo_name: str = 'ponce' ponce_repo: bool = False ponce_repo_path: Path = Path(config.lib_path, 'repositories', ponce_repo_name) - ponce_repo_mirror: str = "https://cgit.ponce.cc/slackbuilds/plain/" - ponce_repo_slackbuilds: str = "SLACKBUILDS.TXT" - ponce_repo_changelog: str = "ChangeLog.txt" - ponce_repo_tag: str = "_SBo" + ponce_repo_mirror: str = 'https://cgit.ponce.cc/slackbuilds/plain/' + ponce_repo_slackbuilds: str = 'SLACKBUILDS.TXT' + ponce_repo_changelog: str = 'ChangeLog.txt' + ponce_repo_tag: str = '_SBo' alien_repo_name: str = 'alien' alien_repo: bool = False alien_repo_path: Path = Path(config.lib_path, 'repositories', alien_repo_name) - alien_repo_mirror: str = "http://slackware.uk/people/alien/sbrepos/15.0/x86_64/" - alien_repo_changelog_mirror: str = "http://slackware.uk/people/alien/sbrepos/" - alien_repo_packages: str = "PACKAGES.TXT" - alien_repo_checksums: str = "CHECKSUMS.md5" - alien_repo_changelog: str = "ChangeLog.txt" + alien_repo_mirror: str = 'http://slackware.uk/people/alien/sbrepos/15.0/x86_64/' + alien_repo_changelog_mirror: str = 'http://slackware.uk/people/alien/sbrepos/' + alien_repo_packages: str = 'PACKAGES.TXT' + alien_repo_checksums: str = 'CHECKSUMS.md5' + alien_repo_changelog: str = 'ChangeLog.txt' multilib_repo_name: str = 'multilib' multilib_repo: bool = False multilib_repo_path: Path = Path(config.lib_path, 'repositories', multilib_repo_name) - multilib_repo_mirror: str = "https://slackware.nl/people/alien/multilib/15.0/" - multilib_repo_changelog_mirror: str = "https://slackware.nl/people/alien/multilib/" - multilib_repo_packages: str = "PACKAGES.TXT" - multilib_repo_checksums: str = "CHECKSUMS.md5" - multilib_repo_changelog: str = "ChangeLog.txt" + multilib_repo_mirror: str = 'https://slackware.nl/people/alien/multilib/15.0/' + multilib_repo_changelog_mirror: str = 'https://slackware.nl/people/alien/multilib/' + multilib_repo_packages: str = 'PACKAGES.TXT' + multilib_repo_checksums: str = 'CHECKSUMS.md5' + multilib_repo_changelog: str = 'ChangeLog.txt' restricted_repo_name: str = 'restricted' restricted_repo: bool = False restricted_repo_path: Path = Path(config.lib_path, 'repositories', restricted_repo_name) - restricted_repo_mirror: str = "https://slackware.nl/people/alien/restricted_sbrepos/15.0/x86_64/" - restricted_repo_changelog_mirror: str = "https://slackware.nl/people/alien/restricted_sbrepos/" - restricted_repo_packages: str = "PACKAGES.TXT" - restricted_repo_checksums: str = "CHECKSUMS.md5" - restricted_repo_changelog: str = "ChangeLog.txt" + restricted_repo_mirror: str = 'https://slackware.nl/people/alien/restricted_sbrepos/15.0/x86_64/' + restricted_repo_changelog_mirror: str = 'https://slackware.nl/people/alien/restricted_sbrepos/' + restricted_repo_packages: str = 'PACKAGES.TXT' + restricted_repo_checksums: str = 'CHECKSUMS.md5' + restricted_repo_changelog: str = 'ChangeLog.txt' gnome_repo_name: str = 'gnome' gnome_repo: bool = False gnome_repo_path: Path = Path(config.lib_path, 'repositories', gnome_repo_name) - gnome_repo_mirror: str = "https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/" - gnome_repo_packages: str = "PACKAGES.TXT" - gnome_repo_checksums: str = "CHECKSUMS.md5" - gnome_repo_changelog: str = "ChangeLog.txt" + gnome_repo_mirror: str = 'https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/' + gnome_repo_packages: str = 'PACKAGES.TXT' + gnome_repo_checksums: str = 'CHECKSUMS.md5' + gnome_repo_changelog: str = 'ChangeLog.txt' conraid_repo_name: str = 'conraid' conraid_repo: bool = False conraid_repo_path: Path = Path(config.lib_path, 'repositories', conraid_repo_name) - conraid_repo_mirror: str = "https://reddoglinux.ddns.net/linux/conraid_43.x/x86_64/" - conraid_repo_packages: str = "PACKAGES.TXT" - conraid_repo_checksums: str = "CHECKSUMS.md5" - conraid_repo_changelog: str = "ChangeLog.txt" + conraid_repo_mirror: str = 'https://reddoglinux.ddns.net/linux/conraid_43.x/x86_64/' + conraid_repo_packages: str = 'PACKAGES.TXT' + conraid_repo_checksums: str = 'CHECKSUMS.md5' + conraid_repo_changelog: str = 'ChangeLog.txt' slackonly_repo_name: str = 'slackonly' slackonly_repo: bool = False slackonly_repo_path: Path = Path(config.lib_path, 'repositories', slackonly_repo_name) - slackonly_repo_mirror: str = "https://packages.slackonly.com/pub/packages/15.0-x86_64/" - slackonly_repo_packages: str = "PACKAGES.TXT" - slackonly_repo_checksums: str = "CHECKSUMS.md5" - slackonly_repo_changelog: str = "ChangeLog.txt" + slackonly_repo_mirror: str = 'https://packages.slackonly.com/pub/packages/15.0-x86_64/' + slackonly_repo_packages: str = 'PACKAGES.TXT' + slackonly_repo_checksums: str = 'CHECKSUMS.md5' + slackonly_repo_changelog: str = 'ChangeLog.txt' ponce_bin_repo_name: str = 'ponce_bin' ponce_bin_repo: bool = False ponce_bin_repo_path: Path = Path(config.lib_path, 'repositories', ponce_bin_repo_name) - ponce_bin_repo_mirror: str = "https://ponce.cc/slackware/slackware64-15.0/packages/" - ponce_bin_repo_packages: str = "PACKAGES.TXT" - ponce_bin_repo_checksums: str = "CHECKSUMS.md5" - ponce_bin_repo_changelog: str = "ChangeLog.txt" + ponce_bin_repo_mirror: str = 'https://ponce.cc/slackware/slackware64-15.0/packages/' + ponce_bin_repo_packages: str = 'PACKAGES.TXT' + ponce_bin_repo_checksums: str = 'CHECKSUMS.md5' + ponce_bin_repo_changelog: str = 'ChangeLog.txt' salixos_repo_name: str = 'salixos' salixos_repo: bool = False salixos_repo_path: Path = Path(config.lib_path, 'repositories', salixos_repo_name) - salixos_repo_mirror: str = "https://download.salixos.org/x86_64/slackware-15.0/" - salixos_repo_packages: str = "PACKAGES.TXT" - salixos_repo_checksums: str = "CHECKSUMS.md5" - salixos_repo_changelog: str = "ChangeLog.txt" + salixos_repo_mirror: str = 'https://download.salixos.org/x86_64/slackware-15.0/' + salixos_repo_packages: str = 'PACKAGES.TXT' + salixos_repo_checksums: str = 'CHECKSUMS.md5' + salixos_repo_changelog: str = 'ChangeLog.txt' + + slackel_repo_name: str = 'slackel' + slackel_repo: bool = False + slackel_repo_path: Path = Path(config.lib_path, 'repositories', slackel_repo_name) + slackel_repo_mirror: str = 'http://www.slackel.gr/repo/x86_64/slackware-current/' + slackel_repo_packages: str = 'PACKAGES.TXT' + slackel_repo_checksums: str = 'CHECKSUMS.md5' + slackel_repo_changelog: str = 'ChangeLog.txt' # Default repository tag. repo_tag: str = sbo_repo_tag @@ -192,8 +200,15 @@ class Repositories: salixos_repo_checksums: str = repos['SALIXOS_REPO_CHECKSUMS'] salixos_repo_changelog: str = repos['SALIXOS_REPO_CHANGELOG'] + slackel_repo_name: str = repos['SLACKEL_REPO_NAME'] + slackel_repo: bool = repos['SLACKEL_REPO'] + slackel_repo_mirror: str = repos['SLACKEL_REPO_MIRROR'] + slackel_repo_packages: str = repos['SLACKEL_REPO_PACKAGES'] + slackel_repo_checksums: str = repos['SLACKEL_REPO_CHECKSUMS'] + slackel_repo_changelog: str = repos['SLACKEL_REPO_CHANGELOG'] + except (tomli.TOMLDecodeError, KeyError) as error: - raise SystemExit(f"\n{config.prog_name} {bred}Error{endc}: {error}: in the configuration file " + raise SystemExit(f'\n{config.prog_name} {bred}Error{endc}: {error}: in the configuration file ' f"'{repositories_file_toml}'.\n" f"\nIf you have upgraded the '{config.prog_name}' probably you need to run:\n" f"'mv {repositories_file_toml}.new {repositories_file_toml}'.\n" @@ -208,7 +223,8 @@ class Repositories: conraid_repo_name: conraid_repo, slackonly_repo_name: slackonly_repo, ponce_bin_repo_name: ponce_bin_repo, - salixos_repo_name:salixos_repo + salixos_repo_name: salixos_repo, + slackel_repo_name: slackel_repo } # All enabled binaries repositories. @@ -232,5 +248,6 @@ class Repositories: conraid_repo_name: [conraid_repo, conraid_repo_path, conraid_repo_changelog], slackonly_repo_name: [slackonly_repo, slackonly_repo_path, slackonly_repo_changelog], ponce_bin_repo_name: [ponce_bin_repo, ponce_bin_repo_path, ponce_bin_repo_changelog], - salixos_repo_name: [salixos_repo, salixos_repo_path, salixos_repo_changelog] + salixos_repo_name: [salixos_repo, salixos_repo_path, salixos_repo_changelog], + slackel_repo_name: [slackel_repo, slackel_repo_path, slackel_repo_changelog] } diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index 7c9752ad..32c98ac8 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -77,6 +77,9 @@ class UpdateRepository(Configs): if self.repo == self.repos.salixos_repo_name or self.repo == '*': self.salixos_repository() + + if self.repo == self.repos.slackel_repo_name or self.repo == '*': + self.slackel_repository() else: self.slackbuild_repositories() @@ -294,6 +297,33 @@ class UpdateRepository(Configs): else: self.not_enabled_message(self.repos.salixos_repo_name) + def slackel_repository(self): + if self.repos.slackel_repo: + urls: list = [] + print('Updating the packages list...\n') + print(f"Downloading the '{self.green}{self.repos.slackel_repo_name}{self.endc}' " + f"repository, please wait...\n") + self.make_dirs(self.repos.slackel_repo_name) + + urls.append(f'{self.repos.slackel_repo_mirror}{self.repos.slackel_repo_packages}') + urls.append(f'{self.repos.slackel_repo_mirror}{self.repos.slackel_repo_changelog}') + urls.append(f'{self.repos.slackel_repo_mirror}{self.repos.slackel_repo_checksums}') + + self.utils.remove_file_if_exists(self.repos.slackel_repo_path, self.repos.slackel_repo_packages) + self.utils.remove_file_if_exists(self.repos.slackel_repo_path, self.repos.slackel_repo_changelog) + self.utils.remove_file_if_exists(self.repos.slackel_repo_path, self.repos.slackel_repo_checksums) + + down = Downloader(self.repos.slackel_repo_path, urls, self.flags) + down.download() + print() + + self.delete_binaries_data(self.repos.slackel_repo_name) + self.delete_last_updated(self.repos.slackel_repo_name) + self.data.install_slackel_data() + print() + else: + self.not_enabled_message(self.repos.slackel_repo_name) + def slackbuild_repositories(self): """ Update the slackbuild repositories. """ if self.repos.ponce_repo: From 90d4da7434ecbbb8545dd6e677951d8ce2c83a5d Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 31 Mar 2023 20:55:40 +0300 Subject: [PATCH 52/74] Added salixos_extra repo --- configs/repositories.toml | 9 ++++ slpkg/check_updates.py | 7 +++ slpkg/install_data.py | 100 +++++++++++++++++++++++++++++++++++++ slpkg/repo_info.py | 1 + slpkg/repositories.py | 19 +++++++ slpkg/update_repository.py | 33 ++++++++++++ slpkg/utilities.py | 2 +- 7 files changed, 170 insertions(+), 1 deletion(-) diff --git a/configs/repositories.toml b/configs/repositories.toml index f9eb037f..7fe3fd5f 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -100,6 +100,15 @@ SALIXOS_REPO_CHECKSUMS = "CHECKSUMS.md5" SALIXOS_REPO_CHANGELOG = "ChangeLog.txt" + # Repository for slackware 15.0 stable. + SALIXOS_EXTRA_REPO_NAME = "salixos_extra" + SALIXOS_EXTRA_REPO = false + SALIXOS_EXTRA_REPO_MIRROR = "https://download.salixos.org/x86_64/slackware-15.0/extra/" + SALIXOS_EXTRA_REPO_CHANGELOG_MIRROR = 'https://download.salixos.org/x86_64/slackware-15.0/' + SALIXOS_EXTRA_REPO_PACKAGES = "PACKAGES.TXT" + SALIXOS_EXTRA_REPO_CHECKSUMS = "CHECKSUMS.md5" + SALIXOS_EXTRA_REPO_CHANGELOG = "ChangeLog.txt" + # Repository for slackware -current. SLACKEL_REPO_NAME = "slackel" SLACKEL_REPO = false diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 68e004d6..4d78b22c 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -81,6 +81,13 @@ class CheckUpdates(Configs): self.repo_chg_txt: str = f'{self.repos.salixos_repo_mirror}{self.repos.salixos_repo_changelog}' compare[self.repos.salixos_repo_name] = self.compare_dates() + if self.repos.salixos_extra_repo and self.repo == self.repos.salixos_extra_repo_name or self.repo == '*': + self.local_chg_txt: Path = Path(self.repos.salixos_extra_repo_path, + self.repos.salixos_extra_repo_changelog) + self.repo_chg_txt: str = (f'{self.repos.salixos_extra_repo_changelog_mirror}' + f'{self.repos.salixos_extra_repo_changelog}') + compare[self.repos.salixos_extra_repo_name] = self.compare_dates() + if self.repos.slackel_repo and self.repo == self.repos.slackel_repo_name or self.repo == '*': self.local_chg_txt: Path = Path(self.repos.slackel_repo_path, self.repos.slackel_repo_changelog) self.repo_chg_txt: str = f'{self.repos.slackel_repo_mirror}{self.repos.slackel_repo_changelog}' diff --git a/slpkg/install_data.py b/slpkg/install_data.py index 7eff12a1..fc75528d 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -801,6 +801,106 @@ class InstallData(Configs): self.session.commit() + def install_salixos_extra_data(self) -> None: + """ Install the data for salixos_extra repository. """ + checksums_dict: dict = {} + pkg_tag = [ + 'PACKAGE NAME:', + 'PACKAGE LOCATION:', + 'PACKAGE SIZE (compressed):', + 'PACKAGE SIZE (uncompressed):', + 'PACKAGE REQUIRED:', + 'PACKAGE DESCRIPTION:' + ] + path_packages: Path = Path(self.repos.salixos_extra_repo_path, self.repos.salixos_extra_repo_packages) + path_checksums: Path = Path(self.repos.salixos_extra_repo_path, self.repos.salixos_extra_repo_checksums) + path_changelog: Path = Path(self.repos.salixos_extra_repo_path, + self.repos.salixos_extra_repo_changelog) + packages_txt: list = self.utils.read_file(path_packages) + checksums_md5: list = self.utils.read_file(path_checksums) + + for line in checksums_md5: + line = line.strip() + + if line.endswith(('.txz', '.tgz')): + file: str = line.split('./')[1].split('/')[-1].strip() + checksum: str = line.split('./')[0].strip() + checksums_dict[file] = checksum + + cache: list = [] # init cache + + print('Creating the database... ', end='', flush=True) + + 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) + cache.append(self.repos.salixos_extra_repo_mirror) + try: + cache.append(checksums_dict[package_name]) + except KeyError: + cache.append('error checksum') + + if line.startswith(pkg_tag[1]): + package_location = line.replace(pkg_tag[1], '').strip() + cache.append(package_location[1:]) # Do not install (.) dot + + if line.startswith(pkg_tag[2]): + package_size_comp = line.replace(pkg_tag[2], '').strip() + cache.append(f'{package_size_comp}B') + + if line.startswith(pkg_tag[3]): + package_size_uncomp = line.replace(pkg_tag[3], '').strip() + cache.append(f'{package_size_uncomp}B') + + if line.startswith(pkg_tag[4]): + deps: list = [] + required = line.replace(pkg_tag[4], '').strip() + + for req in required.split(','): + dep = req.split('|') + if len(dep) > 1: + deps.append(dep[1]) + else: + deps += dep + + cache.append(' '.join(deps)) + + if line.startswith(pkg_tag[5]): + package_description = line.replace(pkg_tag[5], '').strip() + cache.append(package_description) + + if len(cache) == 10: + data: str = BinariesTable( + repo=self.repos.salixos_extra_repo_name, + name=cache[0], + version=cache[1], + package=cache[2], + mirror=cache[3], + checksum=cache[4], + location=cache[5], + size_comp=cache[6], + size_uncomp=cache[7], + required=cache[8], + description=cache[9] + ) + + self.session.add(data) + + cache: list = [] # reset cache + + last_updated: str = self.last_updated(path_changelog) + date: str = LastRepoUpdated(repo=self.repos.salixos_extra_repo_name, date=last_updated) + self.session.add(date) + + print(f'{self.byellow}Done{self.endc}') + + self.session.commit() + def install_slackel_data(self) -> None: """ Install the data for slackel repository. """ checksums_dict: dict = {} diff --git a/slpkg/repo_info.py b/slpkg/repo_info.py index 2736ac47..89539806 100644 --- a/slpkg/repo_info.py +++ b/slpkg/repo_info.py @@ -69,6 +69,7 @@ class RepoInfo(Configs): self.repos.slackonly_repo_name: BinQueries('', repo).count_packages(), self.repos.ponce_bin_repo_name: BinQueries('', repo).count_packages(), self.repos.salixos_repo_name: BinQueries('', repo).count_packages(), + self.repos.salixos_extra_repo_name: BinQueries('', repo).count_packages(), self.repos.slackel_repo_name: BinQueries('', repo).count_packages() } diff --git a/slpkg/repositories.py b/slpkg/repositories.py index 4e86fb7a..90feb5f2 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -107,6 +107,15 @@ class Repositories: salixos_repo_packages: str = 'PACKAGES.TXT' salixos_repo_checksums: str = 'CHECKSUMS.md5' salixos_repo_changelog: str = 'ChangeLog.txt' + + salixos_extra_repo_name: str = 'salixos_extra' + salixos_extra_repo: bool = False + salixos_extra_repo_path: Path = Path(config.lib_path, 'repositories', salixos_extra_repo_name) + salixos_extra_repo_mirror: str = 'https://download.salixos.org/x86_64/slackware-15.0/extra/' + salixos_extra_repo_changelog_mirror: str = 'https://download.salixos.org/x86_64/slackware-15.0/' + salixos_extra_repo_packages: str = 'PACKAGES.TXT' + salixos_extra_repo_checksums: str = 'CHECKSUMS.md5' + salixos_extra_repo_changelog: str = 'ChangeLog.txt' slackel_repo_name: str = 'slackel' slackel_repo: bool = False @@ -200,6 +209,14 @@ class Repositories: salixos_repo_checksums: str = repos['SALIXOS_REPO_CHECKSUMS'] salixos_repo_changelog: str = repos['SALIXOS_REPO_CHANGELOG'] + salixos_extra_repo_name: str = repos['SALIXOS_EXTRA_REPO_NAME'] + salixos_extra_repo: bool = repos['SALIXOS_EXTRA_REPO'] + salixos_extra_repo_mirror: str = repos['SALIXOS_EXTRA_REPO_MIRROR'] + salixos_extra_repo_changelog_mirror: str = repos['SALIXOS_EXTRA_REPO_CHANGELOG_MIRROR'] + salixos_extra_repo_packages: str = repos['SALIXOS_EXTRA_REPO_PACKAGES'] + salixos_extra_repo_checksums: str = repos['SALIXOS_EXTRA_REPO_CHECKSUMS'] + salixos_extra_repo_changelog: str = repos['SALIXOS_EXTRA_REPO_CHANGELOG'] + slackel_repo_name: str = repos['SLACKEL_REPO_NAME'] slackel_repo: bool = repos['SLACKEL_REPO'] slackel_repo_mirror: str = repos['SLACKEL_REPO_MIRROR'] @@ -224,6 +241,7 @@ class Repositories: slackonly_repo_name: slackonly_repo, ponce_bin_repo_name: ponce_bin_repo, salixos_repo_name: salixos_repo, + salixos_extra_repo_name: salixos_extra_repo, slackel_repo_name: slackel_repo } @@ -249,5 +267,6 @@ class Repositories: slackonly_repo_name: [slackonly_repo, slackonly_repo_path, slackonly_repo_changelog], ponce_bin_repo_name: [ponce_bin_repo, ponce_bin_repo_path, ponce_bin_repo_changelog], salixos_repo_name: [salixos_repo, salixos_repo_path, salixos_repo_changelog], + salixos_extra_repo_name: [salixos_extra_repo_name, salixos_extra_repo_path, salixos_extra_repo_changelog], slackel_repo_name: [slackel_repo, slackel_repo_path, slackel_repo_changelog] } diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index 32c98ac8..eacfcebb 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -78,6 +78,9 @@ class UpdateRepository(Configs): if self.repo == self.repos.salixos_repo_name or self.repo == '*': self.salixos_repository() + if self.repo == self.repos.salixos_extra_repo_name or self.repo == '*': + self.salixos_extra_repository() + if self.repo == self.repos.slackel_repo_name or self.repo == '*': self.slackel_repository() else: @@ -297,6 +300,36 @@ class UpdateRepository(Configs): else: self.not_enabled_message(self.repos.salixos_repo_name) + def salixos_extra_repository(self): + if self.repos.salixos_extra_repo: + urls: list = [] + print('Updating the packages list...\n') + print(f"Downloading the '{self.green}{self.repos.salixos_extra_repo_name}{self.endc}' " + f"repository, please wait...\n") + self.make_dirs(self.repos.salixos_extra_repo_name) + + urls.append(f'{self.repos.salixos_extra_repo_mirror}{self.repos.salixos_extra_repo_packages}') + urls.append(f'{self.repos.salixos_extra_repo_changelog_mirror}{self.repos.salixos_extra_repo_changelog}') + urls.append(f'{self.repos.salixos_extra_repo_mirror}{self.repos.salixos_extra_repo_checksums}') + + self.utils.remove_file_if_exists(self.repos.salixos_extra_repo_path, + self.repos.salixos_extra_repo_packages) + self.utils.remove_file_if_exists(self.repos.salixos_extra_repo_path, + self.repos.salixos_extra_repo_changelog) + self.utils.remove_file_if_exists(self.repos.salixos_extra_repo_path, + self.repos.salixos_extra_repo_checksums) + + down = Downloader(self.repos.salixos_extra_repo_path, urls, self.flags) + down.download() + print() + + self.delete_binaries_data(self.repos.salixos_extra_repo_name) + self.delete_last_updated(self.repos.salixos_extra_repo_name) + self.data.install_salixos_extra_data() + print() + else: + self.not_enabled_message(self.repos.salixos_extra_repo_name) + def slackel_repository(self): if self.repos.slackel_repo: urls: list = [] diff --git a/slpkg/utilities.py b/slpkg/utilities.py index a793b246..9392370a 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -148,7 +148,7 @@ class Utilities: @staticmethod def read_file(file: Union[str, Path]) -> list: """ Reads the text file. """ - with open(file, 'r', encoding='utf-8') as f: + with open(file, 'r', encoding='utf-8', errors='replace') as f: return f.readlines() @staticmethod From cbfa9c2aba032c6a8b3d64f6a0acae3f6b41948a Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 31 Mar 2023 21:20:55 +0300 Subject: [PATCH 53/74] Fixed location --- slpkg/install_data.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/slpkg/install_data.py b/slpkg/install_data.py index fc75528d..8a55cfca 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -134,7 +134,7 @@ class InstallData(Configs): if line.startswith(pkg_tag[1]): package_location = line.replace(pkg_tag[1], '').strip() - cache.append(package_location[1:]) # Do not install (.) dot + cache.append(package_location[2:]) # Do not install (.) dot if line.startswith(pkg_tag[2]): package_size_comp = line.replace(pkg_tag[2], '').strip() @@ -224,7 +224,7 @@ class InstallData(Configs): if line.startswith(pkg_tag[1]): package_location = line.replace(pkg_tag[1], '').strip() - cache.append(package_location[1:]) # Do not install (.) dot + cache.append(package_location[2:]) # Do not install (./) dot if line.startswith(pkg_tag[2]): package_size_comp = line.replace(pkg_tag[2], '').strip() @@ -310,7 +310,7 @@ class InstallData(Configs): if line.startswith(pkg_tag[1]): package_location = line.replace(pkg_tag[1], '').strip() - cache.append(package_location[1:]) # Do not install (.) dot + cache.append(package_location[2:]) # Do not install (./) dot if line.startswith(pkg_tag[2]): package_size_comp = line.replace(pkg_tag[2], '').strip() @@ -570,7 +570,7 @@ class InstallData(Configs): if line.startswith(pkg_tag[1]): package_location = line.replace(pkg_tag[1], '').strip() - cache.append(package_location[1:]) # Do not install (.) dot + cache.append(package_location[2:]) # Do not install (./) dot if line.startswith(pkg_tag[2]): package_size_comp = line.replace(pkg_tag[2], '').strip() @@ -747,7 +747,7 @@ class InstallData(Configs): if line.startswith(pkg_tag[1]): package_location = line.replace(pkg_tag[1], '').strip() - cache.append(package_location[1:]) # Do not install (.) dot + cache.append(package_location[2:]) # Do not install (./) dot if line.startswith(pkg_tag[2]): package_size_comp = line.replace(pkg_tag[2], '').strip() @@ -847,7 +847,7 @@ class InstallData(Configs): if line.startswith(pkg_tag[1]): package_location = line.replace(pkg_tag[1], '').strip() - cache.append(package_location[1:]) # Do not install (.) dot + cache.append(package_location[2:]) # Do not install (./) dot if line.startswith(pkg_tag[2]): package_size_comp = line.replace(pkg_tag[2], '').strip() @@ -946,7 +946,7 @@ class InstallData(Configs): if line.startswith(pkg_tag[1]): package_location = line.replace(pkg_tag[1], '').strip() - cache.append(package_location[1:]) # Do not install (.) dot + cache.append(package_location[2:]) # Do not install (./) dot if line.startswith(pkg_tag[2]): package_size_comp = line.replace(pkg_tag[2], '').strip() From cd0f66395e8ca9c6c63959f9d3f1dfafb6e37812 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 31 Mar 2023 21:21:14 +0300 Subject: [PATCH 54/74] Updated for mirror --- configs/repositories.toml | 4 ++-- slpkg/check_updates.py | 2 +- slpkg/download_only.py | 2 ++ slpkg/repositories.py | 6 +++--- slpkg/update_repository.py | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/configs/repositories.toml b/configs/repositories.toml index 7fe3fd5f..635feba4 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -103,8 +103,8 @@ # Repository for slackware 15.0 stable. SALIXOS_EXTRA_REPO_NAME = "salixos_extra" SALIXOS_EXTRA_REPO = false - SALIXOS_EXTRA_REPO_MIRROR = "https://download.salixos.org/x86_64/slackware-15.0/extra/" - SALIXOS_EXTRA_REPO_CHANGELOG_MIRROR = 'https://download.salixos.org/x86_64/slackware-15.0/' + SALIXOS_EXTRA_REPO_MIRROR = "https://download.salixos.org/x86_64/slackware-15.0/" + SALIXOS_EXTRA_REPO_PACKAGES_MIRROR = 'https://download.salixos.org/x86_64/slackware-15.0/extra/' SALIXOS_EXTRA_REPO_PACKAGES = "PACKAGES.TXT" SALIXOS_EXTRA_REPO_CHECKSUMS = "CHECKSUMS.md5" SALIXOS_EXTRA_REPO_CHANGELOG = "ChangeLog.txt" diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 4d78b22c..025e6424 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -84,7 +84,7 @@ class CheckUpdates(Configs): if self.repos.salixos_extra_repo and self.repo == self.repos.salixos_extra_repo_name or self.repo == '*': self.local_chg_txt: Path = Path(self.repos.salixos_extra_repo_path, self.repos.salixos_extra_repo_changelog) - self.repo_chg_txt: str = (f'{self.repos.salixos_extra_repo_changelog_mirror}' + self.repo_chg_txt: str = (f'{self.repos.salixos_extra_repo_mirror}' f'{self.repos.salixos_extra_repo_changelog}') compare[self.repos.salixos_extra_repo_name] = self.compare_dates() diff --git a/slpkg/download_only.py b/slpkg/download_only.py index e8a1723e..3f96095c 100644 --- a/slpkg/download_only.py +++ b/slpkg/download_only.py @@ -50,6 +50,8 @@ class Download(Configs): url = [f'{mirror}{location}/{package}'] + raise SystemExit(url) + down = Downloader(self.tmp_slpkg, url, self.flags) down.download() diff --git a/slpkg/repositories.py b/slpkg/repositories.py index 90feb5f2..a69ce5d5 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -111,8 +111,8 @@ class Repositories: salixos_extra_repo_name: str = 'salixos_extra' salixos_extra_repo: bool = False salixos_extra_repo_path: Path = Path(config.lib_path, 'repositories', salixos_extra_repo_name) - salixos_extra_repo_mirror: str = 'https://download.salixos.org/x86_64/slackware-15.0/extra/' - salixos_extra_repo_changelog_mirror: str = 'https://download.salixos.org/x86_64/slackware-15.0/' + salixos_extra_repo_mirror: str = 'https://download.salixos.org/x86_64/slackware-15.0/' + salixos_extra_repo_packages_mirror: str = 'https://download.salixos.org/x86_64/slackware-15.0/extra/' salixos_extra_repo_packages: str = 'PACKAGES.TXT' salixos_extra_repo_checksums: str = 'CHECKSUMS.md5' salixos_extra_repo_changelog: str = 'ChangeLog.txt' @@ -212,7 +212,7 @@ class Repositories: salixos_extra_repo_name: str = repos['SALIXOS_EXTRA_REPO_NAME'] salixos_extra_repo: bool = repos['SALIXOS_EXTRA_REPO'] salixos_extra_repo_mirror: str = repos['SALIXOS_EXTRA_REPO_MIRROR'] - salixos_extra_repo_changelog_mirror: str = repos['SALIXOS_EXTRA_REPO_CHANGELOG_MIRROR'] + salixos_extra_repo_packages_mirror: str = repos['SALIXOS_EXTRA_REPO_PACKAGES_MIRROR'] salixos_extra_repo_packages: str = repos['SALIXOS_EXTRA_REPO_PACKAGES'] salixos_extra_repo_checksums: str = repos['SALIXOS_EXTRA_REPO_CHECKSUMS'] salixos_extra_repo_changelog: str = repos['SALIXOS_EXTRA_REPO_CHANGELOG'] diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index eacfcebb..b9cb15fe 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -308,8 +308,8 @@ class UpdateRepository(Configs): f"repository, please wait...\n") self.make_dirs(self.repos.salixos_extra_repo_name) - urls.append(f'{self.repos.salixos_extra_repo_mirror}{self.repos.salixos_extra_repo_packages}') - urls.append(f'{self.repos.salixos_extra_repo_changelog_mirror}{self.repos.salixos_extra_repo_changelog}') + urls.append(f'{self.repos.salixos_extra_repo_packages_mirror}{self.repos.salixos_extra_repo_packages}') + urls.append(f'{self.repos.salixos_extra_repo_mirror}{self.repos.salixos_extra_repo_changelog}') urls.append(f'{self.repos.salixos_extra_repo_mirror}{self.repos.salixos_extra_repo_checksums}') self.utils.remove_file_if_exists(self.repos.salixos_extra_repo_path, From 22ed4bb401128f12b0a70b56b380f51e865d7af2 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 31 Mar 2023 21:24:02 +0300 Subject: [PATCH 55/74] Removed test --- slpkg/download_only.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/slpkg/download_only.py b/slpkg/download_only.py index 3f96095c..e8a1723e 100644 --- a/slpkg/download_only.py +++ b/slpkg/download_only.py @@ -50,8 +50,6 @@ class Download(Configs): url = [f'{mirror}{location}/{package}'] - raise SystemExit(url) - down = Downloader(self.tmp_slpkg, url, self.flags) down.download() From 00fdb37f296586d3e964348e3e0ee81424c4a08d Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 31 Mar 2023 21:47:09 +0300 Subject: [PATCH 56/74] Added salixos_patches repo --- configs/repositories.toml | 9 ++++ slpkg/check_updates.py | 8 +++ slpkg/install_data.py | 102 ++++++++++++++++++++++++++++++++++++- slpkg/repo_info.py | 1 + slpkg/repositories.py | 20 ++++++++ slpkg/update_repository.py | 33 ++++++++++++ 6 files changed, 171 insertions(+), 2 deletions(-) diff --git a/configs/repositories.toml b/configs/repositories.toml index 635feba4..d8f5ae02 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -109,6 +109,15 @@ SALIXOS_EXTRA_REPO_CHECKSUMS = "CHECKSUMS.md5" SALIXOS_EXTRA_REPO_CHANGELOG = "ChangeLog.txt" + # Repository for slackware 15.0 stable. + SALIXOS_PATCHES_REPO_NAME = "salixos_patches" + SALIXOS_PATCHES_REPO = false + SALIXOS_PATCHES_REPO_MIRROR = "https://download.salixos.org/x86_64/slackware-15.0/" + SALIXOS_PATCHES_REPO_PACKAGES_MIRROR = 'https://download.salixos.org/x86_64/slackware-15.0/patches/' + SALIXOS_PATCHES_REPO_PACKAGES = "PACKAGES.TXT" + SALIXOS_PATCHES_REPO_CHECKSUMS = "CHECKSUMS.md5" + SALIXOS_PATCHES_REPO_CHANGELOG = "ChangeLog.txt" + # Repository for slackware -current. SLACKEL_REPO_NAME = "slackel" SLACKEL_REPO = false diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 025e6424..8e635b8c 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -88,6 +88,14 @@ class CheckUpdates(Configs): f'{self.repos.salixos_extra_repo_changelog}') compare[self.repos.salixos_extra_repo_name] = self.compare_dates() + if (self.repos.salixos_patches_repo and self.repo == self.repos.salixos_patches_repo_name + or self.repo == '*'): + self.local_chg_txt: Path = Path(self.repos.salixos_patches_repo_path, + self.repos.salixos_patches_repo_changelog) + self.repo_chg_txt: str = (f'{self.repos.salixos_patches_repo_mirror}' + f'{self.repos.salixos_patches_repo_changelog}') + compare[self.repos.salixos_patches_repo_name] = self.compare_dates() + if self.repos.slackel_repo and self.repo == self.repos.slackel_repo_name or self.repo == '*': self.local_chg_txt: Path = Path(self.repos.slackel_repo_path, self.repos.slackel_repo_changelog) self.repo_chg_txt: str = f'{self.repos.slackel_repo_mirror}{self.repos.slackel_repo_changelog}' diff --git a/slpkg/install_data.py b/slpkg/install_data.py index 8a55cfca..9584154c 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -251,7 +251,6 @@ class InstallData(Configs): size_uncomp=cache[7], description=cache[8], required='' - ) self.session.add(data) @@ -337,7 +336,6 @@ class InstallData(Configs): size_uncomp=cache[7], description=cache[8], required='' - ) self.session.add(data) @@ -901,6 +899,106 @@ class InstallData(Configs): self.session.commit() + def install_salixos_patches_data(self) -> None: + """ Install the data for salixos_patches repository. """ + checksums_dict: dict = {} + pkg_tag = [ + 'PACKAGE NAME:', + 'PACKAGE LOCATION:', + 'PACKAGE SIZE (compressed):', + 'PACKAGE SIZE (uncompressed):', + 'PACKAGE REQUIRED:', + 'PACKAGE DESCRIPTION:' + ] + path_packages: Path = Path(self.repos.salixos_patches_repo_path, self.repos.salixos_patches_repo_packages) + path_checksums: Path = Path(self.repos.salixos_patches_repo_path, self.repos.salixos_patches_repo_checksums) + path_changelog: Path = Path(self.repos.salixos_patches_repo_path, + self.repos.salixos_patches_repo_changelog) + packages_txt: list = self.utils.read_file(path_packages) + checksums_md5: list = self.utils.read_file(path_checksums) + + for line in checksums_md5: + line = line.strip() + + if line.endswith(('.txz', '.tgz')): + file: str = line.split('./')[1].split('/')[-1].strip() + checksum: str = line.split('./')[0].strip() + checksums_dict[file] = checksum + + cache: list = [] # init cache + + print('Creating the database... ', end='', flush=True) + + 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) + cache.append(self.repos.salixos_patches_repo_mirror) + try: + cache.append(checksums_dict[package_name]) + except KeyError: + cache.append('error checksum') + + if line.startswith(pkg_tag[1]): + package_location = line.replace(pkg_tag[1], '').strip() + cache.append(package_location[2:]) # Do not install (./) dot + + if line.startswith(pkg_tag[2]): + package_size_comp = line.replace(pkg_tag[2], '').strip() + cache.append(f'{package_size_comp}B') + + if line.startswith(pkg_tag[3]): + package_size_uncomp = line.replace(pkg_tag[3], '').strip() + cache.append(f'{package_size_uncomp}B') + + if line.startswith(pkg_tag[4]): + deps: list = [] + required = line.replace(pkg_tag[4], '').strip() + + for req in required.split(','): + dep = req.split('|') + if len(dep) > 1: + deps.append(dep[1]) + else: + deps += dep + + cache.append(' '.join(deps)) + + if line.startswith(pkg_tag[5]): + package_description = line.replace(pkg_tag[5], '').strip() + cache.append(package_description) + + if len(cache) == 10: + data: str = BinariesTable( + repo=self.repos.salixos_patches_repo_name, + name=cache[0], + version=cache[1], + package=cache[2], + mirror=cache[3], + checksum=cache[4], + location=cache[5], + size_comp=cache[6], + size_uncomp=cache[7], + required=cache[8], + description=cache[9] + ) + + self.session.add(data) + + cache: list = [] # reset cache + + last_updated: str = self.last_updated(path_changelog) + date: str = LastRepoUpdated(repo=self.repos.salixos_patches_repo_name, date=last_updated) + self.session.add(date) + + print(f'{self.byellow}Done{self.endc}') + + self.session.commit() + def install_slackel_data(self) -> None: """ Install the data for slackel repository. """ checksums_dict: dict = {} diff --git a/slpkg/repo_info.py b/slpkg/repo_info.py index 89539806..cc18190f 100644 --- a/slpkg/repo_info.py +++ b/slpkg/repo_info.py @@ -70,6 +70,7 @@ class RepoInfo(Configs): self.repos.ponce_bin_repo_name: BinQueries('', repo).count_packages(), self.repos.salixos_repo_name: BinQueries('', repo).count_packages(), self.repos.salixos_extra_repo_name: BinQueries('', repo).count_packages(), + self.repos.salixos_patches_repo_name: BinQueries('', repo).count_packages(), self.repos.slackel_repo_name: BinQueries('', repo).count_packages() } diff --git a/slpkg/repositories.py b/slpkg/repositories.py index a69ce5d5..747ceebf 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -116,6 +116,15 @@ class Repositories: salixos_extra_repo_packages: str = 'PACKAGES.TXT' salixos_extra_repo_checksums: str = 'CHECKSUMS.md5' salixos_extra_repo_changelog: str = 'ChangeLog.txt' + + salixos_patches_repo_name: str = 'salixos_patches' + salixos_patches_repo: bool = False + salixos_patches_repo_path: Path = Path(config.lib_path, 'repositories', salixos_patches_repo_name) + salixos_patches_repo_mirror: str = 'https://download.salixos.org/x86_64/slackware-15.0/' + salixos_patches_repo_packages_mirror: str = 'https://download.salixos.org/x86_64/slackware-15.0/patches/' + salixos_patches_repo_packages: str = 'PACKAGES.TXT' + salixos_patches_repo_checksums: str = 'CHECKSUMS.md5' + salixos_patches_repo_changelog: str = 'ChangeLog.txt' slackel_repo_name: str = 'slackel' slackel_repo: bool = False @@ -217,6 +226,14 @@ class Repositories: salixos_extra_repo_checksums: str = repos['SALIXOS_EXTRA_REPO_CHECKSUMS'] salixos_extra_repo_changelog: str = repos['SALIXOS_EXTRA_REPO_CHANGELOG'] + salixos_patches_repo_name: str = repos['SALIXOS_PATCHES_REPO_NAME'] + salixos_patches_repo: bool = repos['SALIXOS_PATCHES_REPO'] + salixos_patches_repo_mirror: str = repos['SALIXOS_PATCHES_REPO_MIRROR'] + salixos_patches_repo_packages_mirror: str = repos['SALIXOS_PATCHES_REPO_PACKAGES_MIRROR'] + salixos_patches_repo_packages: str = repos['SALIXOS_PATCHES_REPO_PACKAGES'] + salixos_patches_repo_checksums: str = repos['SALIXOS_PATCHES_REPO_CHECKSUMS'] + salixos_patches_repo_changelog: str = repos['SALIXOS_PATCHES_REPO_CHANGELOG'] + slackel_repo_name: str = repos['SLACKEL_REPO_NAME'] slackel_repo: bool = repos['SLACKEL_REPO'] slackel_repo_mirror: str = repos['SLACKEL_REPO_MIRROR'] @@ -242,6 +259,7 @@ class Repositories: ponce_bin_repo_name: ponce_bin_repo, salixos_repo_name: salixos_repo, salixos_extra_repo_name: salixos_extra_repo, + salixos_patches_repo_name: salixos_patches_repo, slackel_repo_name: slackel_repo } @@ -268,5 +286,7 @@ class Repositories: ponce_bin_repo_name: [ponce_bin_repo, ponce_bin_repo_path, ponce_bin_repo_changelog], salixos_repo_name: [salixos_repo, salixos_repo_path, salixos_repo_changelog], salixos_extra_repo_name: [salixos_extra_repo_name, salixos_extra_repo_path, salixos_extra_repo_changelog], + salixos_patches_repo_name: [salixos_patches_repo_name, salixos_patches_repo_path, + salixos_patches_repo_changelog], slackel_repo_name: [slackel_repo, slackel_repo_path, slackel_repo_changelog] } diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index b9cb15fe..98924c65 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -81,6 +81,9 @@ class UpdateRepository(Configs): if self.repo == self.repos.salixos_extra_repo_name or self.repo == '*': self.salixos_extra_repository() + if self.repo == self.repos.salixos_patches_repo_name or self.repo == '*': + self.salixos_patches_repository() + if self.repo == self.repos.slackel_repo_name or self.repo == '*': self.slackel_repository() else: @@ -330,6 +333,36 @@ class UpdateRepository(Configs): else: self.not_enabled_message(self.repos.salixos_extra_repo_name) + def salixos_patches_repository(self): + if self.repos.salixos_patches_repo: + urls: list = [] + print('Updating the packages list...\n') + print(f"Downloading the '{self.green}{self.repos.salixos_patches_repo_name}{self.endc}' " + f"repository, please wait...\n") + self.make_dirs(self.repos.salixos_patches_repo_name) + + urls.append(f'{self.repos.salixos_patches_repo_packages_mirror}{self.repos.salixos_patches_repo_packages}') + urls.append(f'{self.repos.salixos_patches_repo_mirror}{self.repos.salixos_patches_repo_changelog}') + urls.append(f'{self.repos.salixos_patches_repo_mirror}{self.repos.salixos_patches_repo_checksums}') + + self.utils.remove_file_if_exists(self.repos.salixos_patches_repo_path, + self.repos.salixos_patches_repo_packages) + self.utils.remove_file_if_exists(self.repos.salixos_patches_repo_path, + self.repos.salixos_patches_repo_changelog) + self.utils.remove_file_if_exists(self.repos.salixos_patches_repo_path, + self.repos.salixos_patches_repo_checksums) + + down = Downloader(self.repos.salixos_patches_repo_path, urls, self.flags) + down.download() + print() + + self.delete_binaries_data(self.repos.salixos_patches_repo_name) + self.delete_last_updated(self.repos.salixos_patches_repo_name) + self.data.install_salixos_patches_data() + print() + else: + self.not_enabled_message(self.repos.salixos_patches_repo_name) + def slackel_repository(self): if self.repos.slackel_repo: urls: list = [] From 4f22169992ffe18ec9d8156715677e0ae087f888 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 31 Mar 2023 21:56:47 +0300 Subject: [PATCH 57/74] Removed salixos_patches repo --- configs/repositories.toml | 9 ---- slpkg/check_updates.py | 8 --- slpkg/install_data.py | 100 ------------------------------------- slpkg/repo_info.py | 1 - slpkg/repositories.py | 20 -------- slpkg/update_repository.py | 33 ------------ 6 files changed, 171 deletions(-) diff --git a/configs/repositories.toml b/configs/repositories.toml index d8f5ae02..635feba4 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -109,15 +109,6 @@ SALIXOS_EXTRA_REPO_CHECKSUMS = "CHECKSUMS.md5" SALIXOS_EXTRA_REPO_CHANGELOG = "ChangeLog.txt" - # Repository for slackware 15.0 stable. - SALIXOS_PATCHES_REPO_NAME = "salixos_patches" - SALIXOS_PATCHES_REPO = false - SALIXOS_PATCHES_REPO_MIRROR = "https://download.salixos.org/x86_64/slackware-15.0/" - SALIXOS_PATCHES_REPO_PACKAGES_MIRROR = 'https://download.salixos.org/x86_64/slackware-15.0/patches/' - SALIXOS_PATCHES_REPO_PACKAGES = "PACKAGES.TXT" - SALIXOS_PATCHES_REPO_CHECKSUMS = "CHECKSUMS.md5" - SALIXOS_PATCHES_REPO_CHANGELOG = "ChangeLog.txt" - # Repository for slackware -current. SLACKEL_REPO_NAME = "slackel" SLACKEL_REPO = false diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 8e635b8c..025e6424 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -88,14 +88,6 @@ class CheckUpdates(Configs): f'{self.repos.salixos_extra_repo_changelog}') compare[self.repos.salixos_extra_repo_name] = self.compare_dates() - if (self.repos.salixos_patches_repo and self.repo == self.repos.salixos_patches_repo_name - or self.repo == '*'): - self.local_chg_txt: Path = Path(self.repos.salixos_patches_repo_path, - self.repos.salixos_patches_repo_changelog) - self.repo_chg_txt: str = (f'{self.repos.salixos_patches_repo_mirror}' - f'{self.repos.salixos_patches_repo_changelog}') - compare[self.repos.salixos_patches_repo_name] = self.compare_dates() - if self.repos.slackel_repo and self.repo == self.repos.slackel_repo_name or self.repo == '*': self.local_chg_txt: Path = Path(self.repos.slackel_repo_path, self.repos.slackel_repo_changelog) self.repo_chg_txt: str = f'{self.repos.slackel_repo_mirror}{self.repos.slackel_repo_changelog}' diff --git a/slpkg/install_data.py b/slpkg/install_data.py index 9584154c..6198f2ad 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -899,106 +899,6 @@ class InstallData(Configs): self.session.commit() - def install_salixos_patches_data(self) -> None: - """ Install the data for salixos_patches repository. """ - checksums_dict: dict = {} - pkg_tag = [ - 'PACKAGE NAME:', - 'PACKAGE LOCATION:', - 'PACKAGE SIZE (compressed):', - 'PACKAGE SIZE (uncompressed):', - 'PACKAGE REQUIRED:', - 'PACKAGE DESCRIPTION:' - ] - path_packages: Path = Path(self.repos.salixos_patches_repo_path, self.repos.salixos_patches_repo_packages) - path_checksums: Path = Path(self.repos.salixos_patches_repo_path, self.repos.salixos_patches_repo_checksums) - path_changelog: Path = Path(self.repos.salixos_patches_repo_path, - self.repos.salixos_patches_repo_changelog) - packages_txt: list = self.utils.read_file(path_packages) - checksums_md5: list = self.utils.read_file(path_checksums) - - for line in checksums_md5: - line = line.strip() - - if line.endswith(('.txz', '.tgz')): - file: str = line.split('./')[1].split('/')[-1].strip() - checksum: str = line.split('./')[0].strip() - checksums_dict[file] = checksum - - cache: list = [] # init cache - - print('Creating the database... ', end='', flush=True) - - 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) - cache.append(self.repos.salixos_patches_repo_mirror) - try: - cache.append(checksums_dict[package_name]) - except KeyError: - cache.append('error checksum') - - if line.startswith(pkg_tag[1]): - package_location = line.replace(pkg_tag[1], '').strip() - cache.append(package_location[2:]) # Do not install (./) dot - - if line.startswith(pkg_tag[2]): - package_size_comp = line.replace(pkg_tag[2], '').strip() - cache.append(f'{package_size_comp}B') - - if line.startswith(pkg_tag[3]): - package_size_uncomp = line.replace(pkg_tag[3], '').strip() - cache.append(f'{package_size_uncomp}B') - - if line.startswith(pkg_tag[4]): - deps: list = [] - required = line.replace(pkg_tag[4], '').strip() - - for req in required.split(','): - dep = req.split('|') - if len(dep) > 1: - deps.append(dep[1]) - else: - deps += dep - - cache.append(' '.join(deps)) - - if line.startswith(pkg_tag[5]): - package_description = line.replace(pkg_tag[5], '').strip() - cache.append(package_description) - - if len(cache) == 10: - data: str = BinariesTable( - repo=self.repos.salixos_patches_repo_name, - name=cache[0], - version=cache[1], - package=cache[2], - mirror=cache[3], - checksum=cache[4], - location=cache[5], - size_comp=cache[6], - size_uncomp=cache[7], - required=cache[8], - description=cache[9] - ) - - self.session.add(data) - - cache: list = [] # reset cache - - last_updated: str = self.last_updated(path_changelog) - date: str = LastRepoUpdated(repo=self.repos.salixos_patches_repo_name, date=last_updated) - self.session.add(date) - - print(f'{self.byellow}Done{self.endc}') - - self.session.commit() - def install_slackel_data(self) -> None: """ Install the data for slackel repository. """ checksums_dict: dict = {} diff --git a/slpkg/repo_info.py b/slpkg/repo_info.py index cc18190f..89539806 100644 --- a/slpkg/repo_info.py +++ b/slpkg/repo_info.py @@ -70,7 +70,6 @@ class RepoInfo(Configs): self.repos.ponce_bin_repo_name: BinQueries('', repo).count_packages(), self.repos.salixos_repo_name: BinQueries('', repo).count_packages(), self.repos.salixos_extra_repo_name: BinQueries('', repo).count_packages(), - self.repos.salixos_patches_repo_name: BinQueries('', repo).count_packages(), self.repos.slackel_repo_name: BinQueries('', repo).count_packages() } diff --git a/slpkg/repositories.py b/slpkg/repositories.py index 747ceebf..02cd5e91 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -117,15 +117,6 @@ class Repositories: salixos_extra_repo_checksums: str = 'CHECKSUMS.md5' salixos_extra_repo_changelog: str = 'ChangeLog.txt' - salixos_patches_repo_name: str = 'salixos_patches' - salixos_patches_repo: bool = False - salixos_patches_repo_path: Path = Path(config.lib_path, 'repositories', salixos_patches_repo_name) - salixos_patches_repo_mirror: str = 'https://download.salixos.org/x86_64/slackware-15.0/' - salixos_patches_repo_packages_mirror: str = 'https://download.salixos.org/x86_64/slackware-15.0/patches/' - salixos_patches_repo_packages: str = 'PACKAGES.TXT' - salixos_patches_repo_checksums: str = 'CHECKSUMS.md5' - salixos_patches_repo_changelog: str = 'ChangeLog.txt' - slackel_repo_name: str = 'slackel' slackel_repo: bool = False slackel_repo_path: Path = Path(config.lib_path, 'repositories', slackel_repo_name) @@ -226,14 +217,6 @@ class Repositories: salixos_extra_repo_checksums: str = repos['SALIXOS_EXTRA_REPO_CHECKSUMS'] salixos_extra_repo_changelog: str = repos['SALIXOS_EXTRA_REPO_CHANGELOG'] - salixos_patches_repo_name: str = repos['SALIXOS_PATCHES_REPO_NAME'] - salixos_patches_repo: bool = repos['SALIXOS_PATCHES_REPO'] - salixos_patches_repo_mirror: str = repos['SALIXOS_PATCHES_REPO_MIRROR'] - salixos_patches_repo_packages_mirror: str = repos['SALIXOS_PATCHES_REPO_PACKAGES_MIRROR'] - salixos_patches_repo_packages: str = repos['SALIXOS_PATCHES_REPO_PACKAGES'] - salixos_patches_repo_checksums: str = repos['SALIXOS_PATCHES_REPO_CHECKSUMS'] - salixos_patches_repo_changelog: str = repos['SALIXOS_PATCHES_REPO_CHANGELOG'] - slackel_repo_name: str = repos['SLACKEL_REPO_NAME'] slackel_repo: bool = repos['SLACKEL_REPO'] slackel_repo_mirror: str = repos['SLACKEL_REPO_MIRROR'] @@ -259,7 +242,6 @@ class Repositories: ponce_bin_repo_name: ponce_bin_repo, salixos_repo_name: salixos_repo, salixos_extra_repo_name: salixos_extra_repo, - salixos_patches_repo_name: salixos_patches_repo, slackel_repo_name: slackel_repo } @@ -286,7 +268,5 @@ class Repositories: ponce_bin_repo_name: [ponce_bin_repo, ponce_bin_repo_path, ponce_bin_repo_changelog], salixos_repo_name: [salixos_repo, salixos_repo_path, salixos_repo_changelog], salixos_extra_repo_name: [salixos_extra_repo_name, salixos_extra_repo_path, salixos_extra_repo_changelog], - salixos_patches_repo_name: [salixos_patches_repo_name, salixos_patches_repo_path, - salixos_patches_repo_changelog], slackel_repo_name: [slackel_repo, slackel_repo_path, slackel_repo_changelog] } diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index 98924c65..b9cb15fe 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -81,9 +81,6 @@ class UpdateRepository(Configs): if self.repo == self.repos.salixos_extra_repo_name or self.repo == '*': self.salixos_extra_repository() - if self.repo == self.repos.salixos_patches_repo_name or self.repo == '*': - self.salixos_patches_repository() - if self.repo == self.repos.slackel_repo_name or self.repo == '*': self.slackel_repository() else: @@ -333,36 +330,6 @@ class UpdateRepository(Configs): else: self.not_enabled_message(self.repos.salixos_extra_repo_name) - def salixos_patches_repository(self): - if self.repos.salixos_patches_repo: - urls: list = [] - print('Updating the packages list...\n') - print(f"Downloading the '{self.green}{self.repos.salixos_patches_repo_name}{self.endc}' " - f"repository, please wait...\n") - self.make_dirs(self.repos.salixos_patches_repo_name) - - urls.append(f'{self.repos.salixos_patches_repo_packages_mirror}{self.repos.salixos_patches_repo_packages}') - urls.append(f'{self.repos.salixos_patches_repo_mirror}{self.repos.salixos_patches_repo_changelog}') - urls.append(f'{self.repos.salixos_patches_repo_mirror}{self.repos.salixos_patches_repo_checksums}') - - self.utils.remove_file_if_exists(self.repos.salixos_patches_repo_path, - self.repos.salixos_patches_repo_packages) - self.utils.remove_file_if_exists(self.repos.salixos_patches_repo_path, - self.repos.salixos_patches_repo_changelog) - self.utils.remove_file_if_exists(self.repos.salixos_patches_repo_path, - self.repos.salixos_patches_repo_checksums) - - down = Downloader(self.repos.salixos_patches_repo_path, urls, self.flags) - down.download() - print() - - self.delete_binaries_data(self.repos.salixos_patches_repo_name) - self.delete_last_updated(self.repos.salixos_patches_repo_name) - self.data.install_salixos_patches_data() - print() - else: - self.not_enabled_message(self.repos.salixos_patches_repo_name) - def slackel_repository(self): if self.repos.slackel_repo: urls: list = [] From 05d7d4ca60a716e47f8ba65d70a2b5877d154c60 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 31 Mar 2023 22:12:28 +0300 Subject: [PATCH 58/74] Added slint repo --- configs/repositories.toml | 8 +++ slpkg/check_updates.py | 5 ++ slpkg/install_data.py | 99 ++++++++++++++++++++++++++++++++++++++ slpkg/repo_info.py | 3 +- slpkg/repositories.py | 21 +++++++- slpkg/update_repository.py | 31 ++++++++++++ 6 files changed, 164 insertions(+), 3 deletions(-) diff --git a/configs/repositories.toml b/configs/repositories.toml index 635feba4..6447b149 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -116,3 +116,11 @@ SLACKEL_REPO_PACKAGES = "PACKAGES.TXT" SLACKEL_REPO_CHECKSUMS = "CHECKSUMS.md5" SLACKEL_REPO_CHANGELOG = "ChangeLog.txt" + + # Repository for slackware 15.0 stable. + SLINT_REPO_NAME = "slint" + SLINT_REPO = false + SLINT_REPO_MIRROR = "https://slackware.uk/slint/x86_64/slint-15.0/" + SLINT_REPO_PACKAGES = "PACKAGES.TXT" + SLINT_REPO_CHECKSUMS = "CHECKSUMS.md5" + SLINT_REPO_CHANGELOG = "ChangeLog.txt" diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 025e6424..abee6914 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -93,6 +93,11 @@ class CheckUpdates(Configs): self.repo_chg_txt: str = f'{self.repos.slackel_repo_mirror}{self.repos.slackel_repo_changelog}' compare[self.repos.slackel_repo_name] = self.compare_dates() + if self.repos.slint_repo and self.repo == self.repos.slint_repo_name or self.repo == '*': + self.local_chg_txt: Path = Path(self.repos.slint_repo_path, self.repos.slint_repo_changelog) + self.repo_chg_txt: str = f'{self.repos.slint_repo_mirror}{self.repos.slint_repo_changelog}' + compare[self.repos.slint_repo_name] = self.compare_dates() + else: if self.repos.ponce_repo: self.local_chg_txt: Path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_changelog) diff --git a/slpkg/install_data.py b/slpkg/install_data.py index 6198f2ad..ad05d8e2 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -997,3 +997,102 @@ class InstallData(Configs): print(f'{self.byellow}Done{self.endc}') self.session.commit() + + def install_slint_data(self) -> None: + """ Install the data for slint repository. """ + checksums_dict: dict = {} + pkg_tag = [ + 'PACKAGE NAME:', + 'PACKAGE LOCATION:', + 'PACKAGE SIZE (compressed):', + 'PACKAGE SIZE (uncompressed):', + 'PACKAGE REQUIRED:', + 'PACKAGE DESCRIPTION:' + ] + path_packages: Path = Path(self.repos.slint_repo_path, self.repos.slint_repo_packages) + path_checksums: Path = Path(self.repos.slint_repo_path, self.repos.slint_repo_checksums) + path_changelog: Path = Path(self.repos.slint_repo_path, self.repos.slint_repo_changelog) + packages_txt: list = self.utils.read_file(path_packages) + checksums_md5: list = self.utils.read_file(path_checksums) + + for line in checksums_md5: + line = line.strip() + + if line.endswith(('.txz', '.tgz')): + file: str = line.split('./')[1].split('/')[-1].strip() + checksum: str = line.split('./')[0].strip() + checksums_dict[file] = checksum + + cache: list = [] # init cache + + print('Creating the database... ', end='', flush=True) + + 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) + cache.append(self.repos.slint_repo_mirror) + try: + cache.append(checksums_dict[package_name]) + except KeyError: + cache.append('error checksum') + + if line.startswith(pkg_tag[1]): + package_location = line.replace(pkg_tag[1], '').strip() + cache.append(package_location[2:]) # Do not install (./) dot + + if line.startswith(pkg_tag[2]): + package_size_comp = line.replace(pkg_tag[2], '').strip() + cache.append(f'{package_size_comp}B') + + if line.startswith(pkg_tag[3]): + package_size_uncomp = line.replace(pkg_tag[3], '').strip() + cache.append(f'{package_size_uncomp}B') + + if line.startswith(pkg_tag[4]): + deps: list = [] + required = line.replace(pkg_tag[4], '').strip() + + for req in required.split(','): + dep = req.split('|') + if len(dep) > 1: + deps.append(dep[1]) + else: + deps += dep + + cache.append(' '.join(deps)) + + if line.startswith(pkg_tag[5]): + package_description = line.replace(pkg_tag[5], '').strip() + cache.append(package_description) + + if len(cache) == 10: + data: str = BinariesTable( + repo=self.repos.slint_repo_name, + name=cache[0], + version=cache[1], + package=cache[2], + mirror=cache[3], + checksum=cache[4], + location=cache[5], + size_comp=cache[6], + size_uncomp=cache[7], + required=cache[8], + description=cache[9] + ) + + self.session.add(data) + + cache: list = [] # reset cache + + last_updated: str = self.last_updated(path_changelog) + date: str = LastRepoUpdated(repo=self.repos.slint_repo_name, date=last_updated) + self.session.add(date) + + print(f'{self.byellow}Done{self.endc}') + + self.session.commit() diff --git a/slpkg/repo_info.py b/slpkg/repo_info.py index 89539806..f5bcba7d 100644 --- a/slpkg/repo_info.py +++ b/slpkg/repo_info.py @@ -70,7 +70,8 @@ class RepoInfo(Configs): self.repos.ponce_bin_repo_name: BinQueries('', repo).count_packages(), self.repos.salixos_repo_name: BinQueries('', repo).count_packages(), self.repos.salixos_extra_repo_name: BinQueries('', repo).count_packages(), - self.repos.slackel_repo_name: BinQueries('', repo).count_packages() + self.repos.slackel_repo_name: BinQueries('', repo).count_packages(), + self.repos.slint_repo_name: BinQueries('', repo).count_packages() } if value[0]: diff --git a/slpkg/repositories.py b/slpkg/repositories.py index 02cd5e91..49bfcef5 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -125,6 +125,14 @@ class Repositories: slackel_repo_checksums: str = 'CHECKSUMS.md5' slackel_repo_changelog: str = 'ChangeLog.txt' + slint_repo_name: str = 'slint' + slint_repo: bool = False + slint_repo_path: Path = Path(config.lib_path, 'repositories', slint_repo_name) + slint_repo_mirror: str = 'https://slackware.uk/slint/x86_64/slint-15.0/' + slint_repo_packages: str = 'PACKAGES.TXT' + slint_repo_checksums: str = 'CHECKSUMS.md5' + slint_repo_changelog: str = 'ChangeLog.txt' + # Default repository tag. repo_tag: str = sbo_repo_tag @@ -224,6 +232,13 @@ class Repositories: slackel_repo_checksums: str = repos['SLACKEL_REPO_CHECKSUMS'] slackel_repo_changelog: str = repos['SLACKEL_REPO_CHANGELOG'] + slint_repo_name: str = repos['SLINT_REPO_NAME'] + slint_repo: bool = repos['SLINT_REPO'] + slint_repo_mirror: str = repos['SLINT_REPO_MIRROR'] + slint_repo_packages: str = repos['SLINT_REPO_PACKAGES'] + slint_repo_checksums: str = repos['SLINT_REPO_CHECKSUMS'] + slint_repo_changelog: str = repos['SLINT_REPO_CHANGELOG'] + except (tomli.TOMLDecodeError, KeyError) as error: raise SystemExit(f'\n{config.prog_name} {bred}Error{endc}: {error}: in the configuration file ' f"'{repositories_file_toml}'.\n" @@ -242,7 +257,8 @@ class Repositories: ponce_bin_repo_name: ponce_bin_repo, salixos_repo_name: salixos_repo, salixos_extra_repo_name: salixos_extra_repo, - slackel_repo_name: slackel_repo + slackel_repo_name: slackel_repo, + slint_repo_name: slint_repo } # All enabled binaries repositories. @@ -268,5 +284,6 @@ class Repositories: ponce_bin_repo_name: [ponce_bin_repo, ponce_bin_repo_path, ponce_bin_repo_changelog], salixos_repo_name: [salixos_repo, salixos_repo_path, salixos_repo_changelog], salixos_extra_repo_name: [salixos_extra_repo_name, salixos_extra_repo_path, salixos_extra_repo_changelog], - slackel_repo_name: [slackel_repo, slackel_repo_path, slackel_repo_changelog] + slackel_repo_name: [slackel_repo, slackel_repo_path, slackel_repo_changelog], + slint_repo_name: [slint_repo, slint_repo_path, slint_repo_changelog] } diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index b9cb15fe..d09d7273 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -83,6 +83,10 @@ class UpdateRepository(Configs): if self.repo == self.repos.slackel_repo_name or self.repo == '*': self.slackel_repository() + + if self.repo == self.repos.slint_repo_name or self.repo == '*': + self.slint_repository() + else: self.slackbuild_repositories() @@ -357,6 +361,33 @@ class UpdateRepository(Configs): else: self.not_enabled_message(self.repos.slackel_repo_name) + def slint_repository(self): + if self.repos.slint_repo: + urls: list = [] + print('Updating the packages list...\n') + print(f"Downloading the '{self.green}{self.repos.slint_repo_name}{self.endc}' " + f"repository, please wait...\n") + self.make_dirs(self.repos.slint_repo_name) + + urls.append(f'{self.repos.slint_repo_mirror}{self.repos.slint_repo_packages}') + urls.append(f'{self.repos.slint_repo_mirror}{self.repos.slint_repo_changelog}') + urls.append(f'{self.repos.slint_repo_mirror}{self.repos.slint_repo_checksums}') + + self.utils.remove_file_if_exists(self.repos.slint_repo_path, self.repos.slint_repo_packages) + self.utils.remove_file_if_exists(self.repos.slint_repo_path, self.repos.slint_repo_changelog) + self.utils.remove_file_if_exists(self.repos.slint_repo_path, self.repos.slint_repo_checksums) + + down = Downloader(self.repos.slint_repo_path, urls, self.flags) + down.download() + print() + + self.delete_binaries_data(self.repos.slint_repo_name) + self.delete_last_updated(self.repos.slint_repo_name) + self.data.install_slint_data() + print() + else: + self.not_enabled_message(self.repos.slint_repo_name) + def slackbuild_repositories(self): """ Update the slackbuild repositories. """ if self.repos.ponce_repo: From 721a239b7075a0e238a17ee5f70ee487ddd0b9d9 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 31 Mar 2023 22:16:51 +0300 Subject: [PATCH 59/74] Updated for version print --- slpkg/dependees.py | 4 ++-- slpkg/tracking.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/slpkg/dependees.py b/slpkg/dependees.py index b041219d..d628d553 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -53,7 +53,7 @@ class Dependees(Configs): else: version: str = SBoQueries(pkg).version() - package: str = f'{self.byellow}{pkg}-{version}{self.endc}' + package: str = f'{self.byellow}{pkg} {version}{self.endc}' print(package) @@ -73,7 +73,7 @@ class Dependees(Configs): else: version: str = SBoQueries(dep[0]).version() - dependency: str = (f'{self.cyan}{dep[0]}{self.endc}-{self.yellow}' + dependency: str = (f'{self.cyan}{dep[0]}{self.endc} {self.yellow}' f'{version}{self.endc}') if i == 1: diff --git a/slpkg/tracking.py b/slpkg/tracking.py index b7f8cf36..f126ca22 100644 --- a/slpkg/tracking.py +++ b/slpkg/tracking.py @@ -47,7 +47,7 @@ class Tracking(Configs): if self.utils.is_option(self.flag_bin_repository, self.flags): version: str = BinQueries(package, repo).version() - pkg = f'{self.yellow}{package}-{version}{self.endc}' + pkg = f'{self.yellow}{package} {version}{self.endc}' if self.utils.is_option(self.flag_bin_repository, self.flags): requires: list = Required(package, repo).resolve() @@ -67,9 +67,9 @@ class Tracking(Configs): if self.utils.is_option(self.flag_pkg_version, self.flags): - version: str = f"-{self.yellow}{SBoQueries(req).version()}{self.endc}" + version: str = f" {self.yellow}{SBoQueries(req).version()}{self.endc}" if self.utils.is_option(self.flag_bin_repository, self.flags): - version: str = f"-{self.yellow}{BinQueries(req, repo).version()}{self.endc}" + version: str = f" {self.yellow}{BinQueries(req, repo).version()}{self.endc}" require: str = f'{self.cyan}{req}{self.endc}{version}' From d0a72541f1c4af89745af0008ed4c411beb7bbc1 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 31 Mar 2023 22:18:21 +0300 Subject: [PATCH 60/74] Updated for version print --- slpkg/binaries/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/binaries/install.py b/slpkg/binaries/install.py index eba653c8..67ec8a8a 100644 --- a/slpkg/binaries/install.py +++ b/slpkg/binaries/install.py @@ -229,7 +229,7 @@ class Packages(Configs): status: bool = False repo_ver: str = BinQueries(package, self.repo).version() - help_text: str = f'Package: {package}-{repo_ver}' + help_text: str = f'Package: {package} {repo_ver}' upgradable: bool = self.upgrade.is_package_upgradeable(package) if self.mode == 'upgrade' and upgradable: From 3776a19977b4336d6392eb8fcd39f33354bfbffc Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 1 Apr 2023 10:27:38 +0300 Subject: [PATCH 61/74] Fixed for required --- slpkg/binaries/required.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/slpkg/binaries/required.py b/slpkg/binaries/required.py index 2783ede3..3a6dea08 100644 --- a/slpkg/binaries/required.py +++ b/slpkg/binaries/required.py @@ -15,15 +15,25 @@ class Required: self.repos = Repositories() self.repo_package_names: list = BinQueries(name, self.repo).all_package_names_by_repo() + self.special_repos: list = [ + self.repos.salixos_repo_name, + self.repos.slackel_repo_name, + self.repos.slint_repo_name + ] + def resolve(self) -> list: """ Resolve the dependencies. """ required: list[str] = BinQueries(self.name, self.repo).required() - if self.repos.salixos_repo_name: - return required + if self.repo in self.special_repos: + requires: list = [] + for req in required: + if req in self.repo_package_names: + requires.append(req) + return requires for req in required: - if req: + if req and req in self.repo_package_names: sub_required: list[str] = BinQueries(req, self.repo).required() for sub in sub_required: From 206fd628b76e2de7936d4268836ee661dd50c587 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 1 Apr 2023 10:33:50 +0300 Subject: [PATCH 62/74] Updated for required --- slpkg/binaries/required.py | 2 ++ slpkg/sbos/dependencies.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/slpkg/binaries/required.py b/slpkg/binaries/required.py index 3a6dea08..d72b3ed8 100644 --- a/slpkg/binaries/required.py +++ b/slpkg/binaries/required.py @@ -17,6 +17,7 @@ class Required: self.special_repos: list = [ self.repos.salixos_repo_name, + self.repos.salixos_extra_repo_name, self.repos.slackel_repo_name, self.repos.slint_repo_name ] @@ -25,6 +26,7 @@ class Required: """ Resolve the dependencies. """ required: list[str] = BinQueries(self.name, self.repo).required() + # Resolve dependencies for some special repos. if self.repo in self.special_repos: requires: list = [] for req in required: diff --git a/slpkg/sbos/dependencies.py b/slpkg/sbos/dependencies.py index 74795e20..a97fb5c3 100644 --- a/slpkg/sbos/dependencies.py +++ b/slpkg/sbos/dependencies.py @@ -13,10 +13,11 @@ class Requires: def resolve(self) -> list: """ Resolve the dependencies. """ - requires: list[str] = SBoQueries(self.name).requires() # type: ignore + requires: list[str] = SBoQueries(self.name).requires() + for req in requires: if req: - sub_requires: list[str] = SBoQueries(req).requires() # type: ignore + sub_requires: list[str] = SBoQueries(req).requires() for sub in sub_requires: requires.append(sub) From 1a5d2a482d9cdec8e4ba71e6f761f1de3b916862 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 1 Apr 2023 10:45:20 +0300 Subject: [PATCH 63/74] Updated for dependencies --- slpkg/binaries/required.py | 11 +++++++++-- slpkg/sbos/dependencies.py | 7 +++++++ slpkg/sbos/slackbuild.py | 9 --------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/slpkg/binaries/required.py b/slpkg/binaries/required.py index d72b3ed8..0b8a7554 100644 --- a/slpkg/binaries/required.py +++ b/slpkg/binaries/required.py @@ -13,7 +13,8 @@ class Required: self.name: str = name self.repo: str = repo self.repos = Repositories() - self.repo_package_names: list = BinQueries(name, self.repo).all_package_names_by_repo() + self.repo_package_names: list = BinQueries( + self.name, self.repo).all_package_names_by_repo() self.special_repos: list = [ self.repos.salixos_repo_name, @@ -35,7 +36,13 @@ class Required: return requires for req in required: - if req and req in self.repo_package_names: + + # Remove requirements that are included as dependencies, + # but are not included in the repository. + if req not in self.repo_package_names: + required.remove(req) + + if req: sub_required: list[str] = BinQueries(req, self.repo).required() for sub in sub_required: diff --git a/slpkg/sbos/dependencies.py b/slpkg/sbos/dependencies.py index a97fb5c3..c963b95a 100644 --- a/slpkg/sbos/dependencies.py +++ b/slpkg/sbos/dependencies.py @@ -10,12 +10,19 @@ class Requires: def __init__(self, name: str): self.name: str = name + self.repo_slackbuilds_names: list = SBoQueries(self.name).sbos() def resolve(self) -> list: """ Resolve the dependencies. """ requires: list[str] = SBoQueries(self.name).requires() for req in requires: + + # Remove requirements that are included as dependencies, + # but are not included in the repository. + if req not in self.repo_slackbuilds_names: + requires.remove(req) + if req: sub_requires: list[str] = SBoQueries(req).requires() for sub in sub_requires: diff --git a/slpkg/sbos/slackbuild.py b/slpkg/sbos/slackbuild.py index 2973f49a..df913f7d 100644 --- a/slpkg/sbos/slackbuild.py +++ b/slpkg/sbos/slackbuild.py @@ -91,15 +91,6 @@ class Slackbuilds(Configs): for deps in self.sbos.values(): for dep in deps: - # Checks if dependency exists in the ponce repository. - # Sometimes the dependency reference is in the .info file, - # but there is not exist in the repository as a folder. - if self.repos.ponce_repo: - location: str = SBoQueries(dep).location() - path_ponce_repo_package = Path(self.repos.ponce_repo_path, location, dep) - if not path_ponce_repo_package.is_dir(): - continue - # Skip installed package when the option --skip-installed is applied. if (self.utils.is_option(self.flag_skip_installed, self.flags) and self.utils.is_package_installed(dep)): From d25ba99f3f4972b14164db8f966497fb37c74049 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 1 Apr 2023 10:50:02 +0300 Subject: [PATCH 64/74] Updated for coding style --- slpkg/dependees.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slpkg/dependees.py b/slpkg/dependees.py index d628d553..eefb045b 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -83,9 +83,9 @@ class Dependees(Configs): if self.utils.is_option(self.flag_full_reverse, self.flags): if i == len(dependees): - print(" " * 4 + f' {self.llc}{self.hl} {self.violet}{dep[1]}{self.endc}') + print(' ' * 4 + f' {self.llc}{self.hl} {self.violet}{dep[1]}{self.endc}') else: - print(" " * 4 + f' {self.var}{self.hl} {self.violet}{dep[1]}{self.endc}') + print(' ' * 4 + f' {self.var}{self.hl} {self.violet}{dep[1]}{self.endc}') print(f'\n{self.grey}{len(dependees)} dependees for {pkg}{self.endc}\n') From 98388f5d0360d6ea3394668dbdd8672cd11f51f6 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 1 Apr 2023 11:11:34 +0300 Subject: [PATCH 65/74] Updated for repos names --- slpkg/main.py | 2 +- slpkg/repositories.py | 29 +++++++++-------------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/slpkg/main.py b/slpkg/main.py index 09159c14..76a5894b 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -288,7 +288,7 @@ class Argparse(Configs): if self.binary_repo == '*' and not self.utils.is_option(except_options, self.args): self.usage.help_minimal(f"{self.prog_name}: invalid binary repository '{self.binary_repo}'") - elif self.binary_repo not in self.repos.binaries_repositories_dict.keys() and self.binary_repo != '*': + elif self.binary_repo not in self.repos.bin_repos_names and self.binary_repo != '*': self.usage.help_minimal(f"{self.prog_name}: invalid binary repository '{self.binary_repo}'") def invalid_options(self) -> None: diff --git a/slpkg/repositories.py b/slpkg/repositories.py index 49bfcef5..0526297a 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -246,26 +246,6 @@ class Repositories: f"'mv {repositories_file_toml}.new {repositories_file_toml}'.\n" f"or '{cyan}slpkg_new-configs{endc}' command.\n") - # Dictionary with the binaries repositories. - binaries_repositories_dict = { - alien_repo_name: alien_repo, - multilib_repo_name: multilib_repo, - restricted_repo_name: restricted_repo, - gnome_repo_name: gnome_repo, - conraid_repo_name: conraid_repo, - slackonly_repo_name: slackonly_repo, - ponce_bin_repo_name: ponce_bin_repo, - salixos_repo_name: salixos_repo, - salixos_extra_repo_name: salixos_extra_repo, - slackel_repo_name: slackel_repo, - slint_repo_name: slint_repo - } - - # All enabled binaries repositories. - for repo, enable in binaries_repositories_dict.items(): - if enable: - bin_enabled_repos.append(repo) - if ponce_repo: sbo_enabled_repository: str = ponce_repo_name repo_tag: str = ponce_repo_tag @@ -287,3 +267,12 @@ class Repositories: slackel_repo_name: [slackel_repo, slackel_repo_path, slackel_repo_changelog], slint_repo_name: [slint_repo, slint_repo_path, slint_repo_changelog] } + + # All the binary repositories names. + bin_repos_names = list(repos_dict.keys())[2:] + + # All the enabled binary repositories. + for repo, enabled in repos_dict.items(): + if repo not in [sbo_repo_name, ponce_repo_name]: + if enabled[0]: + bin_enabled_repos.append(repo) From 0e9b112fb31c9938232df2a1185fbed81d3d3687 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 1 Apr 2023 11:12:56 +0300 Subject: [PATCH 66/74] Updated for comments --- slpkg/repositories.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/slpkg/repositories.py b/slpkg/repositories.py index 0526297a..a73af3a7 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -246,6 +246,7 @@ class Repositories: f"'mv {repositories_file_toml}.new {repositories_file_toml}'.\n" f"or '{cyan}slpkg_new-configs{endc}' command.\n") + # Switch to ponce repository if is true. if ponce_repo: sbo_enabled_repository: str = ponce_repo_name repo_tag: str = ponce_repo_tag @@ -271,7 +272,7 @@ class Repositories: # All the binary repositories names. bin_repos_names = list(repos_dict.keys())[2:] - # All the enabled binary repositories. + # All the enabled binary repositories names. for repo, enabled in repos_dict.items(): if repo not in [sbo_repo_name, ponce_repo_name]: if enabled[0]: From 59ab5478dbb88bf9eb3ceec832114a63fae664be Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 1 Apr 2023 11:19:02 +0300 Subject: [PATCH 67/74] Updated for 4.7.0rc2 --- setup.cfg | 2 +- slpkg/views/version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 8e03a5a5..baeb148f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = slpkg -version = r.c.1 +version = r.c.2 license_file = LICENSE author = Dimitris Zlatanidis author_email = d.zlatanidis@gmail.com diff --git a/slpkg/views/version.py b/slpkg/views/version.py index 30086c6f..63048258 100644 --- a/slpkg/views/version.py +++ b/slpkg/views/version.py @@ -5,7 +5,7 @@ class Version: """ Print the version. """ def __init__(self): - self.version_info: tuple = ('r', 'c', 1) + self.version_info: tuple = ('r', 'c', 2) self.version: str = '{0}.{1}.{2}'.format(*self.version_info) self.license: str = 'MIT License' self.author: str = 'Dimitris Zlatanidis (dslackw)' From 2f269030037b5a74a66059dc6348723839f774c1 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 1 Apr 2023 12:12:42 +0300 Subject: [PATCH 68/74] Updated for package pattern --- slpkg/binaries/install.py | 9 +++++++++ slpkg/checks.py | 12 +++++++----- slpkg/sbos/slackbuild.py | 17 ++++++++++++++--- slpkg/upgrade.py | 22 ++++++++++++---------- 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/slpkg/binaries/install.py b/slpkg/binaries/install.py index 67ec8a8a..1db7859e 100644 --- a/slpkg/binaries/install.py +++ b/slpkg/binaries/install.py @@ -59,6 +59,15 @@ class Packages(Configs): self.flag_no_silent: list = ['-n', '--no-silent'] self.flag_resolve_off: list = ['-o', '--resolve-off'] + self.check_for_packages_pattern() + + def check_for_packages_pattern(self): + """ Apply the pattern. """ + for pkg in self.packages: + if pkg == '*': + self.packages.remove(pkg) + self.packages += BinQueries('', self.repo).all_package_names_by_repo() + def execute(self) -> None: self.dependencies() diff --git a/slpkg/checks.py b/slpkg/checks.py index 35fc4b78..88261216 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -37,13 +37,14 @@ class Check(Configs): def exists_in_the_database(self, packages: list, repo=None) -> None: """ Checking if the slackbuild exists in the database. """ not_packages: list = [] + for pkg in packages: if self.utils.is_option(self.flag_bin_repository, self.flags): - if not BinQueries(pkg, repo).package_name(): + if not BinQueries(pkg, repo).package_name() and pkg != '*': not_packages.append(pkg) - elif not SBoQueries(pkg).slackbuild(): + elif not SBoQueries(pkg).slackbuild() and pkg != '*': not_packages.append(pkg) if not_packages: @@ -52,10 +53,11 @@ class Check(Configs): def is_package_unsupported(self, slackbuilds: list) -> None: """ Checking for unsupported slackbuilds. """ for sbo in slackbuilds: - sources = SBoQueries(sbo).sources() + if sbo != '*': + sources = SBoQueries(sbo).sources() - if 'UNSUPPORTED' in sources: - self.utils.raise_error_message(f"Package '{sbo}' unsupported by arch") + if 'UNSUPPORTED' in sources: + self.utils.raise_error_message(f"Package '{sbo}' unsupported by arch") def is_installed(self, packages: list) -> None: """ Checking for installed packages. """ diff --git a/slpkg/sbos/slackbuild.py b/slpkg/sbos/slackbuild.py index df913f7d..2c99d987 100644 --- a/slpkg/sbos/slackbuild.py +++ b/slpkg/sbos/slackbuild.py @@ -63,12 +63,20 @@ class Slackbuilds(Configs): self.flag_jobs: list = ['-j', '--jobs'] self.flag_no_silent: list = ['-n', '--no-silent'] + self.check_for_packages_pattern() + + def check_for_packages_pattern(self): + """ Apply the pattern. """ + for pkg in self.slackbuilds: + if pkg == '*': + self.slackbuilds.remove(pkg) + self.slackbuilds += SBoQueries('').sbos() + def execute(self) -> None: """ Starting build or install the slackbuilds. """ self.creating_dictionary() - if not self.utils.is_option(self.flag_resolve_off, self.flags): - self.creating_dependencies_for_build() + self.creating_dependencies_for_build() self.creating_main_for_build() @@ -84,7 +92,10 @@ class Slackbuilds(Configs): def creating_dictionary(self) -> None: """ Dictionary with the main slackbuilds and dependencies. """ for sbo in self.slackbuilds: - self.sbos[sbo] = Requires(sbo).resolve() + if self.utils.is_option(self.flag_resolve_off, self.flags): + self.sbos[sbo] = [] + else: + self.sbos[sbo] = Requires(sbo).resolve() def creating_dependencies_for_build(self) -> None: """ List with the dependencies. """ diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index e610e291..0ba448d4 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -40,15 +40,17 @@ class Upgrade(Configs): def is_package_upgradeable(self, name: str) -> bool: """ Checks for installed and upgradeable packages. """ inst_package: str = self.utils.is_package_installed(name) - inst_version: str = self.utils.split_binary_pkg(inst_package)[1] - inst_build: str = self.utils.split_binary_pkg(inst_package)[3] - if self.utils.is_option(self.flag_bin_repository, self.flags): - repo_package: str = BinQueries(name, self.repo).package_bin() - repo_version: str = BinQueries(name, self.repo).version() - repo_build: str = self.utils.split_binary_pkg(repo_package)[3] - else: - repo_version: str = SBoQueries(name).version() - repo_build: str = self.utils.read_sbo_build_tag(name) + if inst_package: + inst_version: str = self.utils.split_binary_pkg(inst_package)[1] + inst_build: str = self.utils.split_binary_pkg(inst_package)[3] - return parse(repo_version + repo_build) > parse(inst_version + inst_build) + if self.utils.is_option(self.flag_bin_repository, self.flags): + repo_package: str = BinQueries(name, self.repo).package_bin() + repo_version: str = BinQueries(name, self.repo).version() + repo_build: str = self.utils.split_binary_pkg(repo_package)[3] + else: + repo_version: str = SBoQueries(name).version() + repo_build: str = self.utils.read_sbo_build_tag(name) + + return parse(repo_version + repo_build) > parse(inst_version + inst_build) From 973f7b1ab4f7c15fa493e87ff3a6c75ed0c1050d Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 1 Apr 2023 12:27:53 +0300 Subject: [PATCH 69/74] Updated for package pattern --- slpkg/binaries/install.py | 4 ++-- slpkg/dependees.py | 13 +++++++++++++ slpkg/sbos/slackbuild.py | 4 ++-- slpkg/tracking.py | 15 +++++++++++++++ 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/slpkg/binaries/install.py b/slpkg/binaries/install.py index 1db7859e..644fffc2 100644 --- a/slpkg/binaries/install.py +++ b/slpkg/binaries/install.py @@ -59,9 +59,9 @@ class Packages(Configs): self.flag_no_silent: list = ['-n', '--no-silent'] self.flag_resolve_off: list = ['-o', '--resolve-off'] - self.check_for_packages_pattern() + self.apply_package_pattern() - def check_for_packages_pattern(self): + def apply_package_pattern(self): """ Apply the pattern. """ for pkg in self.packages: if pkg == '*': diff --git a/slpkg/dependees.py b/slpkg/dependees.py index eefb045b..c941a7dd 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -39,6 +39,8 @@ class Dependees(Configs): def find(self, repo: str) -> None: """ Collecting the dependees. """ + self.apply_package_pattern(repo) + print(f"The list below shows the " f"packages that dependees on '{', '.join([p for p in self.packages])}':\n") @@ -99,3 +101,14 @@ class Dependees(Configs): for req in requires: if [r for r in req[1].split() if r == pkg]: yield req + + def apply_package_pattern(self, repo: str): + """ Apply the pattern. """ + for pkg in self.packages: + if pkg == '*': + self.packages.remove(pkg) + + if self.utils.is_option(self.flag_bin_repository, self.flags): + self.packages += BinQueries('', repo).all_package_names_by_repo() + else: + self.packages += SBoQueries('').sbos() diff --git a/slpkg/sbos/slackbuild.py b/slpkg/sbos/slackbuild.py index 2c99d987..7b3bb914 100644 --- a/slpkg/sbos/slackbuild.py +++ b/slpkg/sbos/slackbuild.py @@ -63,9 +63,9 @@ class Slackbuilds(Configs): self.flag_jobs: list = ['-j', '--jobs'] self.flag_no_silent: list = ['-n', '--no-silent'] - self.check_for_packages_pattern() + self.apply_package_pattern() - def check_for_packages_pattern(self): + def apply_package_pattern(self): """ Apply the pattern. """ for pkg in self.slackbuilds: if pkg == '*': diff --git a/slpkg/tracking.py b/slpkg/tracking.py index f126ca22..513fa043 100644 --- a/slpkg/tracking.py +++ b/slpkg/tracking.py @@ -35,6 +35,8 @@ class Tracking(Configs): """ Prints the packages dependencies. """ print(f"The list below shows the packages with dependencies:\n") + packages: list = self.apply_package_pattern(packages, repo) + char: str = f' {self.llc}{self.hl}' sp: str = ' ' * 4 @@ -79,3 +81,16 @@ class Tracking(Configs): print(f'{sp}{require}') print(f'\n{self.grey}{how_many} dependencies for {package}{self.endc}\n') + + def apply_package_pattern(self, packages: list, repo: str): + """ Apply the pattern. """ + for pkg in packages: + if pkg == '*': + packages.remove(pkg) + + if self.utils.is_option(self.flag_bin_repository, self.flags): + packages += BinQueries('', repo).all_package_names_by_repo() + else: + packages += SBoQueries('').sbos() + + return packages From 78fc0a79d345e41c76cb9887a7856f51f0815154 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 1 Apr 2023 12:33:01 +0300 Subject: [PATCH 70/74] Updated for package pattern --- slpkg/binaries/install.py | 2 +- slpkg/dependees.py | 2 +- slpkg/sbos/slackbuild.py | 2 +- slpkg/tracking.py | 2 +- slpkg/views/view_package.py | 12 ++++++++++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/slpkg/binaries/install.py b/slpkg/binaries/install.py index 644fffc2..17ab4dd7 100644 --- a/slpkg/binaries/install.py +++ b/slpkg/binaries/install.py @@ -61,7 +61,7 @@ class Packages(Configs): self.apply_package_pattern() - def apply_package_pattern(self): + def apply_package_pattern(self) -> None: """ Apply the pattern. """ for pkg in self.packages: if pkg == '*': diff --git a/slpkg/dependees.py b/slpkg/dependees.py index c941a7dd..0d19e324 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -102,7 +102,7 @@ class Dependees(Configs): if [r for r in req[1].split() if r == pkg]: yield req - def apply_package_pattern(self, repo: str): + def apply_package_pattern(self, repo: str) -> None: """ Apply the pattern. """ for pkg in self.packages: if pkg == '*': diff --git a/slpkg/sbos/slackbuild.py b/slpkg/sbos/slackbuild.py index 7b3bb914..0b892881 100644 --- a/slpkg/sbos/slackbuild.py +++ b/slpkg/sbos/slackbuild.py @@ -65,7 +65,7 @@ class Slackbuilds(Configs): self.apply_package_pattern() - def apply_package_pattern(self): + def apply_package_pattern(self) -> None: """ Apply the pattern. """ for pkg in self.slackbuilds: if pkg == '*': diff --git a/slpkg/tracking.py b/slpkg/tracking.py index 513fa043..6184aac1 100644 --- a/slpkg/tracking.py +++ b/slpkg/tracking.py @@ -82,7 +82,7 @@ class Tracking(Configs): print(f'\n{self.grey}{how_many} dependencies for {package}{self.endc}\n') - def apply_package_pattern(self, packages: list, repo: str): + def apply_package_pattern(self, packages: list, repo: str) -> list: """ Apply the pattern. """ for pkg in packages: if pkg == '*': diff --git a/slpkg/views/view_package.py b/slpkg/views/view_package.py index d288d006..aa671f13 100644 --- a/slpkg/views/view_package.py +++ b/slpkg/views/view_package.py @@ -34,6 +34,16 @@ class ViewPackage(Configs): self.repo_path: Path = self.repos.ponce_repo_path self.repo_tar_suffix: str = '' + @staticmethod + def apply_package_pattern(packages: list) -> list: + """ Apply the pattern. """ + for pkg in packages: + if pkg == '*': + packages.remove(pkg) + packages += SBoQueries('').sbos() + + return packages + def package(self, packages: list) -> None: """ View the packages from the repository. """ color = self.colour() @@ -44,6 +54,8 @@ class ViewPackage(Configs): red: str = color['red'] endc: str = color['endc'] + packages: list = self.apply_package_pattern(packages) + for package in packages: info: list = self.session.query( From bf7646a9961ed442d60e546a7df9fe415edbb729 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 1 Apr 2023 12:53:31 +0300 Subject: [PATCH 71/74] Merge apply pattern to utils --- slpkg/binaries/install.py | 9 +-------- slpkg/dependees.py | 13 +------------ slpkg/download_only.py | 1 + slpkg/sbos/slackbuild.py | 12 +----------- slpkg/tracking.py | 15 +-------------- slpkg/utilities.py | 15 +++++++++++++++ slpkg/views/view_package.py | 12 +----------- 7 files changed, 21 insertions(+), 56 deletions(-) diff --git a/slpkg/binaries/install.py b/slpkg/binaries/install.py index 17ab4dd7..10823c97 100644 --- a/slpkg/binaries/install.py +++ b/slpkg/binaries/install.py @@ -59,14 +59,7 @@ class Packages(Configs): self.flag_no_silent: list = ['-n', '--no-silent'] self.flag_resolve_off: list = ['-o', '--resolve-off'] - self.apply_package_pattern() - - def apply_package_pattern(self) -> None: - """ Apply the pattern. """ - for pkg in self.packages: - if pkg == '*': - self.packages.remove(pkg) - self.packages += BinQueries('', self.repo).all_package_names_by_repo() + self.packages: list = self.utils.apply_package_pattern(self.flags, self.packages, self.repo) def execute(self) -> None: self.dependencies() diff --git a/slpkg/dependees.py b/slpkg/dependees.py index 0d19e324..dbebc5c2 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -39,7 +39,7 @@ class Dependees(Configs): def find(self, repo: str) -> None: """ Collecting the dependees. """ - self.apply_package_pattern(repo) + self.packages: list = self.utils.apply_package_pattern(self.flags, self.packages, repo) print(f"The list below shows the " f"packages that dependees on '{', '.join([p for p in self.packages])}':\n") @@ -101,14 +101,3 @@ class Dependees(Configs): for req in requires: if [r for r in req[1].split() if r == pkg]: yield req - - def apply_package_pattern(self, repo: str) -> None: - """ Apply the pattern. """ - for pkg in self.packages: - if pkg == '*': - self.packages.remove(pkg) - - if self.utils.is_option(self.flag_bin_repository, self.flags): - self.packages += BinQueries('', repo).all_package_names_by_repo() - else: - self.packages += SBoQueries('').sbos() diff --git a/slpkg/download_only.py b/slpkg/download_only.py index e8a1723e..c9eb08b8 100644 --- a/slpkg/download_only.py +++ b/slpkg/download_only.py @@ -32,6 +32,7 @@ class Download(Configs): def packages(self, packages: list, repo=None) -> None: """ Download the package only. """ + packages: list = self.utils.apply_package_pattern(self.flags, packages, repo) view = ViewMessage(self.flags, repo) view.download_packages(packages, self.directory) view.question() diff --git a/slpkg/sbos/slackbuild.py b/slpkg/sbos/slackbuild.py index 0b892881..6eb3bd90 100644 --- a/slpkg/sbos/slackbuild.py +++ b/slpkg/sbos/slackbuild.py @@ -63,23 +63,13 @@ class Slackbuilds(Configs): self.flag_jobs: list = ['-j', '--jobs'] self.flag_no_silent: list = ['-n', '--no-silent'] - self.apply_package_pattern() - - def apply_package_pattern(self) -> None: - """ Apply the pattern. """ - for pkg in self.slackbuilds: - if pkg == '*': - self.slackbuilds.remove(pkg) - self.slackbuilds += SBoQueries('').sbos() + self.slackbuilds: list = self.utils.apply_package_pattern(self.flags, self.slackbuilds) def execute(self) -> None: """ Starting build or install the slackbuilds. """ self.creating_dictionary() - self.creating_dependencies_for_build() - self.creating_main_for_build() - self.view_before_build() start: float = time.time() diff --git a/slpkg/tracking.py b/slpkg/tracking.py index 6184aac1..c21b17b6 100644 --- a/slpkg/tracking.py +++ b/slpkg/tracking.py @@ -35,7 +35,7 @@ class Tracking(Configs): """ Prints the packages dependencies. """ print(f"The list below shows the packages with dependencies:\n") - packages: list = self.apply_package_pattern(packages, repo) + packages: list = self.utils.apply_package_pattern(self.flags, packages, repo) char: str = f' {self.llc}{self.hl}' sp: str = ' ' * 4 @@ -81,16 +81,3 @@ class Tracking(Configs): print(f'{sp}{require}') print(f'\n{self.grey}{how_many} dependencies for {package}{self.endc}\n') - - def apply_package_pattern(self, packages: list, repo: str) -> list: - """ Apply the pattern. """ - for pkg in packages: - if pkg == '*': - packages.remove(pkg) - - if self.utils.is_option(self.flag_bin_repository, self.flags): - packages += BinQueries('', repo).all_package_names_by_repo() - else: - packages += SBoQueries('').sbos() - - return packages diff --git a/slpkg/utilities.py b/slpkg/utilities.py index 9392370a..8e8800d9 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -12,6 +12,7 @@ from slpkg.configs import Configs from slpkg.blacklist import Blacklist from slpkg.sbos.queries import SBoQueries from slpkg.repositories import Repositories +from slpkg.binaries.queries import BinQueries class Utilities: @@ -29,6 +30,7 @@ class Utilities: self.red: str = self.color['red'] self.endc: str = self.color['endc'] self.bred: str = f'{self.bold}{self.red}' + self.flag_bin_repository: list = ['-B=', '--bin-repo='] self.installed_packages: list = list(self.all_installed()) self.installed_package_names: list = list(self.all_installed_names()) @@ -180,3 +182,16 @@ class Utilities: unit: str = 'GB' return f'{str(round(file_size, 2))} {unit}' + + def apply_package_pattern(self, flags: list, packages: list, repo=None) -> list: + """ Apply the pattern. """ + for pkg in packages: + if pkg == '*': + packages.remove(pkg) + + if self.is_option(self.flag_bin_repository, flags): + packages += BinQueries('', repo).all_package_names_by_repo() + else: + packages += SBoQueries('').sbos() + + return packages diff --git a/slpkg/views/view_package.py b/slpkg/views/view_package.py index aa671f13..54ed15f4 100644 --- a/slpkg/views/view_package.py +++ b/slpkg/views/view_package.py @@ -34,16 +34,6 @@ class ViewPackage(Configs): self.repo_path: Path = self.repos.ponce_repo_path self.repo_tar_suffix: str = '' - @staticmethod - def apply_package_pattern(packages: list) -> list: - """ Apply the pattern. """ - for pkg in packages: - if pkg == '*': - packages.remove(pkg) - packages += SBoQueries('').sbos() - - return packages - def package(self, packages: list) -> None: """ View the packages from the repository. """ color = self.colour() @@ -54,7 +44,7 @@ class ViewPackage(Configs): red: str = color['red'] endc: str = color['endc'] - packages: list = self.apply_package_pattern(packages) + packages: list = self.utils.apply_package_pattern(self.flags, packages) for package in packages: From ef7330c21585faa0d83cf2c64d07a240c163ebdd Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 1 Apr 2023 12:59:05 +0300 Subject: [PATCH 72/74] Updated for the title --- slpkg/dependees.py | 4 ++-- slpkg/tracking.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/slpkg/dependees.py b/slpkg/dependees.py index dbebc5c2..e0eb324b 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -39,11 +39,11 @@ class Dependees(Configs): def find(self, repo: str) -> None: """ Collecting the dependees. """ - self.packages: list = self.utils.apply_package_pattern(self.flags, self.packages, repo) - print(f"The list below shows the " f"packages that dependees on '{', '.join([p for p in self.packages])}':\n") + self.packages: list = self.utils.apply_package_pattern(self.flags, self.packages, repo) + for pkg in self.packages: dependees: list = list(self.find_requires(pkg, repo)) diff --git a/slpkg/tracking.py b/slpkg/tracking.py index c21b17b6..b3cd2a79 100644 --- a/slpkg/tracking.py +++ b/slpkg/tracking.py @@ -33,7 +33,7 @@ class Tracking(Configs): def packages(self, packages: list, repo: str) -> None: """ Prints the packages dependencies. """ - print(f"The list below shows the packages with dependencies:\n") + print(f"The list below shows the packages '{', '.join([p for p in packages])}' with dependencies:\n") packages: list = self.utils.apply_package_pattern(self.flags, packages, repo) From 09e8d6e616b88728825c9680ca2ba478412cc9e3 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 1 Apr 2023 14:21:48 +0300 Subject: [PATCH 73/74] Added msb repository --- configs/repositories.toml | 9 ++++ slpkg/check_updates.py | 5 +++ slpkg/install_data.py | 85 ++++++++++++++++++++++++++++++++++++++ slpkg/repo_info.py | 1 + slpkg/repositories.py | 18 ++++++++ slpkg/update_repository.py | 33 +++++++++++++++ 6 files changed, 151 insertions(+) diff --git a/configs/repositories.toml b/configs/repositories.toml index 6447b149..bc75065f 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -66,6 +66,15 @@ GNOME_REPO_CHECKSUMS = "CHECKSUMS.md5" GNOME_REPO_CHANGELOG = "ChangeLog.txt" + # Repository for slackware 15.0 stable. + MSB_REPO_NAME = "msb" + MSB_REPO = false + MSB_REPO_MIRROR = "https://slackware.uk/msb/15.0/1.26/x86_64/" + MSB_REPO_CHANGELOG_MIRROR = 'https://slackware.uk/msb/' + MSB_REPO_PACKAGES = "PACKAGES.TXT" + MSB_REPO_CHECKSUMS = "CHECKSUMS.md5" + MSB_REPO_CHANGELOG = "ChangeLog.txt" + # Repository for slackware -current. CONRAID_REPO_NAME = "conraid" CONRAID_REPO = false diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index abee6914..40200276 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -61,6 +61,11 @@ class CheckUpdates(Configs): self.repo_chg_txt: str = f'{self.repos.gnome_repo_mirror}{self.repos.gnome_repo_changelog}' compare[self.repos.gnome_repo_name] = self.compare_dates() + if self.repos.msb_repo and self.repo == self.repos.msb_repo_name or self.repo == '*': + self.local_chg_txt: Path = Path(self.repos.msb_repo_path, self.repos.msb_repo_changelog) + self.repo_chg_txt: str = f'{self.repos.msb_repo_changelog_mirror}{self.repos.msb_repo_changelog}' + compare[self.repos.msb_repo_name] = self.compare_dates() + if self.repos.conraid_repo and self.repo == self.repos.conraid_repo_name or self.repo == '*': self.local_chg_txt: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_changelog) self.repo_chg_txt: str = f'{self.repos.conraid_repo_mirror}{self.repos.conraid_repo_changelog}' diff --git a/slpkg/install_data.py b/slpkg/install_data.py index ad05d8e2..cd744c9d 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -436,6 +436,91 @@ class InstallData(Configs): self.session.commit() + def install_msb_data(self) -> None: + """ Install the data for msb repository. """ + checksums_dict: dict = {} + pkg_tag = [ + 'PACKAGE NAME:', + 'PACKAGE LOCATION:', + 'PACKAGE SIZE (compressed):', + 'PACKAGE SIZE (uncompressed):', + 'PACKAGE DESCRIPTION:' + ] + path_packages: Path = Path(self.repos.msb_repo_path, self.repos.msb_repo_packages) + path_checksums: Path = Path(self.repos.msb_repo_path, self.repos.msb_repo_checksums) + path_changelog: Path = Path(self.repos.msb_repo_path, self.repos.msb_repo_changelog) + packages_txt: list = self.utils.read_file(path_packages) + checksums_md5: list = self.utils.read_file(path_checksums) + + for line in checksums_md5: + line = line.strip() + + if line.endswith(('.txz', '.tgz')): + file: str = line.split('./')[1].split('/')[-1].strip() + checksum: str = line.split('./')[0].strip() + checksums_dict[file] = checksum + + cache: list = [] # init cache + + print('Creating the database... ', end='', flush=True) + + 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) + cache.append(self.repos.msb_repo_mirror) + try: + cache.append(checksums_dict[package_name]) + except KeyError: + cache.append('error checksum') + + if line.startswith(pkg_tag[1]): + package_location = line.replace(pkg_tag[1], '').strip() + cache.append(package_location[2:]) # Do not install (./) dot + + if line.startswith(pkg_tag[2]): + package_size_comp = line.replace(pkg_tag[2], '').strip() + cache.append(f'{package_size_comp}B') + + if line.startswith(pkg_tag[3]): + package_size_uncomp = line.replace(pkg_tag[3], '').strip() + cache.append(f'{package_size_uncomp}B') + + if line.startswith(pkg_tag[4]): + package_description = line.replace(pkg_tag[4], '').strip() + cache.append(package_description) + + if len(cache) == 9: + data: str = BinariesTable( + repo=self.repos.msb_repo_name, + name=cache[0], + version=cache[1], + package=cache[2], + mirror=cache[3], + checksum=cache[4], + location=cache[5], + size_comp=cache[6], + size_uncomp=cache[7], + description=cache[8], + required='' + ) + + self.session.add(data) + + cache: list = [] # reset cache + + last_updated: str = self.last_updated(path_changelog) + date: str = LastRepoUpdated(repo=self.repos.msb_repo_name, date=last_updated) + self.session.add(date) + + print(f'{self.byellow}Done{self.endc}') + + self.session.commit() + def install_conraid_data(self) -> None: """ Install the data for conraid repository. """ checksums_dict: dict = {} diff --git a/slpkg/repo_info.py b/slpkg/repo_info.py index f5bcba7d..094caa4c 100644 --- a/slpkg/repo_info.py +++ b/slpkg/repo_info.py @@ -65,6 +65,7 @@ class RepoInfo(Configs): self.repos.multilib_repo_name: BinQueries('', repo).count_packages(), self.repos.restricted_repo_name: BinQueries('', repo).count_packages(), self.repos.gnome_repo_name: BinQueries('', repo).count_packages(), + self.repos.msb_repo_name: BinQueries('', repo).count_packages(), self.repos.conraid_repo_name: BinQueries('', repo).count_packages(), self.repos.slackonly_repo_name: BinQueries('', repo).count_packages(), self.repos.ponce_bin_repo_name: BinQueries('', repo).count_packages(), diff --git a/slpkg/repositories.py b/slpkg/repositories.py index a73af3a7..8a8d5dd1 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -76,6 +76,15 @@ class Repositories: gnome_repo_checksums: str = 'CHECKSUMS.md5' gnome_repo_changelog: str = 'ChangeLog.txt' + msb_repo_name: str = 'msb' + msb_repo: bool = False + msb_repo_path: Path = Path(config.lib_path, 'repositories', msb_repo_name) + msb_repo_mirror: str = 'https://slackware.uk/msb/15.0/1.26/x86_64/' + msb_repo_changelog_mirror: str = 'https://slackware.uk/msb/' + msb_repo_packages: str = 'PACKAGES.TXT' + msb_repo_checksums: str = 'CHECKSUMS.md5' + msb_repo_changelog: str = 'ChangeLog.txt' + conraid_repo_name: str = 'conraid' conraid_repo: bool = False conraid_repo_path: Path = Path(config.lib_path, 'repositories', conraid_repo_name) @@ -189,6 +198,14 @@ class Repositories: gnome_repo_checksums: str = repos['GNOME_REPO_CHECKSUMS'] gnome_repo_changelog: str = repos['GNOME_REPO_CHANGELOG'] + msb_repo_name: str = repos['MSB_REPO_NAME'] + msb_repo: bool = repos['MSB_REPO'] + msb_repo_mirror: str = repos['MSB_REPO_MIRROR'] + msb_repo_changelog_mirror: str = repos['MSB_REPO_CHANGELOG_MIRROR'] + msb_repo_packages: str = repos['MSB_REPO_PACKAGES'] + msb_repo_checksums: str = repos['MSB_REPO_CHECKSUMS'] + msb_repo_changelog: str = repos['MSB_REPO_CHANGELOG'] + conraid_repo_name: str = repos['CONRAID_REPO_NAME'] conraid_repo: bool = repos['CONRAID_REPO'] conraid_repo_mirror: str = repos['CONRAID_REPO_MIRROR'] @@ -260,6 +277,7 @@ class Repositories: multilib_repo_name: [multilib_repo, multilib_repo_path, multilib_repo_changelog], restricted_repo_name: [restricted_repo, restricted_repo_path, restricted_repo_changelog], gnome_repo_name: [gnome_repo, gnome_repo_path, gnome_repo_changelog], + msb_repo_name: [msb_repo, msb_repo_path, msb_repo_changelog], conraid_repo_name: [conraid_repo, conraid_repo_path, conraid_repo_changelog], slackonly_repo_name: [slackonly_repo, slackonly_repo_path, slackonly_repo_changelog], ponce_bin_repo_name: [ponce_bin_repo, ponce_bin_repo_path, ponce_bin_repo_changelog], diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index d09d7273..58d4e73a 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -66,6 +66,9 @@ class UpdateRepository(Configs): if self.repo == self.repos.gnome_repo_name or self.repo == '*': self.gnome_repository() + if self.repo == self.repos.msb_repo_name or self.repo == '*': + self.msb_repository() + if self.repo == self.repos.conraid_repo_name or self.repo == '*': self.conraid_repository() @@ -196,6 +199,36 @@ class UpdateRepository(Configs): else: self.not_enabled_message(self.repos.gnome_repo_name) + def msb_repository(self): + if self.repos.msb_repo: + urls: list = [] + print('Updating the packages list...\n') + print(f"Downloading the '{self.green}{self.repos.msb_repo_name}{self.endc}' " + f"repository, please wait...\n") + self.make_dirs(self.repos.msb_repo_name) + + urls.append(f'{self.repos.msb_repo_mirror}{self.repos.msb_repo_packages}') + urls.append(f'{self.repos.msb_repo_changelog_mirror}{self.repos.msb_repo_changelog}') + urls.append(f'{self.repos.msb_repo_mirror}{self.repos.msb_repo_checksums}') + + self.utils.remove_file_if_exists(self.repos.msb_repo_path, + self.repos.msb_repo_packages) + self.utils.remove_file_if_exists(self.repos.msb_repo_path, + self.repos.msb_repo_changelog) + self.utils.remove_file_if_exists(self.repos.msb_repo_path, + self.repos.msb_repo_checksums) + + down = Downloader(self.repos.msb_repo_path, urls, self.flags) + down.download() + print() + + self.delete_binaries_data(self.repos.msb_repo_name) + self.delete_last_updated(self.repos.msb_repo_name) + self.data.install_msb_data() + print() + else: + self.not_enabled_message(self.repos.msb_repo_name) + def conraid_repository(self): if self.repos.conraid_repo: urls: list = [] From a48e35876c4eec3cee4ec7f1faa9085cab1a0c46 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 1 Apr 2023 14:31:10 +0300 Subject: [PATCH 74/74] Improve speed --- slpkg/repo_info.py | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/slpkg/repo_info.py b/slpkg/repo_info.py index 094caa4c..d61fe034 100644 --- a/slpkg/repo_info.py +++ b/slpkg/repo_info.py @@ -46,6 +46,7 @@ class RepoInfo(Configs): count: int = 0 status: str = 'Disabled' color: str = self.red + if value[0]: enabled += 1 status: str = 'Enabled' @@ -58,25 +59,11 @@ class RepoInfo(Configs): if last is None: last: tuple = ('',) - packages: dict = { - self.repos.sbo_repo_name: SBoQueries('').count_packages(), - self.repos.ponce_repo_name: SBoQueries('').count_packages(), - self.repos.alien_repo_name: BinQueries('', repo).count_packages(), - self.repos.multilib_repo_name: BinQueries('', repo).count_packages(), - self.repos.restricted_repo_name: BinQueries('', repo).count_packages(), - self.repos.gnome_repo_name: BinQueries('', repo).count_packages(), - self.repos.msb_repo_name: BinQueries('', repo).count_packages(), - self.repos.conraid_repo_name: BinQueries('', repo).count_packages(), - self.repos.slackonly_repo_name: BinQueries('', repo).count_packages(), - self.repos.ponce_bin_repo_name: BinQueries('', repo).count_packages(), - self.repos.salixos_repo_name: BinQueries('', repo).count_packages(), - self.repos.salixos_extra_repo_name: BinQueries('', repo).count_packages(), - self.repos.slackel_repo_name: BinQueries('', repo).count_packages(), - self.repos.slint_repo_name: BinQueries('', repo).count_packages() - } - if value[0]: - count: int = packages[repo] + if repo in [self.repos.sbo_repo_name, self.repos.ponce_repo_name]: + count = int(SBoQueries('').count_packages()) + else: + count = int(BinQueries('', repo).count_packages()) total_packages += count