Merge branch 'develop'

This commit is contained in:
Dimitris Zlatanidis 2023-01-15 20:00:26 +02:00
commit de83393f22
17 changed files with 153 additions and 104 deletions

View file

@ -1,3 +1,10 @@
4.5.0 - 14/01/2023
Updated:
- Download first all the slackbuilds
- Rename view_mode to silent_mode
Added:
- Option --no-silent
4.4.9 - 13/01/2023
Updated:
- Color highlight for installed packages

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.9.tar.gz
$ cd slpkg-4.4.9
$ tar xvf slpkg-4.5.0.tar.gz
$ cd slpkg-4.5.0
$ ./install.sh
Screenshots
@ -87,6 +87,7 @@ Usage
--skip-installed Skip installed packages.
--full-reverse Full reverse dependency.
--search Search packages from the repository.
--no-silent Disable silent mode.
-h, --help Show this message and exit.
-v, --version Print version and exit.

View file

@ -53,11 +53,13 @@
# Wget downloader options.
# -c, --continue: resume getting a partially-downloaded file.
# -N, --timestamping: don't re-retrieve files unless newer
# -N, --timestamping: don't re-retrieve files unless newer.
# -q, Turn off Wget's output.
# --show-progress, Force wget to display the progress bar in any verbosity.
# than local.
wget_options = "-c -N"
wget_options = "-c -N -q --show-progress"
# This effect how you see the download and
# how the packages build and install.
# Choose the view mode. Default is new. [new/old]
view_mode = "new"
# If silent mode is true,
# do not print the commands as they are executed.
# Default is true. [true/false]
silent_mode = true

View file

@ -1,4 +1,4 @@
.TH slpkg 1 "Orestiada, Grèce" "slpkg 4.4.7" dslackw
.TH slpkg 1 "Orestiada, Grèce" "slpkg 4.5.0" dslackw
.SH NOM
.P
.B slpkg - [OPTIONS] [COMMANDE] <packages>.
@ -17,12 +17,12 @@ 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
.B update --yes
.B update --yes, --no-silent
.RS
Met à jour la liste des paquets et la base de données.
.RE
.P
.B upgrade --yes, --jobs, --resolve-off, --reinstall
.B upgrade --yes, --jobs, --resolve-off, --reinstall, --no-silent
.RS
Met à niveau tous les paquets installés si une version plus récente existe dans le référentiel.
.RE
@ -47,22 +47,22 @@ Nettoie les journaux de suivi de dépendances. \fBAttention\fP, après cette pro
Supprime tous les scripts et sources des SlackBuilds téléchargés.
.RE
.P
.B -b, build --yes, --jobs, --resolve-off, --search
.B -b, build --yes, --jobs, --resolve-off, --search, --no-silent
.RS
Construit les scripts des Slackbuilds et les ajoute au répertoire \fB/tmp\fP.
.RE
.P
.B -i, install --yes, --jobs, --resolve-off, --reinstall, --skip-installed, --search
.B -i, install --yes, --jobs, --resolve-off, --reinstall, --skip-installed, --search, --no-silent
.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
.B -d, download --yes, --search
.B -d, download --yes, --search, --no-silent
.RS
Télécharger les scripts et les sources des SlackBuilds sans les construire ni les installer.
.RE
.P
.B -r, remove --yes, resolve-off, --search
.B -r, remove --yes, resolve-off, --search, --no-silent
.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.
@ -134,6 +134,11 @@ Active l'utilitaire de dialogue pour rechercher des paquets dans le référentie
Essayez par exemple : \fB`slpkg install python3 --search`\fP ou \fB`slpkg download python3 --search`\fP et ainsi de suite.
.RE
.P
--no-silent
.RS
Désactivez le mode silencieux s'il est activé dans le fichier de configuration.
.RE
.P
-h | --help
.RS
Affiche l'aide.

View file

