Merge branch 'develop'

This commit is contained in:
Dimitris Zlatanidis 2023-01-11 19:56:59 +02:00
commit d23587fcee
14 changed files with 218 additions and 142 deletions

View file

@ -3,6 +3,8 @@ Added:
- Finished report to download only
- The French manpage (Thanks to marav)
- Check if the file dowwnload
Updated:
- os.istdir method with pathlib module
4.4.6 - 06/01/2023
Updated:

View file

@ -31,8 +31,8 @@ Install from the official third-party `SBo repository <https://slackbuilds.org/r
.. code-block:: bash
$ tar xvf slpkg-4.4.6.tar.gz
$ cd slpkg-4.4.6
$ tar xvf slpkg-4.4.7.tar.gz
$ cd slpkg-4.4.7
$ ./install.sh
Screenshots

33
completion/slpkg Normal file
View file

@ -0,0 +1,33 @@
_slpkg_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
case $cur in
-*)
OPTS="
--help
--version
update
upgrade
check-updates
configs
clean-logs
clean-tmp
build
install
download
remove
find
view
search
dependees
tracking
"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
return 0
}
complete -F _slpkg_module slpkg

View file

@ -1,7 +1,7 @@
.TH slpkg 1 "Orestiada, Grèce" "slpkg 4.4.0" dslackw
.TH slpkg 1 "Orestiada, Grèce" "slpkg 4.4.7" dslackw
.SH NOM
.P
slpkg - [OPTIONS] [COMMANDE] <packages>.
.B slpkg - [OPTIONS] [COMMANDE] <packages>.
.SH SYNOPSIS
.P
slpkg [-h|-v] [update] [upgrade] [check-updates] [configs] [clean-logs] [clean-tmp] [-b, build] [-i, install] [-d, download]
@ -17,78 +17,78 @@ Il calcule automatiquement \fBles dépendances\fP et détermine comment doit se
Il utilise également les instructions de \fBSlackware Linux\fP pour l'installation, la mise à jour ou la suppression des paquets.
.SH COMMANDES
.P
update
.B update --yes
.RS
Met à jour la liste des paquets et la base de données.
.RE
.P
upgrade
.B upgrade --yes, --jobs, --resolve-off, --reinstall
.RS
Met à niveau tous les paquets installés si une version plus récente existe dans le référentiel.
.RE
.P
check-updates
.B check-updates
.RS
Vérifie si le fichier \fBChangeLog.txt\fP du SlackBuild contient des mises à jour.
.RE
.P
configs
.B configs
.RS
Modifier le fichier de configuration \fB/etc/slpkg/slpkg.toml\fP.
.RE
.P
clean-logs
.B clean-logs --yes
.RS
Nettoie les journaux de suivi de dépendances. \fBAttention\fP, après cette procédure vous devrez supprimer les dépendances à la main.
.RE
.P
clean-tmp
.B clean-tmp
.RS
Supprime tous les scripts et sources des SlackBuilds téléchargés.
.RE
.P
-b, build
.B -b, build --yes, --jobs, --resolve-off, --search
.RS
Construit les scripts des Slackbuilds et les ajoute au répertoire \fB/tmp\fP.
.RE
.P
-i, install
.B -i, install --yes, --jobs, --resolve-off, --reinstall, --skip-installed, --search
.RS
Construit et installe les paquets dans l'ordre adéquat et enregistre également les paquets avec les dépendances à utiliser pour la suppression.
.RE
.P
-d, download
.B -d, download --yes, --search
.RS
Télécharger les scripts et les sources des SlackBuilds sans les construire ni les installer.
.RE
.P
-r, remove
.B -r, remove --yes, resolve-off, --search
.RS
Supprime les paquets avec leurs dépendances s'ils ont été installés avec la méthode \fB'slpkg install'\fP.
Slpkg examine la configuration \fB'sbo_repo_tag'\fP pour trouver les paquets à supprimer.
.RE
.P
-f, find
.B -f, find --search
.RS
Trouver les paquets installés par \fBSBo\fP (taggés _SBo) sur votre distribution.
.RE
.P
-w, view
.B -w, view --search
.RS
Voir les paquets du dépôt et obtenir toutes les informations dans le terminal.
.RE
.P
-s, search
.B -s, search --search
.RS
Rechercher les paquets.
.RE
.P
-e, dependees
.B -e, dependees --full-reverse, --search
.RS
Montre les dépendances du paquet.
.RE
.P
-t, tracking
.B -t, tracking --search
.RS
Suivi des dépendances des paquets.
.RE

View file

@ -1,7 +1,7 @@
.TH slpkg 1 "Orestiada, Greece" "slpkg 4.4.0" dslackw
.TH slpkg 1 "Orestiada, Greece" "slpkg 4.4.7" dslackw
.SH NAME
.P
slpkg - [OPTIONS] [COMMAND] <packages>
.B slpkg - [OPTIONS] [COMMAND] <packages>
.SH SYNAPSES
.P
slpkg [-h|-v] [update] [upgrade] [check-updates] [configs] [clean-logs] [clean-tmp] [-b, build] [-i, install] [-d, download]
@ -17,78 +17,78 @@ Slpkg works in accordance with the standards of the organization SlackBuilds.org
Also uses the Slackware Linux instructions for installation, upgrading or removing packages.
.SH COMMANDS
.P
update
.B update --yes
.RS
Updates the package list and the database.
.RE
.P
upgrade
.B upgrade --yes, --jobs, --resolve-off, --reinstall
.RS
Upgrade all the installed packages if the newer version exists in the repository.
.RE
.P
check-updates
.B check-updates
.RS
Check if there is any news on the SlackBuild's ChangeLog.txt file.
.RE
.P
configs
.B configs
.RS
Edit the configuration /etc/slpkg/slpkg.toml file.
.RE
.P
clean-logs
.B clean-logs --yes
.RS
Cleans dependencies log tracking. After that procedure you should remove dependencies by hand.
.RE
.P
clean-tmp
.B clean-tmp
.RS
Deletes all the downloaded SlackBuilds scripts and sources.
.RE
.P
-b, build
.B -b, build --yes, --jobs, --resolve-off, --search
.RS
Builds the Slackbuilds scripts and adds them to the /tmp directory.
.RE
.P
-i, install
.B -i, install --yes, --jobs, --resolve-off, --reinstall, --skip-installed, --search
.RS
Builds and installs the packages in the correct order and also logs the packages with dependencies to use for removal.
.RE
.P
-d, download
.B -d, download --yes, --search
.RS
Download the SlackBuilds scripts and the sources without building or installing it.
.RE
.P
-r, remove
.B -r, remove --yes, resolve-off, --search
.RS
Removes packages with dependencies if the packages was installed with 'slpkg install' method.
Slpkg looks at the 'sbo_repo_tag' configuration to find packages for removal.
.RE
.P
-f, find
.B -f, find --search
.RS
Find sbo installed packages on your distribution.
.RE
.P
-w, view
.B -w, view --search
.RS
View packages from the repository and get everything in your terminal.
.RE
.P
-s, search
.B -s, search --search
.RS
Search and match packages from the repository.
.RE
.P
-e, dependees
.B -e, dependees --full-reverse, --search
.RS
Show which SlackBuilds depend on.
.RE
.P
-t, tracking
.B -t, tracking --search
.RS
Tracking the packages dependencies.
.RE
@ -150,7 +150,7 @@ Configuration file in the /etc/slpkg/slpkg.toml file.
Blacklist file in the /etc/slpkg/blacklist.toml file.
.SH REPORT BUGS
.P
Please report any found to https://gitlab.com/dslackw/slpkg/-/issues.
Please report any found to: https://gitlab.com/dslackw/slpkg/-/issues.
.SH AUTHOR
.P
Dimitris Zlatanidis <d.zlatanidis@gmail.com>

View file

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

View file

@ -1,9 +1,8 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
from slpkg.configs import Configs
from slpkg.utilities import Utilities
class FindInstalled:
@ -13,17 +12,19 @@ class FindInstalled:
self.configs = Configs
colors = self.configs.colour
self.color = colors()
self.utils = Utilities()
def find(self, packages: list):
""" Find the packages. """
matching = []
installed = self.utils.all_installed()
print(f'The list below shows the installed packages '
f'that contains \'{", ".join([p for p in packages])}\' files:\n')
for pkg in packages:
for package in os.listdir(self.configs.log_packages):
if pkg in package and self.configs.sbo_repo_tag in package:
for package in installed:
if pkg in package:
matching.append(package)
self.matched(matching)

View file

@ -51,7 +51,7 @@ class Argparse:
self.flag_full_reverse = '--full-reverse'
self.flag_search = '--search'
self.dialog_is_enabled()
self.is_dialog_enabled()
self.options = [self.flag_yes,
self.flag_jobs,
@ -61,7 +61,6 @@ class Argparse:
self.flag_full_reverse,
self.flag_search]
self.check_for_flags()
self.remove_flags()
def remove_flags(self):
@ -71,20 +70,80 @@ class Argparse:
self.args.remove(opt)
self.flags.append(opt)
def dialog_is_enabled(self):
def is_dialog_enabled(self):
""" Checking if the dialog box is enabled. """
if (not self.configs.dialog and self.flag_search in self.args or
not self.configs.dialog and 'configs' in self.args):
print("Error: You should enable the dialog "
"in the '/etc/slpkg/' folder.\n")
self.usage.help(1)
raise SystemExit("\nError: You should enable the dialog "
"in the '/etc/slpkg/' folder.\n")
def check_for_flags(self):
def check_for_flags(self, command):
""" Check for correct flag. """
for opt in self.args:
if opt.startswith('--'):
if opt not in self.options and opt not in ['--help', '--version']:
raise SystemExit(f"\nError: flag '{opt}' does not exist.\n")
commands = {
'--help': [],
'--version': [],
'update': [self.flag_yes],
'upgrade': [
self.flag_yes,
self.flag_jobs,
self.flag_resolve_off,
self.flag_reinstall
],
'check-updates': [],
'configs': [],
'clean-logs': [self.flag_yes],
'clean-tmp': [],
'build': [
self.flag_yes,
self.flag_jobs,
self.flag_resolve_off,
self.flag_search
],
'install': [
self.flag_yes,
self.flag_jobs,
self.flag_resolve_off,
self.flag_reinstall,
self.flag_skip_installed,
self.flag_search
],
'download': [
self.flag_yes,
self.flag_search
],
'remove': [
self.flag_yes,
self.flag_resolve_off,
self.flag_search
],
'find': [self.flag_search],
'view': [self.flag_search],
'search': [self.flag_search],
'dependees': [
self.flag_full_reverse,
self.flag_search
],
'tracking': [self.flag_search]
}
commands['-h'] = commands['--help']
commands['-v'] = commands['--version']
commands['-b'] = commands['build']
commands['-i'] = commands['install']
commands['-d'] = commands['download']
commands['-r'] = commands['remove']
commands['-f'] = commands['find']
commands['-w'] = commands['view']
commands['-s'] = commands['search']
commands['-e'] = commands['dependees']
commands['-t'] = commands['tracking']
flags = commands[command]
for opt in self.flags:
if opt not in flags and opt not in ['--help', '--version']:
self.usage.error_for_options(flags)
def choose_packages(self, packages, method):
""" Choose packages with dialog utility and --search flag. """
@ -96,7 +155,7 @@ class Argparse:
repo_packages = SBoQueries('').sbos()
# Grab all the installed packages
installed = os.listdir(self.configs.log_packages)
installed = self.utils.all_installed()
if method in ['remove', 'find']:
@ -104,10 +163,9 @@ class Argparse:
name = self.utils.split_installed_pkg(package)[0]
version = self.utils.split_installed_pkg(package)[1]
if package.endswith(self.configs.sbo_repo_tag):
for pkg in packages:
if pkg in name:
choices += [(name, version, False)]
for pkg in packages:
if pkg in name:
choices += [(name, version, False)]
else:
for package in repo_packages:
for pkg in packages:
@ -141,21 +199,18 @@ class Argparse:
return tags
def help(self):
if len(self.args) == 1 and not self.flags:
if len(self.args) == 1:
self.usage.help(0)
self.usage.help(1)
def version(self):
if len(self.args) == 1 and not self.flags:
if len(self.args) == 1:
version = Version()
version.view()
raise SystemExit()
self.usage.help(1)
def update(self):
if [f for f in self.flags if f not in [self.flag_yes]]:
self.usage.help(1)
if len(self.args) == 1:
update = UpdateRepository(self.flags)
update.repository()
@ -163,11 +218,7 @@ class Argparse:
self.usage.help(1)
def upgrade(self):
if [f for f in self.flags if f not in [self.flag_yes,
self.flag_jobs,
self.flag_resolve_off,
self.flag_reinstall]]:
self.usage.help(1)
command = Argparse.upgrade.__name__
if len(self.args) == 1:
self.check.database()
@ -175,21 +226,19 @@ class Argparse:
upgrade = Upgrade()
packages = list(upgrade.packages())
packages = self.choose_packages(packages,
Argparse.upgrade.__name__)
packages = self.choose_packages(packages, command)
if not packages:
print('\nEverything is up-to-date.\n')
raise SystemExit()
install = Slackbuilds(packages, self.flags,
mode=Argparse.upgrade.__name__)
install = Slackbuilds(packages, self.flags, mode=command)
install.execute()
raise SystemExit()
self.usage.help(1)
def check_updates(self):
if len(self.args) == 1 and not self.flags:
if len(self.args) == 1:
self.check.database()
check = CheckUpdates()
@ -198,15 +247,12 @@ class Argparse:
self.usage.help(1)
def edit_configs(self):
if len(self.args) == 1 and not self.flags:
if len(self.args) == 1:
self.form_configs.edit()
raise SystemExit()
self.usage.help(1)
def clean_logs(self):
if [f for f in self.flags if f not in [self.flag_yes]]:
self.usage.help(1)
if len(self.args) == 1:
self.check.database()
@ -216,7 +262,7 @@ class Argparse:
self.usage.help(1)
def clean_tmp(self):
if len(self.args) == 1 and not self.flags:
if len(self.args) == 1:
path = self.configs.tmp_path
tmp_slpkg = self.configs.tmp_slpkg
folder = self.configs.prog_name
@ -227,66 +273,49 @@ class Argparse:
self.usage.help(1)
def build(self):
if [f for f in self.flags if f not in [self.flag_yes,
self.flag_jobs,
self.flag_resolve_off,
self.flag_search]]:
self.usage.help(1)
command = Argparse.build.__name__
if len(self.args) >= 2:
packages = list(set(self.args[1:]))
if '--search' in self.flags:
packages = self.choose_packages(packages,
Argparse.build.__name__)
packages = self.choose_packages(packages, command)
self.check.database()
self.check.exists(packages)
self.check.unsupported(packages)
build = Slackbuilds(packages, self.flags,
mode=Argparse.build.__name__)
build = Slackbuilds(packages, self.flags, mode=command)
build.execute()
raise SystemExit()
self.usage.help(1)
def install(self):
if [f for f in self.flags if f not in [self.flag_yes,
self.flag_jobs,
self.flag_resolve_off,
self.flag_reinstall,
self.flag_skip_installed,
self.flag_search]]:
self.usage.help(1)
command = Argparse.install.__name__
if len(self.args) >= 2:
packages = list(set(self.args[1:]))
if '--search' in self.flags:
packages = self.choose_packages(packages,
Argparse.install.__name__)
packages = self.choose_packages(packages, command)
self.check.database()
self.check.exists(packages)
self.check.unsupported(packages)
install = Slackbuilds(packages, self.flags,
mode=Argparse.install.__name__)
install = Slackbuilds(packages, self.flags, mode=command)
install.execute()
raise SystemExit()
self.usage.help(1)
def download(self):
if [f for f in self.flags if f not in [self.flag_yes,
self.flag_search]]:
self.usage.help(1)
command = Argparse.download.__name__
if len(self.args) >= 2:
packages = list(set(self.args[1:]))
if '--search' in self.flags:
packages = self.choose_packages(packages,
Argparse.download.__name__)
packages = self.choose_packages(packages, command)
self.check.database()
self.check.exists(packages)
@ -296,17 +325,13 @@ class Argparse:
self.usage.help(1)
def remove(self):
if [f for f in self.flags if f not in [self.flag_yes,
self.flag_resolve_off,
self.flag_search]]:
self.usage.help(1)
command = Argparse.remove.__name__
if len(self.args) >= 2:
packages = list(set(self.args[1:]))
if '--search' in self.flags:
packages = self.choose_packages(packages,
Argparse.remove.__name__)
packages = self.choose_packages(packages, command)
self.check.database()
packages = self.check.installed(packages)
@ -317,15 +342,13 @@ class Argparse:
self.usage.help(1)
def find(self):
if [f for f in self.flags if f not in [self.flag_search]]:
self.usage.help(1)
command = Argparse.find.__name__
if len(self.args) >= 2:
packages = list(set(self.args[1:]))
if '--search' in self.flags:
packages = self.choose_packages(packages,
Argparse.find.__name__)
packages = self.choose_packages(packages, command)
self.check.database()
@ -335,15 +358,13 @@ class Argparse:
self.usage.help(1)
def view(self):
if [f for f in self.flags if f not in [self.flag_search]]:
self.usage.help(1)
command = Argparse.view.__name__
if len(self.args) >= 2:
packages = list(set(self.args[1:]))
if '--search' in self.flags:
packages = self.choose_packages(packages,
Argparse.view.__name__)
packages = self.choose_packages(packages, command)
self.check.database()
self.check.exists(packages)
@ -354,15 +375,13 @@ class Argparse:
self.usage.help(1)
def search(self):
if [f for f in self.flags if f not in [self.flag_search]]:
self.usage.help(1)
command = Argparse.search.__name__
if len(self.args) >= 2:
packages = list(set(self.args[1:]))
if '--search' in self.flags:
packages = self.choose_packages(packages,
Argparse.search.__name__)
packages = self.choose_packages(packages, command)
self.check.database()
@ -372,16 +391,13 @@ class Argparse:
self.usage.help(1)
def dependees(self):
if [f for f in self.flags if f not in [self.flag_full_reverse,
self.flag_search]]:
self.usage.help(1)
command = Argparse.dependees.__name__
if len(self.args) >= 2:
packages = list(set(self.args[1:]))
if '--search' in self.flags:
packages = self.choose_packages(packages,
Argparse.dependees.__name__)
packages = self.choose_packages(packages, command)
self.check.database()
self.check.exists(packages)
@ -392,15 +408,13 @@ class Argparse:
self.usage.help(1)
def tracking(self):
if [f for f in self.flags if f not in [self.flag_search]]:
self.usage.help(1)
command = Argparse.tracking.__name__
if len(self.args) >= 2:
packages = list(set(self.args[1:]))
if '--search' in self.flags:
packages = self.choose_packages(packages,
Argparse.tracking.__name__)
packages = self.choose_packages(packages, command)
self.check.database()
self.check.exists(packages)
@ -449,6 +463,7 @@ def main():
}
try:
argparse.check_for_flags(args[0])
arguments[args[0]]()
except KeyError:
Usage().help(1)

View file

@ -249,12 +249,10 @@ class Slackbuilds:
installation. """
version = SBoQueries(name).version()
packages = []
pkg = f'{name}-{version}'
pattern = f'{name}-{version}-*{self.configs.sbo_repo_tag}*'
for package in os.listdir(self.configs.tmp_path):
if pkg in package and self.configs.sbo_repo_tag in package:
packages.append(package)
tmp = Path(self.configs.tmp_path)
packages = [file.name for file in tmp.glob(pattern)]
return max(packages)

View file

@ -1,7 +1,6 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
from distutils.version import LooseVersion
@ -27,7 +26,9 @@ class Upgrade:
black = Blacklist().get()
upgrade, requires = [], []
for pkg in os.listdir(self.configs.log_packages):
installed = self.utils.all_installed()
for pkg in installed:
inst_pkg_name = self.utils.split_installed_pkg(pkg)[0]
if (pkg.endswith(self.configs.sbo_repo_tag)

View file

@ -1,7 +1,6 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
import time
import shutil
import tarfile
@ -24,12 +23,26 @@ class Utilities:
def is_installed(self, name: str) -> str:
""" Returns the installed package name. """
for package in os.listdir(self.configs.log_packages):
pattern = f'*{self.configs.sbo_repo_tag}'
var_log_packages = Path(self.configs.log_packages)
packages = [file.name for file in var_log_packages.glob(pattern)]
for package in packages:
pkg = self.split_installed_pkg(package)[0]
if pkg == name and self.configs.sbo_repo_tag in package and pkg not in self.black.get():
if pkg == name and pkg not in self.black.get():
return package
return ''
def all_installed(self):
""" Return all installed SBo packages from /val/log/packages folder. """
pattern = f'*{self.configs.sbo_repo_tag}'
var_log_packages = Path(self.configs.log_packages)
installed = [file.name for file in var_log_packages.glob(pattern)]
return installed
@staticmethod
def untar_archive(path: str, archive: str, ext_path: str):
""" Untar the file to the build folder. """

View file

@ -70,3 +70,15 @@ class Usage:
print(args)
raise SystemExit(status)
def error_for_options(self, flags):
""" Error messages for flags. """
print(f'Usage: {Configs.prog_name} [{self.yellow}OPTIONS{self.endc}] '
f'[{self.cyan}COMMAND{self.endc}] <packages>')
print("Try 'slpkg --help' for help.\n")
if flags:
raise SystemExit(f"{self.red}Error:{self.endc} Got an unexpected extra option, "
f"please use: \n{self.yellow}'{', '.join(flags)}'{self.endc}")
raise SystemExit(f"{self.red}Error:{self.endc} Got an unexpected extra option.")

View file

@ -5,7 +5,7 @@ class Version:
""" Print the version. """
def __init__(self):
self.version_info = (4, 4, 6)
self.version_info = (4, 4, 7)
self.version = '{0}.{1}.{2}'.format(*self.version_info)
self.license = 'MIT License'
self.author = 'Dimitris Zlatanidis (dslackw)'

View file

@ -91,6 +91,7 @@ class ViewMessage:
print(f'{self.bold}{self.green}{self.llc}' + f'{self.hl}' * (self.columns - 2) + f'{self.lrc}{self.endc}')
def view_skipping_packages(self, sbo, version):
""" Print the skipping packages. """
print(f'[{self.yellow}Skipping{self.endc}] {sbo}-{version} {self.red}(already installed){self.endc}')
def build_packages(self, slackbuilds: list, dependencies: list):
@ -179,7 +180,7 @@ class ViewMessage:
def _view_removed(self, name: str):
""" View and creates list with packages for remove. """
installed = os.listdir(self.configs.log_packages)
installed = self.utils.all_installed()
if self.utils.is_installed(name):
for package in installed: