mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-13 20:01:48 +01:00
Merge branch 'develop'
This commit is contained in:
commit
f07a872d88
34 changed files with 304 additions and 231 deletions
|
@ -1,3 +1,8 @@
|
|||
4.5.1 - 16/01/2023
|
||||
Added:
|
||||
- Option --directory=PATH for download command
|
||||
- Option --pkg-version for print repository version
|
||||
|
||||
4.5.0 - 14/01/2023
|
||||
Updated:
|
||||
- Download first all the slackbuilds
|
||||
|
|
|
@ -31,8 +31,8 @@ Install from the official third-party `SBo repository <https://slackbuilds.org/r
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
$ tar xvf slpkg-4.5.0.tar.gz
|
||||
$ cd slpkg-4.5.0
|
||||
$ tar xvf slpkg-4.5.1.tar.gz
|
||||
$ cd slpkg-4.5.1
|
||||
$ ./install.sh
|
||||
|
||||
Screenshots
|
||||
|
@ -88,6 +88,8 @@ Usage
|
|||
--full-reverse Full reverse dependency.
|
||||
--search Search packages from the repository.
|
||||
--no-silent Disable silent mode.
|
||||
--directory=PATH Download files to a specific path.
|
||||
--pkg-version Print the repository package version.
|
||||
|
||||
-h, --help Show this message and exit.
|
||||
-v, --version Print version and exit.
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
sbo_repo_path = "/var/lib/slpkg/repository"
|
||||
|
||||
# The name of the database. Default name is 'database.slpkg'.
|
||||
database = "database.slpkg"
|
||||
database_name = "database.slpkg"
|
||||
|
||||
# Slackbuilds.org repository url.
|
||||
sbo_repo_url = "http://slackbuilds.org/slackbuilds/15.0"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
.P
|
||||
slpkg [-h|-v] [update] [upgrade] [check-updates] [configs] [clean-logs] [clean-tmp] [-b, build] [-i, install] [-d, download]
|
||||
[-r, remove] [-f, find] [-w, view] [-s, search] [-e, dependees] [-t, tracking] --yes, --jobs, --resolve-off,
|
||||
--reinstall, --skip-installed, --full-reverse, --search
|
||||
--reinstall, --skip-installed, --full-reverse, --search, --no-silent, --directory=PATH, --pkg-version
|
||||
.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.
|
||||
|
@ -57,7 +57,7 @@ Construit les scripts des Slackbuilds et les ajoute au répertoire \fB/tmp\fP.
|
|||
Construit et installe les paquets dans l'ordre adéquat et enregistre également les paquets avec les dépendances à utiliser pour la suppression.
|
||||
.RE
|
||||
.P
|
||||
.B -d, download --yes, --search, --no-silent
|
||||
.B -d, download --yes, --search, --no-silent, --directory=PATH
|
||||
.RS
|
||||
Télécharger les scripts et les sources des SlackBuilds sans les construire ni les installer.
|
||||
.RE
|
||||
|
@ -73,7 +73,7 @@ Slpkg examine la configuration \fB'sbo_repo_tag'\fP pour trouver les paquets à
|
|||
Trouver les paquets installés par \fBSBo\fP (taggés _SBo) sur votre distribution.
|
||||
.RE
|
||||
.P
|
||||
.B -w, view --search
|
||||
.B -w, view --search, --pkg-version
|
||||
.RS
|
||||
Voir les paquets du dépôt et obtenir toutes les informations dans le terminal.
|
||||
.RE
|
||||
|
@ -83,12 +83,12 @@ Voir les paquets du dépôt et obtenir toutes les informations dans le terminal.
|
|||
Rechercher les paquets.
|
||||
.RE
|
||||
.P
|
||||
.B -e, dependees --full-reverse, --search
|
||||
.B -e, dependees --full-reverse, --search, --pkg-version
|
||||
.RS
|
||||
Montre les dépendances du paquet.
|
||||
.RE
|
||||
.P
|
||||
.B -t, tracking --search
|
||||
.B -t, tracking --search, --pkg-version
|
||||
.RS
|
||||
Suivi des dépendances des paquets.
|
||||
.RE
|
||||
|
@ -139,6 +139,16 @@ Essayez par exemple : \fB`slpkg install python3 --search`\fP ou \fB`slpkg downlo
|
|||
Désactive le mode silencieux s'il est activé dans le fichier de configuration.
|
||||
.RE
|
||||
.P
|
||||
--directory=PATH
|
||||
.RS
|
||||
Le répertoire est le chemin où les fichiers seront enregistrés.
|
||||
.RE
|
||||
.P
|
||||
--pkg-version
|
||||
.RS
|
||||
Imprimez la version du package du référentiel.
|
||||
.RE
|
||||
.P
|
||||
-h | --help
|
||||
.RS
|
||||
Affiche l'aide.
|
||||
|
|
20
man/slpkg.1
20
man/slpkg.1
|
@ -6,7 +6,7 @@
|
|||
.P
|
||||
slpkg [-h|-v] [update] [upgrade] [check-updates] [configs] [clean-logs] [clean-tmp] [-b, build] [-i, install] [-d, download]
|
||||
[-r, remove] [-f, find] [-w, view] [-s, search] [-e, dependees] [-t, tracking] --yes, --jobs, --resolve-off,
|
||||
--reinstall, --skip-installed, --full-reverse, --search
|
||||
--reinstall, --skip-installed, --full-reverse, --search, --no-silent, --directory=PATH, --pkg-version
|
||||
.SH DESCRIPTION
|
||||
.P
|
||||
Slpkg is a software package manager that installs, updates, and removes packages on Slackware based systems.
|
||||
|
@ -57,7 +57,7 @@ Builds the Slackbuilds scripts and adds them to the /tmp directory.
|
|||
Builds and installs the packages in the correct order and also logs the packages with dependencies to use for removal.
|
||||
.RE
|
||||
.P
|
||||
.B -d, download --yes, --search, --no-silent
|
||||
.B -d, download --yes, --search, --no-silent, --directory=PATH
|
||||
.RS
|
||||
Download the SlackBuilds scripts and the sources without building or installing it.
|
||||
.RE
|
||||
|
@ -73,7 +73,7 @@ Slpkg looks at the 'sbo_repo_tag' configuration to find packages for removal.
|
|||
Find sbo installed packages on your distribution.
|
||||
.RE
|
||||
.P
|
||||
.B -w, view --search
|
||||
.B -w, view --search, --pkg-version
|
||||
.RS
|
||||
View packages from the repository and get everything in your terminal.
|
||||
.RE
|
||||
|
@ -83,12 +83,12 @@ View packages from the repository and get everything in your terminal.
|
|||
Search and match packages from the repository.
|
||||
.RE
|
||||
.P
|
||||
.B -e, dependees --full-reverse, --search
|
||||
.B -e, dependees --full-reverse, --search, --pkg-version
|
||||
.RS
|
||||
Show which SlackBuilds depend on.
|
||||
.RE
|
||||
.P
|
||||
.B -t, tracking --search
|
||||
.B -t, tracking --search, --pkg-version
|
||||
.RS
|
||||
Tracking the packages dependencies.
|
||||
.RE
|
||||
|
@ -139,6 +139,16 @@ Example try: `slpkg install python3 --search` or `slpkg download python3 --searc
|
|||
Disable silent mode if it is enabled in the configuration file.
|
||||
.RE
|
||||
.P
|
||||
--directory=PATH
|
||||
.RS
|
||||
The directory is the path where the files will be saved.
|
||||
.RE
|
||||
.P
|
||||
--pkg-version
|
||||
.RS
|
||||
Print the repository package version.
|
||||
.RE
|
||||
.P
|
||||
-h | --help
|
||||
.RS
|
||||
Show help information and exit.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[metadata]
|
||||
name = slpkg
|
||||
version = 4.5.0
|
||||
version = 4.5.1
|
||||
license_file = LICENSE
|
||||
author = Dimitris Zlatanidis
|
||||
author_email = d.zlatanidis@gmail.com
|
||||
|
|
|
@ -7,15 +7,15 @@ from pathlib import Path
|
|||
from slpkg.configs import Configs
|
||||
|
||||
|
||||
class Blacklist:
|
||||
class Blacklist(Configs):
|
||||
""" Reads and returns the blacklist. """
|
||||
|
||||
def __init__(self):
|
||||
self.configs = Configs
|
||||
super(Configs, self).__init__()
|
||||
|
||||
def get(self) -> list:
|
||||
""" Reads the blacklist file. """
|
||||
file = Path(self.configs.etc_path, 'blacklist.toml')
|
||||
file = Path(self.etc_path, 'blacklist.toml')
|
||||
if file.is_file():
|
||||
with open(file, 'rb') as black:
|
||||
return tomli.load(black)['blacklist']['packages']
|
||||
|
|
|
@ -10,13 +10,12 @@ from slpkg.configs import Configs
|
|||
from slpkg.progress_bar import ProgressBar
|
||||
|
||||
|
||||
class CheckUpdates:
|
||||
class CheckUpdates(Configs):
|
||||
""" Check for changes in the ChangeLog file. """
|
||||
|
||||
def __init__(self):
|
||||
self.configs = Configs
|
||||
self.colors = self.configs.colour
|
||||
self.color = self.colors()
|
||||
super(Configs, self).__init__()
|
||||
self.color = self.colour()
|
||||
self.green = self.color['green']
|
||||
self.yellow = self.color['yellow']
|
||||
self.endc = self.color['endc']
|
||||
|
@ -26,12 +25,10 @@ class CheckUpdates:
|
|||
""" Checks the ChangeLogs and returns True or False. """
|
||||
local_date = 0
|
||||
|
||||
local_chg_txt = Path(self.configs.sbo_repo_path,
|
||||
self.configs.sbo_chglog_txt)
|
||||
local_chg_txt = Path(self.sbo_repo_path, self.sbo_chglog_txt)
|
||||
|
||||
http = urllib3.PoolManager()
|
||||
repo = http.request(
|
||||
'GET', f'{self.configs.sbo_repo_url}/{self.configs.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)
|
||||
|
|
|
@ -9,12 +9,12 @@ from slpkg.blacklist import Blacklist
|
|||
from slpkg.utilities import Utilities
|
||||
|
||||
|
||||
class Check:
|
||||
class Check(Configs, Utilities):
|
||||
""" Some checks before proceed. """
|
||||
|
||||
def __init__(self):
|
||||
self.configs = Configs
|
||||
self.utils = Utilities()
|
||||
super(Configs, self).__init__()
|
||||
super(Utilities, self).__init__()
|
||||
|
||||
@staticmethod
|
||||
def exists(slackbuilds: list):
|
||||
|
@ -43,9 +43,9 @@ class Check:
|
|||
found, not_found = [], []
|
||||
|
||||
for sbo in slackbuilds:
|
||||
package = self.utils.is_installed(sbo)
|
||||
package = self.is_installed(sbo)
|
||||
if package:
|
||||
pkg = self.utils.split_installed_pkg(package)[0]
|
||||
pkg = self.split_installed_pkg(package)[0]
|
||||
found.append(pkg)
|
||||
else:
|
||||
not_found.append(sbo)
|
||||
|
@ -73,7 +73,7 @@ class Check:
|
|||
|
||||
def database(self):
|
||||
""" Checking for empty table """
|
||||
db = Path(self.configs.db_path, self.configs.database)
|
||||
db = Path(self.db_path, self.database_name)
|
||||
if not SBoQueries('').sbos() or not db.is_file():
|
||||
raise SystemExit('\nYou need to update the package lists first.\n'
|
||||
'Please run slpkg update.\n')
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
import hashlib
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
from urllib.parse import unquote
|
||||
|
||||
from slpkg.views.ascii import Ascii
|
||||
from slpkg.views.views import ViewMessage
|
||||
|
@ -18,7 +19,8 @@ class Md5sum:
|
|||
|
||||
def check(self, path: Union[str, Path], source: str, checksum: str, name: str):
|
||||
""" Checksum the source. """
|
||||
source_file = Path(path, source.split('/')[-1])
|
||||
filename = unquote(source)
|
||||
source_file = Path(path, filename.split('/')[-1])
|
||||
|
||||
md5 = self.read_file(source_file)
|
||||
|
||||
|
@ -27,7 +29,7 @@ class Md5sum:
|
|||
checksum = "".join(checksum)
|
||||
|
||||
if file_check != checksum:
|
||||
self.ascii.checksum_error_box(name, checksum, file_check)
|
||||
self.ascii.draw_checksum_error_box(name, checksum, file_check)
|
||||
view = ViewMessage(self.flags)
|
||||
view.question()
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ class Configs:
|
|||
log_packages: str = Path('/var', 'log', 'packages')
|
||||
|
||||
# Database name
|
||||
database: str = f'database.{prog_name}'
|
||||
database_name: str = f'database.{prog_name}'
|
||||
|
||||
# SBo repository configs
|
||||
sbo_repo_url: str = 'http://slackbuilds.org/slackbuilds/15.0'
|
||||
|
@ -87,7 +87,7 @@ class Configs:
|
|||
sbo_repo_path: str = config['sbo_repo_path']
|
||||
|
||||
# Database name
|
||||
database: str = config['database']
|
||||
database_name: str = config['database_name']
|
||||
|
||||
# SBo repository details
|
||||
sbo_repo_url: str = config['sbo_repo_url']
|
||||
|
@ -113,8 +113,9 @@ class Configs:
|
|||
# Choose the view mode
|
||||
silent_mode: str = config['silent_mode']
|
||||
except KeyError as error:
|
||||
raise SystemExit(f"\nKeyError: {error}: in the configuration file "
|
||||
"'/etc/slpkg/slpkg.toml'\n")
|
||||
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")
|
||||
|
||||
# Creating the paths if not exists
|
||||
paths = [tmp_slpkg,
|
||||
|
|
|
@ -9,11 +9,11 @@ from slpkg.models.models import SBoTable
|
|||
from slpkg.models.models import session as Session
|
||||
|
||||
|
||||
class CreateData:
|
||||
class CreateData(Configs):
|
||||
""" Reads the SLACKBUILDS.TXT file and inserts them into the database. """
|
||||
|
||||
def __init__(self):
|
||||
self.configs = Configs
|
||||
super(Configs, self).__init__()
|
||||
self.session = Session
|
||||
|
||||
def insert_sbo_table(self):
|
||||
|
@ -30,7 +30,7 @@ class CreateData:
|
|||
'SLACKBUILD REQUIRES:',
|
||||
'SLACKBUILD SHORT DESCRIPTION:'
|
||||
]
|
||||
path = Path(self.configs.sbo_repo_path, self.configs.sbo_txt)
|
||||
path = Path(self.sbo_repo_path, self.sbo_txt)
|
||||
sbo_file = self.read_file(path)
|
||||
|
||||
cache = [] # init cache
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.views.ascii import Ascii
|
||||
from slpkg.queries import SBoQueries
|
||||
from slpkg.models.models import SBoTable
|
||||
from slpkg.models.models import session as Session
|
||||
|
||||
|
@ -14,6 +15,7 @@ class Dependees:
|
|||
self.packages = packages
|
||||
self.flags = flags
|
||||
self.flag_full_reverse = '--full-reverse'
|
||||
self.flag_pkg_version = '--pkg-version'
|
||||
self.configs = Configs
|
||||
self.session = Session
|
||||
self.ascii = Ascii()
|
||||
|
@ -37,23 +39,38 @@ class Dependees:
|
|||
|
||||
for pkg in self.packages:
|
||||
dependees = list(self.find_requires(pkg))
|
||||
print(f'{self.byellow}{pkg}{self.endc}')
|
||||
|
||||
package = f'{self.byellow}{pkg}{self.endc}'
|
||||
|
||||
if self.flag_pkg_version in self.flags:
|
||||
package = f'{self.byellow}{pkg}-{SBoQueries(pkg).version()}{self.endc}'
|
||||
|
||||
print(package)
|
||||
|
||||
print(f' {self.llc}{self.hl}', end='')
|
||||
|
||||
if not dependees:
|
||||
print(f'{self.cyan} No dependees{self.endc}')
|
||||
|
||||
sp = ' ' * 4
|
||||
for i, dep in enumerate(dependees, start=1):
|
||||
dependency = f'{self.cyan}{dep[0]}{self.endc}'
|
||||
|
||||
if self.flag_pkg_version in self.flags:
|
||||
dependency = (f'{self.cyan}{dep[0]}{self.endc}-{self.yellow}'
|
||||
f'{SBoQueries(dep[0]).version()}{self.endc}')
|
||||
|
||||
if i == 1:
|
||||
print(f' {self.cyan}{dep[0]}{self.endc}')
|
||||
print(f' {dependency}')
|
||||
else:
|
||||
print(f'{sp}{self.cyan}{dep[0]}{self.endc}')
|
||||
print(f'{sp}{dependency}')
|
||||
|
||||
if self.flag_full_reverse in self.flags:
|
||||
if i == len(dependees):
|
||||
print(" " * 4 + f' {self.llc}{self.hl} {self.violet}{dep[1]}{self.endc}')
|
||||
else:
|
||||
print(" " * 4 + f' {self.var}{self.hl} {self.violet}{dep[1]}{self.endc}')
|
||||
|
||||
print(f'\n{self.grey}{len(dependees)} dependees for {pkg}{self.endc}\n')
|
||||
|
||||
def find_requires(self, sbo):
|
||||
|
|
|
@ -12,18 +12,18 @@ from slpkg.views.version import Version
|
|||
locale.setlocale(locale.LC_ALL, '')
|
||||
|
||||
|
||||
class DialogBox:
|
||||
class DialogBox(Configs):
|
||||
""" Class for dialog box"""
|
||||
|
||||
def __init__(self):
|
||||
self.configs = Configs()
|
||||
super(Configs).__init__()
|
||||
self.d = Dialog(dialog="dialog")
|
||||
self.d.set_background_title(f'{self.configs.prog_name} {Version().version} - Software Package Manager')
|
||||
self.d.set_background_title(f'{self.prog_name} {Version().version} - Software Package Manager')
|
||||
|
||||
def checklist(self, text: str, title: str, height: int, width: int,
|
||||
list_height: int, choices: list, packages: list):
|
||||
""" Display a checklist box. """
|
||||
if self.configs.dialog:
|
||||
if self.dialog:
|
||||
code, tags = self.d.checklist(text, title=title, height=height, width=width,
|
||||
list_height=list_height, choices=choices)
|
||||
else:
|
||||
|
@ -34,7 +34,7 @@ class DialogBox:
|
|||
|
||||
def mixedform(self, text: str, title: str, elements: list, height: int, width: int):
|
||||
""" Display a mixedform box. """
|
||||
if self.configs.dialog:
|
||||
if self.dialog:
|
||||
code, tags = self.d.mixedform(text=text, title=title, elements=elements,
|
||||
height=height, width=width, help_button=True)
|
||||
else:
|
||||
|
@ -45,10 +45,10 @@ class DialogBox:
|
|||
|
||||
def msgbox(self, text: str, height: int, width: int):
|
||||
""" Display a message box. """
|
||||
if self.configs.dialog:
|
||||
if self.dialog:
|
||||
self.d.msgbox(text, height, width)
|
||||
|
||||
def textbox(self, text: Union[str, Path], height: int, width: int):
|
||||
""" Display a text box. """
|
||||
if self.configs.dialog:
|
||||
if self.dialog:
|
||||
self.d.textbox(text, height, width)
|
||||
|
|
|
@ -11,14 +11,16 @@ from slpkg.views.views import ViewMessage
|
|||
from slpkg.models.models import session as Session
|
||||
|
||||
|
||||
class Download:
|
||||
class Download(Configs, Utilities):
|
||||
""" Download the slackbuilds with the sources only. """
|
||||
|
||||
def __init__(self, flags: list):
|
||||
self.flags: list = flags
|
||||
self.configs = Configs
|
||||
def __init__(self, directory: str, flags: list):
|
||||
super(Configs, self).__init__()
|
||||
super(Utilities, self).__init__()
|
||||
self.flags = flags
|
||||
self.directory = directory
|
||||
self.flag_directory = '--directory='
|
||||
self.session = Session
|
||||
self.utils = Utilities()
|
||||
|
||||
def packages(self, slackbuilds: list):
|
||||
""" Download the package only. """
|
||||
|
@ -26,19 +28,23 @@ class Download:
|
|||
view.download_packages(slackbuilds)
|
||||
view.question()
|
||||
|
||||
download_path = self.download_only
|
||||
if self.flag_directory in self.flags:
|
||||
download_path = self.directory
|
||||
|
||||
start = time.time()
|
||||
for sbo in slackbuilds:
|
||||
file = f'{sbo}{self.configs.sbo_tar_suffix}'
|
||||
file = f'{sbo}{self.sbo_tar_suffix}'
|
||||
location = SBoQueries(sbo).location()
|
||||
url = f'{self.configs.sbo_repo_url}/{location}/{file}'
|
||||
url = f'{self.sbo_repo_url}/{location}/{file}'
|
||||
|
||||
down_sbo = Downloader(self.configs.download_only, url, self.flags)
|
||||
down_sbo = Downloader(download_path, url, self.flags)
|
||||
down_sbo.download()
|
||||
|
||||
sources = SBoQueries(sbo).sources()
|
||||
for source in sources:
|
||||
down_source = Downloader(self.configs.download_only, source, self.flags)
|
||||
down_source = Downloader(download_path, source, self.flags)
|
||||
down_source.download()
|
||||
|
||||
elapsed_time = time.time() - start
|
||||
self.utils.finished_time(elapsed_time)
|
||||
self.finished_time(elapsed_time)
|
||||
|
|
|
@ -4,13 +4,14 @@
|
|||
import subprocess
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
from urllib.parse import unquote
|
||||
from multiprocessing import Process
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.progress_bar import ProgressBar
|
||||
|
||||
|
||||
class Downloader:
|
||||
class Downloader(Configs):
|
||||
""" Wget downloader. """
|
||||
|
||||
def __init__(self, path: Union[str, Path], url: str, flags: list):
|
||||
|
@ -19,9 +20,7 @@ class Downloader:
|
|||
self.flags = flags
|
||||
self.flag_no_silent = '--no-silent'
|
||||
self.filename = url.split('/')[-1]
|
||||
self.configs = Configs
|
||||
self.colors = self.configs.colour
|
||||
self.color = self.colors()
|
||||
self.color = self.colour()
|
||||
self.bold = self.color['bold']
|
||||
self.green = self.color['green']
|
||||
self.yellow = self.color['yellow']
|
||||
|
@ -37,14 +36,15 @@ class Downloader:
|
|||
|
||||
def wget(self):
|
||||
""" Wget downloader. """
|
||||
self.output = subprocess.call(f'wget {self.configs.wget_options} --directory-prefix={self.path} {self.url}',
|
||||
self.output = subprocess.call(f'wget {self.wget_options} --directory-prefix={self.path} "{self.url}"',
|
||||
shell=True, stderr=self.stderr, stdout=self.stdout)
|
||||
if self.output != 0:
|
||||
raise SystemExit(self.output)
|
||||
|
||||
def check_if_downloaded(self):
|
||||
""" Checks if the file downloaded. """
|
||||
file = self.url.split('/')[-1]
|
||||
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}' "
|
||||
|
@ -52,7 +52,7 @@ class Downloader:
|
|||
|
||||
def download(self):
|
||||
""" Starting multiprocessing download process. """
|
||||
if self.configs.silent_mode and self.flag_no_silent not in self.flags:
|
||||
if self.silent_mode and self.flag_no_silent not in self.flags:
|
||||
|
||||
done = f' {self.byellow} Done{self.endc}'
|
||||
self.stderr = subprocess.DEVNULL
|
||||
|
|
|
@ -5,25 +5,24 @@ from slpkg.configs import Configs
|
|||
from slpkg.utilities import Utilities
|
||||
|
||||
|
||||
class FindInstalled:
|
||||
class FindInstalled(Configs, Utilities):
|
||||
""" Find installed packages. """
|
||||
|
||||
def __init__(self):
|
||||
self.configs = Configs
|
||||
self.colors = self.configs.colour
|
||||
self.color = self.colors()
|
||||
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']
|
||||
self.utils = Utilities()
|
||||
|
||||
def find(self, packages: list):
|
||||
""" Find the packages. """
|
||||
matching = []
|
||||
installed = self.utils.all_installed()
|
||||
installed = self.all_installed()
|
||||
|
||||
print(f'The list below shows the installed packages '
|
||||
f'that contains \'{", ".join([p for p in packages])}\' files:\n')
|
||||
|
@ -38,7 +37,7 @@ class FindInstalled:
|
|||
""" Print the matched packages. """
|
||||
if matching:
|
||||
for package in matching:
|
||||
pkg = self.utils.split_installed_pkg(package)
|
||||
pkg = self.split_installed_pkg(package)
|
||||
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}')
|
||||
|
|
|
@ -9,24 +9,22 @@ from slpkg.configs import LoadConfigs
|
|||
from slpkg.dialog_box import DialogBox
|
||||
|
||||
|
||||
class FormConfigs:
|
||||
class FormConfigs(Configs):
|
||||
|
||||
def __init__(self):
|
||||
self.orig_configs = None
|
||||
self.configs = Configs()
|
||||
self.load_configs = LoadConfigs()
|
||||
self.dialog = DialogBox()
|
||||
self.config_file = Path(self.configs.etc_path, f'{self.configs.prog_name}.toml')
|
||||
self.dialogbox = DialogBox()
|
||||
self.config_file = Path(self.etc_path, f'{self.prog_name}.toml')
|
||||
|
||||
def edit(self):
|
||||
""" Read and write the configuration file. """
|
||||
elements = []
|
||||
config_file = Path(self.configs.etc_path, f'{self.configs.prog_name}.toml')
|
||||
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.configs.etc_path,
|
||||
self.configs.prog_name)
|
||||
configs = 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):
|
||||
|
@ -43,7 +41,7 @@ class FormConfigs:
|
|||
text = f'Edit the configuration file: {config_file}'
|
||||
title = ' Configuration File '
|
||||
|
||||
code, tags = self.dialog.mixedform(text, title, elements, height, width)
|
||||
code, tags = self.dialogbox.mixedform(text, title, elements, height, width)
|
||||
|
||||
os.system('clear')
|
||||
|
||||
|
@ -59,14 +57,14 @@ class FormConfigs:
|
|||
def help(self):
|
||||
""" Load the configuration file on a text box. """
|
||||
self.read_configs()
|
||||
self.dialog.textbox(str(self.config_file), 40, 60)
|
||||
self.dialogbox.textbox(str(self.config_file), 40, 60)
|
||||
self.edit()
|
||||
|
||||
def check_configs(self, configs: dict, tags: list) -> bool:
|
||||
""" Check for true of false values. """
|
||||
for key, value in zip(configs['configs'].keys(), tags):
|
||||
if key in ['colors', 'dialog', 'silent_mode'] and value not in ['true', 'false']:
|
||||
self.dialog.msgbox(f"\nError value for {key}. It must be 'true' or 'false'\n", height=7, width=60)
|
||||
self.dialogbox.msgbox(f"\nError value for {key}. It must be 'true' or 'false'\n", height=7, width=60)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
|
|
@ -26,13 +26,13 @@ from slpkg.clean_logs import CleanLogsDependencies
|
|||
from slpkg.update_repository import UpdateRepository
|
||||
|
||||
|
||||
class Argparse:
|
||||
class Argparse(Configs):
|
||||
|
||||
def __init__(self, args: list):
|
||||
self.args = args
|
||||
self.flags = []
|
||||
self.configs = Configs
|
||||
self.dialog = DialogBox()
|
||||
self.directory = None
|
||||
self.dialogbox = DialogBox()
|
||||
self.utils = Utilities()
|
||||
self.usage = Usage()
|
||||
self.check = Check()
|
||||
|
@ -51,6 +51,8 @@ class Argparse:
|
|||
self.flag_full_reverse = '--full-reverse'
|
||||
self.flag_search = '--search'
|
||||
self.flag_no_silent = '--no-silent'
|
||||
self.flag_directory = '--directory='
|
||||
self.flag_pkg_version = '--pkg-version'
|
||||
|
||||
self.is_dialog_enabled()
|
||||
|
||||
|
@ -61,12 +63,19 @@ class Argparse:
|
|||
self.flag_skip_installed,
|
||||
self.flag_full_reverse,
|
||||
self.flag_search,
|
||||
self.flag_no_silent]
|
||||
self.flag_no_silent,
|
||||
self.flag_directory,
|
||||
self.flag_pkg_version]
|
||||
|
||||
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
|
||||
|
||||
for opt in self.options:
|
||||
if opt in self.args:
|
||||
self.args.remove(opt)
|
||||
|
@ -74,12 +83,12 @@ class Argparse:
|
|||
|
||||
def is_dialog_enabled(self):
|
||||
""" Checking if the dialog box is enabled. """
|
||||
if (not self.configs.dialog and self.flag_search in self.args or
|
||||
not self.configs.dialog and 'configs' in self.args):
|
||||
if (not self.dialogbox and self.flag_search in self.args 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):
|
||||
def check_for_flags(self, command: str):
|
||||
""" Check for correct flags. """
|
||||
|
||||
commands = {
|
||||
|
@ -119,7 +128,8 @@ class Argparse:
|
|||
'download': [
|
||||
self.flag_yes,
|
||||
self.flag_search,
|
||||
self.flag_no_silent
|
||||
self.flag_no_silent,
|
||||
self.flag_directory
|
||||
],
|
||||
'remove': [
|
||||
self.flag_yes,
|
||||
|
@ -128,13 +138,19 @@ class Argparse:
|
|||
self.flag_no_silent
|
||||
],
|
||||
'find': [self.flag_search],
|
||||
'view': [self.flag_search],
|
||||
'view': [
|
||||
self.flag_search,
|
||||
self.flag_pkg_version],
|
||||
'search': [self.flag_search],
|
||||
'dependees': [
|
||||
self.flag_full_reverse,
|
||||
self.flag_search
|
||||
self.flag_search,
|
||||
self.flag_pkg_version
|
||||
],
|
||||
'tracking': [self.flag_search]
|
||||
'tracking': [
|
||||
self.flag_search,
|
||||
self.flag_pkg_version
|
||||
]
|
||||
}
|
||||
|
||||
commands['-h'] = commands['--help']
|
||||
|
@ -155,7 +171,7 @@ class Argparse:
|
|||
if opt not in flags and opt not in ['--help', '--version']:
|
||||
self.usage.error_for_options(flags)
|
||||
|
||||
def choose_packages(self, packages, method):
|
||||
def choose_packages(self, packages: list, method: str):
|
||||
""" Choose packages with dialog utility and --search flag. """
|
||||
height = 10
|
||||
width = 70
|
||||
|
@ -180,23 +196,23 @@ class Argparse:
|
|||
for package in repo_packages:
|
||||
for pkg in packages:
|
||||
|
||||
if method == 'install' and pkg in package:
|
||||
repo_ver = SBoQueries(package).version()
|
||||
choices += [(package, repo_ver, False)]
|
||||
|
||||
elif method == 'upgrade' and pkg == package:
|
||||
if method == 'upgrade' and pkg == package:
|
||||
repo_ver = SBoQueries(package).version()
|
||||
pkg = self.utils.is_installed(package)
|
||||
inst_ver = self.utils.split_installed_pkg(pkg)[1]
|
||||
choices += [(package, f'{inst_ver} -> {repo_ver}', True)]
|
||||
|
||||
elif pkg in package:
|
||||
repo_ver = SBoQueries(package).version()
|
||||
choices += [(package, repo_ver, False)]
|
||||
|
||||
if not choices:
|
||||
return packages
|
||||
|
||||
text = f'There are {len(choices)} packages:'
|
||||
|
||||
code, tags = self.dialog.checklist(text, title, height, width,
|
||||
list_height, choices, packages)
|
||||
code, tags = self.dialogbox.checklist(text, title, height, width,
|
||||
list_height, choices, packages)
|
||||
|
||||
if not code:
|
||||
return packages
|
||||
|
@ -273,9 +289,9 @@ class Argparse:
|
|||
|
||||
def clean_tmp(self):
|
||||
if len(self.args) == 1:
|
||||
path = self.configs.tmp_path
|
||||
tmp_slpkg = self.configs.tmp_slpkg
|
||||
folder = self.configs.prog_name
|
||||
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')
|
||||
|
@ -329,7 +345,7 @@ class Argparse:
|
|||
|
||||
self.check.database()
|
||||
self.check.exists(packages)
|
||||
download = Download(self.flags)
|
||||
download = Download(self.directory, self.flags)
|
||||
download.packages(packages)
|
||||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
@ -379,7 +395,7 @@ class Argparse:
|
|||
self.check.database()
|
||||
self.check.exists(packages)
|
||||
|
||||
view = ViewPackage()
|
||||
view = ViewPackage(self.flags)
|
||||
view.package(packages)
|
||||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
@ -429,7 +445,7 @@ class Argparse:
|
|||
self.check.database()
|
||||
self.check.exists(packages)
|
||||
|
||||
tracking = Tracking()
|
||||
tracking = Tracking(self.flags)
|
||||
tracking.packages(packages)
|
||||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
|
|
@ -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)
|
||||
DATABASE_URI = os.path.join(f'sqlite:///{Configs.db_path}', Configs.database_name)
|
||||
|
||||
engine = create_engine(DATABASE_URI)
|
||||
|
||||
|
|
|
@ -7,12 +7,10 @@ from progress.spinner import PixelSpinner
|
|||
from slpkg.configs import Configs
|
||||
|
||||
|
||||
class ProgressBar:
|
||||
class ProgressBar(Configs):
|
||||
|
||||
def __init__(self):
|
||||
self.configs = Configs
|
||||
self.colors = self.configs.colour
|
||||
self.color = self.colors()
|
||||
self.color = self.colour()
|
||||
self.bold = self.color['bold']
|
||||
self.violet = self.color['violet']
|
||||
self.bviolet = f'{self.bold}{self.violet}'
|
||||
|
|
|
@ -7,13 +7,13 @@ from slpkg.models.models import SBoTable
|
|||
from slpkg.models.models import session as Session
|
||||
|
||||
|
||||
class SBoQueries:
|
||||
class SBoQueries(Configs):
|
||||
""" Queries class for the sbo repository. """
|
||||
|
||||
def __init__(self, name: str):
|
||||
super(Configs, self).__init__()
|
||||
self.name = name
|
||||
self.session = Session
|
||||
self.configs = Configs
|
||||
|
||||
self.black = Blacklist()
|
||||
if self.name in self.black.get():
|
||||
|
@ -48,7 +48,7 @@ class SBoQueries:
|
|||
SBoTable.download, SBoTable.download64).filter(
|
||||
SBoTable.name == self.name).first()
|
||||
|
||||
if self.configs.os_arch == 'x86_64' and source64:
|
||||
if self.os_arch == 'x86_64' and source64:
|
||||
return source64.split()
|
||||
|
||||
return source.split()
|
||||
|
@ -83,7 +83,7 @@ class SBoQueries:
|
|||
SBoTable.md5sum, SBoTable.md5sum64).filter(
|
||||
SBoTable.name == self.name).first()
|
||||
|
||||
if self.configs.os_arch == 'x86_64' and md5s64:
|
||||
if self.os_arch == 'x86_64' and md5s64:
|
||||
return md5s64.split()
|
||||
|
||||
return mds5.split()
|
||||
|
|
|
@ -13,16 +13,14 @@ from slpkg.models.models import LogsDependencies
|
|||
from slpkg.models.models import session as Session
|
||||
|
||||
|
||||
class RemovePackages:
|
||||
class RemovePackages(Configs):
|
||||
""" Removes installed packages. """
|
||||
|
||||
def __init__(self, packages: list, flags: list):
|
||||
self.packages = packages
|
||||
self.flags = flags
|
||||
self.session = Session
|
||||
self.configs = Configs
|
||||
self.colors = self.configs.colour
|
||||
self.color = self.colors()
|
||||
self.color = self.colour()
|
||||
self.bold = self.color['bold']
|
||||
self.yellow = self.color['yellow']
|
||||
self.red = self.color['red']
|
||||
|
@ -65,7 +63,7 @@ class RemovePackages:
|
|||
""" Run Slackware command to remove the packages. """
|
||||
for package in self.installed_packages:
|
||||
self.remove_pkg = package
|
||||
command = f'{self.configs.removepkg} {package}'
|
||||
command = f'{self.removepkg} {package}'
|
||||
self.multi_process(command, package)
|
||||
|
||||
def delete_main_logs(self):
|
||||
|
@ -84,7 +82,7 @@ class RemovePackages:
|
|||
|
||||
def multi_process(self, command, package):
|
||||
""" Starting multiprocessing remove process. """
|
||||
if self.configs.silent_mode and self.flag_no_silent not in self.flags:
|
||||
if self.silent_mode and self.flag_no_silent not in self.flags:
|
||||
|
||||
done = f' {self.byellow} Done{self.endc}'
|
||||
message = f'{self.red}Remove{self.endc}'
|
||||
|
|
|
@ -5,12 +5,11 @@ from slpkg.queries import SBoQueries
|
|||
from slpkg.configs import Configs
|
||||
|
||||
|
||||
class SearchPackage:
|
||||
class SearchPackage(Configs):
|
||||
""" Search slackbuilds from the repository. """
|
||||
|
||||
def __init__(self):
|
||||
self.colors = Configs.colour
|
||||
self.color = self.colors()
|
||||
self.color = self.colour()
|
||||
self.yellow = self.color['yellow']
|
||||
self.cyan = self.color['cyan']
|
||||
self.endc = self.color['endc']
|
||||
|
|
|
@ -22,10 +22,11 @@ from slpkg.models.models import LogsDependencies
|
|||
from slpkg.models.models import session as Session
|
||||
|
||||
|
||||
class Slackbuilds:
|
||||
class Slackbuilds(Configs):
|
||||
""" Download build and install the SlackBuilds. """
|
||||
|
||||
def __init__(self, slackbuilds: list, flags: list, mode: str):
|
||||
super(Configs, self).__init__()
|
||||
self.slackbuilds = slackbuilds
|
||||
self.flags = flags
|
||||
self.mode = mode
|
||||
|
@ -38,12 +39,10 @@ class Slackbuilds:
|
|||
self.process_message = None
|
||||
self.session = Session
|
||||
self.utils = Utilities()
|
||||
self.dialog = DialogBox()
|
||||
self.progress = ProgressBar()
|
||||
self.dialogbox = DialogBox()
|
||||
self.view_message = ViewMessage(self.flags)
|
||||
self.configs = Configs
|
||||
self.colors = self.configs.colour
|
||||
self.color = self.colors()
|
||||
self.color = self.colour()
|
||||
self.bold = self.color['bold']
|
||||
self.cyan = self.color['cyan']
|
||||
self.red = self.color['red']
|
||||
|
@ -131,18 +130,18 @@ class Slackbuilds:
|
|||
|
||||
if self.is_for_skipped(sbo):
|
||||
|
||||
file = f'{sbo}{self.configs.sbo_tar_suffix}'
|
||||
file = f'{sbo}{self.sbo_tar_suffix}'
|
||||
|
||||
self.utils.remove_file_if_exists(self.configs.tmp_slpkg, file)
|
||||
self.utils.remove_folder_if_exists(self.configs.build_path, sbo)
|
||||
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.configs.sbo_repo_url}/{location}/{file}'
|
||||
url = f'{self.sbo_repo_url}/{location}/{file}'
|
||||
|
||||
down_sbo = Downloader(self.configs.tmp_slpkg, url, self.flags)
|
||||
down_sbo = Downloader(self.tmp_slpkg, url, self.flags)
|
||||
down_sbo.download()
|
||||
|
||||
self.utils.untar_archive(self.configs.tmp_slpkg, file, self.configs.build_path)
|
||||
self.utils.untar_archive(self.tmp_slpkg, file, self.build_path)
|
||||
|
||||
self.patch_sbo_tag(sbo)
|
||||
|
||||
|
@ -155,7 +154,7 @@ class Slackbuilds:
|
|||
|
||||
if self.is_for_skipped(sbo):
|
||||
|
||||
self.build_the_script(self.configs.build_path, sbo)
|
||||
self.build_the_script(self.build_path, sbo)
|
||||
|
||||
if not self.mode == 'build':
|
||||
|
||||
|
@ -171,7 +170,7 @@ class Slackbuilds:
|
|||
|
||||
def patch_sbo_tag(self, sbo):
|
||||
""" Patching SBo TAG from the configuration file. """
|
||||
sbo_script = Path(self.configs.build_path, sbo, f'{sbo}.SlackBuild')
|
||||
sbo_script = Path(self.build_path, sbo, f'{sbo}.SlackBuild')
|
||||
|
||||
if sbo_script.is_file():
|
||||
with open(sbo_script, 'r', encoding='utf-8') as f:
|
||||
|
@ -180,7 +179,7 @@ class Slackbuilds:
|
|||
with open(sbo_script, 'w') as script:
|
||||
for line in lines:
|
||||
if line.startswith('TAG=$'):
|
||||
line = f'TAG=${{TAG:-{self.configs.sbo_repo_tag}}}\n'
|
||||
line = f'TAG=${{TAG:-{self.sbo_repo_tag}}}\n'
|
||||
script.write(line)
|
||||
|
||||
def logging_installed_dependencies(self, name: str):
|
||||
|
@ -206,10 +205,10 @@ class Slackbuilds:
|
|||
""" Install the packages that before created in the tmp directory. """
|
||||
pkg = self.utils.split_installed_pkg(package)[0]
|
||||
|
||||
execute = self.configs.installpkg
|
||||
execute = self.installpkg
|
||||
if (self.flag_reinstall in self.flags and
|
||||
self.utils.is_installed(pkg)):
|
||||
execute = self.configs.reinstall
|
||||
execute = self.reinstall
|
||||
|
||||
message = f'{self.cyan}Installing{self.endc}'
|
||||
self.process_message = f"'{pkg}' to install"
|
||||
|
@ -218,7 +217,7 @@ class Slackbuilds:
|
|||
self.process_message = f"package '{pkg}' to upgrade"
|
||||
message = f'{self.cyan}Upgrade{self.endc}'
|
||||
|
||||
command = f'{execute} {self.configs.tmp_path}/{package}'
|
||||
command = f'{execute} {self.tmp_path}/{package}'
|
||||
|
||||
self.multi_process(command, package, message)
|
||||
|
||||
|
@ -227,9 +226,9 @@ class Slackbuilds:
|
|||
installation. """
|
||||
version = SBoQueries(name).version()
|
||||
|
||||
pattern = f'{name}-{version}*{self.configs.sbo_repo_tag}*'
|
||||
pattern = f'{name}-{version}*{self.sbo_repo_tag}*'
|
||||
|
||||
tmp = Path(self.configs.tmp_path)
|
||||
tmp = Path(self.tmp_path)
|
||||
packages = [file.name for file in tmp.glob(pattern)]
|
||||
|
||||
return max(packages)
|
||||
|
@ -259,7 +258,7 @@ class Slackbuilds:
|
|||
|
||||
def download_sources(self, name: str, sources: list):
|
||||
""" Download the sources. """
|
||||
path = Path(self.configs.build_path, name)
|
||||
path = Path(self.build_path, name)
|
||||
checksums = SBoQueries(name).checksum()
|
||||
|
||||
for source, checksum in zip(sources, checksums):
|
||||
|
@ -271,7 +270,7 @@ class Slackbuilds:
|
|||
|
||||
def multi_process(self, command, filename, message):
|
||||
""" Starting multiprocessing install/upgrade process. """
|
||||
if self.configs.silent_mode and self.flag_no_silent not in self.flags:
|
||||
if self.silent_mode and self.flag_no_silent not in self.flags:
|
||||
|
||||
done = f' {self.byellow} Done{self.endc}'
|
||||
self.stderr = subprocess.DEVNULL
|
||||
|
@ -339,8 +338,8 @@ class Slackbuilds:
|
|||
|
||||
text = f'There are {len(choices)} dependencies:'
|
||||
|
||||
code, tags = self.dialog.checklist(text, title, height, width,
|
||||
list_height, choices, dependencies)
|
||||
code, tags = self.dialogbox.checklist(text, title, height, width,
|
||||
list_height, choices, dependencies)
|
||||
|
||||
if not code:
|
||||
return dependencies
|
||||
|
|
|
@ -3,19 +3,22 @@
|
|||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.views.ascii import Ascii
|
||||
from slpkg.queries import SBoQueries
|
||||
from slpkg.dependencies import Requires
|
||||
|
||||
|
||||
class Tracking:
|
||||
class Tracking(Configs):
|
||||
""" Tracking of the package dependencies. """
|
||||
|
||||
def __init__(self):
|
||||
self.configs = Configs
|
||||
def __init__(self, flags: list):
|
||||
super(Configs, self).__init__()
|
||||
self.flags = flags
|
||||
self.flag_pkg_version = '--pkg-version'
|
||||
self.ascii = Ascii()
|
||||
self.llc = self.ascii.lower_left_corner
|
||||
self.hl = self.ascii.horizontal_line
|
||||
self.colors = self.configs.colour
|
||||
self.color = self.colors()
|
||||
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']
|
||||
|
@ -26,13 +29,30 @@ class Tracking:
|
|||
print(f"The list below shows the packages with dependencies:\n")
|
||||
|
||||
char = f' {self.llc}{self.hl}'
|
||||
for i, package in enumerate(packages):
|
||||
sp = ' ' * 4
|
||||
for package in packages:
|
||||
pkg = f'{self.yellow}{package}{self.endc}'
|
||||
|
||||
if self.flag_pkg_version in self.flags:
|
||||
pkg = f'{self.yellow}{package}-{SBoQueries(package).version()}{self.endc}'
|
||||
|
||||
requires = Requires(package).resolve()
|
||||
how_many = len(requires)
|
||||
|
||||
if not requires:
|
||||
requires = ['No dependencies']
|
||||
|
||||
print(f'{self.yellow}{package}{self.endc}')
|
||||
print(f'{char} {self.cyan}{" ".join([req for req in requires])}{self.endc}')
|
||||
print(pkg)
|
||||
print(char, end='')
|
||||
for i, req in enumerate(requires, start=1):
|
||||
require = f'{self.cyan}{req}{self.endc}'
|
||||
|
||||
if self.flag_pkg_version in self.flags:
|
||||
require = f'{self.cyan}{req}{self.endc}-{self.yellow}{SBoQueries(req).version()}{self.endc}'
|
||||
|
||||
if i == 1:
|
||||
print(f' {require}')
|
||||
else:
|
||||
print(f'{sp}{require}')
|
||||
|
||||
print(f'\n{self.grey}{how_many} dependencies for {package}{self.endc}\n')
|
||||
|
|
|
@ -14,17 +14,16 @@ from slpkg.check_updates import CheckUpdates
|
|||
from slpkg.models.models import session as Session
|
||||
|
||||
|
||||
class UpdateRepository:
|
||||
class UpdateRepository(Configs):
|
||||
""" Deletes and install the data. """
|
||||
|
||||
def __init__(self, flags: list):
|
||||
super(Configs, self).__init__()
|
||||
self.flags = flags
|
||||
self.configs = Configs
|
||||
self.colors = self.configs.colour
|
||||
self.color = self.colors()
|
||||
self.endc = self.color['endc']
|
||||
self.session = Session
|
||||
self.progress = ProgressBar()
|
||||
self.color = self.colour()
|
||||
self.endc = self.color['endc']
|
||||
|
||||
def sbo(self):
|
||||
""" Updated the sbo repository. """
|
||||
|
@ -33,17 +32,17 @@ class UpdateRepository:
|
|||
view.question()
|
||||
|
||||
print('Updating the package list...\n')
|
||||
self.delete_file(self.configs.sbo_repo_path, self.configs.sbo_txt)
|
||||
self.delete_file(self.configs.sbo_repo_path, self.configs.sbo_chglog_txt)
|
||||
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()
|
||||
|
||||
slackbuilds_txt = f'{self.configs.sbo_repo_url}/{self.configs.sbo_txt}'
|
||||
changelog_txt = f'{self.configs.sbo_repo_url}/{self.configs.sbo_chglog_txt}'
|
||||
slackbuilds_txt = f'{self.sbo_repo_url}/{self.sbo_txt}'
|
||||
changelog_txt = f'{self.sbo_repo_url}/{self.sbo_chglog_txt}'
|
||||
|
||||
down_slackbuilds = Downloader(self.configs.sbo_repo_path, slackbuilds_txt, self.flags)
|
||||
down_slackbuilds = Downloader(self.sbo_repo_path, slackbuilds_txt, self.flags)
|
||||
down_slackbuilds.download()
|
||||
|
||||
down_changelog = Downloader(self.configs.sbo_repo_path, changelog_txt, self.flags)
|
||||
down_changelog = Downloader(self.sbo_repo_path, changelog_txt, self.flags)
|
||||
down_changelog.download()
|
||||
|
||||
data = CreateData()
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.queries import SBoQueries
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.blacklist import Blacklist
|
||||
from slpkg.dialog_box import DialogBox
|
||||
from slpkg.dependencies import Requires
|
||||
|
||||
|
||||
|
@ -13,9 +11,7 @@ class Upgrade:
|
|||
""" Upgrade the installed packages. """
|
||||
|
||||
def __init__(self):
|
||||
self.configs = Configs
|
||||
self.utils = Utilities()
|
||||
self.dialog = DialogBox()
|
||||
|
||||
def packages(self):
|
||||
""" Compares version of packages and returns the maximum. """
|
||||
|
|
|
@ -25,7 +25,7 @@ class Utilities:
|
|||
|
||||
def is_installed(self, name: str) -> str:
|
||||
""" Returns the installed package name. """
|
||||
installed = self.all_installed()
|
||||
installed = list(self.all_installed())
|
||||
|
||||
for package in installed:
|
||||
pkg = self.split_installed_pkg(package)[0]
|
||||
|
@ -37,15 +37,12 @@ class Utilities:
|
|||
|
||||
def all_installed(self) -> list:
|
||||
""" Return all installed SBo packages from /val/log/packages folder. """
|
||||
installed = []
|
||||
pattern = f'*{self.configs.sbo_repo_tag}'
|
||||
var_log_packages = Path(self.configs.log_packages)
|
||||
|
||||
for file in var_log_packages.glob(pattern):
|
||||
if self.split_installed_pkg(file.name) not in self.black.get():
|
||||
installed.append(file.name)
|
||||
|
||||
return installed
|
||||
yield file.name
|
||||
|
||||
@staticmethod
|
||||
def untar_archive(path: str, archive: str, ext_path: str):
|
||||
|
|
|
@ -2,41 +2,39 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import shutil
|
||||
from dataclasses import dataclass
|
||||
|
||||
from slpkg.configs import Configs
|
||||
|
||||
|
||||
@dataclass
|
||||
class Ascii:
|
||||
class Ascii(Configs):
|
||||
""" ascii characters. """
|
||||
vertical_line = '│'
|
||||
horizontal_line = '─'
|
||||
horizontal_vertical = '┼'
|
||||
upper_right_corner = '┐'
|
||||
lower_left_corner = '└'
|
||||
lower_right_corner = '┘'
|
||||
upper_left_corner = '┌'
|
||||
horizontal_and_up = '┴'
|
||||
horizontal_and_down = '┬'
|
||||
vertical_and_right = '├'
|
||||
vertical_and_left = '┤'
|
||||
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 = '┤'
|
||||
|
||||
configs = Configs
|
||||
colors = configs.colour
|
||||
color = colors()
|
||||
bold = color['bold']
|
||||
blue = color['blue']
|
||||
green = color['green']
|
||||
cyan = color['cyan']
|
||||
red = color['red']
|
||||
yellow = color['yellow']
|
||||
violet = color['violet']
|
||||
endc = color['endc']
|
||||
bgreen = f'{bold}{green}'
|
||||
bred = f'{bold}{red}'
|
||||
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}'
|
||||
|
||||
columns, rows = shutil.get_terminal_size()
|
||||
self.columns, self.rows = shutil.get_terminal_size()
|
||||
|
||||
def draw_package_title_box(self, message, title):
|
||||
""" Drawing package title box. """
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
from slpkg.configs import Configs
|
||||
|
||||
|
||||
class Usage:
|
||||
class Usage(Configs):
|
||||
|
||||
def __init__(self):
|
||||
colors = Configs.colour
|
||||
color = colors()
|
||||
super(Configs, self).__init__()
|
||||
color = self.colour()
|
||||
|
||||
self.bold = color['bold']
|
||||
self.red = color['red']
|
||||
|
@ -26,7 +26,8 @@ class Usage:
|
|||
f' slpkg [{self.cyan}COMMAND{self.endc}] [-f, find, -w, view, -s, search, -e, dependees] <packages>\n'
|
||||
f' slpkg [{self.cyan}COMMAND{self.endc}] [-t, tracking] <packages>\n'
|
||||
f' slpkg [{self.yellow}OPTIONS{self.endc}] [--yes, --jobs, --resolve-off, --reinstall]\n'
|
||||
f' slpkg [{self.yellow}OPTIONS{self.endc}] [--skip-installed, --full-reverse, --search, --no-silent]\n'
|
||||
f' slpkg [{self.yellow}OPTIONS{self.endc}] [--skip-installed, --full-reverse, --search]\n'
|
||||
f' slpkg [{self.yellow}OPTIONS{self.endc}] [--no-silent, --directory=PATH, --pkg-version]\n'
|
||||
" \nIf you need more information please try 'slpkg --help'.")
|
||||
|
||||
print(args)
|
||||
|
@ -63,6 +64,8 @@ class Usage:
|
|||
f' {self.yellow}--full-reverse{self.endc} Full reverse dependency.\n'
|
||||
f' {self.yellow}--search{self.endc} Search packages from the repository.\n'
|
||||
f' {self.yellow}--no-silent{self.endc} Disable silent mode.\n'
|
||||
f' {self.yellow}--directory={self.endc}PATH Download files to a specific path.\n'
|
||||
f' {self.yellow}--pkg-version{self.endc} Print the repository package version.\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'
|
||||
|
|
|
@ -5,7 +5,7 @@ class Version:
|
|||
""" Print the version. """
|
||||
|
||||
def __init__(self):
|
||||
self.version_info = (4, 5, 0)
|
||||
self.version_info = (4, 5, 1)
|
||||
self.version = '{0}.{1}.{2}'.format(*self.version_info)
|
||||
self.license = 'MIT License'
|
||||
self.author = 'Dimitris Zlatanidis (dslackw)'
|
||||
|
|
|
@ -9,17 +9,18 @@ from slpkg.models.models import SBoTable
|
|||
from slpkg.models.models import session as Session
|
||||
|
||||
|
||||
class ViewPackage:
|
||||
class ViewPackage(Configs):
|
||||
""" View the repository packages. """
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, flags):
|
||||
super(Configs, self).__init__()
|
||||
self.flags = flags
|
||||
self.flag_repo_version = '--pkg-version'
|
||||
self.session = Session
|
||||
self.configs = Configs
|
||||
self.colors = self.configs.colour
|
||||
|
||||
def package(self, packages: list):
|
||||
""" View the packages from the repository. """
|
||||
color = self.colors()
|
||||
color = self.colour()
|
||||
green = color['green']
|
||||
blue = color['blue']
|
||||
yellow = color['yellow']
|
||||
|
@ -42,9 +43,9 @@ class ViewPackage:
|
|||
SBoTable.location
|
||||
).filter(SBoTable.name == package).first()
|
||||
|
||||
readme = self.http_request(f'{self.configs.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.configs.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():
|
||||
|
@ -55,23 +56,26 @@ class ViewPackage:
|
|||
if line.startswith('EMAIL'):
|
||||
email = line[7:-1].strip()
|
||||
|
||||
deps = (', '.join([f'{pkg} ({SBoQueries(pkg).version()})' for pkg in info[2].split()]))
|
||||
deps = (', '.join([f'{cyan}{pkg}' for pkg in info[2].split()]))
|
||||
|
||||
if self.flag_repo_version in self.flags:
|
||||
deps = (', '.join([f'{cyan}{pkg}{endc}-{yellow}{SBoQueries(pkg).version()}{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.configs.sbo_repo_url}/{info[9]}/{info[0]}'
|
||||
f'{self.configs.sbo_tar_suffix}{endc}\n'
|
||||
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'
|
||||
f'Md5sum: {yellow}{info[5]}{endc}\n'
|
||||
f'Md5sum_x86_64: {yellow}{info[6]}{endc}\n'
|
||||
f'Files: {green}{info[7]}{endc}\n'
|
||||
f'Description: {green}{info[8]}{endc}\n'
|
||||
f'Slackware: {cyan}{self.configs.sbo_repo_url.split("/")[-1]}{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.configs.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}')
|
||||
|
|
|
@ -14,10 +14,11 @@ from slpkg.models.models import LogsDependencies
|
|||
from slpkg.models.models import session as Session
|
||||
|
||||
|
||||
class ViewMessage:
|
||||
class ViewMessage(Configs):
|
||||
""" Print some messages before. """
|
||||
|
||||
def __init__(self, flags: list):
|
||||
super(Configs, self).__init__()
|
||||
self.flags = flags
|
||||
self.flag_resolve_off = '--resolve-off'
|
||||
self.flag_reinstall = '--reinstall'
|
||||
|
@ -25,10 +26,8 @@ class ViewMessage:
|
|||
self.session = Session
|
||||
self.utils = Utilities()
|
||||
self.black = Blacklist()
|
||||
self.dialog = DialogBox()
|
||||
self.configs = Configs
|
||||
self.colors = self.configs.colour
|
||||
self.color = self.colors()
|
||||
self.dialogbox = DialogBox()
|
||||
self.color = self.colour()
|
||||
self.yellow = self.color['yellow']
|
||||
self.cyan = self.color['cyan']
|
||||
self.red = self.color['red']
|
||||
|
@ -177,7 +176,7 @@ class ViewMessage:
|
|||
|
||||
text = f'There are {len(choices)} dependencies:'
|
||||
|
||||
code, tags = self.dialog.checklist(text, title, height, width, list_height, choices, dependencies)
|
||||
code, tags = self.dialogbox.checklist(text, title, height, width, list_height, choices, dependencies)
|
||||
|
||||
if not code:
|
||||
return dependencies
|
||||
|
@ -211,7 +210,7 @@ class ViewMessage:
|
|||
|
||||
elif option == 'build':
|
||||
print(f'{self.grey}Total {len(slackbuilds)} packages '
|
||||
f'will be build in {self.configs.tmp_path} folder.{self.endc}')
|
||||
f'will be build in {self.tmp_path} folder.{self.endc}')
|
||||
|
||||
elif option == 'remove':
|
||||
print(f'{self.grey}Total {remove} packages '
|
||||
|
@ -219,7 +218,7 @@ class ViewMessage:
|
|||
|
||||
elif option == 'download':
|
||||
print(f'{self.grey}{len(slackbuilds)} packages '
|
||||
f'will be downloaded in {self.configs.download_only} folder.{self.endc}')
|
||||
f'will be downloaded in {self.download_only} folder.{self.endc}')
|
||||
|
||||
def logs_packages(self, dependencies: list):
|
||||
""" View the logging packages. """
|
||||
|
|
Loading…
Reference in a new issue