Added flag --dependees

This commit is contained in:
Dimitris Zlatanidis 2022-12-21 21:23:54 +02:00
parent c5a9221f53
commit 42fb6bf7c5
6 changed files with 43 additions and 20 deletions

View file

@ -2,6 +2,7 @@
Added:
- Feature to check the ChangeLog.txt file before update #153
- Dependees in the view command
- Flag --dependees
BugFixed:
- View installed version

View file

@ -67,6 +67,7 @@ Usage
--resolve-off Turns off dependency resolving.
--reinstall Upgrade packages of the same version.
--skip-installed Skip installed packages.
--dependees Show which packages depend.
-h, --help Show this message and exit.
-v, --version Print version and exit.

View file

@ -1,10 +1,10 @@
.TH slpkg 1 "Orestiada, Greece" "slpkg 4.3.1" dslackw
.TH slpkg 1 "Orestiada, Greece" "slpkg 4.3.9" dslackw
.SH NAME
.P
slpkg - [OPTIONS] [COMMAND] <packages>
.SH SYNAPSES
.P
slpkg [-h|-v] [update] [upgrade] [check-updates] [clean-logs] [clean-tmp] [-b, build] [-i, install] [-d, download] [-r, remove] [-f, find] [-w, view] [-s, search] --yes --jobs --resolve-off --reinstall --skip-installed
slpkg [-h|-v] [update] [upgrade] [check-updates] [clean-logs] [clean-tmp] [-b, build] [-i, install] [-d, download] [-r, remove] [-f, find] [-w, view] [-s, search] --yes --jobs --resolve-off --reinstall --skip-installed, --dependees
.SH DESCRIPTION
.P
Slpkg is a software package manager that installs, updates, and removes packages on Slackware based systems. It automatically computes dependencies and figures out what things should occur to install packages. Slpkg makes it easier to maintain groups of machines without having to manually update.
@ -98,10 +98,16 @@ Use this option if you want to upgrade all packages even if the same version is
This a helpful option if you want to avoid building and reinstalling packages.
Note: This option affects only the dependencies.
.RE
.RE
.P
--dependees
.RS
This flag works only with the -w, view command to show which packages depend.
.RE
.P
-h | --help
.RS
Show help informatio and exit.
Show help information and exit.
.RE
.P
-v | --version

View file

@ -39,7 +39,13 @@ class Argparse:
'--jobs',
'--resolve-off',
'--reinstall',
'--skip-installed']
'--skip-installed',
'--dependees']
for opt in self.args:
if opt.startswith('--'):
if opt not in self.options:
raise SystemExit(f"\nError: flag '{opt}' does not exist.\n")
for option in self.options:
if option in self.args:
@ -127,7 +133,6 @@ class Argparse:
self.check.exists(packages)
download = Download(self.flags)
download.packages(packages)
raise SystemExit()
self.usage.help(1)
@ -147,13 +152,13 @@ class Argparse:
self.usage.help(1)
def view(self):
if len(self.args) >= 2 and not self.flags:
if len(self.args) >= 2:
packages = list(set(self.args[1:]))
self.check.database()
self.check.exists(packages)
view = ViewPackage()
view = ViewPackage(self.flags)
view.package(packages)
raise SystemExit()
self.usage.help(1)

View file

@ -21,7 +21,7 @@ class Usage:
""" Prints the short menu. """
args = (
f'Usage: {Configs.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] <packages>\n'
f'\n slpkg [{self.yellow}OPTIONS{self.endc}] [--yes, --jobs, --resolve-off, --reinstall, --skip-installed]\n'
f'\n slpkg [{self.yellow}OPTIONS{self.endc}] [--yes, --jobs, --resolve-off, --reinstall, --skip-installed, --dependees]\n'
f' slpkg [{self.cyan}COMMAND{self.endc}] [update, upgrade, check-updates, clean-logs, clean-tmp]\n'
f' slpkg [{self.cyan}COMMAND{self.endc}] [-b, build, -i, install, -d, download] <packages>\n'
f' slpkg [{self.cyan}COMMAND{self.endc}] [-r, remove, -f, find, -w, view, -s, search] <packages>\n'
@ -54,7 +54,8 @@ class Usage:
f' {self.yellow}--jobs{self.endc} Set it for multicore systems.',
f' {self.yellow}--resolve-off{self.endc} Turns off dependency resolving.',
f' {self.yellow}--reinstall{self.endc} Upgrade packages of the same version.',
f' {self.yellow}--skip-installed{self.endc} Skip installed packages.\n',
f' {self.yellow}--skip-installed{self.endc} Skip installed packages.',
f' {self.yellow}--dependees{self.endc} Show which packages depend.\n',
' -h, --help Show this message and exit.',
' -v, --version Print version and exit.\n',
'Edit the configuration file in the /etc/slpkg/slpkg.toml.',

View file

@ -14,7 +14,8 @@ from slpkg.models.models import session as Session
class ViewPackage:
""" View the repository packages. """
def __init__(self):
def __init__(self, flags):
self.flags = flags
self.session = Session
self.configs = Configs
self.colors = self.configs.colour
@ -29,8 +30,10 @@ class ViewPackage:
red = color['red']
endc = color['endc']
print(end='\rCollecting the data... ')
for package in packages:
dependees = " ".join(list(self.dependees(package)))
info = self.session.query(
SBoTable.name,
SBoTable.version,
@ -59,10 +62,10 @@ class ViewPackage:
deps = (', '.join([f'{pkg} ({SBoQueries(pkg).version()})' for pkg in info[2].split()]))
print(f'\n\nName: {green}{info[0]}{endc}\n'
print(f'Name: {green}{info[0]}{endc}\n'
f'Version: {green}{info[1]}{endc}\n'
f'Requires: {green}{deps}{endc}\n'
f'Dependees: {green}{" ".join(list(self.dependees(package)))}{endc}\n'
f'Dependees: {green}{dependees}{endc}\n'
f'Homepage: {blue}{homepage}{endc}\n'
f'Download SlackBuild: {blue}{self.configs.sbo_repo_url}/{info[9]}/{info[0]}'
f'{self.configs.sbo_tar_suffix}{endc}\n'
@ -79,14 +82,20 @@ class ViewPackage:
f'Email: {yellow}{email}{endc}\n'
f'\nREADME: {cyan}{readme.data.decode()}{endc}')
@staticmethod
def dependees(name):
def dependees(self, name):
""" Collecting the dependees. """
sbos = SBoQueries(name).names()
for sbo in sbos:
requires = SBoQueries(sbo).requires()
if name in requires:
yield sbo
if '--dependees' in self.flags:
print(end='\rCollecting the data... ')
sbos = SBoQueries(name).names()
for sbo in sbos:
requires = SBoQueries(sbo).requires()
if name in requires:
version = SBoQueries(sbo).version()
yield f'{sbo} ({version})'
else:
return ''
print('\n')
@staticmethod
def http_request(link):