@ -1,4 +1,4 @@
.TH slpkg 1 "Orestiada, Greece" "slpkg 4.4.7" dslackw
.TH slpkg 1 "Orestiada, Greece" "slpkg 4.5.0" dslackw
.SH NAME
.P
.B slpkg - [OPTIONS] [COMMAND] <packages>
@ -17,12 +17,12 @@ 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
.B update --yes
.B update --yes, --no-silent
.RS
Updates the package list and the database.
.RE
.P
.B upgrade --yes, --jobs, --resolve-off, --reinstall
.B upgrade --yes, --jobs, --resolve-off, --reinstall, --no-silent
.RS
Upgrade all the installed packages if the newer version exists in the repository.
.RE
@ -47,22 +47,22 @@ Cleans dependencies log tracking. After that procedure you should remove depende
Deletes all the downloaded SlackBuilds scripts and sources.
.RE
.P
.B -b, build --yes, --jobs, --resolve-off, --search
.B -b, build --yes, --jobs, --resolve-off, --search, --no-silent
.RS
Builds the Slackbuilds scripts and adds them to the /tmp directory.
.RE
.P
.B -i, install --yes, --jobs, --resolve-off, --reinstall, --skip-installed, --search
.B -i, install --yes, --jobs, --resolve-off, --reinstall, --skip-installed, --search, --no-silent
.RS
Builds and installs the packages in the correct order and also logs the packages with dependencies to use for removal.
.RE
.P
.B -d, download --yes, --search
.B -d, download --yes, --search, --no-silent
.RS
Download the SlackBuilds scripts and the sources without building or installing it.
.RE
.P
.B -r, remove --yes, resolve-off, --search
.B -r, remove --yes, resolve-off, --search, --no-silent
.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.
@ -134,6 +134,11 @@ Enable the dialog utility to search packages from the repository.
Example try: `slpkg install python3 --search` or `slpkg download python3 --search` and etc.
.RE
.P
--no-silent
.RS
Disable silent mode if it is enabled in the configuration file.
.RE
.P
-h | --help
.RS
Show help information and exit.

View file

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

View file

@ -66,10 +66,10 @@ class Configs:
dialog: str = True
# Wget options
wget_options = '-c -N'
wget_options = '-c -N -q --show-progress'
# Choose the view mode
view_mode: str = 'new'
silent_mode: str = True
load = LoadConfigs()
configs = load.file(etc_path, prog_name)
@ -111,7 +111,7 @@ class Configs:
wget_options: str = config['wget_options']
# Choose the view mode
view_mode: str = config['view_mode']
silent_mode: str = config['silent_mode']
except KeyError as error:
raise SystemExit(f"\nKeyError: {error}: in the configuration file "
"'/etc/slpkg/slpkg.toml'\n")

View file

@ -32,12 +32,12 @@ class Download:
location = SBoQueries(sbo).location()
url = f'{self.configs.sbo_repo_url}/{location}/{file}'
down_sbo = Downloader(self.configs.download_only, url)
down_sbo = Downloader(self.configs.download_only, url, self.flags)
down_sbo.download()
sources = SBoQueries(sbo).sources()
for source in sources:
down_source = Downloader(self.configs.download_only, source)
down_source = Downloader(self.configs.download_only, source, self.flags)
down_source.download()
elapsed_time = time.time() - start

View file

@ -13,9 +13,11 @@ from slpkg.progress_bar import ProgressBar
class Downloader:
""" Wget downloader. """
def __init__(self, path: Union[str, Path], url: str):
def __init__(self, path: Union[str, Path], url: str, flags: list):
self.path = path
self.url = url
self.flags = flags
self.flag_no_silent = '--no-silent'
self.filename = url.split('/')[-1]
self.configs = Configs
self.colors = self.configs.colour
@ -50,7 +52,8 @@ class Downloader:
def download(self):
""" Starting multiprocessing download process. """
if self.configs.view_mode == 'new':
if self.configs.silent_mode and self.flag_no_silent not in self.flags:
done = f' {self.byellow} Done{self.endc}'
self.stderr = subprocess.DEVNULL
self.stdout = subprocess.DEVNULL

View file

