Added search package

This commit is contained in:
Dimitris Zlatanidis 2022-06-19 21:38:52 +03:00
parent 4612c98590
commit e3eb28bc13
4 changed files with 81 additions and 10 deletions

View file

@ -4,7 +4,7 @@
slpkg - [OPTIONS] [packages]
.SH SYNAPSES
.P
slpkg [-h | -v] [update] [build] [install] [remove] [clean-logs] --yes --resolve-off --reinstall
slpkg [-h|-v] [update] [build] [install] [remove] [search] [clean-logs] --yes --resolve-off --reinstall
.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.
@ -24,17 +24,17 @@ Print version and exit.
.P
update
.RS
Updates the data packages and the database.
Updates the package list and the database.
.RE
.P
build
.RS
Builds and creates only the scripts and puts them in the /tmp directory.
Builds the scripts and puts them in the /tmp directory.
.RE
.P
install
.RS
Builds, creates and installs the packages in the correct order and also logs the packages with dependencies to use for removal.
Builds and installs the packages in the correct order and also logs the packages with dependencies to use for removal.
.RE
.P
remove
@ -42,6 +42,11 @@ remove
Removes packages with dependencies if the packages was installed with slpkg install method.
.RE
.P
search
.RS
Search packages by name and view everything in your terminal.
.RE
.P
clean-logs
.RS
Purge logs of dependencies.
@ -61,9 +66,11 @@ Turns off dependency resolving.
.RS
Use this option if you want to upgrade all packages even if the same version is already installed. Do not skip installed packages.
.RE
.SH CONFIGURATION FILE
.SH CONFIGURATIONS FILE
.P
Configuration file in the /etc/slpkg/slpkg.json file.
.RE
Blacklist file in the /etc/slpkg/blacklist.json file.
.SH REPORT BUGS
.P
Please report any found to https://gitlab.com/dslackw/slpkg/-/issues.

View file

@ -12,10 +12,11 @@ def usage(status: int):
' build Build only the packages.',
' install Build and install the packages.',
' remove Remove installed packages.',
' clean-logs Purge logs of dependencies.',
' search Search packages by name.',
' clean-logs Purge logs of dependencies.\n',
' --yes Answer Yes to all questions.',
' --resolve-off Turns off dependency resolving.',
' --reinstall Use this option if you want to upgrade.',
' --reinstall Use this option if you want to upgrade.\n',
' -h, --help Show this message and exit.',
' -v, --version Print version and exit.\n',
'If you need more information try to use slpkg manpage.']

View file

@ -5,13 +5,14 @@
import sys
from dataclasses import dataclass
from slpkg.checks import Check
from slpkg.search import Search
from slpkg.version import Version
from slpkg.cli_menu import usage
from slpkg.slackbuild import Slackbuilds
from slpkg.remove_packages import RemovePackages
from slpkg.update_repository import UpdateRepository
from slpkg.clean_logs import CleanLogsDependencies
from slpkg.checks import Check
from slpkg.version import Version
from slpkg.update_repository import UpdateRepository
@dataclass
@ -100,6 +101,18 @@ class Argparse:
remove.remove()
raise SystemExit()
# Search package
if self.args[0] == 'search':
packages = list(set(self.args[1:]))
packages = check.blacklist(packages)
check.exists(packages)
search = Search()
search.package(packages)
raise SystemExit()
usage(1)

50
slpkg/search.py Normal file
View file

@ -0,0 +1,50 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from dataclasses import dataclass
from slpkg.configs import Configs
from slpkg.models.models import SBoTable
from slpkg.models.models import session as Session
@dataclass
class Search:
session: str = Session
colors: list = Configs.colour
sbo_url: str = Configs.sbo_url
def package(self, packages):
color = self.colors()
GREEN = color['GREEN']
BLUE = color['BLUE']
YELLOW = color['YELLOW']
ENDC = color['ENDC']
for package in packages:
info = self.session.query(
SBoTable.name,
SBoTable.version,
SBoTable.requires,
SBoTable.download,
SBoTable.download64,
SBoTable.md5sum,
SBoTable.md5sum64,
SBoTable.files,
SBoTable.short_description,
SBoTable.location
).filter(
SBoTable.name == package).first()
print(f'Name: {GREEN}{info[0]}{ENDC}\n'
f'Version: {GREEN}{info[1]}{ENDC}\n'
f'Requires: {GREEN}{info[2]}{ENDC}\n'
f'Download: {BLUE}{info[3]}{ENDC}\n'
f'Download_x86_64: {BLUE}{info[4]}{ENDC}\n'
f'Md5sum: {YELLOW}{info[5]}{ENDC}\n'
f'Md5sum_x86_64: {YELLOW}{info[6]}{ENDC}\n'
f'Files: {GREEN}{info[7]}{ENDC}\n'
f'Description: {GREEN}{info[8]}{ENDC}\n'
f'SBo url: {BLUE}{self.sbo_url}/{info[9]}/'
f'{info[0]}{ENDC}\n')