mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-02-07 08:46:21 +01:00
Merge branch 'develop' into 'master'
Develop See merge request dslackw/slpkg!110
This commit is contained in:
commit
4928df0d77
40 changed files with 1202 additions and 860 deletions
|
@ -1,3 +1,15 @@
|
|||
4.5.4 - 05/02/2023
|
||||
Updated:
|
||||
- Message for configs
|
||||
Added:
|
||||
- For concatenating the short options (Thanks to marav)
|
||||
- Help command for extra helping
|
||||
- Ponce repository
|
||||
- lftp downloader
|
||||
Fixed:
|
||||
- TOML decoder error for blacklist file
|
||||
- Fixed to compare versions for dependencies (Thanks to marav)
|
||||
|
||||
4.5.3 - 27/01/2023
|
||||
Added:
|
||||
- Short options
|
||||
|
|
31
README.rst
31
README.rst
|
@ -31,8 +31,8 @@ Install from the official third-party `SBo repository <https://slackbuilds.org/r
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
$ tar xvf slpkg-4.5.3.tar.gz
|
||||
$ cd slpkg-4.5.3
|
||||
$ tar xvf slpkg-4.5.4.tar.gz
|
||||
$ cd slpkg-4.5.4
|
||||
$ ./install.sh
|
||||
|
||||
Screenshots
|
||||
|
@ -57,7 +57,7 @@ Usage
|
|||
USAGE: slpkg [OPTIONS] [COMMAND] <packages>
|
||||
|
||||
DESCRIPTION:
|
||||
Packaging tool that interacts with the SBo repository.
|
||||
Package manager utility for Slackware.
|
||||
|
||||
COMMANDS:
|
||||
-u, update Update the package lists.
|
||||
|
@ -69,7 +69,7 @@ Usage
|
|||
-b, build <packages> Build only the packages.
|
||||
-i, install <packages> Build and install the packages.
|
||||
-d, download <packages> Download only the scripts and sources.
|
||||
-r, remove <packages> Remove installed packages.
|
||||
-R, remove <packages> Remove installed packages.
|
||||
-f, find <packages> Find installed packages.
|
||||
-w, view <packages> View packages from the repository.
|
||||
-s, search <packages> Search packages from the repository.
|
||||
|
@ -79,22 +79,23 @@ Usage
|
|||
OPTIONS:
|
||||
-y, --yes Answer Yes to all questions.
|
||||
-j, --jobs Set it for multicore systems.
|
||||
-ro, --resolve-off Turns off dependency resolving.
|
||||
-R, --reinstall Upgrade packages of the same version.
|
||||
-si, --skip-installed Skip installed packages.
|
||||
-fr, --full-reverse Full reverse dependency.
|
||||
-o, --resolve-off Turns off dependency resolving.
|
||||
-r, --reinstall Upgrade packages of the same version.
|
||||
-k, --skip-installed Skip installed packages.
|
||||
-E, --full-reverse Full reverse dependency.
|
||||
-S, --search Search packages from the repository.
|
||||
-ns, --no-silent Disable silent mode.
|
||||
-dir=, --directory=PATH Download files to a specific path.
|
||||
-pv, --pkg-version Print the repository package version.
|
||||
-fp=, --file-pattern=PATTERN Include specific installed files.
|
||||
-n, --no-silent Disable silent mode.
|
||||
-p, --pkg-version Print the repository package version.
|
||||
-z, --directory=PATH Download files to a specific path.
|
||||
-F, --file-pattern=PATTERN Include specific installed files.
|
||||
|
||||
-h, --help Show this message and exit.
|
||||
-v, --version Print version and exit.
|
||||
|
||||
Edit the configuration file in the /etc/slpkg/slpkg.toml
|
||||
or run 'slpkg configs'.
|
||||
If you need more information try to use slpkg manpage.
|
||||
If you need more information try to use slpkg manpage.
|
||||
Extra help for the commands, use: 'slpkg help <command>'.
|
||||
Edit the config file in the /etc/slpkg/slpkg.toml or 'slpkg configs'.
|
||||
|
||||
|
||||
|
||||
Configuration files
|
||||
|
|
|
@ -8,6 +8,7 @@ _slpkg_module()
|
|||
OPTS="
|
||||
--help
|
||||
--version
|
||||
help
|
||||
update
|
||||
upgrade
|
||||
check-updates
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[blacklist]
|
||||
|
||||
# Add packages and separate them with commas.
|
||||
packages = [
|
||||
"%README%"
|
||||
]
|
||||
# Example: ["package_1", "package_2", "package_3"].
|
||||
# The "%README%" is part of REQUIRES indicating that important
|
||||
# informationabout dependencies is available in the README file.
|
||||
packages = ["%README%"]
|
||||
|
|
|
@ -1,78 +1,100 @@
|
|||
[configs]
|
||||
[CONFIGS]
|
||||
# OS architecture by default.
|
||||
os_arch = "x86_64"
|
||||
OS_ARCH = "x86_64"
|
||||
|
||||
# Tmp path for slpkg.
|
||||
tmp_slpkg = "/tmp/slpkg"
|
||||
TMP_SLPKG = "/tmp/slpkg/"
|
||||
|
||||
# Path for building source and the script
|
||||
build_path = "/tmp/slpkg/build"
|
||||
# Path for building source and the script.
|
||||
BUILD_PATH = "/tmp/slpkg/build/"
|
||||
|
||||
# This path working only with the command download.
|
||||
download_only = "/tmp/slpkg"
|
||||
DOWNLOAD_ONLY_PATH = "/tmp/slpkg/"
|
||||
|
||||
# The path that the SLACKBUILDS.TXT file downloaded.
|
||||
sbo_repo_path = "/var/lib/slpkg/repository"
|
||||
SBO_REPO_PATH = "/var/lib/slpkg/repository/"
|
||||
|
||||
# The name of the database. Default name is 'database.slpkg'.
|
||||
database_name = "database.slpkg"
|
||||
DATABASE_NAME = "database.slpkg"
|
||||
|
||||
# Slackbuilds.org repository url.
|
||||
sbo_repo_url = "https://slackbuilds.org/slackbuilds/15.0"
|
||||
SBO_REPO_URL = "https://slackbuilds.org/slackbuilds/15.0/"
|
||||
|
||||
# The SLACKBUILDS.TXT repository file.
|
||||
sbo_txt = "SLACKBUILDS.TXT"
|
||||
SBO_TXT = "SLACKBUILDS.TXT"
|
||||
|
||||
# The ChangeLog.txt file.
|
||||
sbo_chglog_txt = "ChangeLog.txt"
|
||||
SBO_CHGLOG_TXT = "ChangeLog.txt"
|
||||
|
||||
# The sbo tar suffix.
|
||||
sbo_tar_suffix = ".tar.gz"
|
||||
SBO_TAR_SUFFIX = ".tar.gz"
|
||||
|
||||
# The sbo repository tag.
|
||||
sbo_repo_tag = "_SBo"
|
||||
SBO_REPO_TAG = "_SBo"
|
||||
|
||||
# Slackware install command. Instead you can
|
||||
# use 'installpkg', if you want.
|
||||
installpkg = "upgradepkg --install-new"
|
||||
# Slackware command for install packages, instead, you can use 'installpkg'.
|
||||
INSTALLPKG = "upgradepkg --install-new"
|
||||
|
||||
# Upgrade or reinstall slackware command.
|
||||
reinstall = "upgradepkg --reinstall"
|
||||
# Slackware command to reinstall packages.
|
||||
REINSTALL = "upgradepkg --reinstall"
|
||||
|
||||
# Slackware command to remove packages.
|
||||
removepkg = "removepkg"
|
||||
REMOVEPKG = "removepkg"
|
||||
|
||||
# Cli menu colors configs. Default is false. [true/false]
|
||||
colors = true
|
||||
# Cli menu colors configs. Default is true. [true/false].
|
||||
COLORS = true
|
||||
|
||||
# Dialog is a program that will let you to present
|
||||
# a variety of questions or display messages using
|
||||
# dialog boxes from a shell script.
|
||||
# Default is true. [true/false]
|
||||
dialog = true
|
||||
# Dialog is a program that will let you to presenta variety of questions
|
||||
# or display messages using dialog boxes from a shell script.
|
||||
# Default is true. [true/false].
|
||||
DIALOG = true
|
||||
|
||||
# You can choose downloader between wget and curl:
|
||||
# Default is wget.
|
||||
downloader = "wget"
|
||||
# You can choose downloader between wget and curl.
|
||||
# Ponce repository works only with 'lftp' downloader.
|
||||
# Default is wget. [wget/curl/lftp].
|
||||
DOWNLOADER = "wget"
|
||||
|
||||
# Wget downloader options.
|
||||
# -c, --continue: resume getting a partially-downloaded file.
|
||||
# -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 -q --show-progress"
|
||||
WGET_OPTIONS = "-c -N -q --show-progress"
|
||||
|
||||
# Curl downloader options.
|
||||
# Pass the options you want here.
|
||||
curl_options = ""
|
||||
CURL_OPTIONS = ""
|
||||
|
||||
# If silent mode is true,
|
||||
# do not print the commands as they are executed.
|
||||
# Default is true. [true/false]
|
||||
silent_mode = true
|
||||
# Lftp downloader options.
|
||||
# 'LFTP_MIRROR_OPTIONS' are used for the ponce repository to download files
|
||||
# from a remote directory, and 'LFTP_GET_OPTIONS' are used to download the sources.
|
||||
LFTP_MIRROR_OPTIONS = "-c mirror --delete-first --parallel=10"
|
||||
LFTP_GET_OPTIONS = "-c get -e"
|
||||
|
||||
# If silent mode is true, it does not print the commands as they are executed.
|
||||
# Default is true. [true/false].
|
||||
SILENT_MODE = true
|
||||
|
||||
# Choose ascii printable characters.
|
||||
# If true use the extended characters otherwise the basic ones.
|
||||
# Default is true. [true/false]
|
||||
ascii_characters = true
|
||||
# If true, it uses the extended characters, otherwise the basic ones.
|
||||
# Default is true. [true/false].
|
||||
ASCII_CHARACTERS = true
|
||||
|
||||
# Set the 'PONCE_REPO = true' and 'DOWNLOADER = lftp' to switch with
|
||||
# the ponce repository. Do not unset SBO_REPO_URL and SBO_TXT.
|
||||
# NOTE: Ponce repository works only with 'lftp' downloader.
|
||||
#########################################################################
|
||||
# This is not going to fully support this repository, since it does not #
|
||||
# provide its own SLACKBUILDS.TXT file. The only difference is that #
|
||||
# scripts are used from ponce repository and not from SBo repository. #
|
||||
# Slpkg is still going to use SLACKBUILDS.TXT and ChangeLog.txt from #
|
||||
# SBo repository and compare these with the Slackware -current #
|
||||
# ChangeLog.txt file for auto-add blacklisted packages that do not #
|
||||
# include in the ponce repository. Default is false. [true/false]. #
|
||||
#########################################################################
|
||||
PONCE_REPO = false
|
||||
PONCE_URL = "https://cgit.ponce.cc/slackbuilds/plain/"
|
||||
# Use a Slackware mirror for your country, get one from /etc/slackpkg/mirrors.
|
||||
SLACK_CURRENT_MIRROR = "https://mirrors.slackware.com/slackware/slackware64-current/"
|
||||
SLACK_CHGLOG_TXT = "ChangeLog.txt"
|
||||
SLACK_CHGLOG_PATH = "/var/lib/slpkg/repository/slack_current/"
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
.TH slpkg 1 "Orestiada, Grèce" "slpkg 4.5.3" dslackw
|
||||
.TH slpkg 1 "Orestiada, Grèce" "slpkg 4.5.4" dslackw
|
||||
.SH NOM
|
||||
.P
|
||||
.B slpkg - [OPTIONS] [COMMANDE] <packages>.
|
||||
.SH SYNOPSIS
|
||||
.P
|
||||
slpkg [-h|-v] [-u, update] [-U, upgrade] [-c, check-updates] [-g, configs] [-L, clean-logs] [-D, clean-tmp] [-b, build] [-i, install] [-d, download]
|
||||
[-r, remove] [-f, find] [-w, view] [-s, search] [-e, dependees] [-t, tracking] -y, --yes, -j, --jobs, -ro, --resolve-off,
|
||||
-R, --reinstall, -si, --skip-installed, -fr, --full-reverse, -S, --search, -ns, --no-silent, -dir=, --directory=PATH, -pv, --pkg-version, -fp=, --file-pattern=PATTERN
|
||||
[-R, remove] [-f, find] [-w, view] [-s, search] [-e, dependees] [-t, tracking] -y, --yes, -j, --jobs, -o, --resolve-off,
|
||||
-r, --reinstall, -k, --skip-installed, -E, --full-reverse, -S, --search, -n, --no-silent, -p, --pkg-version, -z, --directory=[PATH], -F, --file-pattern=[PATTERN]
|
||||
.SH DESCRIPTION
|
||||
.P
|
||||
\fBSlpkg\fP est un gestionnaire de paquets logiciels qui \fBinstalle\fP, \fBmet à jour\fP et \fBsupprime\fP les paquets pour les systèmes basés sur \fBSlackware\fP.
|
||||
|
@ -62,7 +62,7 @@ Construire et installer les paquets dans l'ordre adéquat et enregistre égaleme
|
|||
Télécharger les scripts et les sources des SlackBuilds sans les construire ni les installer.
|
||||
.RE
|
||||
.P
|
||||
.B -r, remove
|
||||
.B -R, remove
|
||||
.RS
|
||||
Supprimer 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.
|
||||
|
@ -96,35 +96,35 @@ Suivi des dépendances des paquets.
|
|||
.P
|
||||
-y, --yes
|
||||
.RS
|
||||
Répondre \fBOui\fP à toutes les questions. (à utiliser avec: update, upgrade, clean-logs, -b, build,
|
||||
-i, install, -d, download, -r, remove)
|
||||
Répondre \fBOui\fP à toutes les questions. (à utiliser avec: -u, update, -U, upgrade, -L, clean-logs, -b, build,
|
||||
-i, install, -d, download) (Non utilisée avec -R, remove, option supprimée pour des raisons de sécurité)
|
||||
.RE
|
||||
.P
|
||||
-j, --jobs
|
||||
.RS
|
||||
Accélération des scripts SlackBuild. Lorsque l'indicateur \fB--jobs\fP est activé, slpkg détecte automatiquement le nombre de
|
||||
de processeurs et le saisit dans la variable \fBMAKEFLAGS\fP. Certains SlackBuilds échouent lorsque \fBMAKEFLAGS\fP est déclaré ou que
|
||||
le nombre de processeurs (-j) est supérieur à 1. (à utiliser avec: upgrade, build, -i, install)
|
||||
le nombre de processeurs (-j) est supérieur à 1. (à utiliser avec: -U, upgrade, build, -i, install)
|
||||
.RE
|
||||
.P
|
||||
-ro, --resolve-off
|
||||
-o, --resolve-off
|
||||
.RS
|
||||
Désactiver la résolution des dépendances. (à utiliser avec: upgrade, build, -i, install)
|
||||
Désactiver la résolution des dépendances. (à utiliser avec: -U, upgrade, -b, build, -i, install)
|
||||
.RE
|
||||
.P
|
||||
-R, --reinstall
|
||||
-r, --reinstall
|
||||
.RS
|
||||
Utilisez cette option si vous voulez mettre à niveau tous les paquets même si la même version est déjà installée.
|
||||
Ne saute pas les paquets déjà installés. (à utiliser avec: upgrade, -i, install)
|
||||
Ne saute pas les paquets déjà installés. (à utiliser avec: -U, upgrade, -i, install)
|
||||
.RE
|
||||
.P
|
||||
-si, --skip-installed
|
||||
-k, --skip-installed
|
||||
.RS
|
||||
Utilisez cette option si vous voulez éviter de construire et de réinstaller des paquets.
|
||||
Remarque : Cette option n'affecte que les dépendances. (à utiliser avec: -i, install)
|
||||
.RE
|
||||
.P
|
||||
-fr, --full-reverse
|
||||
-E, --full-reverse
|
||||
.RS
|
||||
Dépendances inverses complètes. Ne fonctionne qu'avec la commande \fB-e, dependees\fP et montre aussi les \fBRequires\fP.
|
||||
(à utiliser avec: -e, dependees)
|
||||
|
@ -134,34 +134,34 @@ Dépendances inverses complètes. Ne fonctionne qu'avec la commande \fB-e, depen
|
|||
.RS
|
||||
Active l'utilitaire de dialogue pour rechercher des paquets dans le dépôt.
|
||||
Essayez par exemple : \fB`slpkg install python3 --search`\fP ou \fB`slpkg download python3 --search`\fP et ainsi de suite.
|
||||
(à utiliser avec: -b, build, -i, install, -d, download, -r, remove, -f, find, -w, view,
|
||||
(à utiliser avec: -b, build, -i, install, -d, download, -R, remove, -f, find, -w, view,
|
||||
-s, search, -e, dependees, -t, tracking)
|
||||
.RE
|
||||
.P
|
||||
-ns, --no-silent
|
||||
-n, --no-silent
|
||||
.RS
|
||||
Désactiver le mode silencieux s'il est activé dans le fichier de configuration. (à utiliser avec: update, upgrade, -b, build,
|
||||
-i, install, -d, download, -r, remove)
|
||||
Désactiver le mode silencieux s'il est activé dans le fichier de configuration. (à utiliser avec: -u, update, -U,upgrade, -b, build,
|
||||
-i, install, -d, download, -R, remove)
|
||||
.RE
|
||||
.P
|
||||
-dir=, --directory=PATH
|
||||
-z, --directory=[PATH]
|
||||
.RS
|
||||
Définir le répertoire où seront enregistrés les fichiers téléchargés. (à utiliser avec: -d, download)
|
||||
.RE
|
||||
.P
|
||||
-pv, --pkg-version
|
||||
-p, --pkg-version
|
||||
.RS
|
||||
Afficher la version du package du dépôt. (à utiliser avec: -e, dependees, -t, tracking, -w, view)
|
||||
.RE
|
||||
.P
|
||||
-fp=, --file-pattern=PATTERN
|
||||
-F, --file-pattern=[PATTERN]
|
||||
.RS
|
||||
Inclure des fichiers installés spécifiques avec un motif, comme \fB`slpkg -f 'python' --file-pattern='*'`\fP,
|
||||
et afficher tous les paquets installés qui incluent le nom 'python', et pas seulement les paquets SBo.
|
||||
Aussi, lorsque vous voulez installer et visualiser des paquets que vous avez installés à partir d'autres dépôts, essayez comme suit
|
||||
\fB`slpkg -i podman --file-pattern='*alien'`\fP ou si vous voulez vérifier et mettre à jour des paquets provenant d'autres dépôts
|
||||
\fB`slpkg upgrade --file-pattern='*alien'`\fP ou supprimez des paquets avec \fB`slpkg -r <packages> --file-pattern='*'`\fP.
|
||||
(à utiliser avec : upgrade, -i, install, -r, remove, -f, find)
|
||||
\fB`slpkg upgrade --file-pattern='*alien'`\fP ou supprimez des paquets avec \fB`slpkg -R <packages> --file-pattern='*'`\fP.
|
||||
(à utiliser avec : -U, upgrade, -i, install, -R, remove, -f, find)
|
||||
.RE
|
||||
.P
|
||||
-h | --help
|
||||
|
|
77
man/slpkg.1
77
man/slpkg.1
|
@ -1,12 +1,15 @@
|
|||
.TH slpkg 1 "Orestiada, Greece" "slpkg 4.5.3" dslackw
|
||||
.TH slpkg 1 "Orestiada, Greece" "slpkg 4.5.4" dslackw
|
||||
.SH NAME
|
||||
.P
|
||||
.B slpkg - [OPTIONS] [COMMAND] <packages>
|
||||
.SH SYNAPSES
|
||||
slpkg \- Package manager utility for Slackware.
|
||||
.SH SYNOPSIS
|
||||
.P
|
||||
.B slpkg \c
|
||||
.RI [ OPTIONS ] " COMMAND " [ PACKAGES... ]
|
||||
.P
|
||||
slpkg [-h|-v] [-u, update] [-U, upgrade] [-c, check-updates] [-g, configs] [-L, clean-logs] [-D, clean-tmp] [-b, build] [-i, install] [-d, download]
|
||||
[-r, remove] [-f, find] [-w, view] [-s, search] [-e, dependees] [-t, tracking] -y, --yes, -j, --jobs, -ro, --resolve-off,
|
||||
-ri, --reinstall, -si, --skip-installed, -fr, --full-reverse, -S, --search, -ns, --no-silent, -dir=, --directory=PATH, -pv, --pkg-version, -fp=, --file-pattern=PATTERN
|
||||
[-R, remove] [-f, find] [-w, view] [-s, search] [-e, dependees] [-t, tracking] -y, --yes, -j, --jobs, -o, --resolve-off,
|
||||
-r, --reinstall, -k, --skip-installed, -E, --full-reverse, -S, --search, -n, --no-silent, -p, --pkg-version, -z, --directory=[PATH], -F, --file-pattern=[PATTERN]
|
||||
.SH DESCRIPTION
|
||||
.P
|
||||
Slpkg is a software package manager that installs, updates, and removes packages on Slackware based systems.
|
||||
|
@ -54,28 +57,28 @@ Builds the Slackbuilds scripts and adds them to the /tmp directory.
|
|||
.P
|
||||
.B -i, install
|
||||
.RS
|
||||
Builds 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 the dependencies for removal.
|
||||
.RE
|
||||
.P
|
||||
.B -d, download
|
||||
.RS
|
||||
Download the SlackBuilds scripts and the sources without building or installing it.
|
||||
Download the SlackBuilds scripts and the sources without building or installing it.
|
||||
.RE
|
||||
.P
|
||||
.B -r, remove
|
||||
.B -R, remove
|
||||
.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.
|
||||
Slpkg looks at the 'sbo_repo_tag' configuration to find packages for removal by default, except if you are using --file-pattern option.
|
||||
.RE
|
||||
.P
|
||||
.B -f, find
|
||||
.RS
|
||||
Find sbo installed packages on your distribution.
|
||||
Find your installed packages on your system..
|
||||
.RE
|
||||
.P
|
||||
.B -w, view
|
||||
.RS
|
||||
View packages from the repository and get everything in your terminal.
|
||||
View information packages from the repository and get everything in your terminal.
|
||||
.RE
|
||||
.P
|
||||
.B -s, search
|
||||
|
@ -94,82 +97,82 @@ Tracking the packages dependencies.
|
|||
.RE
|
||||
.SH OPTIONS
|
||||
.P
|
||||
-y, --yes
|
||||
.B -y, --yes
|
||||
.RS
|
||||
Answer Yes to all questions. (to be used with: update, upgrade, clean-logs, -b, build,
|
||||
-i, install, -d, download, -r, remove)
|
||||
Answer Yes to all questions. (to be used with: -u, update, -U, upgrade, -L, clean-logs, -b, build,
|
||||
-i, install, -d, download,) (Not used with -R, remove, option removed for security reasons)
|
||||
.RE
|
||||
.P
|
||||
-j, --jobs
|
||||
.B -j, --jobs
|
||||
.RS
|
||||
Acceleration of SlackBuild scripts. When the --jobs flag is set, slpkg automatically detects the number
|
||||
of processors and enters it into the MAKEFLAGS variable. Some SlackBuilds fail when MAKEFLAGS is declared or
|
||||
the number of processors (-j) is greater than one. (to be used with: upgrade, build, -i, install)
|
||||
the number of processors (-j) is greater than one. (to be used with: -U, upgrade, -b, build, -i, install)
|
||||
.RE
|
||||
.P
|
||||
-ro, --resolve-off
|
||||
.B -o, --resolve-off
|
||||
.RS
|
||||
Turns off dependency resolving. (to be used with: upgrade, build, -i, install)
|
||||
Turns off dependency resolving. (to be used with: -U, upgrade, -b, build, -i, install)
|
||||
.RE
|
||||
.P
|
||||
-R, --reinstall
|
||||
.B -r, --reinstall
|
||||
.RS
|
||||
Use this option if you want to upgrade all packages even if the same version is already installed.
|
||||
Do not skip installed packages. (to be used with: upgrade, -i, install)
|
||||
.RE
|
||||
.P
|
||||
-si, --skip-installed
|
||||
.B -k, --skip-installed
|
||||
.RS
|
||||
This a helpful option if you want to avoid building and reinstalling packages.
|
||||
Note: This option affects only the dependencies. (to be used with: -i, install)
|
||||
.RE
|
||||
.P
|
||||
-fr, --full-reverse
|
||||
.B -E, --full-reverse
|
||||
.RS
|
||||
Full reverse dependency. Works only with -e, dependees command and show the requires too.
|
||||
(to be used with: -e, dependees)
|
||||
.RE
|
||||
.P
|
||||
-S, --search
|
||||
.B -S, --search
|
||||
.RS
|
||||
Enable the dialog utility to search packages from the repository.
|
||||
Example try: `slpkg install python3 --search` or `slpkg download python3 --search` and etc.
|
||||
(to be used with: -b, build, -i, install, -d, download, -r, remove, -f, find, -w, view,
|
||||
(to be used with: -b, build, -i, install, -d, download, -R, remove, -f, find, -w, view,
|
||||
-s, search, -e, dependees, -t, tracking)
|
||||
.RE
|
||||
.P
|
||||
-ns, --no-silent
|
||||
.B -n, --no-silent
|
||||
.RS
|
||||
Disable silent mode if it is enabled in the configuration file. (to be used with: update, upgrade, -b, build,
|
||||
-i, install, -d, download, -r, remove)
|
||||
Disable silent mode if it is enabled in the configuration file. (to be used with: -u, update, -U, upgrade, -b, build,
|
||||
-i, install, -d, download, -R, remove)
|
||||
.RE
|
||||
.P
|
||||
-dir=, --directory=PATH
|
||||
.RS
|
||||
The directory is the path where the files will be saved. (to be used with: -d, download)
|
||||
.RE
|
||||
.P
|
||||
-pv, --pkg-version
|
||||
.B -p, --pkg-version
|
||||
.RS
|
||||
Print the repository package version. (to be used with: -e, dependees, -t, tracking, -w, view)
|
||||
.RE
|
||||
.P
|
||||
-fp=, --file-pattern=PATTERN
|
||||
.BI "-z," "" " \-\-directory=[" PATH "]
|
||||
.RS
|
||||
The directory is the path where the files will be saved. (to be used with: -d, download)
|
||||
.RE
|
||||
.P
|
||||
.BI "-F," "" " \-\-file-pattern=[" PATTERN "]
|
||||
.RS
|
||||
Include specific installed files with a pattern, such as `slpkg -f 'python' --file-pattern='*'`,
|
||||
and prints all installed packages that include the name 'python', not only the SBo packages.
|
||||
Also when you want to install and view packages that you have installed from other repositories, try like
|
||||
`slpkg -i podman --file-pattern='*alien'` or if you want to check and upgrade packages from other repositories
|
||||
`slpkg upgrade --file-pattern='*alien'` or remove packages with `slpkg -r <packages> --file-pattern='*'`.
|
||||
(to be used with: upgrade, -i, install, -r, remove, -f, find)
|
||||
`slpkg upgrade --file-pattern='*alien'` or remove packages with `slpkg -R <packages> --file-pattern='*'`.
|
||||
(to be used with: -U, upgrade, -i, install, -R, remove, -f, find)
|
||||
.RE
|
||||
.P
|
||||
-h | --help
|
||||
.B -h | --help
|
||||
.RS
|
||||
Show help information and exit.
|
||||
.RE
|
||||
.P
|
||||
-v | --version
|
||||
.B -v | --version
|
||||
.RS
|
||||
Print version and exit.
|
||||
.RE
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[metadata]
|
||||
name = slpkg
|
||||
version = 4.5.3
|
||||
version = 4.5.4
|
||||
license_file = LICENSE
|
||||
author = Dimitris Zlatanidis
|
||||
author_email = d.zlatanidis@gmail.com
|
||||
|
|
|
@ -5,6 +5,8 @@ import tomli
|
|||
from pathlib import Path
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.models.models import PonceTable
|
||||
from slpkg.models.models import session as Session
|
||||
|
||||
|
||||
class Blacklist(Configs):
|
||||
|
@ -12,10 +14,23 @@ class Blacklist(Configs):
|
|||
|
||||
def __init__(self):
|
||||
super(Configs, self).__init__()
|
||||
self.session = Session
|
||||
|
||||
def get(self) -> list:
|
||||
def packages(self) -> list:
|
||||
""" Reads the blacklist file. """
|
||||
file = Path(self.etc_path, 'blacklist.toml')
|
||||
if file.is_file():
|
||||
with open(file, 'rb') as black:
|
||||
return tomli.load(black)['blacklist']['packages']
|
||||
toml_blacks, ponce_blacks = [], []
|
||||
file_toml = Path(self.etc_path, 'blacklist.toml')
|
||||
|
||||
if self.ponce_repo:
|
||||
sbos: list = self.session.query(PonceTable.name).all()
|
||||
ponce_blacks: list = [sbo[0] for sbo in sbos]
|
||||
|
||||
if file_toml.is_file():
|
||||
try:
|
||||
with open(file_toml, 'rb') as black:
|
||||
toml_blacks = tomli.load(black)['blacklist']['packages']
|
||||
except tomli.TOMLDecodeError as error:
|
||||
raise SystemExit(f"\nValueError: {error}: in the configuration file "
|
||||
"'/etc/slpkg/blacklist.toml'\n")
|
||||
|
||||
return toml_blacks + ponce_blacks
|
||||
|
|
|
@ -15,37 +15,38 @@ class CheckUpdates(Configs):
|
|||
|
||||
def __init__(self):
|
||||
super(Configs, self).__init__()
|
||||
self.color = self.colour()
|
||||
self.green = self.color['green']
|
||||
self.yellow = self.color['yellow']
|
||||
self.endc = self.color['endc']
|
||||
self.progress = ProgressBar()
|
||||
|
||||
self.color = self.colour()
|
||||
self.green: str = self.color['green']
|
||||
self.yellow: str = self.color['yellow']
|
||||
self.endc: str = self.color['endc']
|
||||
|
||||
def check(self) -> bool:
|
||||
""" Checks the ChangeLogs and returns True or False. """
|
||||
local_date = 0
|
||||
local_date: int = 0
|
||||
|
||||
local_chg_txt = Path(self.sbo_repo_path, self.sbo_chglog_txt)
|
||||
|
||||
http = urllib3.PoolManager()
|
||||
repo = http.request('GET', f'{self.sbo_repo_url}/{self.sbo_chglog_txt}')
|
||||
repo = http.request('GET', f'{self.sbo_repo_url}{self.sbo_chglog_txt}')
|
||||
|
||||
if local_chg_txt.is_file():
|
||||
local_date = int(os.stat(local_chg_txt).st_size)
|
||||
|
||||
repo_date = int(repo.headers['Content-Length'])
|
||||
repo_date: int = int(repo.headers['Content-Length'])
|
||||
|
||||
return repo_date != local_date
|
||||
|
||||
def view_message(self):
|
||||
def view_message(self) -> None:
|
||||
if self.check():
|
||||
print(f'\n\n{self.endc}There are new updates available!')
|
||||
else:
|
||||
print(f'\n\n{self.endc}No updated packages since the last check.')
|
||||
|
||||
def updates(self):
|
||||
def updates(self) -> None:
|
||||
""" Starting multiprocessing download process. """
|
||||
message = f'Checking for news in the Changelog.txt file...'
|
||||
message: str = f'Checking for news in the {self.sbo_chglog_txt} file...'
|
||||
|
||||
# Starting multiprocessing
|
||||
p1 = Process(target=self.view_message)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from pathlib import Path
|
||||
from typing import NoReturn
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.queries import SBoQueries
|
||||
|
@ -17,9 +18,9 @@ class Check(Configs, Utilities):
|
|||
super(Utilities, self).__init__()
|
||||
|
||||
@staticmethod
|
||||
def exists(slackbuilds: list):
|
||||
def exists(slackbuilds: list) -> NoReturn:
|
||||
""" Checking if the slackbuild exists in the repository. """
|
||||
not_packages = []
|
||||
not_packages: list = []
|
||||
|
||||
for sbo in slackbuilds:
|
||||
if not SBoQueries(sbo).slackbuild():
|
||||
|
@ -30,7 +31,7 @@ class Check(Configs, Utilities):
|
|||
'does not exists.\n')
|
||||
|
||||
@staticmethod
|
||||
def unsupported(slackbuilds: list):
|
||||
def unsupported(slackbuilds: list) -> NoReturn:
|
||||
""" Checking for unsupported slackbuilds. """
|
||||
for sbo in slackbuilds:
|
||||
sources = SBoQueries(sbo).sources()
|
||||
|
@ -43,9 +44,9 @@ class Check(Configs, Utilities):
|
|||
found, not_found = [], []
|
||||
|
||||
for sbo in slackbuilds:
|
||||
package = self.is_installed(sbo, file_pattern)
|
||||
package: str = self.is_installed(sbo, file_pattern)
|
||||
if package:
|
||||
pkg = self.split_installed_pkg(package)[0]
|
||||
pkg: str = self.split_installed_pkg(package)[0]
|
||||
found.append(pkg)
|
||||
else:
|
||||
not_found.append(sbo)
|
||||
|
@ -56,12 +57,12 @@ class Check(Configs, Utilities):
|
|||
|
||||
return found
|
||||
|
||||
def blacklist(self, slackbuilds: list):
|
||||
def blacklist(self, slackbuilds: list) -> NoReturn:
|
||||
""" Checking if the packages are blacklisted. """
|
||||
packages = []
|
||||
packages: list = []
|
||||
black = Blacklist()
|
||||
|
||||
for package in black.get():
|
||||
for package in black.packages():
|
||||
if package in slackbuilds:
|
||||
packages.append(package)
|
||||
|
||||
|
@ -71,7 +72,7 @@ class Check(Configs, Utilities):
|
|||
f'Please edit the blacklist.toml file in '
|
||||
f'{self.configs.etc_path} folder.\n')
|
||||
|
||||
def database(self):
|
||||
def database(self) -> NoReturn:
|
||||
""" Checking for empty table """
|
||||
db = Path(self.db_path, self.database_name)
|
||||
if not SBoQueries('').sbos() or not db.is_file():
|
||||
|
|
|
@ -14,10 +14,10 @@ class Md5sum:
|
|||
""" Checksum the sources. """
|
||||
|
||||
def __init__(self, flags: list):
|
||||
self.flags = flags
|
||||
self.flags: list = flags
|
||||
self.ascii = Ascii()
|
||||
|
||||
def check(self, path: Union[str, Path], source: str, checksum: str, name: str):
|
||||
def check(self, path: Union[str, Path], source: str, checksum: str, name: str) -> None:
|
||||
""" Checksum the source. """
|
||||
filename = unquote(source)
|
||||
source_file = Path(path, filename.split('/')[-1])
|
||||
|
|
|
@ -10,12 +10,12 @@ class CleanLogsDependencies:
|
|||
""" Cleans the logs from packages. """
|
||||
|
||||
def __init__(self, flags: list):
|
||||
self.flags = flags
|
||||
self.flags: list = flags
|
||||
self.session = Session
|
||||
|
||||
def clean(self):
|
||||
def clean(self) -> None:
|
||||
""" Deletes the log table from the database. """
|
||||
dependencies = self.session.query(
|
||||
dependencies: list = self.session.query(
|
||||
LogsDependencies.name, LogsDependencies.requires).all()
|
||||
|
||||
if dependencies:
|
||||
|
|
151
slpkg/configs.py
151
slpkg/configs.py
|
@ -27,132 +27,157 @@ class LoadConfigs:
|
|||
class Configs:
|
||||
""" Default configurations. """
|
||||
|
||||
# Programme name
|
||||
# Programme name.
|
||||
prog_name: str = 'slpkg'
|
||||
|
||||
# OS architecture by default
|
||||
os_arch: str = platform.machine()
|
||||
|
||||
# All necessary paths
|
||||
tmp_path: str = '/tmp'
|
||||
# All necessary paths.
|
||||
tmp_path: str = '/tmp/'
|
||||
tmp_slpkg: str = Path(tmp_path, prog_name)
|
||||
build_path: str = Path('tmp', prog_name, 'build')
|
||||
download_only: str = Path(tmp_slpkg, '')
|
||||
download_only_path: str = Path(tmp_slpkg, '')
|
||||
lib_path: str = Path('/var/lib/', prog_name)
|
||||
etc_path: str = Path('/etc/', prog_name)
|
||||
db_path: str = Path(lib_path, 'database')
|
||||
sbo_repo_path: str = Path(lib_path, 'repository')
|
||||
log_packages: str = Path('/var', 'log', 'packages')
|
||||
|
||||
# Database name
|
||||
# Database name.
|
||||
database_name: str = f'database.{prog_name}'
|
||||
|
||||
# SBo repository configs
|
||||
sbo_repo_url: str = 'https://slackbuilds.org/slackbuilds/15.0'
|
||||
# SBo repository configs.
|
||||
sbo_repo_url: str = 'https://slackbuilds.org/slackbuilds/15.0/'
|
||||
sbo_txt: str = 'SLACKBUILDS.TXT'
|
||||
sbo_chglog_txt: str = 'ChangeLog.txt'
|
||||
sbo_tar_suffix: str = '.tar.gz'
|
||||
sbo_repo_tag: str = '_SBo'
|
||||
|
||||
# Slackware commands
|
||||
# Ponce repo configs.
|
||||
ponce_repo: bool = False
|
||||
ponce_url: str = 'https://cgit.ponce.cc/slackbuilds/plain/'
|
||||
slack_current_mirror: str = 'https://mirrors.slackware.com/slackware/slackware64-current/'
|
||||
slack_chglog_txt: str = 'ChangeLog.txt'
|
||||
slack_chglog_path: str = Path('/var/lib/slpkg/repository/slack_current/')
|
||||
|
||||
# Slackware commands.
|
||||
installpkg: str = 'upgradepkg --install-new'
|
||||
reinstall: str = 'upgradepkg --reinstall'
|
||||
removepkg: str = 'removepkg'
|
||||
|
||||
# Cli menu colors configs
|
||||
colors: str = True
|
||||
# Cli menu colors configs.
|
||||
colors: bool = True
|
||||
|
||||
# Dialog utility
|
||||
dialog: str = True
|
||||
# Dialog utility.
|
||||
dialog: bool = True
|
||||
|
||||
# Downloader command. Wget and curl.
|
||||
downloader = 'wget'
|
||||
downloader: str = 'wget'
|
||||
|
||||
# Wget options
|
||||
wget_options = '-c -N -q --show-progress'
|
||||
# Wget options.
|
||||
wget_options: str = '-c -N -q --show-progress'
|
||||
|
||||
# Curl options
|
||||
curl_options = ''
|
||||
# Curl options.
|
||||
curl_options: str = ''
|
||||
|
||||
# Choose the view mode
|
||||
silent_mode: str = True
|
||||
# Lftp options'
|
||||
lftp_mirror_options: str = '-c mirror --delete-first --parallel=10'
|
||||
lftp_get_options: str = '-c get -e'
|
||||
|
||||
# Choose the view mode.
|
||||
silent_mode: bool = True
|
||||
|
||||
# Choose ascii characters.
|
||||
# If True use extended else basic.
|
||||
ascii_characters = True
|
||||
ascii_characters: bool = True
|
||||
|
||||
# Load configurations from the file.
|
||||
load = LoadConfigs()
|
||||
configs = load.file(etc_path, prog_name)
|
||||
config = configs['configs']
|
||||
|
||||
if config:
|
||||
if configs:
|
||||
try:
|
||||
# OS architecture by default
|
||||
os_arch: str = config['os_arch']
|
||||
config = configs['CONFIGS']
|
||||
|
||||
# All necessary paths
|
||||
tmp_slpkg: str = config['tmp_slpkg']
|
||||
build_path: str = config['build_path']
|
||||
download_only: str = config['download_only']
|
||||
sbo_repo_path: str = config['sbo_repo_path']
|
||||
# OS architecture by default.
|
||||
os_arch: str = config['OS_ARCH']
|
||||
|
||||
# Database name
|
||||
database_name: str = config['database_name']
|
||||
# All necessary paths.
|
||||
tmp_slpkg: str = config['TMP_SLPKG']
|
||||
build_path: str = config['BUILD_PATH']
|
||||
download_only_path: str = config['DOWNLOAD_ONLY_PATH']
|
||||
sbo_repo_path: str = config['SBO_REPO_PATH']
|
||||
|
||||
# SBo repository details
|
||||
sbo_repo_url: str = config['sbo_repo_url']
|
||||
sbo_txt: str = config['sbo_txt']
|
||||
sbo_chglog_txt: str = config['sbo_chglog_txt']
|
||||
sbo_tar_suffix: str = config['sbo_tar_suffix']
|
||||
sbo_repo_tag: str = config['sbo_repo_tag']
|
||||
# Database name.
|
||||
database_name: str = config['DATABASE_NAME']
|
||||
|
||||
# Slackware commands
|
||||
installpkg: str = config['installpkg']
|
||||
reinstall: str = config['reinstall']
|
||||
removepkg: str = config['removepkg']
|
||||
# SBo repository details.
|
||||
sbo_repo_url: str = config['SBO_REPO_URL']
|
||||
sbo_txt: str = config['SBO_TXT']
|
||||
sbo_chglog_txt: str = config['SBO_CHGLOG_TXT']
|
||||
sbo_tar_suffix: str = config['SBO_TAR_SUFFIX']
|
||||
sbo_repo_tag: str = config['SBO_REPO_TAG']
|
||||
|
||||
# Cli menu colors configs
|
||||
colors: str = config['colors']
|
||||
# Ponce repo configs.
|
||||
ponce_repo: bool = config['PONCE_REPO']
|
||||
ponce_url: str = config['PONCE_URL']
|
||||
slack_current_mirror: str = config['SLACK_CURRENT_MIRROR']
|
||||
slack_chglog_txt: str = config['SLACK_CHGLOG_TXT']
|
||||
slack_chglog_path: str = config['SLACK_CHGLOG_PATH']
|
||||
|
||||
# Dialog utility
|
||||
dialog: str = config['dialog']
|
||||
# Slackware commands.
|
||||
installpkg: str = config['INSTALLPKG']
|
||||
reinstall: str = config['REINSTALL']
|
||||
removepkg: str = config['REMOVEPKG']
|
||||
|
||||
# Downloader command
|
||||
downloader: str = config['downloader']
|
||||
# Cli menu colors configs.
|
||||
colors: bool = config['COLORS']
|
||||
|
||||
# Wget options
|
||||
wget_options: str = config['wget_options']
|
||||
# Dialog utility.
|
||||
dialog: str = config['DIALOG']
|
||||
|
||||
# Curl options
|
||||
curl_options: str = config['curl_options']
|
||||
# Downloader command.
|
||||
downloader: str = config['DOWNLOADER']
|
||||
|
||||
# Choose the view mode
|
||||
silent_mode: str = config['silent_mode']
|
||||
# Wget options.
|
||||
wget_options: str = config['WGET_OPTIONS']
|
||||
|
||||
# Curl options.
|
||||
curl_options: str = config['CURL_OPTIONS']
|
||||
|
||||
# Lftp options.
|
||||
lftp_mirror_options: str = config['LFTP_MIRROR_OPTIONS']
|
||||
lftp_get_options: str = config['LFTP_GET_OPTIONS']
|
||||
|
||||
# Choose the view mode.
|
||||
silent_mode: bool = config['SILENT_MODE']
|
||||
|
||||
# Choose ascii characters. Extended or basic.
|
||||
ascii_characters: str = config['ascii_characters']
|
||||
ascii_characters: bool = config['ASCII_CHARACTERS']
|
||||
|
||||
except KeyError as error:
|
||||
raise SystemExit(f"\nKeyError: {error}: in the configuration file '/etc/slpkg/slpkg.toml'.\n"
|
||||
f"\nIf you have upgraded the '{prog_name}' probably you need to run:\n"
|
||||
f"mv {etc_path}/{prog_name}.toml.new {etc_path}/{prog_name}.toml")
|
||||
f"mv {etc_path}/{prog_name}.toml.new {etc_path}/{prog_name}.toml\n")
|
||||
|
||||
# Creating the paths if not exists
|
||||
paths = [tmp_slpkg,
|
||||
build_path,
|
||||
download_only,
|
||||
sbo_repo_path,
|
||||
lib_path,
|
||||
etc_path,
|
||||
db_path]
|
||||
paths = [
|
||||
tmp_slpkg,
|
||||
build_path,
|
||||
download_only_path,
|
||||
sbo_repo_path,
|
||||
lib_path,
|
||||
etc_path,
|
||||
db_path,
|
||||
slack_chglog_path]
|
||||
|
||||
for path in paths:
|
||||
if not os.path.isdir(path):
|
||||
os.makedirs(path)
|
||||
|
||||
@classmethod
|
||||
def colour(cls):
|
||||
def colour(cls) -> dict:
|
||||
color = {
|
||||
'bold': '',
|
||||
'red': '',
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
from slpkg.queries import SBoQueries
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.models.models import SBoTable
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.models.models import SBoTable, PonceTable
|
||||
from slpkg.models.models import session as Session
|
||||
|
||||
|
||||
|
@ -14,10 +18,13 @@ class CreateData(Configs):
|
|||
|
||||
def __init__(self):
|
||||
super(Configs, self).__init__()
|
||||
self.session = Session
|
||||
|
||||
def insert_sbo_table(self):
|
||||
""" Install the data. """
|
||||
self.session = Session
|
||||
self.utils = Utilities()
|
||||
self.query = SBoQueries('')
|
||||
|
||||
def insert_sbo_table(self) -> None:
|
||||
""" Install the data for SBo repository. """
|
||||
sbo_tags = [
|
||||
'SLACKBUILD NAME:',
|
||||
'SLACKBUILD LOCATION:',
|
||||
|
@ -31,9 +38,9 @@ class CreateData(Configs):
|
|||
'SLACKBUILD SHORT DESCRIPTION:'
|
||||
]
|
||||
path = Path(self.sbo_repo_path, self.sbo_txt)
|
||||
sbo_file = self.read_file(path)
|
||||
sbo_file: list = self.read_file(path)
|
||||
|
||||
cache = [] # init cache
|
||||
cache: list = [] # init cache
|
||||
|
||||
print('\nCreating the database... ', end='', flush=True)
|
||||
|
||||
|
@ -45,19 +52,50 @@ class CreateData(Configs):
|
|||
cache.append(line)
|
||||
|
||||
if (i % 11) == 0:
|
||||
data = SBoTable(name=cache[0], location=cache[1].split('/')[1],
|
||||
files=cache[2], version=cache[3],
|
||||
download=cache[4], download64=cache[5],
|
||||
md5sum=cache[6], md5sum64=cache[7],
|
||||
requires=cache[8], short_description=cache[9])
|
||||
data: str = SBoTable(name=cache[0], location=cache[1].split('/')[1],
|
||||
files=cache[2], version=cache[3],
|
||||
download=cache[4], download64=cache[5],
|
||||
md5sum=cache[6], md5sum64=cache[7],
|
||||
requires=cache[8], short_description=cache[9])
|
||||
self.session.add(data)
|
||||
|
||||
cache = [] # reset cache after 11 lines
|
||||
cache: list = [] # reset cache after 11 lines
|
||||
|
||||
print('Done')
|
||||
|
||||
self.session.commit()
|
||||
|
||||
def insert_ponce_blacklist_packages(self) -> None:
|
||||
""" Install data for ponce repository. """
|
||||
sbos: list = self.query.sbos()
|
||||
|
||||
path = Path(self.slack_chglog_path, self.slack_chglog_txt)
|
||||
slack_chglog: list = self.read_file(path)
|
||||
|
||||
for line in slack_chglog:
|
||||
|
||||
# Clean the line from white spaces.
|
||||
line: str = line.strip()
|
||||
|
||||
if re.findall('Added[.]', line):
|
||||
|
||||
# Clean the line.
|
||||
line = re.sub(r'Added.|.txz:', '', line)
|
||||
pkg: str = line.split('/')[-1]
|
||||
|
||||
# Split and get the name only.
|
||||
name = self.utils.split_installed_pkg(pkg)[0]
|
||||
|
||||
if name in sbos:
|
||||
data = PonceTable(name=name)
|
||||
self.session.add(data)
|
||||
|
||||
# Stop the date when the Slackware 15.0 released.
|
||||
if line == 'Wed Feb 2 22:22:22 UTC 2022':
|
||||
break
|
||||
|
||||
self.session.commit()
|
||||
|
||||
@staticmethod
|
||||
def read_file(file: Union[str, Path]) -> list:
|
||||
""" Reads the text file. """
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from typing import Generator
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.views.ascii import Ascii
|
||||
from slpkg.queries import SBoQueries
|
||||
|
@ -15,23 +16,25 @@ class Dependees(Configs, Utilities):
|
|||
def __init__(self, packages: list, flags: list):
|
||||
super(Configs, self).__init__()
|
||||
super(Utilities, self).__init__()
|
||||
self.packages = packages
|
||||
self.flags = flags
|
||||
self.flag_full_reverse = ['-fr', '--full-reverse']
|
||||
self.flag_pkg_version = ['-pv', '--pkg-version']
|
||||
self.packages: list = packages
|
||||
self.flags: list = flags
|
||||
|
||||
self.session = Session
|
||||
self.ascii = Ascii()
|
||||
self.llc = self.ascii.lower_left_corner
|
||||
self.hl = self.ascii.horizontal_line
|
||||
self.var = self.ascii.vertical_and_right
|
||||
self.color = self.colour()
|
||||
self.bold = self.color['bold']
|
||||
self.violet = self.color['violet']
|
||||
self.cyan = self.color['cyan']
|
||||
self.grey = self.color['grey']
|
||||
self.yellow = self.color['yellow']
|
||||
self.byellow = f'{self.bold}{self.yellow}'
|
||||
self.endc = self.color['endc']
|
||||
|
||||
self.llc: str = self.ascii.lower_left_corner
|
||||
self.hl: str = self.ascii.horizontal_line
|
||||
self.var: str = self.ascii.vertical_and_right
|
||||
self.bold: str = self.color['bold']
|
||||
self.violet: str = self.color['violet']
|
||||
self.cyan: str = self.color['cyan']
|
||||
self.grey: str = self.color['grey']
|
||||
self.yellow: str = self.color['yellow']
|
||||
self.byellow: str = f'{self.bold}{self.yellow}'
|
||||
self.endc: str = self.color['endc']
|
||||
self.flag_full_reverse: list = ['-E', '--full-reverse']
|
||||
self.flag_pkg_version: list = ['-p', '--pkg-version']
|
||||
|
||||
def slackbuilds(self):
|
||||
""" Collecting the dependees. """
|
||||
|
@ -39,12 +42,12 @@ class Dependees(Configs, Utilities):
|
|||
f"packages that dependees on '{', '.join([p for p in self.packages])}':\n")
|
||||
|
||||
for pkg in self.packages:
|
||||
dependees = list(self.find_requires(pkg))
|
||||
dependees: list = list(self.find_requires(pkg))
|
||||
|
||||
package = f'{self.byellow}{pkg}{self.endc}'
|
||||
package: str = f'{self.byellow}{pkg}{self.endc}'
|
||||
|
||||
if self.is_option(self.flag_pkg_version, self.flags):
|
||||
package = f'{self.byellow}{pkg}-{SBoQueries(pkg).version()}{self.endc}'
|
||||
package: str = f'{self.byellow}{pkg}-{SBoQueries(pkg).version()}{self.endc}'
|
||||
|
||||
print(package)
|
||||
|
||||
|
@ -53,13 +56,13 @@ class Dependees(Configs, Utilities):
|
|||
if not dependees:
|
||||
print(f'{self.cyan} No dependees{self.endc}')
|
||||
|
||||
sp = ' ' * 4
|
||||
sp: str = ' ' * 4
|
||||
for i, dep in enumerate(dependees, start=1):
|
||||
dependency = f'{self.cyan}{dep[0]}{self.endc}'
|
||||
dependency: str = f'{self.cyan}{dep[0]}{self.endc}'
|
||||
|
||||
if self.is_option(self.flag_pkg_version, self.flags):
|
||||
dependency = (f'{self.cyan}{dep[0]}{self.endc}-{self.yellow}'
|
||||
f'{SBoQueries(dep[0]).version()}{self.endc}')
|
||||
dependency: str = (f'{self.cyan}{dep[0]}{self.endc}-{self.yellow}'
|
||||
f'{SBoQueries(dep[0]).version()}{self.endc}')
|
||||
|
||||
if i == 1:
|
||||
print(f' {dependency}')
|
||||
|
@ -74,9 +77,9 @@ class Dependees(Configs, Utilities):
|
|||
|
||||
print(f'\n{self.grey}{len(dependees)} dependees for {pkg}{self.endc}\n')
|
||||
|
||||
def find_requires(self, sbo):
|
||||
def find_requires(self, sbo: str) -> Generator[str, None, None]:
|
||||
""" Find requires that slackbuild dependees. """
|
||||
requires = self.session.query(SBoTable.name, SBoTable.requires).all()
|
||||
requires: list = self.session.query(SBoTable.name, SBoTable.requires).all()
|
||||
for req in requires:
|
||||
if [r for r in req[1].split() if r == sbo]:
|
||||
yield req
|
||||
|
|
|
@ -9,7 +9,7 @@ class Requires:
|
|||
the right order to install. """
|
||||
|
||||
def __init__(self, name: str):
|
||||
self.name = name
|
||||
self.name: str = name
|
||||
|
||||
def resolve(self) -> list:
|
||||
""" Resolve the dependencies. """
|
||||
|
|
|
@ -17,6 +17,7 @@ class DialogBox(Configs):
|
|||
|
||||
def __init__(self):
|
||||
super(Configs).__init__()
|
||||
|
||||
self.d = Dialog(dialog="dialog")
|
||||
self.d.set_background_title(f'{self.prog_name} {Version().version} - Software Package Manager')
|
||||
|
||||
|
@ -27,8 +28,8 @@ class DialogBox(Configs):
|
|||
code, tags = self.d.checklist(text, title=title, height=height, width=width,
|
||||
list_height=list_height, choices=choices)
|
||||
else:
|
||||
code = False
|
||||
tags = packages
|
||||
code: bool = False
|
||||
tags: list = packages
|
||||
|
||||
return code, tags
|
||||
|
||||
|
@ -38,8 +39,8 @@ class DialogBox(Configs):
|
|||
code, tags = self.d.mixedform(text=text, title=title, elements=elements,
|
||||
height=height, width=width, help_button=True)
|
||||
else:
|
||||
code = False
|
||||
tags = elements
|
||||
code: bool = False
|
||||
tags: list = elements
|
||||
|
||||
return code, tags
|
||||
|
||||
|
|
|
@ -17,26 +17,28 @@ class Download(Configs, Utilities):
|
|||
def __init__(self, directory: str, flags: list):
|
||||
super(Configs, self).__init__()
|
||||
super(Utilities, self).__init__()
|
||||
self.flags = flags
|
||||
self.directory = directory
|
||||
self.flag_directory = ['-dir=', '--directory=']
|
||||
self.flags: list = flags
|
||||
self.directory: str = directory
|
||||
|
||||
self.session = Session
|
||||
|
||||
def packages(self, slackbuilds: list):
|
||||
self.flag_directory: list = ['-z=', '--directory=']
|
||||
|
||||
def packages(self, slackbuilds: list) -> None:
|
||||
""" Download the package only. """
|
||||
view = ViewMessage(self.flags)
|
||||
view.download_packages(slackbuilds, self.directory)
|
||||
view.question()
|
||||
|
||||
download_path = self.download_only
|
||||
download_path: str = self.download_only_path
|
||||
if self.is_option(self.flag_directory, self.flags):
|
||||
download_path = self.directory
|
||||
download_path: str = self.directory
|
||||
|
||||
start = time.time()
|
||||
start: float = time.time()
|
||||
for sbo in slackbuilds:
|
||||
file = f'{sbo}{self.sbo_tar_suffix}'
|
||||
location = SBoQueries(sbo).location()
|
||||
url = f'{self.sbo_repo_url}/{location}/{file}'
|
||||
file: str = f'{sbo}{self.sbo_tar_suffix}'
|
||||
location: str = SBoQueries(sbo).location()
|
||||
url: str = f'{self.sbo_repo_url}{location}/{file}'
|
||||
|
||||
down_sbo = Downloader(download_path, url, self.flags)
|
||||
down_sbo.download()
|
||||
|
@ -46,5 +48,5 @@ class Download(Configs, Utilities):
|
|||
down_source = Downloader(download_path, source, self.flags)
|
||||
down_source.download()
|
||||
|
||||
elapsed_time = time.time() - start
|
||||
elapsed_time: float = time.time() - start
|
||||
self.finished_time(elapsed_time)
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
from urllib.parse import unquote
|
||||
from typing import Union, NoReturn
|
||||
from multiprocessing import Process
|
||||
|
||||
from slpkg.configs import Configs
|
||||
|
@ -18,26 +19,29 @@ class Downloader(Configs, Utilities):
|
|||
def __init__(self, path: Union[str, Path], url: str, flags: list):
|
||||
super(Configs, self).__init__()
|
||||
super(Utilities, self).__init__()
|
||||
self.path = path
|
||||
self.url = url
|
||||
self.flags = flags
|
||||
self.flag_no_silent = ['-ns', '--no-silent']
|
||||
self.filename = url.split('/')[-1]
|
||||
self.path: str = path
|
||||
self.url: str = url
|
||||
self.flags: list = flags
|
||||
|
||||
self.color = self.colour()
|
||||
self.bold = self.color['bold']
|
||||
self.green = self.color['green']
|
||||
self.yellow = self.color['yellow']
|
||||
self.red = self.color['red']
|
||||
self.blue = self.color['blue']
|
||||
self.endc = self.color['endc']
|
||||
self.byellow = f'{self.bold}{self.yellow}'
|
||||
self.bred = f'{self.bold}{self.red}'
|
||||
self.progress = ProgressBar()
|
||||
self.output = 0
|
||||
|
||||
self.output: int = 0
|
||||
self.stderr = None
|
||||
self.stdout = None
|
||||
|
||||
def wget(self):
|
||||
self.filename: str = url.split('/')[-1]
|
||||
self.bold: str = self.color['bold']
|
||||
self.green: str = self.color['green']
|
||||
self.yellow = self.color['yellow']
|
||||
self.red: str = self.color['red']
|
||||
self.blue: str = self.color['blue']
|
||||
self.endc: str = self.color['endc']
|
||||
self.byellow: str = f'{self.bold}{self.yellow}'
|
||||
self.bred: str = f'{self.bold}{self.red}'
|
||||
self.flag_no_silent: list = ['-n', '--no-silent']
|
||||
|
||||
def transfer_tools(self) -> NoReturn:
|
||||
""" Wget downloader. """
|
||||
if self.downloader == 'wget':
|
||||
self.output = subprocess.call(f'{self.downloader} {self.wget_options} --directory-prefix={self.path} '
|
||||
|
@ -46,33 +50,50 @@ class Downloader(Configs, Utilities):
|
|||
self.output = subprocess.call(f'{self.downloader} {self.curl_options} "{self.url}" --output '
|
||||
f'{self.path}/{self.filename}', shell=True, stderr=self.stderr,
|
||||
stdout=self.stdout)
|
||||
elif self.downloader == 'lftp':
|
||||
|
||||
if self.ponce_repo and 'ponce' in self.url:
|
||||
# Download files from a directory.
|
||||
self.output = subprocess.call(f"lftp {self.lftp_mirror_options} {self.url} {self.path}",
|
||||
shell=True, stderr=self.stderr, stdout=self.stdout)
|
||||
# Create /path/name.Slackbuild
|
||||
slackbuild = Path(self.path, f'{str(self.path).split("/")[-1]}.SlackBuild')
|
||||
|
||||
if slackbuild.is_file():
|
||||
os.chmod(slackbuild, 0o775)
|
||||
else:
|
||||
# Download binaries files and the sources.
|
||||
self.output = subprocess.call(f"lftp {self.lftp_get_options} {self.url} -o {self.path}",
|
||||
shell=True, stderr=self.stderr, stdout=self.stdout)
|
||||
|
||||
else:
|
||||
raise SystemExit(f"{self.red}Error:{self.endc} Downloader '{self.downloader}' not supported.\n")
|
||||
|
||||
if self.output != 0:
|
||||
raise SystemExit(self.output)
|
||||
|
||||
def check_if_downloaded(self):
|
||||
def check_if_downloaded(self) -> NoReturn:
|
||||
""" Checks if the file downloaded. """
|
||||
url = unquote(self.url)
|
||||
file = url.split('/')[-1]
|
||||
path_file = Path(self.path, file)
|
||||
if not path_file.exists():
|
||||
raise SystemExit(f"\n{self.red}FAILED {self.output}:{self.endc} '{self.blue}{self.url}{self.endc}' "
|
||||
f"to download.\n")
|
||||
if 'ponce' not in self.url:
|
||||
url: str = unquote(self.url)
|
||||
file: str = url.split('/')[-1]
|
||||
path_file = Path(self.path, file)
|
||||
if not path_file.exists():
|
||||
raise SystemExit(f"\n{self.red}FAILED {self.output}:{self.endc} '{self.blue}{self.url}{self.endc}' "
|
||||
f"to download.\n")
|
||||
|
||||
def download(self):
|
||||
def download(self) -> None:
|
||||
""" Starting multiprocessing download process. """
|
||||
if self.silent_mode and not self.is_option(self.flag_no_silent, self.flags):
|
||||
|
||||
done = f' {self.byellow} Done{self.endc}'
|
||||
done: str = f' {self.byellow} Done{self.endc}'
|
||||
self.stderr = subprocess.DEVNULL
|
||||
self.stdout = subprocess.DEVNULL
|
||||
|
||||
message = f'[{self.green}Downloading{self.endc}]'
|
||||
message: str = f'[{self.green}Downloading{self.endc}]'
|
||||
|
||||
# Starting multiprocessing
|
||||
p1 = Process(target=self.wget)
|
||||
p1 = Process(target=self.transfer_tools)
|
||||
p2 = Process(target=self.progress.bar, args=(message, self.filename))
|
||||
|
||||
p1.start()
|
||||
|
@ -97,6 +118,9 @@ class Downloader(Configs, Utilities):
|
|||
# Restore the terminal cursor
|
||||
print('\x1b[?25h', self.endc)
|
||||
else:
|
||||
self.wget()
|
||||
# if self.ponce_repo and 'ponce' in self.url:
|
||||
# self.lftp()
|
||||
# else:
|
||||
self.transfer_tools()
|
||||
|
||||
self.check_if_downloaded()
|
||||
|
|
|
@ -12,18 +12,19 @@ class FindInstalled(Configs, Utilities):
|
|||
super(Configs, self).__init__()
|
||||
super(Utilities, self).__init__()
|
||||
self.color = self.colour()
|
||||
self.yellow = self.color['yellow']
|
||||
self.cyan = self.color['cyan']
|
||||
self.green = self.color['green']
|
||||
self.blue = self.color['blue']
|
||||
self.endc = self.color['endc']
|
||||
self.grey = self.color['grey']
|
||||
|
||||
def find(self, packages: list, pattern):
|
||||
self.yellow: str = self.color['yellow']
|
||||
self.cyan: str = self.color['cyan']
|
||||
self.green: str = self.color['green']
|
||||
self.blue: str = self.color['blue']
|
||||
self.endc: str = self.color['endc']
|
||||
self.grey: str = self.color['grey']
|
||||
|
||||
def find(self, packages: list, pattern: str) -> None:
|
||||
""" Find the packages. """
|
||||
matching = []
|
||||
matching: list = []
|
||||
|
||||
installed = self.all_installed(pattern)
|
||||
installed: list = self.all_installed(pattern)
|
||||
|
||||
print(f'The list below shows the installed packages '
|
||||
f'that contains \'{", ".join([p for p in packages])}\' files:\n')
|
||||
|
@ -34,14 +35,11 @@ class FindInstalled(Configs, Utilities):
|
|||
matching.append(package)
|
||||
self.matched(matching)
|
||||
|
||||
def matched(self, matching: list):
|
||||
def matched(self, matching: list) -> None:
|
||||
""" Print the matched packages. """
|
||||
if matching:
|
||||
for package in matching:
|
||||
# pkg = self.split_installed_pkg(package)
|
||||
print(f'{self.cyan}{package}{self.endc}')
|
||||
# print(f'{self.cyan}{pkg[0]}{self.endc}-{self.yellow}{pkg[1]}{self.endc}-{pkg[2]}-'
|
||||
# f'{self.blue}{pkg[3]}{self.endc}_{pkg[4]}')
|
||||
print(f'\n{self.grey}Total found {len(matching)} packages.{self.endc}')
|
||||
else:
|
||||
print('\nDoes not match any package.\n')
|
||||
|
|
|
@ -12,49 +12,52 @@ from slpkg.dialog_box import DialogBox
|
|||
class FormConfigs(Configs):
|
||||
|
||||
def __init__(self):
|
||||
self.orig_configs = None
|
||||
super(Configs).__init__()
|
||||
self.load_configs = LoadConfigs()
|
||||
self.dialogbox = DialogBox()
|
||||
|
||||
self.orig_configs = None
|
||||
self.config_file = Path(self.etc_path, f'{self.prog_name}.toml')
|
||||
|
||||
def edit(self):
|
||||
def edit(self) -> None:
|
||||
""" Read and write the configuration file. """
|
||||
elements = []
|
||||
elements: list = []
|
||||
config_file = Path(self.etc_path, f'{self.prog_name}.toml')
|
||||
|
||||
if config_file.is_file():
|
||||
# Load the toml config file.
|
||||
configs = self.load_configs.file(self.etc_path, self.prog_name)
|
||||
configs: dict = self.load_configs.file(self.etc_path, self.prog_name)
|
||||
|
||||
# Creating the elements for the dialog form.
|
||||
for i, (key, value) in enumerate(configs['configs'].items(), start=1):
|
||||
for i, (key, value) in enumerate(configs['CONFIGS'].items(), start=1):
|
||||
if value is True:
|
||||
value = 'true'
|
||||
value: str = 'true'
|
||||
elif value is False:
|
||||
value = 'false'
|
||||
value: str = 'false'
|
||||
elements += [
|
||||
(key, i, 1, value, i, 17, 47, 200, '0x0')
|
||||
(key, i, 1, value, i, 21, 47, 200, '0x0')
|
||||
]
|
||||
|
||||
height = 28
|
||||
width = 70
|
||||
text = f'Edit the configuration file: {config_file}'
|
||||
title = ' Configuration File '
|
||||
height: int = 35
|
||||
width: int = 74
|
||||
text: str = f'Edit the configuration file: {config_file}'
|
||||
title: str = ' Configuration File '
|
||||
|
||||
code, tags = self.dialogbox.mixedform(text, title, elements, height, width)
|
||||
|
||||
os.system('clear')
|
||||
|
||||
check = self.check_configs(configs, tags)
|
||||
if code == 'help':
|
||||
self.help()
|
||||
|
||||
check: bool = self.check_configs(configs, tags)
|
||||
|
||||
if code == 'ok' and check:
|
||||
self.write_file(configs, tags)
|
||||
elif not check:
|
||||
self.edit()
|
||||
elif code == 'help':
|
||||
self.help()
|
||||
|
||||
def help(self):
|
||||
def help(self) -> None:
|
||||
""" Load the configuration file on a text box. """
|
||||
self.read_configs()
|
||||
self.dialogbox.textbox(str(self.config_file), 40, 60)
|
||||
|
@ -62,31 +65,38 @@ class FormConfigs(Configs):
|
|||
|
||||
def check_configs(self, configs: dict, tags: list) -> bool:
|
||||
""" Check for true of false values. """
|
||||
for key, value in zip(configs['configs'].keys(), tags):
|
||||
for key, value in zip(configs['CONFIGS'].keys(), tags):
|
||||
|
||||
if key in ['colors', 'dialog', 'silent_mode', 'ascii_characters'] and value not in ['true', 'false']:
|
||||
if (key in ['COLORS', 'DIALOG', 'SILENT_MODE', 'ASCII_CHARACTERS', 'PONCE_REPO'] and
|
||||
value not in ['true', 'false']):
|
||||
self.dialogbox.msgbox(f"\nError value for {key}. It must be 'true' or 'false'\n", height=7, width=60)
|
||||
return False
|
||||
|
||||
if key in ['downloader'] and value not in ['wget', 'curl']:
|
||||
if key in ['DOWNLOADER'] and value not in ['wget', 'curl', 'lftp']:
|
||||
self.dialogbox.msgbox(f"\nError value for {key}. It must be 'wget' or 'curl'\n", height=7, width=60)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def read_configs(self):
|
||||
def read_configs(self) -> None:
|
||||
""" Read the original config file. """
|
||||
with open(self.config_file, 'r') as toml_file:
|
||||
self.orig_configs = toml_file.readlines()
|
||||
|
||||
def write_file(self, configs: dict, tags: list):
|
||||
def write_file(self, configs: dict, tags: list) -> None:
|
||||
""" Write the new values to the config file. """
|
||||
self.read_configs()
|
||||
|
||||
with open(self.config_file, 'w') as patch_toml:
|
||||
|
||||
for line in self.orig_configs:
|
||||
for key, value in zip(configs['configs'].keys(), tags):
|
||||
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 =', 'silent_mode =', 'ascii_characters =')):
|
||||
|
||||
if line.lstrip().startswith(('COLORS =', 'DIALOG =', 'SILENT_MODE =',
|
||||
'ASCII_CHARACTERS =', 'PONCE_REPO =')):
|
||||
line = line.replace('"', '')
|
||||
|
||||
patch_toml.write(line)
|
||||
|
|
376
slpkg/main.py
376
slpkg/main.py
|
@ -3,6 +3,7 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
from typing import NoReturn
|
||||
|
||||
from slpkg.checks import Check
|
||||
from slpkg.upgrade import Upgrade
|
||||
|
@ -18,6 +19,7 @@ from slpkg.views.version import Version
|
|||
from slpkg.download_only import Download
|
||||
from slpkg.slackbuild import Slackbuilds
|
||||
from slpkg.form_configs import FormConfigs
|
||||
from slpkg.views.help_commands import Help
|
||||
from slpkg.check_updates import CheckUpdates
|
||||
from slpkg.find_installed import FindInstalled
|
||||
from slpkg.views.view_package import ViewPackage
|
||||
|
@ -29,10 +31,10 @@ from slpkg.update_repository import UpdateRepository
|
|||
class Argparse(Configs):
|
||||
|
||||
def __init__(self, args: list):
|
||||
self.args = args
|
||||
self.flags = []
|
||||
self.args: list = args
|
||||
self.flags: list = []
|
||||
self.directory = None
|
||||
self.file_pattern = f'*{self.sbo_repo_tag}'
|
||||
self.file_pattern: str = f'*{self.sbo_repo_tag}'
|
||||
self.dialogbox = DialogBox()
|
||||
self.utils = Utilities()
|
||||
self.usage = Usage()
|
||||
|
@ -44,95 +46,62 @@ class Argparse(Configs):
|
|||
|
||||
self.check.blacklist(self.args)
|
||||
|
||||
self.flag_yes = '--yes'
|
||||
self.flag_short_yes = '-y'
|
||||
self.flag_jobs = '--jobs'
|
||||
self.flag_short_jobs = '-j'
|
||||
self.flag_resolve_off = '--resolve-off'
|
||||
self.flag_short_resolve_off = '-ro'
|
||||
self.flag_reinstall = '--reinstall'
|
||||
self.flag_short_reinstall = '-R'
|
||||
self.flag_skip_installed = '--skip-installed'
|
||||
self.flag_short_skip_installed = '-si'
|
||||
self.flag_full_reverse = '--full-reverse'
|
||||
self.flag_short_full_reverse = '-fr'
|
||||
self.flag_search = '--search'
|
||||
self.flag_short_search = '-S'
|
||||
self.flag_no_silent = '--no-silent'
|
||||
self.flag_short_no_silent = '-ns'
|
||||
self.flag_directory = '--directory='
|
||||
self.flag_short_directory = '-dir='
|
||||
self.flag_pkg_version = '--pkg-version'
|
||||
self.flag_short_pkg_version = '-pv'
|
||||
self.flag_file_pattern = '--file-pattern='
|
||||
self.flag_short_file_pattern = '-fp='
|
||||
self.flag_yes: str = '--yes'
|
||||
self.flag_short_yes: str = '-y'
|
||||
self.flag_jobs: str = '--jobs'
|
||||
self.flag_short_jobs: str = '-j'
|
||||
self.flag_resolve_off: str = '--resolve-off'
|
||||
self.flag_short_resolve_off: str = '-o'
|
||||
self.flag_reinstall: str = '--reinstall'
|
||||
self.flag_short_reinstall: str = '-r'
|
||||
self.flag_skip_installed: str = '--skip-installed'
|
||||
self.flag_short_skip_installed: str = '-k'
|
||||
self.flag_full_reverse: str = '--full-reverse'
|
||||
self.flag_short_full_reverse: str = '-E'
|
||||
self.flag_search: str = '--search'
|
||||
self.flag_short_search: str = '-S'
|
||||
self.flag_no_silent: str = '--no-silent'
|
||||
self.flag_short_no_silent: str = '-n'
|
||||
self.flag_pkg_version: str = '--pkg-version'
|
||||
self.flag_short_pkg_version: str = '-p'
|
||||
self.flag_directory: str = '--directory='
|
||||
self.flag_short_directory: str = '-z='
|
||||
self.flag_file_pattern: str = '--file-pattern='
|
||||
self.flag_short_file_pattern: str = '-F='
|
||||
|
||||
self.flag_searches = [self.flag_short_search, self.flag_search]
|
||||
self.flag_searches: list = [self.flag_short_search, self.flag_search]
|
||||
|
||||
self.is_dialog_enabled()
|
||||
|
||||
self.options = [self.flag_yes,
|
||||
self.flag_short_yes,
|
||||
self.flag_jobs,
|
||||
self.flag_short_jobs,
|
||||
self.flag_resolve_off,
|
||||
self.flag_short_resolve_off,
|
||||
self.flag_reinstall,
|
||||
self.flag_short_reinstall,
|
||||
self.flag_skip_installed,
|
||||
self.flag_short_skip_installed,
|
||||
self.flag_full_reverse,
|
||||
self.flag_short_full_reverse,
|
||||
self.flag_search,
|
||||
self.flag_short_search,
|
||||
self.flag_no_silent,
|
||||
self.flag_short_no_silent,
|
||||
self.flag_directory,
|
||||
self.flag_short_directory,
|
||||
self.flag_pkg_version,
|
||||
self.flag_short_pkg_version,
|
||||
self.flag_file_pattern,
|
||||
self.flag_short_file_pattern]
|
||||
|
||||
self.remove_flags()
|
||||
|
||||
def remove_flags(self):
|
||||
""" Remove flags from args. """
|
||||
for arg in self.args:
|
||||
if arg.startswith(self.flag_directory):
|
||||
self.directory = arg.split('=')[1]
|
||||
self.args[self.args.index(arg)] = self.flag_directory
|
||||
|
||||
if arg.startswith(self.flag_short_directory):
|
||||
self.directory = arg.split('=')[1]
|
||||
self.args[self.args.index(arg)] = self.flag_directory
|
||||
|
||||
if arg.startswith(self.flag_file_pattern):
|
||||
self.file_pattern = arg.split('=')[1]
|
||||
self.args[self.args.index(arg)] = self.flag_file_pattern
|
||||
|
||||
if arg.startswith(self.flag_short_file_pattern):
|
||||
self.file_pattern = arg.split('=')[1]
|
||||
self.args[self.args.index(arg)] = self.flag_file_pattern
|
||||
|
||||
for opt in self.options:
|
||||
if opt in self.args:
|
||||
self.args.remove(opt)
|
||||
self.flags.append(opt)
|
||||
|
||||
def is_dialog_enabled(self):
|
||||
""" Checking if the dialog box is enabled. """
|
||||
if (not self.dialogbox and self.utils.is_option(self.flag_searches, self.flags) or
|
||||
not self.dialogbox.dialog and 'configs' in self.args):
|
||||
raise SystemExit("\nError: You should enable the dialog "
|
||||
"in the '/etc/slpkg/' folder.\n")
|
||||
|
||||
def check_for_flags(self, command: str):
|
||||
""" Check for correct flags. """
|
||||
|
||||
commands = {
|
||||
self.options: list = [
|
||||
self.flag_yes,
|
||||
self.flag_short_yes,
|
||||
self.flag_jobs,
|
||||
self.flag_short_jobs,
|
||||
self.flag_resolve_off,
|
||||
self.flag_short_resolve_off,
|
||||
self.flag_reinstall,
|
||||
self.flag_short_reinstall,
|
||||
self.flag_skip_installed,
|
||||
self.flag_short_skip_installed,
|
||||
self.flag_full_reverse,
|
||||
self.flag_short_full_reverse,
|
||||
self.flag_search,
|
||||
self.flag_short_search,
|
||||
self.flag_no_silent,
|
||||
self.flag_short_no_silent,
|
||||
self.flag_directory,
|
||||
self.flag_short_directory,
|
||||
self.flag_pkg_version,
|
||||
self.flag_short_pkg_version,
|
||||
self.flag_file_pattern,
|
||||
self.flag_short_file_pattern
|
||||
]
|
||||
|
||||
self.commands: dict = {
|
||||
'--help': [],
|
||||
'--version': [],
|
||||
'help': [],
|
||||
'update': [
|
||||
self.flag_yes,
|
||||
self.flag_short_yes,
|
||||
|
@ -141,6 +110,7 @@ class Argparse(Configs):
|
|||
],
|
||||
'upgrade': [
|
||||
self.flag_yes,
|
||||
self.flag_short_yes,
|
||||
self.flag_jobs,
|
||||
self.flag_short_jobs,
|
||||
self.flag_resolve_off,
|
||||
|
@ -197,8 +167,6 @@ class Argparse(Configs):
|
|||
self.flag_short_directory
|
||||
],
|
||||
'remove': [
|
||||
self.flag_yes,
|
||||
self.flag_short_yes,
|
||||
self.flag_resolve_off,
|
||||
self.flag_short_resolve_off,
|
||||
self.flag_search,
|
||||
|
@ -240,52 +208,116 @@ class Argparse(Configs):
|
|||
]
|
||||
}
|
||||
|
||||
commands['-h'] = commands['--help']
|
||||
commands['-v'] = commands['--version']
|
||||
commands['-u'] = commands['update']
|
||||
commands['-U'] = commands['upgrade']
|
||||
commands['-c'] = commands['check-updates']
|
||||
commands['-g'] = commands['configs']
|
||||
commands['-L'] = commands['clean-logs']
|
||||
commands['-D'] = commands['clean-tmp']
|
||||
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']
|
||||
self.commands['-h']: dict = self.commands['--help']
|
||||
self.commands['-v']: dict = self.commands['--version']
|
||||
self.commands['-u']: dict = self.commands['update']
|
||||
self.commands['-U']: dict = self.commands['upgrade']
|
||||
self.commands['-c']: dict = self.commands['check-updates']
|
||||
self.commands['-g']: dict = self.commands['configs']
|
||||
self.commands['-L']: dict = self.commands['clean-logs']
|
||||
self.commands['-D']: dict = self.commands['clean-tmp']
|
||||
self.commands['-b']: dict = self.commands['build']
|
||||
self.commands['-i']: dict = self.commands['install']
|
||||
self.commands['-d']: dict = self.commands['download']
|
||||
self.commands['-R']: dict = self.commands['remove']
|
||||
self.commands['-f']: dict = self.commands['find']
|
||||
self.commands['-w']: dict = self.commands['view']
|
||||
self.commands['-s']: dict = self.commands['search']
|
||||
self.commands['-e']: dict = self.commands['dependees']
|
||||
self.commands['-t']: dict = self.commands['tracking']
|
||||
|
||||
flags = commands[command]
|
||||
self.split_options()
|
||||
self.split_options_from_args()
|
||||
self.move_options()
|
||||
|
||||
def split_options(self) -> None:
|
||||
""" Split options and commands, like: -iyjR
|
||||
|
||||
slpkg -jyiR package
|
||||
|
||||
Puts the command first and options after.
|
||||
Result: ['-i', '-y', '-j', '-R']
|
||||
"""
|
||||
for args in self.args:
|
||||
if args[0] == '-' and args[:2] != '--' and len(args) >= 3 and '=' not in args:
|
||||
self.args.remove(args)
|
||||
|
||||
for opt in list(map(lambda item: f'-{item}', [arg for arg in list(args[1:])])):
|
||||
if opt in self.commands.keys():
|
||||
self.args.insert(0, opt)
|
||||
continue
|
||||
|
||||
self.args.append(opt)
|
||||
|
||||
def split_options_from_args(self) -> None:
|
||||
""" Split options from arguments.
|
||||
|
||||
slpkg -f package --file-pattern='*'
|
||||
|
||||
Splits the option ['--file-pattern'] and ['*']
|
||||
"""
|
||||
for arg in self.args:
|
||||
if arg.startswith(self.flag_directory):
|
||||
self.directory = arg.split('=')[1]
|
||||
self.args[self.args.index(arg)]: list = self.flag_directory
|
||||
|
||||
if arg.startswith(self.flag_short_directory):
|
||||
self.directory = arg.split('=')[1]
|
||||
self.args[self.args.index(arg)]: list = self.flag_short_directory
|
||||
|
||||
if arg.startswith(self.flag_file_pattern):
|
||||
self.file_pattern = arg.split('=')[1]
|
||||
self.args[self.args.index(arg)]: list = self.flag_file_pattern
|
||||
|
||||
if arg.startswith(self.flag_short_file_pattern):
|
||||
self.file_pattern = arg.split('=')[1]
|
||||
self.args[self.args.index(arg)]: list = self.flag_short_file_pattern
|
||||
|
||||
def move_options(self) -> None:
|
||||
""" Move options to the flags and removes from the arguments. """
|
||||
for opt in self.options:
|
||||
if opt in self.args:
|
||||
self.args.remove(opt)
|
||||
self.flags.append(opt)
|
||||
|
||||
def is_dialog_enabled(self) -> NoReturn:
|
||||
""" Checking if the dialog box is enabled. """
|
||||
if (not self.dialogbox and self.utils.is_option(self.flag_searches, self.flags) or
|
||||
not self.dialogbox.dialog and 'configs' in self.args):
|
||||
|
||||
raise SystemExit("\nError: You should enable the dialog "
|
||||
"in the '/etc/slpkg/' folder.\n")
|
||||
|
||||
def check_for_flags(self, command: str) -> None:
|
||||
""" Check for correct flags. """
|
||||
flags: list = self.commands[command]
|
||||
|
||||
for opt in self.flags:
|
||||
if opt not in flags and opt not in ['--help', '--version']:
|
||||
self.usage.error_for_options(flags)
|
||||
self.usage.error_for_options(command, flags)
|
||||
|
||||
def choose_packages(self, packages: list, method: str):
|
||||
def choose_packages(self, packages: list, method: str) -> list:
|
||||
""" Choose packages with dialog utility and -S, --search flag. """
|
||||
height = 10
|
||||
width = 70
|
||||
list_height = 0
|
||||
choices = []
|
||||
title = f' Choose packages you want to {method} '
|
||||
repo_packages = SBoQueries('').sbos()
|
||||
height: int = 10
|
||||
width: int = 70
|
||||
list_height: int = 0
|
||||
choices: list = []
|
||||
title: str = f' Choose packages you want to {method} '
|
||||
repo_packages: list = SBoQueries('').sbos()
|
||||
|
||||
# Grab all the installed packages
|
||||
pattern = f'*{self.sbo_repo_tag}'
|
||||
pattern: str = f'*{self.sbo_repo_tag}'
|
||||
|
||||
if method == 'find' and self.file_pattern:
|
||||
pattern = self.file_pattern
|
||||
pattern: str = self.file_pattern
|
||||
|
||||
installed = self.utils.all_installed(pattern)
|
||||
installed: list = self.utils.all_installed(pattern)
|
||||
|
||||
if method in ['remove', 'find']:
|
||||
|
||||
for package in installed:
|
||||
name = self.utils.split_installed_pkg(package)[0]
|
||||
version = self.utils.split_installed_pkg(package)[1]
|
||||
name: str = self.utils.split_installed_pkg(package)[0]
|
||||
version: str = self.utils.split_installed_pkg(package)[1]
|
||||
|
||||
for pkg in packages:
|
||||
if pkg in name:
|
||||
|
@ -296,9 +328,9 @@ class Argparse(Configs):
|
|||
for package in repo_packages:
|
||||
|
||||
if pkg == package:
|
||||
repo_ver = SBoQueries(package).version()
|
||||
inst_pkg = self.utils.is_installed(package, self.file_pattern)
|
||||
inst_ver = self.utils.split_installed_pkg(inst_pkg)[1]
|
||||
repo_ver: str = SBoQueries(package).version()
|
||||
inst_pkg: str = self.utils.is_installed(package, self.file_pattern)
|
||||
inst_ver: str = self.utils.split_installed_pkg(inst_pkg)[1]
|
||||
choices += [(package, f'{inst_ver} -> {repo_ver}', True)]
|
||||
|
||||
else:
|
||||
|
@ -312,7 +344,7 @@ class Argparse(Configs):
|
|||
if not choices:
|
||||
return packages
|
||||
|
||||
text = f'There are {len(choices)} packages:'
|
||||
text: str = f'There are {len(choices)} packages:'
|
||||
|
||||
code, tags = self.dialogbox.checklist(text, title, height, width,
|
||||
list_height, choices, packages)
|
||||
|
@ -327,35 +359,35 @@ class Argparse(Configs):
|
|||
|
||||
return tags
|
||||
|
||||
def help(self):
|
||||
def help(self) -> None:
|
||||
if len(self.args) == 1:
|
||||
self.usage.help(0)
|
||||
self.usage.help(1)
|
||||
|
||||
def version(self):
|
||||
def version(self) -> NoReturn:
|
||||
if len(self.args) == 1:
|
||||
version = Version()
|
||||
version.view()
|
||||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
||||
def update(self):
|
||||
def update(self) -> NoReturn:
|
||||
if len(self.args) == 1:
|
||||
update = UpdateRepository(self.flags)
|
||||
update.repository()
|
||||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
||||
def upgrade(self):
|
||||
def upgrade(self) -> NoReturn:
|
||||
command = Argparse.upgrade.__name__
|
||||
|
||||
if len(self.args) == 1:
|
||||
self.check.database()
|
||||
|
||||
upgrade = Upgrade(self.file_pattern)
|
||||
packages = list(upgrade.packages())
|
||||
packages: list = list(upgrade.packages())
|
||||
|
||||
packages = self.choose_packages(packages, command)
|
||||
packages: list = self.choose_packages(packages, command)
|
||||
|
||||
if not packages:
|
||||
print('\nEverything is up-to-date.\n')
|
||||
|
@ -366,7 +398,7 @@ class Argparse(Configs):
|
|||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
||||
def check_updates(self):
|
||||
def check_updates(self) -> NoReturn:
|
||||
if len(self.args) == 1:
|
||||
self.check.database()
|
||||
|
||||
|
@ -375,13 +407,13 @@ class Argparse(Configs):
|
|||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
||||
def edit_configs(self):
|
||||
def edit_configs(self) -> NoReturn:
|
||||
if len(self.args) == 1:
|
||||
self.form_configs.edit()
|
||||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
||||
def clean_logs(self):
|
||||
def clean_logs(self) -> NoReturn:
|
||||
if len(self.args) == 1:
|
||||
self.check.database()
|
||||
|
||||
|
@ -390,25 +422,24 @@ class Argparse(Configs):
|
|||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
||||
def clean_tmp(self):
|
||||
def clean_tmp(self) -> NoReturn:
|
||||
if len(self.args) == 1:
|
||||
path = self.tmp_path
|
||||
tmp_slpkg = self.tmp_slpkg
|
||||
folder = self.prog_name
|
||||
|
||||
self.utils.remove_folder_if_exists(path, folder)
|
||||
self.utils.create_folder(tmp_slpkg, 'build')
|
||||
self.utils.remove_folder_if_exists(path=self.tmp_path, folder=self.prog_name)
|
||||
self.utils.create_folder(path=self.tmp_slpkg, folder='build')
|
||||
|
||||
raise SystemExit()
|
||||
|
||||
self.usage.help(1)
|
||||
|
||||
def build(self):
|
||||
def build(self) -> NoReturn:
|
||||
command = Argparse.build.__name__
|
||||
|
||||
if len(self.args) >= 2:
|
||||
packages = list(set(self.args[1:]))
|
||||
packages: list = list(set(self.args[1:]))
|
||||
|
||||
if self.utils.is_option(self.flag_searches, self.flags):
|
||||
packages = self.choose_packages(packages, command)
|
||||
packages: list = self.choose_packages(packages, command)
|
||||
|
||||
self.check.database()
|
||||
self.check.exists(packages)
|
||||
|
@ -419,14 +450,14 @@ class Argparse(Configs):
|
|||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
||||
def install(self):
|
||||
def install(self) -> NoReturn:
|
||||
command = Argparse.install.__name__
|
||||
|
||||
if len(self.args) >= 2:
|
||||
packages = list(set(self.args[1:]))
|
||||
packages: list = list(set(self.args[1:]))
|
||||
|
||||
if self.utils.is_option(self.flag_searches, self.flags):
|
||||
packages = self.choose_packages(packages, command)
|
||||
packages: list = self.choose_packages(packages, command)
|
||||
|
||||
self.check.database()
|
||||
self.check.exists(packages)
|
||||
|
@ -437,14 +468,14 @@ class Argparse(Configs):
|
|||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
||||
def download(self):
|
||||
def download(self) -> NoReturn:
|
||||
command = Argparse.download.__name__
|
||||
|
||||
if len(self.args) >= 2:
|
||||
packages = list(set(self.args[1:]))
|
||||
packages: list = list(set(self.args[1:]))
|
||||
|
||||
if self.utils.is_option(self.flag_searches, self.flags):
|
||||
packages = self.choose_packages(packages, command)
|
||||
packages: list = self.choose_packages(packages, command)
|
||||
|
||||
self.check.database()
|
||||
self.check.exists(packages)
|
||||
|
@ -453,31 +484,31 @@ class Argparse(Configs):
|
|||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
||||
def remove(self):
|
||||
def remove(self) -> NoReturn:
|
||||
command = Argparse.remove.__name__
|
||||
|
||||
if len(self.args) >= 2:
|
||||
packages = list(set(self.args[1:]))
|
||||
packages: list = list(set(self.args[1:]))
|
||||
|
||||
if self.utils.is_option(self.flag_searches, self.flags):
|
||||
packages = self.choose_packages(packages, command)
|
||||
packages: list = self.choose_packages(packages, command)
|
||||
|
||||
self.check.database()
|
||||
packages = self.check.installed(packages, self.file_pattern)
|
||||
packages: list = self.check.installed(packages, self.file_pattern)
|
||||
|
||||
remove = RemovePackages(packages, self.flags, self.file_pattern)
|
||||
remove.remove()
|
||||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
||||
def find(self):
|
||||
def find(self) -> NoReturn:
|
||||
command = Argparse.find.__name__
|
||||
|
||||
if len(self.args) >= 2:
|
||||
packages = list(set(self.args[1:]))
|
||||
packages: list = list(set(self.args[1:]))
|
||||
|
||||
if self.utils.is_option(self.flag_searches, self.flags):
|
||||
packages = self.choose_packages(packages, command)
|
||||
packages: list = self.choose_packages(packages, command)
|
||||
|
||||
self.check.database()
|
||||
|
||||
|
@ -486,14 +517,14 @@ class Argparse(Configs):
|
|||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
||||
def view(self):
|
||||
def view(self) -> NoReturn:
|
||||
command = Argparse.view.__name__
|
||||
|
||||
if len(self.args) >= 2:
|
||||
packages = list(set(self.args[1:]))
|
||||
packages: list = list(set(self.args[1:]))
|
||||
|
||||
if self.utils.is_option(self.flag_searches, self.flags):
|
||||
packages = self.choose_packages(packages, command)
|
||||
packages: list = self.choose_packages(packages, command)
|
||||
|
||||
self.check.database()
|
||||
self.check.exists(packages)
|
||||
|
@ -503,14 +534,14 @@ class Argparse(Configs):
|
|||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
||||
def search(self):
|
||||
def search(self) -> NoReturn:
|
||||
command = Argparse.search.__name__
|
||||
|
||||
if len(self.args) >= 2:
|
||||
packages = list(set(self.args[1:]))
|
||||
packages: list = list(set(self.args[1:]))
|
||||
|
||||
if self.utils.is_option(self.flag_searches, self.flags):
|
||||
packages = self.choose_packages(packages, command)
|
||||
packages: list = self.choose_packages(packages, command)
|
||||
|
||||
self.check.database()
|
||||
|
||||
|
@ -519,14 +550,14 @@ class Argparse(Configs):
|
|||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
||||
def dependees(self):
|
||||
def dependees(self) -> NoReturn:
|
||||
command = Argparse.dependees.__name__
|
||||
|
||||
if len(self.args) >= 2:
|
||||
packages = list(set(self.args[1:]))
|
||||
packages: list = list(set(self.args[1:]))
|
||||
|
||||
if self.utils.is_option(self.flag_searches, self.flags):
|
||||
packages = self.choose_packages(packages, command)
|
||||
packages: list = self.choose_packages(packages, command)
|
||||
|
||||
self.check.database()
|
||||
self.check.exists(packages)
|
||||
|
@ -536,14 +567,14 @@ class Argparse(Configs):
|
|||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
||||
def tracking(self):
|
||||
def tracking(self) -> NoReturn:
|
||||
command = Argparse.tracking.__name__
|
||||
|
||||
if len(self.args) >= 2:
|
||||
packages = list(set(self.args[1:]))
|
||||
packages: list = list(set(self.args[1:]))
|
||||
|
||||
if self.utils.is_option(self.flag_searches, self.flags):
|
||||
packages = self.choose_packages(packages, command)
|
||||
packages: list = self.choose_packages(packages, command)
|
||||
|
||||
self.check.database()
|
||||
self.check.exists(packages)
|
||||
|
@ -553,6 +584,14 @@ class Argparse(Configs):
|
|||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
||||
def help_for_commands(self) -> None:
|
||||
""" Extra help information for commands. """
|
||||
if len(self.args) == 2:
|
||||
flags = self.commands[self.args[1]]
|
||||
Help(self.args[1], flags).view()
|
||||
else:
|
||||
self.usage.help(1)
|
||||
|
||||
|
||||
def main():
|
||||
args = sys.argv
|
||||
|
@ -560,11 +599,12 @@ def main():
|
|||
|
||||
argparse = Argparse(args)
|
||||
|
||||
arguments = {
|
||||
arguments: dict = {
|
||||
'-h': argparse.help,
|
||||
'--help': argparse.help,
|
||||
'-v': argparse.version,
|
||||
'--version': argparse.version,
|
||||
'help': argparse.help_for_commands,
|
||||
'update': argparse.update,
|
||||
'-u': argparse.update,
|
||||
'upgrade': argparse.upgrade,
|
||||
|
@ -584,7 +624,7 @@ def main():
|
|||
'download': argparse.download,
|
||||
'-d': argparse.download,
|
||||
'remove': argparse.remove,
|
||||
'-r': argparse.remove,
|
||||
'-R': argparse.remove,
|
||||
'view': argparse.view,
|
||||
'-w': argparse.view,
|
||||
'find': argparse.find,
|
||||
|
|
|
@ -11,7 +11,7 @@ from sqlalchemy import create_engine, Column, Integer, Text
|
|||
from slpkg.configs import Configs
|
||||
|
||||
|
||||
DATABASE_URI = os.path.join(f'sqlite:///{Configs.db_path}', Configs.database_name)
|
||||
DATABASE_URI: str = os.path.join(f'sqlite:///{Configs.db_path}', Configs.database_name)
|
||||
|
||||
engine = create_engine(DATABASE_URI)
|
||||
|
||||
|
@ -38,6 +38,14 @@ class SBoTable(Base):
|
|||
short_description: str = Column(Text)
|
||||
|
||||
|
||||
class PonceTable(Base):
|
||||
|
||||
__tablename__ = 'poncetable'
|
||||
|
||||
id: int = Column(Integer, primary_key=True)
|
||||
name: str = Column(Text)
|
||||
|
||||
|
||||
@dataclass
|
||||
class LogsDependencies(Base):
|
||||
""" The table that stores the dependencies after installing a package. """
|
||||
|
|
|
@ -10,13 +10,15 @@ from slpkg.configs import Configs
|
|||
class ProgressBar(Configs):
|
||||
|
||||
def __init__(self):
|
||||
super(Configs, self).__init__()
|
||||
self.color = self.colour()
|
||||
self.bold = self.color['bold']
|
||||
self.violet = self.color['violet']
|
||||
self.bviolet = f'{self.bold}{self.violet}'
|
||||
self.endc = self.color['endc']
|
||||
|
||||
def bar(self, message, filename):
|
||||
self.bold: str = self.color['bold']
|
||||
self.violet: str = self.color['violet']
|
||||
self.bviolet: str = f'{self.bold}{self.violet}'
|
||||
self.endc: str = self.color['endc']
|
||||
|
||||
def bar(self, message: str, filename: str) -> None:
|
||||
""" Creating progress bar. """
|
||||
spinner = PixelSpinner(f'{self.endc}{message} {filename} {self.bviolet}')
|
||||
# print('\033[F', end='', flush=True)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from typing import Union
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.blacklist import Blacklist
|
||||
from slpkg.models.models import SBoTable
|
||||
|
@ -12,21 +14,21 @@ class SBoQueries(Configs):
|
|||
|
||||
def __init__(self, name: str):
|
||||
super(Configs, self).__init__()
|
||||
self.name = name
|
||||
self.name: str = name
|
||||
self.session = Session
|
||||
|
||||
self.black = Blacklist()
|
||||
if self.name in self.black.get():
|
||||
self.name = ''
|
||||
if self.name in self.black.packages():
|
||||
self.name: str = ''
|
||||
|
||||
def sbos(self) -> list:
|
||||
""" Returns all the slackbuilds. """
|
||||
sbos = self.session.query(SBoTable.name).all()
|
||||
sbos: tuple = self.session.query(SBoTable.name).all()
|
||||
return [sbo[0] for sbo in sbos]
|
||||
|
||||
def slackbuild(self) -> str:
|
||||
""" Returns a slackbuild. """
|
||||
sbo = self.session.query(
|
||||
sbo: tuple = self.session.query(
|
||||
SBoTable.name).filter(SBoTable.name == self.name).first()
|
||||
|
||||
if sbo:
|
||||
|
@ -35,7 +37,7 @@ class SBoQueries(Configs):
|
|||
|
||||
def location(self) -> str:
|
||||
""" Returns the category of a slackbuild. """
|
||||
location = self.session.query(
|
||||
location: tuple = self.session.query(
|
||||
SBoTable.location).filter(SBoTable.name == self.name).first()
|
||||
|
||||
if location:
|
||||
|
@ -53,23 +55,23 @@ class SBoQueries(Configs):
|
|||
|
||||
return source.split()
|
||||
|
||||
def requires(self) -> str:
|
||||
def requires(self) -> Union[str, list]:
|
||||
""" Returns the requirements of a slackbuild. """
|
||||
requires = self.session.query(
|
||||
requires: tuple = self.session.query(
|
||||
SBoTable.requires).filter(
|
||||
SBoTable.name == self.name).first()
|
||||
|
||||
if requires:
|
||||
requires = requires[0].split()
|
||||
requires: list = requires[0].split()
|
||||
for req in requires:
|
||||
if req in self.black.get():
|
||||
if req in self.black.packages():
|
||||
requires.remove(req)
|
||||
return requires
|
||||
return ''
|
||||
|
||||
def version(self) -> str:
|
||||
""" Returns the version of a slackbuild. """
|
||||
version = self.session.query(
|
||||
version: tuple = self.session.query(
|
||||
SBoTable.version).filter(
|
||||
SBoTable.name == self.name).first()
|
||||
|
||||
|
@ -90,7 +92,7 @@ class SBoQueries(Configs):
|
|||
|
||||
def description(self) -> str:
|
||||
""" Returns the slackbuild description. """
|
||||
desc = self.session.query(
|
||||
desc: tuple = self.session.query(
|
||||
SBoTable.short_description).filter(
|
||||
SBoTable.name == self.name).first()
|
||||
|
||||
|
@ -100,7 +102,7 @@ class SBoQueries(Configs):
|
|||
|
||||
def files(self) -> str:
|
||||
""" Returns the files of a slackbuild. """
|
||||
files = self.session.query(
|
||||
files: tuple = self.session.query(
|
||||
SBoTable.files).filter(
|
||||
SBoTable.name == self.name).first()
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
import time
|
||||
import subprocess
|
||||
from typing import NoReturn
|
||||
from multiprocessing import Process
|
||||
|
||||
from slpkg.configs import Configs
|
||||
|
@ -17,29 +18,32 @@ class RemovePackages(Configs):
|
|||
""" Removes installed packages. """
|
||||
|
||||
def __init__(self, packages: list, flags: list, file_pattern: str):
|
||||
self.packages = packages
|
||||
self.flags = flags
|
||||
self.file_pattern = file_pattern
|
||||
super(Configs, self).__init__()
|
||||
self.packages: list = packages
|
||||
self.flags: list = flags
|
||||
self.file_pattern: str = file_pattern
|
||||
|
||||
self.session = Session
|
||||
self.color = self.colour()
|
||||
self.bold = self.color['bold']
|
||||
self.yellow = self.color['yellow']
|
||||
self.red = self.color['red']
|
||||
self.endc = self.color['endc']
|
||||
self.byellow = f'{self.bold}{self.yellow}'
|
||||
self.bred = f'{self.bold}{self.red}'
|
||||
self.installed_packages = []
|
||||
self.dependencies = []
|
||||
self.utils = Utilities()
|
||||
self.progress = ProgressBar()
|
||||
self.flag_resolve_off = ['-ro', '--resolve-off']
|
||||
self.flag_no_silent = ['-ns', '--no-silent']
|
||||
self.output = 0
|
||||
|
||||
self.output: int = 0
|
||||
self.installed_packages: list = []
|
||||
self.dependencies: list = []
|
||||
self.remove_pkg = None
|
||||
self.stderr = None
|
||||
self.stdout = None
|
||||
self.bold: str = self.color['bold']
|
||||
self.yellow: str = self.color['yellow']
|
||||
self.red: str = self.color['red']
|
||||
self.endc: str = self.color['endc']
|
||||
self.byellow: str = f'{self.bold}{self.yellow}'
|
||||
self.bred: str = f'{self.bold}{self.red}'
|
||||
self.flag_resolve_off: list = ['-o', '--resolve-off']
|
||||
self.flag_no_silent: list = ['-n', '--no-silent']
|
||||
|
||||
def remove(self):
|
||||
def remove(self) -> None:
|
||||
""" Removes package with dependencies. """
|
||||
view = ViewMessage(self.flags)
|
||||
|
||||
|
@ -48,7 +52,7 @@ class RemovePackages(Configs):
|
|||
|
||||
view.question()
|
||||
|
||||
start = time.time()
|
||||
start: float = time.time()
|
||||
self.remove_packages()
|
||||
|
||||
if self.dependencies and not self.utils.is_option(self.flag_resolve_off, self.flags):
|
||||
|
@ -56,37 +60,37 @@ class RemovePackages(Configs):
|
|||
|
||||
self.delete_main_logs()
|
||||
|
||||
elapsed_time = time.time() - start
|
||||
elapsed_time: float = time.time() - start
|
||||
|
||||
self.utils.finished_time(elapsed_time)
|
||||
|
||||
def remove_packages(self):
|
||||
def remove_packages(self) -> None:
|
||||
""" Run Slackware command to remove the packages. """
|
||||
for package in self.installed_packages:
|
||||
self.remove_pkg = package
|
||||
command = f'{self.removepkg} {package}'
|
||||
command: str = f'{self.removepkg} {package}'
|
||||
self.multi_process(command, package)
|
||||
|
||||
def delete_main_logs(self):
|
||||
def delete_main_logs(self) -> None:
|
||||
""" Deletes main packages from logs. """
|
||||
for pkg in self.packages:
|
||||
self.session.query(LogsDependencies).filter(
|
||||
LogsDependencies.name == pkg).delete()
|
||||
self.session.commit()
|
||||
|
||||
def delete_deps_logs(self):
|
||||
def delete_deps_logs(self) -> None:
|
||||
""" Deletes depends packages from logs. """
|
||||
for pkg in self.dependencies:
|
||||
self.session.query(LogsDependencies).filter(
|
||||
LogsDependencies.name == pkg).delete()
|
||||
self.session.commit()
|
||||
|
||||
def multi_process(self, command, package):
|
||||
def multi_process(self, command: str, package: str) -> None:
|
||||
""" Starting multiprocessing remove process. """
|
||||
if self.silent_mode and not self.utils.is_option(self.flag_no_silent, self.flags):
|
||||
|
||||
done = f' {self.byellow} Done{self.endc}'
|
||||
message = f'{self.red}Remove{self.endc}'
|
||||
done: str = f' {self.byellow} Done{self.endc}'
|
||||
message: str = f'{self.red}Remove{self.endc}'
|
||||
self.stderr = subprocess.DEVNULL
|
||||
self.stdout = subprocess.DEVNULL
|
||||
|
||||
|
@ -120,14 +124,14 @@ class RemovePackages(Configs):
|
|||
|
||||
self.print_error()
|
||||
|
||||
def process(self, command):
|
||||
def process(self, command: str) -> NoReturn:
|
||||
""" Processes execution. """
|
||||
self.output = subprocess.call(command, shell=True,
|
||||
stderr=self.stderr, stdout=self.stdout)
|
||||
if self.output != 0:
|
||||
raise SystemExit(self.output)
|
||||
|
||||
def print_error(self):
|
||||
def print_error(self) -> NoReturn:
|
||||
""" Stop the process and print the error message. """
|
||||
if self.output != 0:
|
||||
raise SystemExit(f"\n{self.red}FAILED {self.stderr}:{self.endc} package '{self.remove_pkg}' to remove.\n")
|
||||
|
|
|
@ -9,18 +9,20 @@ class SearchPackage(Configs):
|
|||
""" Search slackbuilds from the repository. """
|
||||
|
||||
def __init__(self):
|
||||
super(Configs, self).__init__()
|
||||
self.color = self.colour()
|
||||
self.yellow = self.color['yellow']
|
||||
self.cyan = self.color['cyan']
|
||||
self.endc = self.color['endc']
|
||||
self.green = self.color['green']
|
||||
self.grey = self.color['grey']
|
||||
|
||||
def package(self, packages: list):
|
||||
self.yellow: str = self.color['yellow']
|
||||
self.cyan: str = self.color['cyan']
|
||||
self.endc: str = self.color['endc']
|
||||
self.green: str = self.color['green']
|
||||
self.grey: str = self.color['grey']
|
||||
|
||||
def package(self, packages: list) -> None:
|
||||
""" Searching and print the matched slackbuilds. """
|
||||
matching = 0
|
||||
matching: int = 0
|
||||
|
||||
names = SBoQueries('').sbos()
|
||||
names: list = SBoQueries('').sbos()
|
||||
|
||||
print(f'The list below shows the repo '
|
||||
f'packages that contains \'{", ".join([p for p in packages])}\':\n')
|
||||
|
@ -29,7 +31,7 @@ class SearchPackage(Configs):
|
|||
for package in packages:
|
||||
if package in name:
|
||||
matching += 1
|
||||
desc = SBoQueries(name).description().replace(name, '')
|
||||
desc: str = SBoQueries(name).description().replace(name, '')
|
||||
print(f'{self.cyan}{name}{self.endc}-{self.yellow}{SBoQueries(name).version()}{self.endc}'
|
||||
f'{self.green}{desc}{self.endc}')
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
import os
|
||||
import time
|
||||
import subprocess
|
||||
from typing import NoReturn
|
||||
|
||||
from pathlib import Path
|
||||
from collections import OrderedDict
|
||||
|
@ -27,37 +28,39 @@ class Slackbuilds(Configs):
|
|||
|
||||
def __init__(self, slackbuilds: list, flags: list, file_pattern, mode: str):
|
||||
super(Configs, self).__init__()
|
||||
self.slackbuilds = slackbuilds
|
||||
self.flags = flags
|
||||
self.file_pattern = file_pattern
|
||||
self.mode = mode
|
||||
self.install_order = []
|
||||
self.dependencies = []
|
||||
self.sbos = {}
|
||||
self.output = 0
|
||||
self.stderr = None
|
||||
self.stdout = None
|
||||
self.process_message = None
|
||||
self.slackbuilds: list = slackbuilds
|
||||
self.flags: list = flags
|
||||
self.file_pattern: str = file_pattern
|
||||
self.mode: str = mode
|
||||
|
||||
self.session = Session
|
||||
self.utils = Utilities()
|
||||
self.progress = ProgressBar()
|
||||
self.dialogbox = DialogBox()
|
||||
self.view_message = ViewMessage(self.flags)
|
||||
self.color = self.colour()
|
||||
self.bold = self.color['bold']
|
||||
self.cyan = self.color['cyan']
|
||||
self.red = self.color['red']
|
||||
self.yellow = self.color['yellow']
|
||||
self.endc = self.color['endc']
|
||||
self.byellow = f'{self.bold}{self.yellow}'
|
||||
self.bred = f'{self.bold}{self.red}'
|
||||
self.flag_reinstall = ['-R', '--reinstall']
|
||||
self.flag_skip_installed = ['-si', '--skip-installed']
|
||||
self.flag_resolve_off = ['-ro', '--resolve-off']
|
||||
self.flag_jobs = ['-j', '--jobs']
|
||||
self.flag_no_silent = ['-ns', '--no-silent']
|
||||
|
||||
def execute(self):
|
||||
self.install_order: list = []
|
||||
self.dependencies: list = []
|
||||
self.sbos: dict = {}
|
||||
self.output: int = 0
|
||||
self.stderr = None
|
||||
self.stdout = None
|
||||
self.process_message = None
|
||||
self.bold: str = self.color['bold']
|
||||
self.cyan: str = self.color['cyan']
|
||||
self.red: str = self.color['red']
|
||||
self.yellow: str = self.color['yellow']
|
||||
self.endc: str = self.color['endc']
|
||||
self.byellow: str = f'{self.bold}{self.yellow}'
|
||||
self.bred: str = f'{self.bold}{self.red}'
|
||||
self.flag_reinstall: list = ['-r', '--reinstall']
|
||||
self.flag_skip_installed: list = ['-k', '--skip-installed']
|
||||
self.flag_resolve_off: list = ['-o', '--resolve-off']
|
||||
self.flag_jobs: list = ['-j', '--jobs']
|
||||
self.flag_no_silent: list = ['-n', '--no-silent']
|
||||
|
||||
def execute(self) -> None:
|
||||
""" Starting build or install the slackbuilds. """
|
||||
self.creating_dictionary()
|
||||
|
||||
|
@ -68,19 +71,19 @@ class Slackbuilds(Configs):
|
|||
|
||||
self.view_before_build()
|
||||
|
||||
start = time.time()
|
||||
start: float = time.time()
|
||||
self.download_slackbuilds()
|
||||
self.build_and_install()
|
||||
elapsed_time = time.time() - start
|
||||
elapsed_time: float = time.time() - start
|
||||
|
||||
self.utils.finished_time(elapsed_time)
|
||||
|
||||
def creating_dictionary(self):
|
||||
def creating_dictionary(self) -> None:
|
||||
""" Dictionary with the main slackbuilds and dependencies. """
|
||||
for sbo in self.slackbuilds:
|
||||
self.sbos[sbo] = Requires(sbo).resolve()
|
||||
|
||||
def creating_dependencies_for_build(self):
|
||||
def creating_dependencies_for_build(self) -> None:
|
||||
""" List with the dependencies. """
|
||||
for deps in self.sbos.values():
|
||||
for dep in deps:
|
||||
|
@ -105,11 +108,11 @@ class Slackbuilds(Configs):
|
|||
|
||||
self.install_order.extend(self.dependencies)
|
||||
|
||||
def creating_main_for_build(self):
|
||||
def creating_main_for_build(self) -> None:
|
||||
""" List with the main slackbuilds. """
|
||||
[self.install_order.append(main) for main in self.sbos.keys() if main not in self.install_order]
|
||||
|
||||
def view_before_build(self):
|
||||
def view_before_build(self) -> None:
|
||||
""" View slackbuilds before proceed. """
|
||||
if not self.mode == 'build':
|
||||
self.view_message.install_packages(self.slackbuilds, self.dependencies, self.mode)
|
||||
|
@ -120,37 +123,43 @@ class Slackbuilds(Configs):
|
|||
|
||||
self.view_message.question()
|
||||
|
||||
def is_for_skipped(self, sbo):
|
||||
def is_for_skipped(self, sbo) -> None:
|
||||
""" Condition to check if slackbuild is for skipped. """
|
||||
return (not self.utils.is_installed(sbo, self.file_pattern) or
|
||||
self.utils.is_repo_version_bigger(sbo, self.file_pattern) or
|
||||
self.utils.is_package_upgradeable(sbo, self.file_pattern) or
|
||||
self.mode == 'build' or self.utils.is_option(self.flag_reinstall, self.flags))
|
||||
|
||||
def download_slackbuilds(self):
|
||||
def download_slackbuilds(self) -> None:
|
||||
""" Downloads files and sources. """
|
||||
for sbo in self.install_order:
|
||||
|
||||
if self.is_for_skipped(sbo):
|
||||
|
||||
file = f'{sbo}{self.sbo_tar_suffix}'
|
||||
file: str = f'{sbo}{self.sbo_tar_suffix}'
|
||||
|
||||
self.utils.remove_file_if_exists(self.tmp_slpkg, file)
|
||||
self.utils.remove_folder_if_exists(self.build_path, sbo)
|
||||
|
||||
location = SBoQueries(sbo).location()
|
||||
url = f'{self.sbo_repo_url}/{location}/{file}'
|
||||
sbo_url: str = f'{self.sbo_repo_url}{location}/{file}'
|
||||
ponce_url: str = f'{self.ponce_url}{location}/{sbo}'
|
||||
|
||||
down_sbo = Downloader(self.tmp_slpkg, url, self.flags)
|
||||
down_sbo.download()
|
||||
if self.ponce_repo:
|
||||
path = Path(self.build_path, sbo)
|
||||
lftp = Downloader(path, ponce_url, self.flags)
|
||||
lftp.download()
|
||||
else:
|
||||
down_sbo = Downloader(self.tmp_slpkg, sbo_url, self.flags)
|
||||
down_sbo.download()
|
||||
|
||||
self.utils.untar_archive(self.tmp_slpkg, file, self.build_path)
|
||||
self.utils.untar_archive(self.tmp_slpkg, file, self.build_path)
|
||||
|
||||
self.patch_sbo_tag(sbo)
|
||||
|
||||
sources = SBoQueries(sbo).sources()
|
||||
self.download_sources(sbo, sources)
|
||||
|
||||
def build_and_install(self):
|
||||
def build_and_install(self) -> None:
|
||||
""" Build the slackbuilds and install. """
|
||||
for sbo in self.install_order:
|
||||
|
||||
|
@ -160,17 +169,17 @@ class Slackbuilds(Configs):
|
|||
|
||||
if not self.mode == 'build':
|
||||
|
||||
pkg = self.creating_package_for_install(sbo)
|
||||
pkg: str = self.creating_package_for_install(sbo)
|
||||
self.install_package(pkg)
|
||||
|
||||
if not self.utils.is_option(self.flag_resolve_off, self.flags):
|
||||
self.logging_installed_dependencies(sbo)
|
||||
else:
|
||||
package = self.utils.is_installed(sbo, self.file_pattern)
|
||||
version = self.utils.split_installed_pkg(package)[1]
|
||||
package: str = self.utils.is_installed(sbo, self.file_pattern)
|
||||
version: str = self.utils.split_installed_pkg(package)[1]
|
||||
self.view_message.view_skipping_packages(sbo, version)
|
||||
|
||||
def patch_sbo_tag(self, sbo):
|
||||
def patch_sbo_tag(self, sbo: str) -> None:
|
||||
""" Patching SBo TAG from the configuration file. """
|
||||
sbo_script = Path(self.build_path, sbo, f'{sbo}.SlackBuild')
|
||||
|
||||
|
@ -181,15 +190,15 @@ class Slackbuilds(Configs):
|
|||
with open(sbo_script, 'w') as script:
|
||||
for line in lines:
|
||||
if line.startswith('TAG=$'):
|
||||
line = f'TAG=${{TAG:-{self.sbo_repo_tag}}}\n'
|
||||
line: str = f'TAG=${{TAG:-{self.sbo_repo_tag}}}\n'
|
||||
script.write(line)
|
||||
|
||||
def logging_installed_dependencies(self, name: str):
|
||||
def logging_installed_dependencies(self, name: str) -> None:
|
||||
""" Logging installed dependencies and used for remove. """
|
||||
exist = self.session.query(LogsDependencies.name).filter(
|
||||
LogsDependencies.name == name).first()
|
||||
|
||||
requires = Requires(name).resolve()
|
||||
requires: list = Requires(name).resolve()
|
||||
|
||||
# Update the dependencies if exist else create it.
|
||||
if exist:
|
||||
|
@ -199,46 +208,46 @@ class Slackbuilds(Configs):
|
|||
{LogsDependencies.requires: ' '.join(requires)})
|
||||
|
||||
elif requires:
|
||||
deps = LogsDependencies(name=name, requires=' '.join(requires))
|
||||
deps: list = LogsDependencies(name=name, requires=' '.join(requires))
|
||||
self.session.add(deps)
|
||||
self.session.commit()
|
||||
|
||||
def install_package(self, package: str):
|
||||
def install_package(self, package: str) -> None:
|
||||
""" Install the packages that before created in the tmp directory. """
|
||||
pkg = self.utils.split_installed_pkg(package)[0]
|
||||
pkg: str = self.utils.split_installed_pkg(package)[0]
|
||||
|
||||
execute = self.installpkg
|
||||
execute: str = self.installpkg
|
||||
if (self.utils.is_option(self.flag_reinstall, self.flags) and
|
||||
self.utils.is_installed(pkg, self.file_pattern)):
|
||||
execute = self.reinstall
|
||||
execute: str = self.reinstall
|
||||
|
||||
message = f'{self.cyan}Installing{self.endc}'
|
||||
self.process_message = f"'{pkg}' to install"
|
||||
message: str = f'{self.cyan}Installing{self.endc}'
|
||||
self.process_message: str = f"'{pkg}' to install"
|
||||
|
||||
if self.mode == 'upgrade':
|
||||
self.process_message = f"package '{pkg}' to upgrade"
|
||||
message = f'{self.cyan}Upgrade{self.endc}'
|
||||
self.process_message: str = f"package '{pkg}' to upgrade"
|
||||
message: str = f'{self.cyan}Upgrade{self.endc}'
|
||||
|
||||
command = f'{execute} {self.tmp_path}/{package}'
|
||||
command: str = f'{execute} {self.tmp_path}{package}'
|
||||
|
||||
self.multi_process(command, package, message)
|
||||
|
||||
def creating_package_for_install(self, name: str):
|
||||
def creating_package_for_install(self, name: str) -> str:
|
||||
""" Creating a list with all the finished packages for
|
||||
installation. """
|
||||
version = SBoQueries(name).version()
|
||||
version: str = SBoQueries(name).version()
|
||||
|
||||
pattern = f'{name}-{version}*{self.sbo_repo_tag}*'
|
||||
pattern: str = f'{name}-{version}*{self.sbo_repo_tag}*'
|
||||
|
||||
tmp = Path(self.tmp_path)
|
||||
packages = [file.name for file in tmp.glob(pattern)]
|
||||
packages: list = [file.name for file in tmp.glob(pattern)]
|
||||
|
||||
return max(packages)
|
||||
|
||||
def build_the_script(self, path: str, name: str):
|
||||
def build_the_script(self, path: str, name: str) -> None:
|
||||
""" Run the .SlackBuild script. """
|
||||
folder = f'{Path(path, name)}/'
|
||||
execute = f'{folder}./{name}.SlackBuild'
|
||||
folder: str = f'{Path(path, name)}/'
|
||||
execute: str = f'{folder}./{name}.SlackBuild'
|
||||
|
||||
# Change to root privileges
|
||||
os.chown(folder, 0, 0)
|
||||
|
@ -248,20 +257,20 @@ class Slackbuilds(Configs):
|
|||
if self.utils.is_option(self.flag_jobs, self.flags):
|
||||
self.set_makeflags()
|
||||
|
||||
message = f'{self.red}Build{self.endc}'
|
||||
self.process_message = f"package '{name}' to build"
|
||||
message: str = f'{self.red}Build{self.endc}'
|
||||
self.process_message: str = f"package '{name}' to build"
|
||||
|
||||
self.multi_process(execute, name, message)
|
||||
|
||||
@staticmethod
|
||||
def set_makeflags():
|
||||
def set_makeflags() -> None:
|
||||
""" Set number of processors. """
|
||||
os.environ['MAKEFLAGS'] = f'-j {cpu_count()}'
|
||||
|
||||
def download_sources(self, name: str, sources: list):
|
||||
def download_sources(self, name: str, sources: list) -> None:
|
||||
""" Download the sources. """
|
||||
path = Path(self.build_path, name)
|
||||
checksums = SBoQueries(name).checksum()
|
||||
checksums: list = SBoQueries(name).checksum()
|
||||
|
||||
for source, checksum in zip(sources, checksums):
|
||||
down_source = Downloader(path, source, self.flags)
|
||||
|
@ -270,11 +279,11 @@ class Slackbuilds(Configs):
|
|||
md5sum = Md5sum(self.flags)
|
||||
md5sum.check(path, source, checksum, name)
|
||||
|
||||
def multi_process(self, command, filename, message):
|
||||
def multi_process(self, command: str, filename: str, message: str) -> None:
|
||||
""" Starting multiprocessing install/upgrade process. """
|
||||
if self.silent_mode and not self.utils.is_option(self.flag_no_silent, self.flags):
|
||||
|
||||
done = f' {self.byellow} Done{self.endc}'
|
||||
done: str = f' {self.byellow} Done{self.endc}'
|
||||
self.stderr = subprocess.DEVNULL
|
||||
self.stdout = subprocess.DEVNULL
|
||||
|
||||
|
@ -292,7 +301,7 @@ class Slackbuilds(Configs):
|
|||
if not p1.is_alive():
|
||||
|
||||
if p1.exitcode != 0:
|
||||
done = f' {self.bred} Failed{self.endc}'
|
||||
done: str = f' {self.bred} Failed{self.endc}'
|
||||
self.output = p1.exitcode
|
||||
|
||||
print(f'{self.endc}{done}', end='')
|
||||
|
@ -308,37 +317,43 @@ class Slackbuilds(Configs):
|
|||
|
||||
self.print_error()
|
||||
|
||||
def process(self, command):
|
||||
def process(self, command: str) -> NoReturn:
|
||||
""" Processes execution. """
|
||||
self.output = subprocess.call(command, shell=True,
|
||||
stderr=self.stderr, stdout=self.stdout)
|
||||
if self.output != 0:
|
||||
raise SystemExit(self.output)
|
||||
|
||||
def print_error(self):
|
||||
def print_error(self) -> NoReturn:
|
||||
""" 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):
|
||||
def choose_dependencies(self, dependencies: list) -> list:
|
||||
""" Choose packages for install. """
|
||||
height = 10
|
||||
width = 70
|
||||
list_height = 0
|
||||
choices = []
|
||||
title = ' Choose dependencies you want to install '
|
||||
height: int = 10
|
||||
width: int = 70
|
||||
list_height: int = 0
|
||||
choices: list = []
|
||||
title: str = ' Choose dependencies you want to install '
|
||||
|
||||
for package in dependencies:
|
||||
status = True
|
||||
status: bool = False
|
||||
repo_ver = SBoQueries(package).version()
|
||||
installed = self.utils.is_installed(package, self.file_pattern)
|
||||
self.utils.is_package_upgradeable(package, self.file_pattern)
|
||||
|
||||
if installed:
|
||||
status = False
|
||||
if self.mode == 'upgrade' and self.utils.is_package_upgradeable(package, self.file_pattern):
|
||||
status: bool = True
|
||||
|
||||
if self.mode == 'install' and not self.utils.is_installed(package, self.file_pattern):
|
||||
status: bool = True
|
||||
|
||||
if self.mode == 'install' and self.utils.is_package_upgradeable(package, self.file_pattern):
|
||||
status: bool = True
|
||||
|
||||
choices += [(package, repo_ver, status)]
|
||||
|
||||
text = f'There are {len(choices)} dependencies:'
|
||||
text: str = f'There are {len(choices)} dependencies:'
|
||||
|
||||
code, tags = self.dialogbox.checklist(text, title, height, width,
|
||||
list_height, choices, dependencies)
|
||||
|
|
|
@ -14,32 +14,34 @@ class Tracking(Configs, Utilities):
|
|||
def __init__(self, flags: list):
|
||||
super(Configs, self).__init__()
|
||||
super(Utilities, self).__init__()
|
||||
self.flags = flags
|
||||
self.flag_pkg_version = ['-pv', '--pkg-version']
|
||||
self.ascii = Ascii()
|
||||
self.llc = self.ascii.lower_left_corner
|
||||
self.hl = self.ascii.horizontal_line
|
||||
self.vl = self.ascii.vertical_line
|
||||
self.color = self.colour()
|
||||
self.cyan = self.color['cyan']
|
||||
self.grey = self.color['grey']
|
||||
self.yellow = self.color['yellow']
|
||||
self.endc = self.color['endc']
|
||||
self.flags: list = flags
|
||||
|
||||
def packages(self, packages: list):
|
||||
self.ascii = Ascii()
|
||||
self.color = self.colour()
|
||||
|
||||
self.llc: str = self.ascii.lower_left_corner
|
||||
self.hl: str = self.ascii.horizontal_line
|
||||
self.vl: str = self.ascii.vertical_line
|
||||
self.cyan: str = self.color['cyan']
|
||||
self.grey: str = self.color['grey']
|
||||
self.yellow: str = self.color['yellow']
|
||||
self.endc: str = self.color['endc']
|
||||
self.flag_pkg_version: list = ['-p', '--pkg-version']
|
||||
|
||||
def packages(self, packages: list) -> None:
|
||||
""" Prints the packages dependencies. """
|
||||
print(f"The list below shows the packages with dependencies:\n")
|
||||
|
||||
char = f' {self.llc}{self.hl}'
|
||||
sp = ' ' * 4
|
||||
char: str = f' {self.llc}{self.hl}'
|
||||
sp: str = ' ' * 4
|
||||
for package in packages:
|
||||
pkg = f'{self.yellow}{package}{self.endc}'
|
||||
|
||||
if self.is_option(self.flag_pkg_version, self.flags):
|
||||
pkg = f'{self.yellow}{package}-{SBoQueries(package).version()}{self.endc}'
|
||||
|
||||
requires = Requires(package).resolve()
|
||||
how_many = len(requires)
|
||||
requires: list = Requires(package).resolve()
|
||||
how_many: int = len(requires)
|
||||
|
||||
if not requires:
|
||||
requires = ['No dependencies']
|
||||
|
@ -47,10 +49,10 @@ class Tracking(Configs, Utilities):
|
|||
print(pkg)
|
||||
print(char, end='')
|
||||
for i, req in enumerate(requires, start=1):
|
||||
require = f'{self.cyan}{req}{self.endc}'
|
||||
require: str = f'{self.cyan}{req}{self.endc}'
|
||||
|
||||
if self.is_option(self.flag_pkg_version, self.flags):
|
||||
require = f'{self.cyan}{req}{self.endc}-{self.yellow}{SBoQueries(req).version()}{self.endc}'
|
||||
require: str = f'{self.cyan}{req}{self.endc}-{self.yellow}{SBoQueries(req).version()}{self.endc}'
|
||||
|
||||
if i == 1:
|
||||
print(f' {require}')
|
||||
|
|
|
@ -7,7 +7,7 @@ from multiprocessing import Process
|
|||
from slpkg.configs import Configs
|
||||
from slpkg.downloader import Downloader
|
||||
from slpkg.create_data import CreateData
|
||||
from slpkg.models.models import SBoTable
|
||||
from slpkg.models.models import SBoTable, PonceTable
|
||||
from slpkg.views.views import ViewMessage
|
||||
from slpkg.progress_bar import ProgressBar
|
||||
from slpkg.check_updates import CheckUpdates
|
||||
|
@ -19,13 +19,15 @@ class UpdateRepository(Configs):
|
|||
|
||||
def __init__(self, flags: list):
|
||||
super(Configs, self).__init__()
|
||||
self.flags = flags
|
||||
self.flags: list = flags
|
||||
self.session = Session
|
||||
|
||||
self.progress = ProgressBar()
|
||||
self.color = self.colour()
|
||||
self.endc = self.color['endc']
|
||||
|
||||
def sbo(self):
|
||||
self.endc: str = self.color['endc']
|
||||
|
||||
def sbo(self) -> None:
|
||||
""" Updated the sbo repository. """
|
||||
view = ViewMessage(self.flags)
|
||||
|
||||
|
@ -34,28 +36,39 @@ class UpdateRepository(Configs):
|
|||
print('Updating the package list...\n')
|
||||
self.delete_file(self.sbo_repo_path, self.sbo_txt)
|
||||
self.delete_file(self.sbo_repo_path, self.sbo_chglog_txt)
|
||||
self.delete_sbo_data()
|
||||
self.delete_file(self.slack_chglog_path, self.slack_chglog_txt)
|
||||
|
||||
slackbuilds_txt = f'{self.sbo_repo_url}/{self.sbo_txt}'
|
||||
changelog_txt = f'{self.sbo_repo_url}/{self.sbo_chglog_txt}'
|
||||
self.delete_sbo_data()
|
||||
self.delete_ponce_data()
|
||||
|
||||
slackbuilds_txt: str = f'{self.sbo_repo_url}{self.sbo_txt}'
|
||||
changelog_txt: str = f'{self.sbo_repo_url}{self.sbo_chglog_txt}'
|
||||
slack_changelog_txt: str = f'{self.slack_current_mirror}{self.slack_chglog_txt}'
|
||||
|
||||
down_slackbuilds = Downloader(self.sbo_repo_path, slackbuilds_txt, self.flags)
|
||||
down_slackbuilds.download()
|
||||
|
||||
down_changelog = Downloader(self.sbo_repo_path, changelog_txt, self.flags)
|
||||
down_changelog.download()
|
||||
down_sbo_changelog = Downloader(self.sbo_repo_path, changelog_txt, self.flags)
|
||||
down_sbo_changelog.download()
|
||||
|
||||
if self.ponce_repo:
|
||||
down_slack_current_changelog = Downloader(self.slack_chglog_path, slack_changelog_txt, self.flags)
|
||||
down_slack_current_changelog.download()
|
||||
|
||||
data = CreateData()
|
||||
data.insert_sbo_table()
|
||||
|
||||
def check(self):
|
||||
if self.ponce_repo:
|
||||
data.insert_ponce_blacklist_packages()
|
||||
|
||||
def check(self) -> None:
|
||||
check_updates = CheckUpdates()
|
||||
if not check_updates.check():
|
||||
print(f'\n\n{self.endc}No changes in ChangeLog.txt between your last update and now.')
|
||||
else:
|
||||
print(f'\n\n{self.endc}There are new updates available!')
|
||||
|
||||
def repository(self):
|
||||
def repository(self) -> None:
|
||||
""" Starting multiprocessing download process. """
|
||||
message = f'Checking for news in the Changelog.txt file...'
|
||||
|
||||
|
@ -82,13 +95,19 @@ class UpdateRepository(Configs):
|
|||
self.sbo()
|
||||
|
||||
@staticmethod
|
||||
def delete_file(folder: str, txt_file: str):
|
||||
def delete_file(folder: str, txt_file: str) -> None:
|
||||
""" Delete the file. """
|
||||
file = Path(folder, txt_file)
|
||||
if file.exists():
|
||||
file.unlink()
|
||||
|
||||
def delete_sbo_data(self):
|
||||
def delete_sbo_data(self) -> None:
|
||||
""" Delete the table from the database. """
|
||||
self.session.query(SBoTable).delete()
|
||||
self.session.commit()
|
||||
|
||||
def delete_ponce_data(self) -> None:
|
||||
""" Delete the table from the database. """
|
||||
if self.ponce_repo:
|
||||
self.session.query(PonceTable).delete()
|
||||
self.session.commit()
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from typing import Generator
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.queries import SBoQueries
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.blacklist import Blacklist
|
||||
from slpkg.dependencies import Requires
|
||||
from slpkg.configs import Configs
|
||||
|
||||
|
||||
class Upgrade(Configs, Utilities):
|
||||
|
@ -14,22 +16,24 @@ class Upgrade(Configs, Utilities):
|
|||
def __init__(self, file_pattern):
|
||||
super(Configs, self).__init__()
|
||||
super(Utilities, self).__init__()
|
||||
self.file_pattern = file_pattern
|
||||
self.file_pattern: str = file_pattern
|
||||
|
||||
def packages(self):
|
||||
self.black = Blacklist()
|
||||
|
||||
def packages(self) -> Generator[str, None, None]:
|
||||
""" Compares version of packages and returns the maximum. """
|
||||
repo_packages = SBoQueries('').sbos()
|
||||
black = Blacklist().get()
|
||||
repo_packages: list = SBoQueries('').sbos()
|
||||
black: list = self.black.packages()
|
||||
upgrade, requires = [], []
|
||||
|
||||
installed = self.all_installed(self.file_pattern)
|
||||
installed: list = self.all_installed(self.file_pattern)
|
||||
|
||||
for pkg in installed:
|
||||
inst_pkg_name = self.split_installed_pkg(pkg)[0]
|
||||
inst_pkg_name: str = self.split_installed_pkg(pkg)[0]
|
||||
|
||||
if inst_pkg_name not in black and inst_pkg_name in repo_packages:
|
||||
|
||||
if self.is_repo_version_bigger(inst_pkg_name, self.file_pattern):
|
||||
if self.is_package_upgradeable(inst_pkg_name, self.file_pattern):
|
||||
requires += Requires(inst_pkg_name).resolve()
|
||||
upgrade.append(inst_pkg_name)
|
||||
|
||||
|
|
|
@ -18,17 +18,18 @@ class Utilities:
|
|||
self.configs = Configs
|
||||
self.colors = self.configs.colour
|
||||
self.color = self.colors()
|
||||
self.yellow = self.color['yellow']
|
||||
self.cyan = self.color['cyan']
|
||||
self.endc = self.color['endc']
|
||||
self.black = Blacklist()
|
||||
|
||||
self.yellow: str = self.color['yellow']
|
||||
self.cyan: str = self.color['cyan']
|
||||
self.endc: str = self.color['endc']
|
||||
|
||||
def is_installed(self, name: str, pattern: str) -> str:
|
||||
""" Returns the installed package name. """
|
||||
installed = list(self.all_installed(pattern))
|
||||
installed: list = list(self.all_installed(pattern))
|
||||
|
||||
for package in installed:
|
||||
pkg = self.split_installed_pkg(package)[0]
|
||||
pkg: str = self.split_installed_pkg(package)[0]
|
||||
|
||||
if pkg == name:
|
||||
return package
|
||||
|
@ -42,11 +43,11 @@ class Utilities:
|
|||
for file in var_log_packages.glob(pattern):
|
||||
package_name = self.split_installed_pkg(file.name)[0]
|
||||
|
||||
if package_name not in self.black.get():
|
||||
if package_name not in self.black.packages():
|
||||
yield file.name
|
||||
|
||||
@staticmethod
|
||||
def untar_archive(path: str, archive: str, ext_path: str):
|
||||
def untar_archive(path: str, archive: str, ext_path: str) -> None:
|
||||
""" Untar the file to the build folder. """
|
||||
tar_file = Path(path, archive)
|
||||
untar = tarfile.open(tar_file)
|
||||
|
@ -54,21 +55,21 @@ class Utilities:
|
|||
untar.close()
|
||||
|
||||
@staticmethod
|
||||
def remove_file_if_exists(path: str, file: str):
|
||||
def remove_file_if_exists(path: str, file: str) -> None:
|
||||
""" Clean the old files. """
|
||||
archive = Path(path, file)
|
||||
if archive.is_file():
|
||||
archive.unlink()
|
||||
|
||||
@staticmethod
|
||||
def remove_folder_if_exists(path: str, folder: str):
|
||||
def remove_folder_if_exists(path: str, folder: str) -> None:
|
||||
""" Clean the old folders. """
|
||||
directory = Path(path, folder)
|
||||
if directory.exists():
|
||||
shutil.rmtree(directory)
|
||||
|
||||
@staticmethod
|
||||
def create_folder(path: str, folder: str):
|
||||
def create_folder(path: str, folder: str) -> None:
|
||||
""" Creates folder. """
|
||||
directory = Path(path, folder)
|
||||
if not directory.exists():
|
||||
|
@ -76,22 +77,22 @@ class Utilities:
|
|||
|
||||
def split_installed_pkg(self, package: str) -> list:
|
||||
""" Split the package by the name, version, arch, build and tag. """
|
||||
name = '-'.join(package.split('-')[:-3])
|
||||
version = ''.join(package[len(name):].split('-')[:-2])
|
||||
arch = ''.join(package[len(name + version) + 2:].split('-')[:-1])
|
||||
build = ''.join(package[len(name + version + arch) + 3:].split('-')).replace(self.configs.sbo_repo_tag, '')
|
||||
tag = ''.join(package[len(name + version + arch + build) + 4:].split('-'))
|
||||
name: str = '-'.join(package.split('-')[:-3])
|
||||
version: str = ''.join(package[len(name):].split('-')[:-2])
|
||||
arch: str = ''.join(package[len(name + version) + 2:].split('-')[:-1])
|
||||
build: str = ''.join(package[len(name + version + arch) + 3:].split('-')).replace(self.configs.sbo_repo_tag, '')
|
||||
tag: str = ''.join(package[len(name + version + arch + build) + 4:].split('-'))
|
||||
|
||||
return [name, version, arch, build, tag]
|
||||
|
||||
def finished_time(self, elapsed_time: float):
|
||||
def finished_time(self, elapsed_time: float) -> None:
|
||||
""" Printing the elapsed time. """
|
||||
print(f'\n{self.yellow}Finished Successfully:{self.endc}',
|
||||
time.strftime(f'[{self.cyan}%H:%M:%S{self.endc}]',
|
||||
time.gmtime(elapsed_time)))
|
||||
|
||||
def is_repo_version_bigger(self, package: str, file_pattern: str) -> bool:
|
||||
""" Compare two versions. """
|
||||
def is_package_upgradeable(self, package: str, file_pattern: str) -> bool:
|
||||
""" Checks if the package is installed and if it is upgradeable, returns true. """
|
||||
installed = self.is_installed(package, file_pattern)
|
||||
if installed:
|
||||
installed_version = self.split_installed_pkg(installed)[1]
|
||||
|
@ -100,8 +101,6 @@ class Utilities:
|
|||
return LooseVersion(repository_version) > LooseVersion(installed_version)
|
||||
|
||||
@staticmethod
|
||||
def is_option(flag, flags):
|
||||
def is_option(flag: list, flags: list) -> True:
|
||||
""" Checking for flags. """
|
||||
for f in flag:
|
||||
if f in flags:
|
||||
return True
|
||||
return [f for f in flag if f in flags]
|
||||
|
|
|
@ -10,94 +10,105 @@ class Ascii(Configs):
|
|||
""" ascii characters. """
|
||||
def __init__(self):
|
||||
super(Configs, self).__init__()
|
||||
self.vertical_line = '|'
|
||||
self.horizontal_line = '='
|
||||
self.horizontal_vertical = '+'
|
||||
self.upper_right_corner = '+'
|
||||
self.lower_left_corner = '+'
|
||||
self.lower_right_corner = '+'
|
||||
self.upper_left_corner = '+'
|
||||
self.horizontal_and_up = '+'
|
||||
self.horizontal_and_down = '+'
|
||||
self.vertical_and_right = '+'
|
||||
self.vertical_and_left = '+'
|
||||
|
||||
if self.ascii_characters:
|
||||
self.vertical_line = '│'
|
||||
self.horizontal_line = '─'
|
||||
self.horizontal_vertical = '┼'
|
||||
self.upper_right_corner = '┐'
|
||||
self.lower_left_corner = '└'
|
||||
self.lower_right_corner = '┘'
|
||||
self.upper_left_corner = '┌'
|
||||
self.horizontal_and_up = '┴'
|
||||
self.horizontal_and_down = '┬'
|
||||
self.vertical_and_right = '├'
|
||||
self.vertical_and_left = '┤'
|
||||
|
||||
self.color = self.colour()
|
||||
self.bold = self.color['bold']
|
||||
self.blue = self.color['blue']
|
||||
self.green = self.color['green']
|
||||
self.cyan = self.color['cyan']
|
||||
self.red = self.color['red']
|
||||
self.yellow = self.color['yellow']
|
||||
self.violet = self.color['violet']
|
||||
self.endc = self.color['endc']
|
||||
self.bgreen = f'{self.bold}{self.green}'
|
||||
self.bred = f'{self.bold}{self.red}'
|
||||
|
||||
self.columns, self.rows = shutil.get_terminal_size()
|
||||
|
||||
def draw_package_title_box(self, message, title):
|
||||
self.vertical_line: str = '|'
|
||||
self.horizontal_line: str = '='
|
||||
self.horizontal_vertical: str = '+'
|
||||
self.upper_right_corner: str = '+'
|
||||
self.lower_left_corner: str = '+'
|
||||
self.lower_right_corner: str = '+'
|
||||
self.upper_left_corner: str = '+'
|
||||
self.horizontal_and_up: str = '+'
|
||||
self.horizontal_and_down: str = '+'
|
||||
self.vertical_and_right: str = '+'
|
||||
self.vertical_and_left: str = '+'
|
||||
|
||||
if self.ascii_characters:
|
||||
self.vertical_line: str = '│'
|
||||
self.horizontal_line: str = '─'
|
||||
self.horizontal_vertical: str = '┼'
|
||||
self.upper_right_corner: str = '┐'
|
||||
self.lower_left_corner: str = '└'
|
||||
self.lower_right_corner: str = '┘'
|
||||
self.upper_left_corner: str = '┌'
|
||||
self.horizontal_and_up: str = '┴'
|
||||
self.horizontal_and_down: str = '┬'
|
||||
self.vertical_and_right: str = '├'
|
||||
self.vertical_and_left: str = '┤'
|
||||
|
||||
self.bold: str = self.color['bold']
|
||||
self.blue: str = self.color['blue']
|
||||
self.green: str = self.color['green']
|
||||
self.cyan: str = self.color['cyan']
|
||||
self.red: str = self.color['red']
|
||||
self.yellow: str = self.color['yellow']
|
||||
self.violet: str = self.color['violet']
|
||||
self.endc: str = self.color['endc']
|
||||
self.bgreen: str = f'{self.bold}{self.green}'
|
||||
self.bred: str = f'{self.bold}{self.red}'
|
||||
|
||||
def draw_package_title_box(self, message: str, title: str) -> None:
|
||||
""" Drawing package title box. """
|
||||
middle_title = int((self.columns / 2) - len(title) + 2)
|
||||
middle_title: int = int((self.columns / 2) - len(title) + 6)
|
||||
|
||||
print(f'{self.bgreen}{self.upper_left_corner}' + f'{self.horizontal_line}' * (self.columns - 2) +
|
||||
f'{self.upper_right_corner}')
|
||||
|
||||
print(f'{self.vertical_line}' + ' ' * middle_title + f'{title}' + ' ' *
|
||||
(self.columns - middle_title - len(title) - 2) + f'{self.vertical_line}')
|
||||
|
||||
self.draw_middle_line()
|
||||
|
||||
print(f'{self.vertical_line}{self.endc} {message}' + ' ' * (self.columns - len(message) - 3) +
|
||||
f'{self.bgreen}{self.vertical_line}')
|
||||
|
||||
self.draw_middle_line()
|
||||
|
||||
print(f'{self.bgreen}{self.vertical_line}{self.endc} Package:' + ' ' * 27 + 'Version:' +
|
||||
' ' * (self.columns - 51) + f'Size{self.bgreen} {self.vertical_line}{self.endc}')
|
||||
|
||||
def draw_view_package(self, package, version, color):
|
||||
def draw_view_package(self, package: str, version: str, color: str) -> None:
|
||||
""" Draw nad print the packages. """
|
||||
print(f'{self.bgreen}{self.vertical_line} {self.bold}{color}{package}{self.endc}' + ' ' * (35 - len(package)) +
|
||||
f'{self.blue}{version}' + ' ' * ((self.columns - 37) - len(version) - 1) +
|
||||
f'{self.bgreen}{self.vertical_line}{self.endc}')
|
||||
|
||||
def draw_log_package(self, package):
|
||||
def draw_log_package(self, package: str) -> None:
|
||||
""" Drawing and print logs packages. """
|
||||
print(f' {self.lower_left_corner}{self.horizontal_line}{self.cyan} {package}{self.endc}\n')
|
||||
|
||||
def draw_middle_line(self):
|
||||
def draw_middle_line(self) -> None:
|
||||
""" Drawing a middle line. """
|
||||
print(f'{self.bgreen}{self.vertical_and_right}' + f'{self.horizontal_line}' *
|
||||
(self.columns - 2) + f'{self.vertical_and_left}')
|
||||
|
||||
def draw_dependency_line(self):
|
||||
def draw_dependency_line(self) -> None:
|
||||
""" Drawing the dependencies line. """
|
||||
print(f'{self.bgreen}{self.vertical_line}{self.endc} Dependencies:' + ' ' * (self.columns - 16) +
|
||||
f'{self.bgreen}{self.vertical_line}{self.endc}')
|
||||
|
||||
def draw_bottom_line(self):
|
||||
def draw_bottom_line(self) -> None:
|
||||
""" Drawing the bottom line. """
|
||||
print(f'{self.bold}{self.green}{self.lower_left_corner}' + f'{self.horizontal_line}' *
|
||||
(self.columns - 2) + f'{self.lower_right_corner}{self.endc}')
|
||||
|
||||
def draw_checksum_error_box(self, name, checksum, file_check):
|
||||
def draw_checksum_error_box(self, name: str, checksum: str, file_check: str) -> None:
|
||||
""" Drawing checksum error box. """
|
||||
print('\n' + self.bred + self.upper_left_corner + self.horizontal_line * (self.columns - 2) +
|
||||
self.upper_right_corner)
|
||||
|
||||
print(f"{self.bred}{self.vertical_line}{self.bred} Error:{self.endc} MD5SUM check for "
|
||||
f"'{self.cyan}{name}'{self.red} FAILED!" + ' ' * (self.columns - (len(name)) - 37) + self.vertical_line)
|
||||
|
||||
print(self.bred + self.vertical_and_right + self.horizontal_line * (self.columns - 2) + self.vertical_and_left)
|
||||
|
||||
print(f'{self.bred}{self.vertical_line}{self.yellow} Expected:{self.endc} {checksum}{self.bred}'
|
||||
+ ' ' * (self.columns - (len(checksum)) - 13) + self.vertical_line)
|
||||
|
||||
print(f'{self.bred}{self.vertical_line}{self.violet} Found:{self.endc} {file_check}{self.bred}'
|
||||
+ ' ' * (self.columns - (len(file_check)) - 10) + self.vertical_line)
|
||||
|
||||
print(self.bred + self.lower_left_corner + self.horizontal_line * (self.columns - 2) +
|
||||
self.lower_right_corner + self.endc)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from typing import NoReturn
|
||||
from slpkg.configs import Configs
|
||||
|
||||
|
||||
|
@ -10,36 +11,36 @@ class Usage(Configs):
|
|||
super(Configs, self).__init__()
|
||||
color = self.colour()
|
||||
|
||||
self.bold = color['bold']
|
||||
self.red = color['red']
|
||||
self.cyan = color['cyan']
|
||||
self.yellow = color['yellow']
|
||||
self.endc = color['endc']
|
||||
self.bold: str = color['bold']
|
||||
self.red: str = color['red']
|
||||
self.cyan: str = color['cyan']
|
||||
self.yellow: str = color['yellow']
|
||||
self.endc: str = color['endc']
|
||||
|
||||
def help_short(self):
|
||||
def help_short(self) -> NoReturn:
|
||||
""" Prints the short menu. """
|
||||
args = (
|
||||
f'Usage: {Configs.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] <packages>\n'
|
||||
f'Usage: {self.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] [PACKAGES...]\n'
|
||||
f'\n slpkg [{self.cyan}COMMAND{self.endc}] [-u, update, -U, upgrade, -c, check-updates]\n'
|
||||
f' slpkg [{self.cyan}COMMAND{self.endc}] [-L, clean-logs, -D, clean-tmp, -g, configs]\n'
|
||||
f' slpkg [{self.cyan}COMMAND{self.endc}] [-b, build, -i, install, -d, download, -r, remove] <packages>\n'
|
||||
f' slpkg [{self.cyan}COMMAND{self.endc}] [-f, find, -w, view, -s, search] <packages>\n'
|
||||
f' slpkg [{self.cyan}COMMAND{self.endc}] [-e, dependees, -t, tracking] <packages>\n'
|
||||
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-y, --yes, -j, --jobs, -ro, --resolve-off, -R, --reinstall]\n'
|
||||
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-si, --skip-installed, -fr, --full-reverse, -S, --search]\n'
|
||||
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-ns, --no-silent, -dir=, --directory=PATH]\n'
|
||||
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-pv, --pkg-version, -fp=, --file-pattern=PATTERN]\n'
|
||||
f' slpkg [{self.cyan}COMMAND{self.endc}] [-b, build, -i, install, -d, download] [packages...]\n'
|
||||
f' slpkg [{self.cyan}COMMAND{self.endc}] [-R, remove, -f, find, -w, view, -s, search] [packages...]\n'
|
||||
f' slpkg [{self.cyan}COMMAND{self.endc}] [-e, dependees, -t, tracking] [packages...]\n'
|
||||
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-y, --yes, -j, --jobs, -o, --resolve-off, -r, --reinstall]\n'
|
||||
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-k, --skip-installed, -E, --full-reverse, -S, --search]\n'
|
||||
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-n, --no-silent, -p, --pkg-version]\n'
|
||||
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-z, --directory=[PATH], -F, --file-pattern=[PATTERN]]\n'
|
||||
" \nIf you need more information please try 'slpkg --help'.")
|
||||
|
||||
print(args)
|
||||
raise SystemExit()
|
||||
|
||||
def help(self, status: int):
|
||||
def help(self, status: int) -> NoReturn:
|
||||
""" Prints the main menu. """
|
||||
args = (
|
||||
f'{self.bold}USAGE:{self.endc} {Configs.prog_name} [{self.yellow}OPTIONS{self.endc}] '
|
||||
f'[{self.cyan}COMMAND{self.endc}] <packages>\n'
|
||||
f'\n{self.bold}DESCRIPTION:{self.endc} Packaging tool that interacts with the SBo repository.\n'
|
||||
args: str = (
|
||||
f'{self.bold}USAGE:{self.endc} {self.prog_name} [{self.yellow}OPTIONS{self.endc}] '
|
||||
f'[{self.cyan}COMMAND{self.endc}] [PACKAGES...]\n'
|
||||
f'\n{self.bold}DESCRIPTION:{self.endc} Package manager utility for Slackware.\n'
|
||||
f'\n{self.bold}COMMANDS:{self.endc}\n'
|
||||
f' {self.red}-u, update{self.endc} Update the package lists.\n'
|
||||
f' {self.cyan}-U, upgrade{self.endc} Upgrade all the packages.\n'
|
||||
|
@ -47,43 +48,45 @@ class Usage(Configs):
|
|||
f' {self.cyan}-g, configs{self.endc} Edit the configuration file.\n'
|
||||
f' {self.cyan}-L, clean-logs{self.endc} Clean dependencies log tracking.\n'
|
||||
f' {self.cyan}-D, clean-tmp{self.endc} Delete all the downloaded sources.\n'
|
||||
f' {self.cyan}-b, build{self.endc} <packages> Build only the packages.\n'
|
||||
f' {self.cyan}-i, install{self.endc} <packages> Build and install the packages.\n'
|
||||
f' {self.cyan}-d, download{self.endc} <packages> Download only the scripts and sources.\n'
|
||||
f' {self.cyan}-r, remove{self.endc} <packages> Remove installed packages.\n'
|
||||
f' {self.cyan}-f, find{self.endc} <packages> Find installed packages.\n'
|
||||
f' {self.cyan}-w, view{self.endc} <packages> View packages from the repository.\n'
|
||||
f' {self.cyan}-s, search{self.endc} <packages> Search packages from the repository.\n'
|
||||
f' {self.cyan}-e, dependees{self.endc} <packages> Show which packages depend.\n'
|
||||
f' {self.cyan}-t, tracking{self.endc} <packages> Tracking the packages dependencies.\n'
|
||||
f' {self.cyan}-b, build{self.endc} [packages...] Build only the packages.\n'
|
||||
f' {self.cyan}-i, install{self.endc} [packages...] Build and install the packages.\n'
|
||||
f' {self.cyan}-d, download{self.endc} [packages...] Download only the scripts and sources.\n'
|
||||
f' {self.cyan}-R, remove{self.endc} [packages...] Remove installed packages.\n'
|
||||
f' {self.cyan}-f, find{self.endc} [packages...] Find installed packages.\n'
|
||||
f' {self.cyan}-w, view{self.endc} [packages...] View packages from the repository.\n'
|
||||
f' {self.cyan}-s, search{self.endc} [packages...] Search packages from the repository.\n'
|
||||
f' {self.cyan}-e, dependees{self.endc} [packages...] Show which packages depend.\n'
|
||||
f' {self.cyan}-t, tracking{self.endc} [packages...] Tracking the packages dependencies.\n'
|
||||
f'\n{self.bold}OPTIONS:{self.endc}\n'
|
||||
f' {self.yellow}-y, --yes{self.endc} Answer Yes to all questions.\n'
|
||||
f' {self.yellow}-j, --jobs{self.endc} Set it for multicore systems.\n'
|
||||
f' {self.yellow}-ro, --resolve-off{self.endc} Turns off dependency resolving.\n'
|
||||
f' {self.yellow}-R, --reinstall{self.endc} Upgrade packages of the same version.\n'
|
||||
f' {self.yellow}-si, --skip-installed{self.endc} Skip installed packages.\n'
|
||||
f' {self.yellow}-fr, --full-reverse{self.endc} Full reverse dependency.\n'
|
||||
f' {self.yellow}-o, --resolve-off{self.endc} Turns off dependency resolving.\n'
|
||||
f' {self.yellow}-r, --reinstall{self.endc} Upgrade packages of the same version.\n'
|
||||
f' {self.yellow}-k, --skip-installed{self.endc} Skip installed packages.\n'
|
||||
f' {self.yellow}-E, --full-reverse{self.endc} Full reverse dependency.\n'
|
||||
f' {self.yellow}-S, --search{self.endc} Search packages from the repository.\n'
|
||||
f' {self.yellow}-ns, --no-silent{self.endc} Disable silent mode.\n'
|
||||
f' {self.yellow}-dir=, --directory={self.endc}PATH Download files to a specific path.\n'
|
||||
f' {self.yellow}-pv, --pkg-version{self.endc} Print the repository package version.\n'
|
||||
f' {self.yellow}-fp=, --file-pattern={self.endc}PATTERN Include specific installed files.\n'
|
||||
f' {self.yellow}-n, --no-silent{self.endc} Disable silent mode.\n'
|
||||
f' {self.yellow}-p, --pkg-version{self.endc} Print the repository package version.\n'
|
||||
f' {self.yellow}-z, --directory={self.endc}[PATH] Download files to a specific path.\n'
|
||||
f' {self.yellow}-F, --file-pattern={self.endc}[PATTERN] Include specific installed files.\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'
|
||||
"or run 'slpkg configs'.\n"
|
||||
'If you need more information try to use slpkg manpage.')
|
||||
"\nIf you need more information try to use slpkg manpage.\n"
|
||||
"Extra help for the commands, use: 'slpkg help <command>'.\n"
|
||||
"Edit the config file in the /etc/slpkg/slpkg.toml or 'slpkg configs'.")
|
||||
|
||||
print(args)
|
||||
raise SystemExit(status)
|
||||
|
||||
def error_for_options(self, flags):
|
||||
def error_for_options(self, command: str, flags: list) -> NoReturn:
|
||||
""" 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}")
|
||||
flags.reverse() # Put first the short options.
|
||||
print(f'Usage: {self.prog_name} [{self.yellow}OPTIONS{self.endc}] '
|
||||
f'[{self.cyan}COMMAND{self.endc}] [PACKAGES...]\n'
|
||||
f"Try 'slpkg --help' for help.\n")
|
||||
|
||||
raise SystemExit(f"{self.red}Error:{self.endc} Got an unexpected extra option.")
|
||||
print(f"{self.bold}{self.red}Error:{self.endc} Got an unexpected extra option.\n"
|
||||
f"\n{self.bold}COMMAND:{self.endc} {self.cyan}{command}{self.endc}"
|
||||
f"\n{self.bold}OPTIONS:{self.endc} {self.yellow}{', '.join(flags)}{self.endc}\n")
|
||||
print('If you need more information try to use slpkg manpage.')
|
||||
raise SystemExit(1)
|
||||
|
|
69
slpkg/views/help_commands.py
Normal file
69
slpkg/views/help_commands.py
Normal file
|
@ -0,0 +1,69 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from slpkg.configs import Configs
|
||||
|
||||
|
||||
class Help(Configs):
|
||||
|
||||
def __init__(self, command: str, flags: list):
|
||||
super(Configs, self).__init__()
|
||||
self.command: str = command
|
||||
self.flags: list = flags
|
||||
|
||||
color = self.colour()
|
||||
|
||||
self.bold: str = color['bold']
|
||||
self.green: str = color['green']
|
||||
self.cyan: str = color['cyan']
|
||||
self.yellow: str = color['yellow']
|
||||
self.endc: str = color['endc']
|
||||
|
||||
def view(self) -> None:
|
||||
self.flags.reverse() # Put first the short options.
|
||||
|
||||
help_commands: dict = {
|
||||
'update': "Updates the package list and the database.",
|
||||
'upgrade': "Upgrade all the installed packages if the newer version exists in the repository.",
|
||||
'check-updates': "Check if there is any news on the SlackBuild's ChangeLog.txt file.",
|
||||
'configs': "Edit the configuration /etc/slpkg/slpkg.toml file.",
|
||||
'clean-logs': "Cleans dependencies log tracking. After that procedure you should remove dependencies "
|
||||
"by hand.",
|
||||
'clean-tmp': "Deletes all the downloaded SlackBuilds scripts and sources.",
|
||||
'build': "Builds the Slackbuilds scripts and adds them to the /tmp directory.",
|
||||
'install': "Builds and installs the packages in the correct order, and also logs the packages with the "
|
||||
"dependencies for removal.",
|
||||
'download': "Download the SlackBuilds scripts and the sources without building or installing it.",
|
||||
'remove': "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 by default, except "
|
||||
"if you are using '--file-pattern=' option.",
|
||||
'find': "Find your installed packages on your system.",
|
||||
'view': "View information packages from the repository and get everything in your terminal.",
|
||||
'search': "Search and match packages from the repository.",
|
||||
'dependees': "Show which SlackBuilds depend on.",
|
||||
'tracking': "Tracking the packages dependencies."
|
||||
}
|
||||
|
||||
help_commands['-u']: dict = help_commands['update']
|
||||
help_commands['-U']: dict = help_commands['upgrade']
|
||||
help_commands['-c']: dict = help_commands['check-updates']
|
||||
help_commands['-g']: dict = help_commands['configs']
|
||||
help_commands['-L']: dict = help_commands['clean-logs']
|
||||
help_commands['-D']: dict = help_commands['clean-tmp']
|
||||
help_commands['-b']: dict = help_commands['build']
|
||||
help_commands['-i']: dict = help_commands['install']
|
||||
help_commands['-d']: dict = help_commands['download']
|
||||
help_commands['-r']: dict = help_commands['remove']
|
||||
help_commands['-f']: dict = help_commands['find']
|
||||
help_commands['-w']: dict = help_commands['view']
|
||||
help_commands['-s']: dict = help_commands['search']
|
||||
help_commands['-e']: dict = help_commands['dependees']
|
||||
help_commands['-t']: dict = help_commands['tracking']
|
||||
|
||||
print(f'Usage: {self.prog_name} [{self.yellow}OPTIONS{self.endc}] '
|
||||
f'[{self.cyan}COMMAND{self.endc}] [PACKAGES...]')
|
||||
print(f"Try 'slpkg --help' for help.\n")
|
||||
print(f'{self.bold}{self.green}Help: {self.endc}{help_commands[self.command]}\n')
|
||||
print(f"{self.bold}COMMAND{self.endc}: {self.cyan}{self.command}{self.endc}")
|
||||
print(f"{self.bold}OPTIONS:{self.endc} {self.yellow}{', '.join(self.flags)}{self.endc}\n")
|
||||
print('If you need more information try to use slpkg manpage.')
|
|
@ -5,13 +5,13 @@ class Version:
|
|||
""" Print the version. """
|
||||
|
||||
def __init__(self):
|
||||
self.version_info = (4, 5, 3)
|
||||
self.version = '{0}.{1}.{2}'.format(*self.version_info)
|
||||
self.license = 'MIT License'
|
||||
self.author = 'Dimitris Zlatanidis (dslackw)'
|
||||
self.homepage = 'https://dslackw.gitlab.io/slpkg'
|
||||
self.version_info: tuple = (4, 5, 4)
|
||||
self.version: str = '{0}.{1}.{2}'.format(*self.version_info)
|
||||
self.license: str = 'MIT License'
|
||||
self.author: str = 'Dimitris Zlatanidis (dslackw)'
|
||||
self.homepage: str = 'https://dslackw.gitlab.io/slpkg'
|
||||
|
||||
def view(self):
|
||||
def view(self) -> None:
|
||||
""" Prints the version. """
|
||||
print(f'Version: {self.version}\n'
|
||||
f'Author: {self.author}\n'
|
||||
|
|
|
@ -13,26 +13,27 @@ from slpkg.models.models import session as Session
|
|||
class ViewPackage(Configs, Utilities):
|
||||
""" View the repository packages. """
|
||||
|
||||
def __init__(self, flags):
|
||||
def __init__(self, flags: list):
|
||||
super(Configs, self).__init__()
|
||||
super(Utilities, self).__init__()
|
||||
self.flags = flags
|
||||
self.flag_pkg_version = ['-pv', '--pkg-version']
|
||||
self.session = Session
|
||||
self.flags: list = flags
|
||||
|
||||
def package(self, packages: list):
|
||||
self.session = Session
|
||||
self.flag_pkg_version: list = ['-p', '--pkg-version']
|
||||
|
||||
def package(self, packages: list) -> None:
|
||||
""" View the packages from the repository. """
|
||||
color = self.colour()
|
||||
green = color['green']
|
||||
blue = color['blue']
|
||||
yellow = color['yellow']
|
||||
cyan = color['cyan']
|
||||
red = color['red']
|
||||
endc = color['endc']
|
||||
green: str = color['green']
|
||||
blue: str = color['blue']
|
||||
yellow: str = color['yellow']
|
||||
cyan: str = color['cyan']
|
||||
red: str = color['red']
|
||||
endc: str = color['endc']
|
||||
|
||||
for package in packages:
|
||||
|
||||
info = self.session.query(
|
||||
info: list = self.session.query(
|
||||
SBoTable.name,
|
||||
SBoTable.version,
|
||||
SBoTable.requires,
|
||||
|
@ -45,30 +46,30 @@ class ViewPackage(Configs, Utilities):
|
|||
SBoTable.location
|
||||
).filter(SBoTable.name == package).first()
|
||||
|
||||
readme = self.http_request(f'{self.sbo_repo_url}/{info[9]}/{info[0]}/README')
|
||||
readme = self.http_request(f'{self.sbo_repo_url}{info[9]}/{info[0]}/README')
|
||||
|
||||
info_file = self.http_request(f'{self.sbo_repo_url}/{info[9]}/{info[0]}/{info[0]}.info')
|
||||
info_file = self.http_request(f'{self.sbo_repo_url}{info[9]}/{info[0]}/{info[0]}.info')
|
||||
|
||||
maintainer, email, homepage = '', '', ''
|
||||
for line in info_file.data.decode().splitlines():
|
||||
if line.startswith('HOMEPAGE'):
|
||||
homepage = line[10:-1].strip()
|
||||
homepage: str = line[10:-1].strip()
|
||||
if line.startswith('MAINTAINER'):
|
||||
maintainer = line[12:-1].strip()
|
||||
maintainer: str = line[12:-1].strip()
|
||||
if line.startswith('EMAIL'):
|
||||
email = line[7:-1].strip()
|
||||
email: str = line[7:-1].strip()
|
||||
|
||||
deps = (', '.join([f'{cyan}{pkg}' for pkg in info[2].split()]))
|
||||
deps: str = (', '.join([f'{cyan}{pkg}' for pkg in info[2].split()]))
|
||||
|
||||
if self.is_option(self.flag_pkg_version, self.flags):
|
||||
deps = (', '.join([f'{cyan}{pkg}{endc}-{yellow}{SBoQueries(pkg).version()}'
|
||||
f'{green}' for pkg in info[2].split()]))
|
||||
deps: str = (', '.join([f'{cyan}{pkg}{endc}-{yellow}{SBoQueries(pkg).version()}'
|
||||
f'{green}' for pkg in info[2].split()]))
|
||||
|
||||
print(f'Name: {green}{info[0]}{endc}\n'
|
||||
f'Version: {green}{info[1]}{endc}\n'
|
||||
f'Requires: {green}{deps}{endc}\n'
|
||||
f'Homepage: {blue}{homepage}{endc}\n'
|
||||
f'Download SlackBuild: {blue}{self.sbo_repo_url}/{info[9]}/{info[0]}'
|
||||
f'Download SlackBuild: {blue}{self.sbo_repo_url}{info[9]}/{info[0]}'
|
||||
f'{self.sbo_tar_suffix}{endc}\n'
|
||||
f'Download sources: {blue}{info[3]}{endc}\n'
|
||||
f'Download_x86_64 sources: {blue}{info[4]}{endc}\n'
|
||||
|
@ -78,7 +79,7 @@ class ViewPackage(Configs, Utilities):
|
|||
f'Description: {green}{info[8]}{endc}\n'
|
||||
f'Slackware: {cyan}{self.sbo_repo_url.split("/")[-1]}{endc}\n'
|
||||
f'Category: {red}{info[9]}{endc}\n'
|
||||
f'SBo url: {blue}{self.sbo_repo_url}/{info[9]}/{info[0]}{endc}\n'
|
||||
f'SBo url: {blue}{self.sbo_repo_url}{info[9]}/{info[0]}{endc}\n'
|
||||
f'Maintainer: {yellow}{maintainer}{endc}\n'
|
||||
f'Email: {yellow}{email}{endc}\n'
|
||||
f'\nREADME: {cyan}{readme.data.decode()}{endc}')
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
from typing import Any
|
||||
from typing import Any, NoReturn
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.views.ascii import Ascii
|
||||
|
@ -19,48 +19,51 @@ class ViewMessage(Configs):
|
|||
|
||||
def __init__(self, flags: list):
|
||||
super(Configs, self).__init__()
|
||||
self.flags = flags
|
||||
self.flag_resolve_off = ['-ro', '--resolve-off']
|
||||
self.flag_reinstall = ['-R', '--reinstall']
|
||||
self.flag_yes = ['-y', '--yes']
|
||||
self.file_pattern = f'*{self.sbo_repo_tag}'
|
||||
self.flags: list = flags
|
||||
|
||||
self.session = Session
|
||||
self.utils = Utilities()
|
||||
self.black = Blacklist()
|
||||
self.dialogbox = DialogBox()
|
||||
self.color = self.colour()
|
||||
self.yellow = self.color['yellow']
|
||||
self.cyan = self.color['cyan']
|
||||
self.red = self.color['red']
|
||||
self.grey = self.color['grey']
|
||||
self.violet = self.color['violet']
|
||||
self.endc = self.color['endc']
|
||||
self.installed_packages = []
|
||||
self.ascii = Ascii()
|
||||
self.color = self.colour()
|
||||
|
||||
self.yellow: str = self.color['yellow']
|
||||
self.cyan: str = self.color['cyan']
|
||||
self.red: str = self.color['red']
|
||||
self.grey: str = self.color['grey']
|
||||
self.violet: str = self.color['violet']
|
||||
self.endc: str = self.color['endc']
|
||||
self.download_only = None
|
||||
self.installed_packages: list = []
|
||||
self.flag_resolve_off: list = ['-o', '--resolve-off']
|
||||
self.flag_reinstall: list = ['-r', '--reinstall']
|
||||
self.flag_yes: list = ['-y', '--yes']
|
||||
self.file_pattern: str = f'*{self.sbo_repo_tag}'
|
||||
|
||||
def view_packages(self, package, version, mode):
|
||||
""" Printing the main packages. """
|
||||
color = self.red
|
||||
color: str = self.red
|
||||
|
||||
if mode in ['install', 'download']:
|
||||
color = self.cyan
|
||||
color: str = self.cyan
|
||||
if mode == 'build':
|
||||
color = self.yellow
|
||||
color: str = self.yellow
|
||||
if mode == 'upgrade':
|
||||
color = self.violet
|
||||
color: str = self.violet
|
||||
|
||||
self.ascii.draw_view_package(package, version, color)
|
||||
|
||||
def view_skipping_packages(self, sbo, version):
|
||||
def view_skipping_packages(self, sbo: str, version: str) -> None:
|
||||
""" 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):
|
||||
def build_packages(self, slackbuilds: list, dependencies: list) -> None:
|
||||
""" View packages for build only. """
|
||||
self.ascii.draw_package_title_box('The following packages will be build:', 'Build Packages')
|
||||
|
||||
for sbo in slackbuilds:
|
||||
version = SBoQueries(sbo).version()
|
||||
version: str = SBoQueries(sbo).version()
|
||||
self.view_packages(sbo, version, mode='build')
|
||||
|
||||
if dependencies:
|
||||
|
@ -68,21 +71,21 @@ class ViewMessage(Configs):
|
|||
self.ascii.draw_dependency_line()
|
||||
|
||||
for sbo in dependencies:
|
||||
version = SBoQueries(sbo).version()
|
||||
version: str = SBoQueries(sbo).version()
|
||||
self.view_packages(sbo, version, mode='build')
|
||||
|
||||
self.summary(slackbuilds, dependencies, option='build')
|
||||
|
||||
def install_packages(self, slackbuilds: list, dependencies: list, mode: str):
|
||||
def install_packages(self, slackbuilds: list, dependencies: list, mode: str) -> None:
|
||||
""" View packages for install. """
|
||||
title = 'Install Packages'
|
||||
title: str = 'Install Packages'
|
||||
if mode == 'upgrade':
|
||||
title = 'Upgrade Packages'
|
||||
title: str = 'Upgrade Packages'
|
||||
|
||||
self.ascii.draw_package_title_box('The following packages will be installed or upgraded:', title)
|
||||
|
||||
for sbo in slackbuilds:
|
||||
version = SBoQueries(sbo).version()
|
||||
version: str = SBoQueries(sbo).version()
|
||||
self.view_packages(sbo, version, mode=mode)
|
||||
|
||||
if dependencies:
|
||||
|
@ -90,20 +93,20 @@ class ViewMessage(Configs):
|
|||
self.ascii.draw_dependency_line()
|
||||
|
||||
for sbo in dependencies:
|
||||
version = SBoQueries(sbo).version()
|
||||
version: str = SBoQueries(sbo).version()
|
||||
self.view_packages(sbo, version, mode=mode)
|
||||
|
||||
self.summary(slackbuilds, dependencies, option=mode)
|
||||
|
||||
def download_packages(self, slackbuilds: list, directory):
|
||||
def download_packages(self, slackbuilds: list, directory: str) -> None:
|
||||
""" View downloaded packages. """
|
||||
self.ascii.draw_package_title_box('The following packages will be downloaded:', 'Download Packages')
|
||||
|
||||
if directory:
|
||||
self.download_only = directory
|
||||
self.download_only: str = directory
|
||||
|
||||
for sbo in slackbuilds:
|
||||
version = SBoQueries(sbo).version()
|
||||
version: str = SBoQueries(sbo).version()
|
||||
self.view_packages(sbo, version, mode='download')
|
||||
|
||||
self.summary(slackbuilds, dependencies=[], option='download')
|
||||
|
@ -111,7 +114,7 @@ class ViewMessage(Configs):
|
|||
def remove_packages(self, packages: list, file_pattern: str) -> Any:
|
||||
""" View remove packages. """
|
||||
if file_pattern:
|
||||
self.file_pattern = file_pattern
|
||||
self.file_pattern: str = file_pattern
|
||||
|
||||
slackbuilds, dependencies = [], []
|
||||
for pkg in packages:
|
||||
|
@ -125,7 +128,7 @@ class ViewMessage(Configs):
|
|||
dependencies += requires[0].split()
|
||||
|
||||
if dependencies and not self.utils.is_option(self.flag_resolve_off, self.flags):
|
||||
dependencies = self.choose_dependencies_for_remove(list(set(dependencies)))
|
||||
dependencies: list = self.choose_dependencies_for_remove(list(set(dependencies)))
|
||||
|
||||
self.ascii.draw_package_title_box('The following packages will be removed:', 'Remove Packages')
|
||||
|
||||
|
@ -140,19 +143,19 @@ class ViewMessage(Configs):
|
|||
for pkg in dependencies:
|
||||
self._view_removed(pkg)
|
||||
else:
|
||||
dependencies = []
|
||||
dependencies: list = []
|
||||
|
||||
self.summary(slackbuilds, dependencies, option='remove')
|
||||
|
||||
return self.installed_packages, dependencies
|
||||
|
||||
def _view_removed(self, name: str):
|
||||
def _view_removed(self, name: str) -> None:
|
||||
""" View and creates list with packages for remove. """
|
||||
installed = self.utils.all_installed(self.file_pattern)
|
||||
|
||||
if self.utils.is_installed(name, self.file_pattern):
|
||||
for package in installed:
|
||||
pkg = self.utils.split_installed_pkg(package)[0]
|
||||
pkg: str = self.utils.split_installed_pkg(package)[0]
|
||||
if pkg == name:
|
||||
self.installed_packages.append(package)
|
||||
version = self.utils.split_installed_pkg(package)[1]
|
||||
|
@ -160,17 +163,17 @@ class ViewMessage(Configs):
|
|||
|
||||
def choose_dependencies_for_remove(self, dependencies: list) -> list:
|
||||
""" Choose packages for remove using the dialog box. """
|
||||
height = 10
|
||||
width = 70
|
||||
list_height = 0
|
||||
choices = []
|
||||
title = " Choose dependencies you want to remove "
|
||||
height: int = 10
|
||||
width: int = 70
|
||||
list_height: int = 0
|
||||
choices: list = []
|
||||
title: str = " Choose dependencies you want to remove "
|
||||
|
||||
for package in dependencies:
|
||||
repo_ver = SBoQueries(package).version()
|
||||
repo_ver: str = SBoQueries(package).version()
|
||||
choices += [(package, repo_ver, True)]
|
||||
|
||||
text = f'There are {len(choices)} dependencies:'
|
||||
text: str = f'There are {len(choices)} dependencies:'
|
||||
|
||||
code, tags = self.dialogbox.checklist(text, title, height, width, list_height, choices, dependencies)
|
||||
|
||||
|
@ -180,20 +183,20 @@ class ViewMessage(Configs):
|
|||
os.system('clear')
|
||||
return tags
|
||||
|
||||
def summary(self, slackbuilds: list, dependencies: list, option: str):
|
||||
def summary(self, slackbuilds: list, dependencies: list, option: str) -> None:
|
||||
""" View the status of the packages action. """
|
||||
slackbuilds.extend(dependencies)
|
||||
install = upgrade = remove = 0
|
||||
|
||||
for sbo in slackbuilds:
|
||||
installed = self.utils.is_installed(sbo, self.file_pattern)
|
||||
installed: str = self.utils.is_installed(sbo, self.file_pattern)
|
||||
|
||||
if not installed:
|
||||
install += 1
|
||||
elif installed and self.utils.is_option(self.flag_reinstall, self.flags):
|
||||
upgrade += 1
|
||||
elif (installed and self.utils.is_repo_version_bigger(sbo, self.file_pattern) and
|
||||
self.utils.is_option(self.flag_reinstall, self.flags)):
|
||||
elif (installed and self.utils.is_package_upgradeable(sbo, self.file_pattern) and
|
||||
self.utils.is_option(self.flag_reinstall, self.flags)):
|
||||
upgrade += 1
|
||||
elif installed and option == 'remove':
|
||||
remove += 1
|
||||
|
@ -216,7 +219,7 @@ class ViewMessage(Configs):
|
|||
print(f'{self.grey}{len(slackbuilds)} packages '
|
||||
f'will be downloaded in {self.download_only} folder.{self.endc}')
|
||||
|
||||
def logs_packages(self, dependencies: list):
|
||||
def logs_packages(self, dependencies: list) -> None:
|
||||
""" View the logging packages. """
|
||||
print('The following logs will be removed:\n')
|
||||
|
||||
|
@ -226,10 +229,10 @@ class ViewMessage(Configs):
|
|||
|
||||
print('Note: After cleaning you should remove them one by one.')
|
||||
|
||||
def question(self):
|
||||
def question(self) -> NoReturn:
|
||||
""" Manage to proceed. """
|
||||
if not self.utils.is_option(self.flag_yes, self.flags):
|
||||
answer = input('\nDo you want to continue? [y/N] ')
|
||||
answer: str = input('\nDo you want to continue? [y/N] ')
|
||||
if answer not in ['Y', 'y']:
|
||||
raise SystemExit()
|
||||
print()
|
||||
|
|
|
@ -6,7 +6,7 @@ class TestBlacklist(unittest.TestCase):
|
|||
|
||||
def test_blacklist(self):
|
||||
black = Blacklist()
|
||||
self.assertListEqual(['%README%'], black.get())
|
||||
self.assertListEqual(['%README%'], black.packages())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Reference in a new issue