@ -65,7 +65,7 @@ class FormConfigs:
def check_configs(self, configs: dict, tags: list) -> bool:
""" Check for true of false values. """
for key, value in zip(configs['configs'].keys(), tags):
if key in ['colors', 'dialog'] and value not in ['true', 'false']:
if key in ['colors', 'dialog', 'silent_mode'] and value not in ['true', 'false']:
self.dialog.msgbox(f"\nError value for {key}. It must be 'true' or 'false'\n", height=7, width=60)
return False
return True
@ -83,6 +83,6 @@ class FormConfigs:
for key, value in zip(configs['configs'].keys(), tags):
if line.lstrip().startswith(key):
line = f' {key} = "{value}"\n'
if line.lstrip().startswith(('colors =', 'dialog =')):
if line.lstrip().startswith(('colors =', 'dialog =', 'silent_mode =')):
line = line.replace('"', '')
patch_toml.write(line)

View file

@ -50,6 +50,7 @@ class Argparse:
self.flag_skip_installed = '--skip-installed'
self.flag_full_reverse = '--full-reverse'
self.flag_search = '--search'
self.flag_no_silent = '--no-silent'
self.is_dialog_enabled()
@ -59,7 +60,8 @@ class Argparse:
self.flag_reinstall,
self.flag_skip_installed,
self.flag_full_reverse,
self.flag_search]
self.flag_search,
self.flag_no_silent]
self.remove_flags()
@ -78,17 +80,21 @@ class Argparse:
"in the '/etc/slpkg/' folder.\n")
def check_for_flags(self, command):
""" Check for correct flag. """
""" Check for correct flags. """
commands = {
'--help': [],
'--version': [],
'update': [self.flag_yes],
'update': [
self.flag_yes,
self.flag_no_silent
],
'upgrade': [
self.flag_yes,
self.flag_jobs,
self.flag_resolve_off,
self.flag_reinstall
self.flag_reinstall,
self.flag_no_silent
],
'check-updates': [],
'configs': [],
@ -98,7 +104,8 @@ class Argparse:
self.flag_yes,
self.flag_jobs,
self.flag_resolve_off,
self.flag_search
self.flag_search,
self.flag_no_silent
],
'install': [
self.flag_yes,
@ -106,16 +113,19 @@ class Argparse:
self.flag_resolve_off,
self.flag_reinstall,
self.flag_skip_installed,
self.flag_search
self.flag_search,
self.flag_no_silent
],
'download': [
self.flag_yes,
self.flag_search
self.flag_search,
self.flag_no_silent
],
'remove': [
self.flag_yes,
self.flag_resolve_off,
self.flag_search
self.flag_search,
self.flag_no_silent
],
'find': [self.flag_search],
'view': [self.flag_search],

View file

@ -34,6 +34,7 @@ class RemovePackages:
self.utils = Utilities()
self.progress = ProgressBar()
self.flag_resolve_off = '--resolve-off'
self.flag_no_silent = '--no-silent'
self.output = 0
self.remove_pkg = None
self.stderr = None
@ -83,7 +84,8 @@ class RemovePackages:
def multi_process(self, command, package):
""" Starting multiprocessing remove process. """
if self.configs.view_mode == 'new':
if self.configs.silent_mode and self.flag_no_silent not in self.flags:
done = f' {self.byellow} Done{self.endc}'
message = f'{self.red}Remove{self.endc}'
self.stderr = subprocess.DEVNULL

View file

