mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-11-17 07:48:18 +01:00
Added repo-info command
This commit is contained in:
parent
7d93744e08
commit
8fb21fb425
6 changed files with 113 additions and 3 deletions
|
@ -6,6 +6,7 @@ Removed:
|
|||
- File pattern from cli menu
|
||||
Added:
|
||||
- Binaries support repositories
|
||||
- Repositories inforamtion
|
||||
|
||||
4.6.1 - 15/03/2023
|
||||
Updated:
|
||||
|
|
|
@ -7,7 +7,7 @@ slpkg \- Package manager utility for Slackware.
|
|||
slpkg \c
|
||||
[\fICOMMAND\fR] [\fIOPTIONS\fR] [\fIFILELIST|PACKAGES...\fR]
|
||||
.P
|
||||
slpkg [-h|-v] [-u, update] [-U, upgrade] [-c, check-updates] [-g, configs] [-L, clean-logs]
|
||||
slpkg [-h|-v] [-u, update] [-U, upgrade] [-c, check-updates] [-I, repo-info] [-g, configs] [-L, clean-logs]
|
||||
[-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,
|
||||
|
@ -37,6 +37,11 @@ Upgrade all the installed packages if the newer version exists in the repository
|
|||
Check if there is any news on the SlackBuild's ChangeLog.txt file.
|
||||
.RE
|
||||
.P
|
||||
.B -I, repo-info
|
||||
.RS
|
||||
Prints the repositories information.
|
||||
.RE
|
||||
.P
|
||||
.B -L, clean-logs
|
||||
.RS
|
||||
Cleans dependencies log tracking. After that procedure you should remove dependencies by hand.
|
||||
|
|
|
@ -9,6 +9,7 @@ from slpkg.checks import Check
|
|||
from slpkg.upgrade import Upgrade
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.tracking import Tracking
|
||||
from slpkg.repo_info import RepoInfo
|
||||
from slpkg.dependees import Dependees
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.search import SearchPackage
|
||||
|
@ -148,6 +149,7 @@ class Argparse(Configs):
|
|||
self.flag_bin_repository,
|
||||
self.flag_short_bin_repository
|
||||
],
|
||||
'repo-info': [],
|
||||
'configs': [],
|
||||
'clean-logs': [
|
||||
self.flag_yes,
|
||||
|
@ -255,6 +257,7 @@ class Argparse(Configs):
|
|||
self.commands['-u'] = self.commands['update']
|
||||
self.commands['-U'] = self.commands['upgrade']
|
||||
self.commands['-c'] = self.commands['check-updates']
|
||||
self.commands['-I'] = self.commands['repo-info']
|
||||
self.commands['-g'] = self.commands['configs']
|
||||
self.commands['-L'] = self.commands['clean-logs']
|
||||
self.commands['-D'] = self.commands['clean-tmp']
|
||||
|
@ -525,6 +528,13 @@ class Argparse(Configs):
|
|||
raise SystemExit()
|
||||
self.usage.help_short(1)
|
||||
|
||||
def repo_info(self) -> None:
|
||||
if len(self.args) == 1:
|
||||
repo = RepoInfo()
|
||||
repo.info()
|
||||
raise SystemExit()
|
||||
self.usage.help_short(1)
|
||||
|
||||
def edit_configs(self) -> None:
|
||||
if len(self.args) == 1:
|
||||
self.form_configs.edit()
|
||||
|
@ -757,6 +767,8 @@ def main():
|
|||
'-U': argparse.upgrade,
|
||||
'check-updates': argparse.check_updates,
|
||||
'-c': argparse.check_updates,
|
||||
'repo-info': argparse.repo_info,
|
||||
'-I': argparse.repo_info,
|
||||
'configs': argparse.edit_configs,
|
||||
'-g': argparse.edit_configs,
|
||||
'clean-logs': argparse.clean_logs,
|
||||
|
|
79
slpkg/repo_info.py
Normal file
79
slpkg/repo_info.py
Normal file
|
@ -0,0 +1,79 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- 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
|
||||
|
||||
|
||||
class RepoInfo(Configs):
|
||||
|
||||
def __init__(self):
|
||||
super(Configs, self).__init__()
|
||||
|
||||
self.utils = Utilities()
|
||||
self.repos = Repositories()
|
||||
self.color = self.colour()
|
||||
self.columns, self.rows = shutil.get_terminal_size()
|
||||
|
||||
self.bold: str = self.color['bold']
|
||||
self.green: str = self.color['green']
|
||||
self.red: str = self.color['red']
|
||||
self.cyan: str = self.color['cyan']
|
||||
self.grey: str = self.color['grey']
|
||||
self.yellow: str = self.color['yellow']
|
||||
self.byellow: str = f'{self.bold}{self.yellow}'
|
||||
self.endc: str = self.color['endc']
|
||||
|
||||
def info(self):
|
||||
""" Prints information about repositories. """
|
||||
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'
|
||||
color: str = self.red
|
||||
if value[0]:
|
||||
enabled += 1
|
||||
status: str = 'Enabled'
|
||||
color: str = self.green
|
||||
|
||||
last: str = self.last_update(Path(value[1], value[2]))
|
||||
|
||||
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())
|
||||
}
|
||||
|
||||
if value[0]:
|
||||
count: int = packages[repo]
|
||||
|
||||
total_packages += count
|
||||
|
||||
print(f"{self.cyan}{repo:<18}{self.endc}{color}{status:<15}{self.endc}{last:<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', '')
|
|
@ -23,6 +23,7 @@ class Repositories:
|
|||
repos = {}
|
||||
binaries_repositories_dict = {}
|
||||
bin_enabled_repositories = []
|
||||
sbo_enabled: bool = True
|
||||
|
||||
sbo_repo_name: str = 'sbo'
|
||||
sbo_repo_path: Path = Path(config.lib_path, 'repositories', sbo_repo_name)
|
||||
|
@ -147,7 +148,18 @@ class Repositories:
|
|||
if enable:
|
||||
bin_enabled_repositories.append(repo)
|
||||
|
||||
# The enabled slackbuild repository.
|
||||
if ponce_repo:
|
||||
sbo_enabled_repository: str = ponce_repo_name
|
||||
repo_tag: str = ponce_repo_tag
|
||||
sbo_enabled: bool = False
|
||||
|
||||
# List of repositories.
|
||||
repos_dict = {
|
||||
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],
|
||||
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]
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class Usage(Configs):
|
|||
args = (
|
||||
f'Usage: {self.prog_name} [{self.cyan}COMMAND{self.endc}] [{self.yellow}OPTIONS{self.endc}] '
|
||||
f'[FILELIST|PACKAGES...]\n'
|
||||
f'\n slpkg [{self.cyan}COMMAND{self.endc}] [-u, update, -U, upgrade, -c, check-updates]\n'
|
||||
f'\n slpkg [{self.cyan}COMMAND{self.endc}] [-u, update, -U, upgrade, -c, check-updates, -I, repo-info]\n'
|
||||
f' slpkg [{self.cyan}COMMAND{self.endc}] [-L, clean-logs, -T, clean-data, -D, clean-tmp, -g, configs]\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 [packages...]]\n'
|
||||
|
@ -58,6 +58,7 @@ class Usage(Configs):
|
|||
f' {self.red}-u, update{self.endc} Update the package lists.\n'
|
||||
f' {self.cyan}-U, upgrade{self.endc} Upgrade all the packages.\n'
|
||||
f' {self.cyan}-c, check-updates{self.endc} Check for news on ChangeLog.txt.\n'
|
||||
f' {self.cyan}-I, repo-info{self.endc} Prints the repositories information.\n'
|
||||
f' {self.cyan}-g, configs{self.endc} Edit the configuration file.\n'
|
||||
f' {self.cyan}-L, clean-logs{self.endc} Clean dependencies log tracking.\n'
|
||||
f' {self.cyan}-T, clean-data{self.endc} Clean all the repositories data.\n'
|
||||
|
|
Loading…
Reference in a new issue