Merge branch 'develop'

This commit is contained in:
Dimitris Zlatanidis 2022-10-28 08:46:53 +03:00
commit bda8a439ea
14 changed files with 141 additions and 70 deletions

View file

@ -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 4.2.1 - 18/10/2022
Added: Added:
- Print the README file in the search option - Print the README file in the search option

View file

@ -30,8 +30,8 @@ Install from the official third-party `SBo repository <https://slackbuilds.org/r
.. code-block:: bash .. code-block:: bash
$ tar xvf slpkg-4.2.1.tar.gz $ tar xvf slpkg-4.2.2.tar.gz
$ cd slpkg-4.2.1 $ cd slpkg-4.2.2
$ ./install.sh $ ./install.sh
@ -55,7 +55,8 @@ Usage
download <packages> Download only the packages. download <packages> Download only the packages.
remove <packages> Remove installed packages. remove <packages> Remove installed packages.
find <packages> Find installed packages. find <packages> Find installed packages.
search <packages> Search packages on repository. view <packages> View packages from the repository.
search <packages> Search packages from the repository.
clean-logs Clean dependencies log tracking. clean-logs Clean dependencies log tracking.
clean-tmp Deletes all the downloaded sources. clean-tmp Deletes all the downloaded sources.

View file

@ -2,33 +2,48 @@ configs:
# OS architecture by default. # OS architecture by default.
os_arch: x86_64 os_arch: x86_64
# All necessary paths. # Tmp path for slpkg.
tmp_path: /tmp
tmp_slpkg: /tmp/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 database: database.slpkg
# SBo repository configs. # Slackbuilds.org repository url.
sbo_repo_url: http://slackbuilds.org/slackbuilds/15.0 sbo_repo_url: http://slackbuilds.org/slackbuilds/15.0
# The sbo repository main file.
sbo_txt: SLACKBUILDS.TXT sbo_txt: SLACKBUILDS.TXT
# The sbo tar suffix.
sbo_tar_suffix: .tar.gz sbo_tar_suffix: .tar.gz
# The sbo repo tag.
sbo_repo_tag: _SBo sbo_repo_tag: _SBo
# Slackware commands. # Slackware install command. Alternative you can
# use 'installpkg', if you want.
installpkg: upgradepkg --install-new installpkg: upgradepkg --install-new
# Upgrade or reinstall slackware command.
reinstall: upgradepkg --reinstall reinstall: upgradepkg --reinstall
# Slackware command fro remove packages.
removepkg: removepkg removepkg: removepkg
# Cli menu colors configs. # Cli menu colors configs. Default is on. [on/off]
colors: on 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 wget_options: -c -N

View file

@ -4,7 +4,7 @@
slpkg - [OPTIONS] [COMMAND] <packages> slpkg - [OPTIONS] [COMMAND] <packages>
.SH SYNAPSES .SH SYNAPSES
.P .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 .SH DESCRIPTION
.P .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. 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. Find sbo installed packages on your distribution.
.RE .RE
.P .P
view
.RS
View packages from the repository and get everything in your terminal.
.RE
.P
search search
.RS .RS
Search packages on repository and view everything in your terminal. Search and match packages from the repository.
.RE .RE
.P .P
clean-logs clean-logs

View file

@ -1,6 +1,6 @@
[metadata] [metadata]
name = slpkg name = slpkg
version = 4.2.1 version = 4.2.2
license_file = LICENSE license_file = LICENSE
author = Dimitris Zlatanidis author = Dimitris Zlatanidis
author_email = d.zlatanidis@gmail.com author_email = d.zlatanidis@gmail.com

View file

@ -67,15 +67,10 @@ class Configs:
os_arch: str = config['os_arch'] os_arch: str = config['os_arch']
# All necessary paths # All necessary paths
tmp_path: str = config['tmp_path']
tmp_slpkg: str = config['tmp_slpkg'] tmp_slpkg: str = config['tmp_slpkg']
build_path: str = config['build_path'] build_path: str = config['build_path']
download_only: str = config['download_only'] 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'] sbo_repo_path: str = config['sbo_repo_path']
log_packages: str = config['log_packages']
# Database name # Database name
database: str = config['database'] database: str = config['database']

View file

@ -15,6 +15,10 @@ class FindInstalled:
def find(self, packages: list): def find(self, packages: list):
matching = [] 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 pkg in packages:
for package in os.listdir(self.log_packages): for package in os.listdir(self.log_packages):
if pkg in package and self.sbo_repo_tag in package: if pkg in package and self.sbo_repo_tag in package:

View file

@ -6,14 +6,15 @@ import sys
from dataclasses import dataclass from dataclasses import dataclass
from slpkg.checks import Check from slpkg.checks import Check
from slpkg.search import Search
from slpkg.upgrade import Upgrade from slpkg.upgrade import Upgrade
from slpkg.version import Version from slpkg.version import Version
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.utilities import Utilities from slpkg.utilities import Utilities
from slpkg.search import SearchPackage
from slpkg.views.cli_menu import usage from slpkg.views.cli_menu import usage
from slpkg.download_only import Download from slpkg.download_only import Download
from slpkg.slackbuild import Slackbuilds from slpkg.slackbuild import Slackbuilds
from slpkg.view_package import ViewPackage
from slpkg.find_installed import FindInstalled from slpkg.find_installed import FindInstalled
from slpkg.remove_packages import RemovePackages from slpkg.remove_packages import RemovePackages
from slpkg.clean_logs import CleanLogsDependencies from slpkg.clean_logs import CleanLogsDependencies
@ -131,14 +132,24 @@ class Argparse:
raise SystemExit() raise SystemExit()
usage(1) usage(1)
def search(self): def view(self):
if len(self.args) >= 2 and not self.flags: if len(self.args) >= 2 and not self.flags:
packages = list(set(self.args[1:])) packages = list(set(self.args[1:]))
packages = self.check.blacklist(packages) packages = self.check.blacklist(packages)
self.check.exists(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) search.package(packages)
raise SystemExit() raise SystemExit()
usage(1) usage(1)
@ -193,8 +204,9 @@ def main():
'install': argparse.install, 'install': argparse.install,
'download': argparse.download, 'download': argparse.download,
'remove': argparse.remove, 'remove': argparse.remove,
'search': argparse.search, 'view': argparse.view,
'find': argparse.find, 'find': argparse.find,
'search': argparse.search,
'clean-logs': argparse.clean_logs, 'clean-logs': argparse.clean_logs,
'clean-tmp': argparse.clean_tmp 'clean-tmp': argparse.clean_tmp
} }

View file

@ -106,7 +106,7 @@ class SBoQueries:
return '' return ''
def _chose_arch(self, arch, arch64): def _chose_arch(self, arch, arch64):
if self.os_arch and arch64: if self.os_arch == 'x86_64' and arch64:
return arch64 return arch64
return arch return arch

View file

@ -2,53 +2,29 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import urllib3
from dataclasses import dataclass from dataclasses import dataclass
from slpkg.queries import SBoQueries
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.models.models import SBoTable
from slpkg.models.models import session as Session
@dataclass @dataclass
class Search: class SearchPackage:
session: str = Session
colors: dict = Configs.colour colors: dict = Configs.colour
sbo_repo_url: str = Configs.sbo_repo_url
def package(self, packages): def package(self, packages):
http = urllib3.PoolManager()
color = self.colors() color = self.colors()
GREEN = color['GREEN'] CYAN = color['CYAN']
BLUE = color['BLUE']
YELLOW = color['YELLOW']
ENDC = color['ENDC'] ENDC = color['ENDC']
for package in packages: names = SBoQueries('').names()
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( print(f'The list below shows the packages '
'GET', f'{self.sbo_repo_url}/{info[9]}/{info[0]}/README') f'that contains \'{", ".join([p for p in packages])}\' files:\n')
print(f'Name: {GREEN}{info[0]}{ENDC}\n' for name in names:
f'Version: {GREEN}{info[1]}{ENDC}\n' for package in packages:
f'Requires: {GREEN}{info[2]}{ENDC}\n' if package in name:
f'Download: {BLUE}{info[3]}{ENDC}\n' desc = SBoQueries(name).description().replace(name, '')
f'Download_x86_64: {BLUE}{info[4]}{ENDC}\n' print(f'{name}-{SBoQueries(name).version()}'
f'Md5sum: {YELLOW}{info[5]}{ENDC}\n' f'{CYAN}{desc}{ENDC}')
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()}')

View file

@ -75,9 +75,8 @@ class Slackbuilds:
for dep in deps: for dep in deps:
# Checks if the package was installed and skipped. # Checks if the package was installed and skipped.
pkg = f'{dep}-{SBoQueries(dep).version()}'
if ('--skip-installed' in self.flags and if ('--skip-installed' in self.flags and
self.utils.is_installed(f'{pkg}-')): self.utils.is_installed(f'{dep}-')):
continue continue
if dep not in self.slackbuilds: if dep not in self.slackbuilds:

View file

@ -10,7 +10,7 @@ from slpkg.configs import Configs
@dataclass @dataclass
class Version: class Version:
prog_name: str = Configs.prog_name 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) version: str = '{0}.{1}.{2}'.format(*version_info)
license: str = 'MIT License' license: str = 'MIT License'
author: str = 'dslackw' author: str = 'dslackw'

55
slpkg/view_package.py Normal file
View file

@ -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}')

View file

@ -26,7 +26,8 @@ def usage(status: int):
f' {CYAN}download{ENDC} <packages> Download only the packages.', f' {CYAN}download{ENDC} <packages> Download only the packages.',
f' {CYAN}remove{ENDC} <packages> Remove installed packages.', f' {CYAN}remove{ENDC} <packages> Remove installed packages.',
f' {CYAN}find{ENDC} <packages> Find installed packages.', f' {CYAN}find{ENDC} <packages> Find installed packages.',
f' {CYAN}search{ENDC} <packages> Search packages on repository.', f' {CYAN}view{ENDC} <packages> View packages from the repository.',
f' {CYAN}search{ENDC} <packages> Search packages from the repository.',
f' {CYAN}clean-logs{ENDC} Clean dependencies log tracking.', f' {CYAN}clean-logs{ENDC} Clean dependencies log tracking.',
f' {CYAN}clean-tmp{ENDC} Delete all the downloaded sources.\n', f' {CYAN}clean-tmp{ENDC} Delete all the downloaded sources.\n',
f'{BOLD}OPTIONS:{ENDC}', f'{BOLD}OPTIONS:{ENDC}',