Updated for bin repo

This commit is contained in:
Dimitris Zlatanidis 2023-03-27 22:01:53 +03:00
parent 1fd81dc78b
commit c2c3a61843
11 changed files with 64 additions and 68 deletions

View file

@ -11,7 +11,7 @@ slpkg [-h|-v] [-u, update] [-U, upgrade] [-c, check-updates] [-g, configs] [-L,
[-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, --binary, -O, --bin-repo=[\fIPATH\fR], -z, --directory=[\fIPATH\fR]
-G, --generate-only, -P, --parallel, -B, --bin-repo=[\fIPATH\fR], -z, --directory=[\fIPATH\fR]
.SH DESCRIPTION
.P
Slpkg is a software package manager that installs, updates, and removes packages on Slackware based systems.
@ -173,16 +173,10 @@ Download files in parallel to speed up the process.
(to be used with: -u, update, -U, upgrade, -b, build, -i, install, -d, download)
.RE
.P
.B -B, --binary
.BI "-B," "" " \-\-bin-repo=[" REPO "]
.RS
Switch to binaries repositories.
(to be used with: -u, update, -U, upgrade, -i, install, -d, download, -s, search)
.RE
.P
.BI "-O," "" " \-\-bin-repo=[" REPO "]
.RS
Select a binary repository. Used only combine with '-B, --binary' option.
Example: slpkg -iB xbill --bin=repo='conraid'.
Switch to binaries repositories and select a repository.
Example: slpkg -i xbill --bin=repo='conraid'.
(to be used with: -u, update, -U, upgrade, -i, install, -d, download, -s, search)
.RE
.P

View file

@ -19,12 +19,12 @@ class BinQueries(Configs):
self.repos = Repositories()
self.bin_repo: list = []
self.bin_repo: list = self.repos.enabled_repositories
self.bin_repo: list = self.repos.bin_enabled_repositories
if self.repo == '*':
self.bin_repo: list = self.repos.enabled_repositories
self.bin_repo: list = self.repos.bin_enabled_repositories
elif self.repo and self.repo in self.repos.enabled_repositories:
elif self.repo and self.repo in self.repos.bin_enabled_repositories:
self.bin_repo: list = [self.repo]
self.black = Blacklist()
@ -52,12 +52,24 @@ class BinQueries(Configs):
repository: tuple = self.session.query(
BinariesTable.repo).filter(
BinariesTable.name == self.name).where(
BinariesTable.repo.in_(self.bin_repo)) .first()
BinariesTable.repo.in_(self.bin_repo)).first()
if repository:
return repository[0]
return ''
def package_name_repo(self) -> tuple:
""" Returns the package name with the repo. """
pkgs: tuple = self.session.query(
BinariesTable.name, BinariesTable.repo).filter(
BinariesTable.name == self.name).where(
BinariesTable.repo.in_(self.bin_repo)).all()
if pkgs:
return pkgs
return ()
def package_name(self) -> str:
""" Returns the package name. """
pkg: tuple = self.session.query(

View file

@ -26,9 +26,9 @@ class Check(Configs):
self.repos = Repositories()
self.session = Session
self.flag_binary: list = ['-B', '--binary']
self.flag_bin_repository: list = ['-B=', '--bin-repo=']
if self.utils.is_option(self.flag_binary, self.flags):
if self.utils.is_option(self.flag_bin_repository, self.flags):
self.repo_table = BinariesTable
else:
self.repo_table = SBoTable
@ -41,7 +41,7 @@ class Check(Configs):
for pkg in packages:
if self.utils.is_option(self.flag_binary, self.flags):
if self.utils.is_option(self.flag_bin_repository, self.flags):
if not BinQueries(pkg, repo).package_name():
not_packages.append(pkg)

View file

@ -28,7 +28,7 @@ class Download(Configs):
self.session = Session
self.flag_directory: list = ['-z=', '--directory=']
self.flag_binary: list = ['-B', '--binary']
self.flag_bin_repository: list = ['-B=', '--bin-repo=']
def packages(self, packages: list, repo=None) -> None:
""" Download the package only. """
@ -43,7 +43,7 @@ class Download(Configs):
start: float = time.time()
for pkg in packages:
if self.utils.is_option(self.flag_binary, self.flags):
if self.utils.is_option(self.flag_bin_repository, self.flags):
mirror: str = BinQueries(pkg, repo).mirror()
location: str = BinQueries(pkg, repo).location()
package: str = BinQueries(pkg, repo).package_bin()

View file

@ -77,10 +77,8 @@ class Argparse(Configs):
self.flag_short_generate: str = '-G'
self.flag_parallel: str = '--parallel'
self.flag_short_parallel: str = '-P'
self.flag_binary: str = '--binary'
self.flag_short_binary: str = '-B'
self.flag_bin_repository: str = '--bin-repo='
self.flag_short_bin_repository: str = '-O='
self.flag_short_bin_repository: str = '-B='
self.flag_directory: str = '--directory='
self.flag_short_directory: str = '-z='
@ -109,8 +107,6 @@ class Argparse(Configs):
self.flag_short_generate,
self.flag_parallel,
self.flag_short_parallel,
self.flag_binary,
self.flag_short_binary,
self.flag_bin_repository,
self.flag_short_bin_repository,
self.flag_directory,
@ -126,8 +122,6 @@ class Argparse(Configs):
self.flag_short_yes,
self.flag_generate,
self.flag_short_generate,
self.flag_binary,
self.flag_short_binary,
self.flag_bin_repository,
self.flag_short_bin_repository,
self.flag_parallel,
@ -144,16 +138,12 @@ class Argparse(Configs):
self.flag_short_reinstall,
self.flag_no_silent,
self.flag_short_no_silent,
self.flag_binary,
self.flag_short_binary,
self.flag_bin_repository,
self.flag_short_bin_repository,
self.flag_parallel,
self.flag_short_parallel
],
'check-updates': [
self.flag_binary,
self.flag_short_binary,
self.flag_bin_repository,
self.flag_short_bin_repository
],
@ -196,8 +186,6 @@ class Argparse(Configs):
self.flag_short_search,
self.flag_no_silent,
self.flag_short_no_silent,
self.flag_binary,
self.flag_short_binary,
self.flag_bin_repository,
self.flag_short_bin_repository,
self.flag_parallel,
@ -212,8 +200,6 @@ class Argparse(Configs):
self.flag_short_no_silent,
self.flag_directory,
self.flag_short_directory,
self.flag_binary,
self.flag_short_binary,
self.flag_bin_repository,
self.flag_short_bin_repository,
self.flag_parallel,
@ -240,8 +226,6 @@ class Argparse(Configs):
'search': [
self.flag_search,
self.flag_short_search,
self.flag_binary,
self.flag_short_binary,
self.flag_bin_repository,
self.flag_short_bin_repository
],
@ -292,7 +276,7 @@ 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_bin_repository, self.flag_short_bin_repository], self.flags)
and not self.utils.is_option([self.flag_binary, self.flag_short_binary], self.flags)):
and not self.utils.is_option([self.flag_bin_repository, self.flag_short_bin_repository], self.flags)):
self.usage.help_minimal(f"{self.prog_name}: invalid options '{', '.join(self.flags)}'")
if (self.binary_repo and self.binary_repo not in self.repos.binaries_repositories_dict.keys()
@ -409,7 +393,7 @@ class Argparse(Configs):
title: str = f' Choose packages you want to {method} '
repo_packages: list = SBoQueries('').sbos()
if self.utils.is_option([self.flag_binary, self.flag_short_binary], self.flags):
if self.utils.is_option([self.flag_bin_repository, self.flag_short_bin_repository], self.flags):
repo_packages: list = BinQueries('', self.binary_repo).all_name_packages()
installed: list = self.utils.installed_packages
@ -433,7 +417,7 @@ class Argparse(Configs):
inst_pkg: str = self.utils.is_package_installed(package)
split_inst_pkg: list = self.utils.split_binary_pkg(inst_pkg)
if self.utils.is_option([self.flag_binary, self.flag_short_binary], self.flags):
if self.utils.is_option([self.flag_bin_repository, self.flag_short_bin_repository], self.flags):
repo_ver: str = BinQueries(package, self.binary_repo).version()
bin_pkg: str = BinQueries(package, self.binary_repo).package_bin()
repo_build_tag: str = self.utils.split_binary_pkg(bin_pkg[:-4])[3]
@ -446,16 +430,21 @@ class Argparse(Configs):
f'Available: {repo_ver} Build: {repo_build_tag}')]
else:
for pkg in packages:
for package in repo_packages:
if self.utils.is_option([self.flag_bin_repository, self.flag_short_bin_repository], self.flags):
for pkg in packages:
pkg_repo = BinQueries(pkg, self.binary_repo).package_name_repo()
if pkg in package:
for pr in pkg_repo:
repo_ver: str = BinQueries(pr[0], pr[1]).version()
choices += [(pkg, repo_ver, False, f'Package: {pkg}-{repo_ver} > {pr[1]}')]
repo_ver: str = SBoQueries(package).version()
if self.utils.is_option([self.flag_binary, self.flag_short_binary], self.flags):
repo_ver: str = BinQueries(package, self.binary_repo).version()
choices += [(package, repo_ver, False, f'Package: {package}-{repo_ver}')]
else:
for pkg in packages:
for package in repo_packages:
if pkg in package:
repo_ver: str = SBoQueries(package).version()
choices += [(package, repo_ver, False, f'Package: {package}-{repo_ver} '
f'> {self.repos.sbo_enabled_repository}')]
if not choices:
return packages
@ -508,7 +497,7 @@ class Argparse(Configs):
print('\nEverything is up-to-date.\n')
raise SystemExit()
if self.utils.is_option([self.flag_binary, self.flag_short_binary], self.flags):
if self.utils.is_option([self.flag_bin_repository, self.flag_short_bin_repository], self.flags):
install = Packages(packages, self.flags, self.binary_repo, mode=command)
install.execute()
else:
@ -593,7 +582,7 @@ class Argparse(Configs):
if self.utils.is_option(self.flag_searches, self.flags):
packages: list = self.choose_packages(packages, command)
if self.utils.is_option([self.flag_binary, self.flag_short_binary], self.flags):
if self.utils.is_option([self.flag_bin_repository, self.flag_short_bin_repository], self.flags):
self.check.exists_in_the_database(packages, self.binary_repo)
install = Packages(packages, self.flags, self.binary_repo, mode=command)
@ -784,10 +773,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__':

