diff --git a/ChangeLog.txt b/ChangeLog.txt index 7565c939..a0edf413 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,11 @@ +4.2.2 - 20/10/2022 +Updated: +- Removed version for skip installed option +- Removed unused configurations +- Search command to view +Added: +- A new search command to search and match packages from the repository + 4.2.1 - 18/10/2022 Added: - Print the README file in the search option diff --git a/README.rst b/README.rst index 41c1a295..82f0a21c 100644 --- a/README.rst +++ b/README.rst @@ -30,8 +30,8 @@ Install from the official third-party `SBo repository Download only the packages. remove Remove installed packages. find Find installed packages. - search Search packages on repository. + view View packages from the repository. + search Search packages from the repository. clean-logs Clean dependencies log tracking. clean-tmp Deletes all the downloaded sources. diff --git a/configs/slpkg.yml b/configs/slpkg.yml index 889b3fc4..163cf606 100644 --- a/configs/slpkg.yml +++ b/configs/slpkg.yml @@ -2,33 +2,48 @@ configs: # OS architecture by default. os_arch: x86_64 - # All necessary paths. - tmp_path: /tmp + # Tmp path for slpkg. tmp_slpkg: /tmp/slpkg - build_path: /tmp/slpkg/build - download_only: /tmp/slpkg - lib_path: /var/lib/slpkg - etc_path: /etc/slpkg - db_path: /var/lib/slpkg/database - sbo_repo_path: /var/lib/slpkg/repository - log_packages: /var/log/packages - # Database name. + # Path for building source and the script + build_path: /tmp/slpkg/build + + # This path working only with the command download. + download_only: /tmp/slpkg + + # The path that the SLACKBUILDS.TXT file downloaded. + sbo_repo_path: /var/lib/slpkg/repository + + # The name of the database. Default name is 'database.slpkg'. database: database.slpkg - # SBo repository configs. + # Slackbuilds.org repository url. sbo_repo_url: http://slackbuilds.org/slackbuilds/15.0 + + # The sbo repository main file. sbo_txt: SLACKBUILDS.TXT + + # The sbo tar suffix. sbo_tar_suffix: .tar.gz + + # The sbo repo tag. sbo_repo_tag: _SBo - # Slackware commands. + # Slackware install command. Alternative you can + # use 'installpkg', if you want. installpkg: upgradepkg --install-new + + # Upgrade or reinstall slackware command. reinstall: upgradepkg --reinstall + + # Slackware command fro remove packages. removepkg: removepkg - # Cli menu colors configs. + # Cli menu colors configs. Default is on. [on/off] colors: on - # Wget options. + # Wget downloader options. + # -c, --continue: resume getting a partially-downloaded file. + # -N, --timestamping: don't re-retrieve files unless newer + # than local. wget_options: -c -N diff --git a/man/slpkg.1 b/man/slpkg.1 index f9b0cc8d..74932573 100644 --- a/man/slpkg.1 +++ b/man/slpkg.1 @@ -4,7 +4,7 @@ slpkg - [OPTIONS] [COMMAND] .SH SYNAPSES .P -slpkg [-h|-v] [update] [upgrade] [build] [install] [download] [remove] [find] [search] [clean-logs] [clean-tmp] --yes --jobs --resolve-off --reinstall --skip-installed +slpkg [-h|-v] [update] [upgrade] [build] [install] [download] [remove] [find] [view] [search] [clean-logs] [clean-tmp] --yes --jobs --resolve-off --reinstall --skip-installed .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. @@ -47,9 +47,14 @@ find Find sbo installed packages on your distribution. .RE .P +view +.RS +View packages from the repository and get everything in your terminal. +.RE +.P search .RS -Search packages on repository and view everything in your terminal. +Search and match packages from the repository. .RE .P clean-logs diff --git a/setup.cfg b/setup.cfg index 55becd7f..fce6d0db 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = slpkg -version = 4.2.1 +version = 4.2.2 license_file = LICENSE author = Dimitris Zlatanidis author_email = d.zlatanidis@gmail.com diff --git a/slpkg/configs.py b/slpkg/configs.py index 0c3d2c84..d79dab7f 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -67,15 +67,10 @@ class Configs: os_arch: str = config['os_arch'] # All necessary paths - tmp_path: str = config['tmp_path'] tmp_slpkg: str = config['tmp_slpkg'] build_path: str = config['build_path'] download_only: str = config['download_only'] - lib_path: str = config['lib_path'] - etc_path: str = config['etc_path'] - db_path: str = config['db_path'] sbo_repo_path: str = config['sbo_repo_path'] - log_packages: str = config['log_packages'] # Database name database: str = config['database'] diff --git a/slpkg/find_installed.py b/slpkg/find_installed.py index f3ea255c..62904a72 100644 --- a/slpkg/find_installed.py +++ b/slpkg/find_installed.py @@ -15,6 +15,10 @@ class FindInstalled: def find(self, packages: list): matching = [] + + print(f'The list below shows the packages ' + f'that contains \'{", ".join([p for p in packages])}\' files:\n') + for pkg in packages: for package in os.listdir(self.log_packages): if pkg in package and self.sbo_repo_tag in package: diff --git a/slpkg/main.py b/slpkg/main.py index f8b2bb95..fc2c49a3 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -6,14 +6,15 @@ import sys from dataclasses import dataclass from slpkg.checks import Check -from slpkg.search import Search from slpkg.upgrade import Upgrade from slpkg.version import Version from slpkg.configs import Configs from slpkg.utilities import Utilities +from slpkg.search import SearchPackage from slpkg.views.cli_menu import usage from slpkg.download_only import Download from slpkg.slackbuild import Slackbuilds +from slpkg.view_package import ViewPackage from slpkg.find_installed import FindInstalled from slpkg.remove_packages import RemovePackages from slpkg.clean_logs import CleanLogsDependencies @@ -131,14 +132,24 @@ class Argparse: raise SystemExit() usage(1) - def search(self): + def view(self): if len(self.args) >= 2 and not self.flags: packages = list(set(self.args[1:])) packages = self.check.blacklist(packages) self.check.exists(packages) - search = Search() + view = ViewPackage() + view.package(packages) + raise SystemExit() + usage(1) + + def search(self): + if len(self.args) >= 2 and not self.flags: + packages = list(set(self.args[1:])) + packages = self.check.blacklist(packages) + + search = SearchPackage() search.package(packages) raise SystemExit() usage(1) @@ -193,8 +204,9 @@ def main(): 'install': argparse.install, 'download': argparse.download, 'remove': argparse.remove, - 'search': argparse.search, + 'view': argparse.view, 'find': argparse.find, + 'search': argparse.search, 'clean-logs': argparse.clean_logs, 'clean-tmp': argparse.clean_tmp } diff --git a/slpkg/queries.py b/slpkg/queries.py index f6b24c4b..25a54c17 100644 --- a/slpkg/queries.py +++ b/slpkg/queries.py @@ -106,7 +106,7 @@ class SBoQueries: return '' def _chose_arch(self, arch, arch64): - if self.os_arch and arch64: + if self.os_arch == 'x86_64' and arch64: return arch64 return arch diff --git a/slpkg/search.py b/slpkg/search.py index a302ecb6..ca069db5 100644 --- a/slpkg/search.py +++ b/slpkg/search.py @@ -2,53 +2,29 @@ # -*- coding: utf-8 -*- -import urllib3 from dataclasses import dataclass +from slpkg.queries import SBoQueries 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 +class SearchPackage: colors: dict = Configs.colour - sbo_repo_url: str = Configs.sbo_repo_url def package(self, packages): - http = urllib3.PoolManager() color = self.colors() - GREEN = color['GREEN'] - BLUE = color['BLUE'] - YELLOW = color['YELLOW'] + CYAN = color['CYAN'] 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() + names = SBoQueries('').names() - readme = http.request( - 'GET', f'{self.sbo_repo_url}/{info[9]}/{info[0]}/README') + print(f'The list below shows the packages ' + f'that contains \'{", ".join([p for p in packages])}\' files:\n') - 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_repo_url}/{info[9]}/{info[0]}{ENDC}\n' - f'README: {readme.data.decode()}') + for name in names: + for package in packages: + if package in name: + desc = SBoQueries(name).description().replace(name, '') + print(f'{name}-{SBoQueries(name).version()}' + f'{CYAN}{desc}{ENDC}') diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py index 885da919..7f3407d8 100644 --- a/slpkg/slackbuild.py +++ b/slpkg/slackbuild.py @@ -75,9 +75,8 @@ class Slackbuilds: for dep in deps: # Checks if the package was installed and skipped. - pkg = f'{dep}-{SBoQueries(dep).version()}' if ('--skip-installed' in self.flags and - self.utils.is_installed(f'{pkg}-')): + self.utils.is_installed(f'{dep}-')): continue if dep not in self.slackbuilds: diff --git a/slpkg/version.py b/slpkg/version.py index afe6d609..6ad1682f 100644 --- a/slpkg/version.py +++ b/slpkg/version.py @@ -10,7 +10,7 @@ from slpkg.configs import Configs @dataclass class Version: prog_name: str = Configs.prog_name - version_info: tuple = (4, 2, 1) + version_info: tuple = (4, 2, 2) version: str = '{0}.{1}.{2}'.format(*version_info) license: str = 'MIT License' author: str = 'dslackw' diff --git a/slpkg/view_package.py b/slpkg/view_package.py new file mode 100644 index 00000000..0d9efeea --- /dev/null +++ b/slpkg/view_package.py @@ -0,0 +1,55 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + + +import urllib3 +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 ViewPackage: + session: str = Session + colors: dict = Configs.colour + sbo_repo_url: str = Configs.sbo_repo_url + + def package(self, packages): + http = urllib3.PoolManager() + color = self.colors() + GREEN = color['GREEN'] + BLUE = color['BLUE'] + YELLOW = color['YELLOW'] + CYAN = color['CYAN'] + 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() + + readme = http.request( + 'GET', f'{self.sbo_repo_url}/{info[9]}/{info[0]}/README') + + 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_repo_url}/{info[9]}/{info[0]}{ENDC}\n' + f'README: {CYAN}{readme.data.decode()}{ENDC}') diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index 2d11ddfc..5cf78c30 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -26,7 +26,8 @@ def usage(status: int): f' {CYAN}download{ENDC} Download only the packages.', f' {CYAN}remove{ENDC} Remove installed packages.', f' {CYAN}find{ENDC} Find installed packages.', - f' {CYAN}search{ENDC} Search packages on repository.', + f' {CYAN}view{ENDC} View packages from the repository.', + f' {CYAN}search{ENDC} Search packages from the repository.', f' {CYAN}clean-logs{ENDC} Clean dependencies log tracking.', f' {CYAN}clean-tmp{ENDC} Delete all the downloaded sources.\n', f'{BOLD}OPTIONS:{ENDC}',