@ -29,9 +29,17 @@ class Slackbuilds:
self.slackbuilds = slackbuilds
self.flags = flags
self.mode = mode
self.install_order = []
self.dependencies = []
self.sbos = {}
self.output = 0
self.stderr = None
self.stdout = None
self.process_message = None
self.session = Session
self.utils = Utilities()
self.dialog = DialogBox()
self.progress = ProgressBar()
self.view_message = ViewMessage(self.flags)
self.configs = Configs
self.colors = self.configs.colour
@ -43,18 +51,11 @@ class Slackbuilds:
self.endc = self.color['endc']
self.byellow = f'{self.bold}{self.yellow}'
self.bred = f'{self.bold}{self.red}'
self.install_order = []
self.dependencies = []
self.sbos = {}
self.progress = ProgressBar()
self.flag_reinstall = '--reinstall'
self.flag_skip_installed = '--skip-installed'
self.flag_resolve_off = '--resolve-off'
self.flag_jobs = '--jobs'
self.process_message = None
self.output = 0
self.stderr = None
self.stdout = None
self.flag_no_silent = '--no-silent'
def execute(self):
""" Starting build or install the slackbuilds. """
@ -68,7 +69,8 @@ class Slackbuilds:
self.view_before_build()
start = time.time()
self.download_slackbuilds_and_build()
self.download_slackbuilds()
self.build_and_install()
elapsed_time = time.time() - start
self.utils.finished_time(elapsed_time)
@ -103,36 +105,6 @@ class Slackbuilds:
self.install_order.extend(self.dependencies)
def choose_dependencies(self, dependencies: list):
""" Choose packages for install. """
height = 10
width = 70
list_height = 0
choices = []
title = ' Choose dependencies you want to install '
for package in dependencies:
status = True
repo_ver = SBoQueries(package).version()
installed = self.utils.is_installed(package)
if installed:
status = False
choices += [(package, repo_ver, status)]
text = f'There are {len(choices)} dependencies:'
code, tags = self.dialog.checklist(text, title, height, width,
list_height, choices, dependencies)
if not code:
return dependencies
os.system('clear')
return tags
def creating_main_for_build(self):
""" List with the main slackbuilds. """
[self.install_order.append(main) for main in self.sbos.keys() if main not in self.install_order]
@ -148,14 +120,16 @@ class Slackbuilds:
self.view_message.question()
def download_slackbuilds_and_build(self):
""" Downloads files and sources and starting the build. """
def is_for_skipped(self, sbo):
""" Condition to check if slackbuild is for skipped. """
return (not self.utils.is_installed(sbo) or self.utils.is_repo_version_bigger(sbo) or
self.mode == 'build' or self.flag_reinstall in self.flags)
def download_slackbuilds(self):
""" Downloads files and sources. """
for sbo in self.install_order:
package = self.utils.is_installed(sbo)
if (not package or self.utils.is_repo_version_bigger(sbo) or
self.mode == 'build' or self.flag_reinstall in self.flags):
if self.is_for_skipped(sbo):
file = f'{sbo}{self.configs.sbo_tar_suffix}'
@ -165,7 +139,7 @@ class Slackbuilds:
location = SBoQueries(sbo).location()
url = f'{self.configs.sbo_repo_url}/{location}/{file}'
down_sbo = Downloader(self.configs.tmp_slpkg, url)
down_sbo = Downloader(self.configs.tmp_slpkg, url, self.flags)
down_sbo.download()
self.utils.untar_archive(self.configs.tmp_slpkg, file, self.configs.build_path)
@ -175,6 +149,12 @@ class Slackbuilds:
sources = SBoQueries(sbo).sources()
self.download_sources(sbo, sources)
def build_and_install(self):
""" Build the slackbuilds and install. """
for sbo in self.install_order:
if self.is_for_skipped(sbo):
self.build_the_script(self.configs.build_path, sbo)
if not self.mode == 'build':
@ -185,6 +165,7 @@ class Slackbuilds:
if self.flag_resolve_off not in self.flags:
self.logging_installed_dependencies(sbo)
else:
package = self.utils.is_installed(sbo)
version = self.utils.split_installed_pkg(package)[1]
self.view_message.view_skipping_packages(sbo, version)
@ -246,7 +227,7 @@ class Slackbuilds:
installation. """
version = SBoQueries(name).version()
pattern = f'{name}-{version}-*{self.configs.sbo_repo_tag}*'
pattern = f'{name}-{version}*{self.configs.sbo_repo_tag}*'
tmp = Path(self.configs.tmp_path)
packages = [file.name for file in tmp.glob(pattern)]
@ -282,7 +263,7 @@ class Slackbuilds:
checksums = SBoQueries(name).checksum()
for source, checksum in zip(sources, checksums):
down_source = Downloader(path, source)
down_source = Downloader(path, source, self.flags)
down_source.download()
md5sum = Md5sum(self.flags)
@ -290,7 +271,8 @@ class Slackbuilds:
def multi_process(self, command, filename, message):
""" Starting multiprocessing install/upgrade process. """
if self.configs.view_mode == 'new':
if self.configs.silent_mode and self.flag_no_silent not in self.flags:
done = f' {self.byellow} Done{self.endc}'
self.stderr = subprocess.DEVNULL
self.stdout = subprocess.DEVNULL
@ -336,3 +318,33 @@ class Slackbuilds:
""" Stop the process and print the error message. """
if self.output != 0:
raise SystemExit(f"\n{self.red}FAILED {self.output}:{self.endc} {self.process_message}.\n")
def choose_dependencies(self, dependencies: list):
""" Choose packages for install. """
height = 10
width = 70
list_height = 0
choices = []
title = ' Choose dependencies you want to install '
for package in dependencies:
status = True
repo_ver = SBoQueries(package).version()
installed = self.utils.is_installed(package)
if installed:
status = False
choices += [(package, repo_ver, status)]
text = f'There are {len(choices)} dependencies:'
code, tags = self.dialog.checklist(text, title, height, width,
list_height, choices, dependencies)
if not code:
return dependencies
os.system('clear')
return tags

View file

@ -40,10 +40,10 @@ class UpdateRepository:
slackbuilds_txt = f'{self.configs.sbo_repo_url}/{self.configs.sbo_txt}'
changelog_txt = f'{self.configs.sbo_repo_url}/{self.configs.sbo_chglog_txt}'
down_slackbuilds = Downloader(self.configs.sbo_repo_path, slackbuilds_txt)
down_slackbuilds = Downloader(self.configs.sbo_repo_path, slackbuilds_txt, self.flags)
down_slackbuilds.download()
down_changelog = Downloader(self.configs.sbo_repo_path, changelog_txt)
down_changelog = Downloader(self.configs.sbo_repo_path, changelog_txt, self.flags)
down_changelog.download()
data = CreateData()

View file

@ -25,23 +25,25 @@ class Utilities:
def is_installed(self, name: str) -> str:
""" Returns the installed package name. """
pattern = f'*{self.configs.sbo_repo_tag}'
installed = self.all_installed()
var_log_packages = Path(self.configs.log_packages)
packages = [file.name for file in var_log_packages.glob(pattern)]
for package in packages:
for package in installed:
pkg = self.split_installed_pkg(package)[0]
if pkg == name and pkg not in self.black.get():
if pkg == name:
return package
return ''
def all_installed(self):
def all_installed(self) -> list:
""" Return all installed SBo packages from /val/log/packages folder. """
installed = []
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)]
for file in var_log_packages.glob(pattern):
if self.split_installed_pkg(file.name) not in self.black.get():
installed.append(file.name)
return installed
@ -90,7 +92,7 @@ class Utilities:
time.strftime(f'[{self.cyan}%H:%M:%S{self.endc}]',
time.gmtime(elapsed_time)))
def is_repo_version_bigger(self, package):
def is_repo_version_bigger(self, package: str) -> bool:
""" Compare two versions. """
installed = self.is_installed(package)
if installed:

View file

@ -26,7 +26,7 @@ class Usage:
f' slpkg [{self.cyan}COMMAND{self.endc}] [-f, find, -w, view, -s, search, -e, dependees] <packages>\n'
f' slpkg [{self.cyan}COMMAND{self.endc}] [-t, tracking] <packages>\n'
f' slpkg [{self.yellow}OPTIONS{self.endc}] [--yes, --jobs, --resolve-off, --reinstall]\n'
f' slpkg [{self.yellow}OPTIONS{self.endc}] [--skip-installed, --full-reverse, --search]\n'
f' slpkg [{self.yellow}OPTIONS{self.endc}] [--skip-installed, --full-reverse, --search, --no-silent]\n'
" \nIf you need more information please try 'slpkg --help'.")
print(args)
@ -62,6 +62,7 @@ class Usage:
f' {self.yellow}--skip-installed{self.endc} Skip installed packages.\n'
f' {self.yellow}--full-reverse{self.endc} Full reverse dependency.\n'
f' {self.yellow}--search{self.endc} Search packages from the repository.\n'
f' {self.yellow}--no-silent{self.endc} Disable silent mode.\n'
'\n -h, --help Show this message and exit.\n'
' -v, --version Print version and exit.\n'
'\nEdit the configuration file in the /etc/slpkg/slpkg.toml \n'
@ -81,4 +82,3 @@ class Usage:
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, 9)
self.version_info = (4, 5, 0)
self.version = '{0}.{1}.{2}'.format(*self.version_info)
self.license = 'MIT License'
self.author = 'Dimitris Zlatanidis (dslackw)'