View file

@ -22,7 +22,7 @@ class Repositories:
repos = {}
binaries_repositories_dict = {}
enabled_repositories = []
bin_enabled_repositories = []
sbo_repo_name: str = 'sbo'
sbo_repo_path: Path = Path(config.lib_path, 'repositories', sbo_repo_name)
@ -105,7 +105,9 @@ class Repositories:
for repo, enable in binaries_repositories_dict.items():
if enable:
enabled_repositories.append(repo)
bin_enabled_repositories.append(repo)
sbo_enabled_repository: str = sbo_repo_name
if ponce_repo:
sbo_enabled_repository: str = ponce_repo_name
repo_tag: str = ponce_repo_tag

View file

@ -23,14 +23,14 @@ class SearchPackage(Configs):
self.grey: str = self.color['grey']
self.endc: str = self.color['endc']
self.flag_binary: list = ['-B', '--binary']
self.flag_bin_repository: list = ['-B=', '--bin-repo=']
def package(self, packages: list, repo=None) -> None:
""" Searching and print the matched slackbuilds. """
matching: int = 0
names: list = SBoQueries('').sbos()
if self.utils.is_option(self.flag_binary, self.flags):
if self.utils.is_option(self.flag_bin_repository, self.flags):
names: list = BinQueries('', repo).all_name_packages()
print(f'The list below shows the repo '
@ -45,7 +45,7 @@ class SearchPackage(Configs):
desc: str = SBoQueries(name).description().replace(name, '')
version: str = SBoQueries(name).version()
if self.utils.is_option(self.flag_binary, self.flags):
if self.utils.is_option(self.flag_bin_repository, self.flags):
desc: str = BinQueries(name, repo).description()
version: str = BinQueries(name, repo).version()

View file

@ -43,7 +43,7 @@ class UpdateRepository(Configs):
self.bred: str = f'{self.bold}{self.red}'
self.endc: str = self.color['endc']
self.flag_generate: list = ['-G', '--generate-only']
self.flag_binary: list = ['-B', '--binary']
self.flag_bin_repository: list = ['-B=', '--bin-repo=']
def update_the_repositories(self) -> None:
""" Updated the sbo repository. """
@ -52,7 +52,7 @@ class UpdateRepository(Configs):
else:
print()
if self.utils.is_option(self.flag_binary, self.flags):
if self.utils.is_option(self.flag_bin_repository, self.flags):
self.binary_repositories()
else:
self.slackbuild_repositories()

View file

@ -19,14 +19,14 @@ class Upgrade(Configs):
self.repo = repo
self.utils = Utilities()
self.flag_binary: list = ['-B', '--binary']
self.flag_bin_repository: list = ['-B=', '--bin-repo=']
def packages(self) -> Generator[str, None, None]:
""" Compares version of packages and returns the maximum. """
upgrade, requires = [], []
repo_packages: list = SBoQueries('').sbos()
if self.utils.is_option(self.flag_binary, self.flags):
if self.utils.is_option(self.flag_bin_repository, self.flags):
repo_packages: list = BinQueries('', self.repo).all_name_packages()
installed: list = self.utils.installed_packages
@ -38,7 +38,7 @@ class Upgrade(Configs):
if self.utils.is_package_upgradeable(inst_pkg_name):
if not self.utils.is_option(self.flag_binary, self.flags):
if not self.utils.is_option(self.flag_bin_repository, self.flags):
requires += Requires(inst_pkg_name).resolve()
upgrade.append(inst_pkg_name)

View file

@ -41,7 +41,7 @@ class Usage(Configs):
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-y, --yes, -j, --jobs, -o, --resolve-off, -r, --reinstall]\n'
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-k, --skip-installed, -E, --full-reverse, -S, --search]\n'
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-n, --no-silent, -p, --pkg-version, -G, --generate-only]\n'
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-P, --parallel, -B, --binary, -O, --bin-repo=[REPO]]\n'
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-P, --parallel, -B, --bin-repo=[REPO]]\n'
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-z, --directory=[PATH]]\n'
" \nIf you need more information please try 'slpkg --help'.")
@ -83,8 +83,7 @@ class Usage(Configs):
f' {self.yellow}-p, --pkg-version{self.endc} Print the repository package version.\n'
f' {self.yellow}-G, --generate-only{self.endc} Generates only the SLACKBUILDS.TXT file.\n'
f' {self.yellow}-P, --parallel{self.endc} Download files in parallel.\n'
f' {self.yellow}-B, --binary{self.endc} Switch with binaries repositories.\n'
f' {self.yellow}-O, --bin-repo={self.endc}[REPO] Set the binary repository.\n'
f' {self.yellow}-B, --bin-repo={self.endc}[REPO] Set a binary repository.\n'
f' {self.yellow}-z, --directory={self.endc}[PATH] Download files to a specific path.\n'
'\n -h, --help Show this message and exit.\n'
' -v, --version Print version and exit.\n'

View file

@ -41,14 +41,14 @@ class ViewMessage(Configs):
self.flag_resolve_off: list = ['-o', '--resolve-off']
self.flag_reinstall: list = ['-r', '--reinstall']
self.flag_yes: list = ['-y', '--yes']
self.flag_binary: list = ['-B', '--binary']
self.flag_bin_repository: list = ['-B=', '--bin-repo=']
def view_packages(self, package: str, mode: str, repo=None) -> None:
""" Printing the main packages. """
size: str = ''
color: str = self.red
if self.utils.is_option(self.flag_binary, self.flags):
if self.utils.is_option(self.flag_bin_repository, self.flags):
version: str = BinQueries(package, repo).version()
size: str = BinQueries(package, repo).size_comp()
if repo is None: