Merge branch 'develop' of https://gitlab.com/dslackw/slpkg into develop

This commit is contained in:
maravtdm 2023-04-01 15:34:10 +02:00
commit 999aed687a
30 changed files with 1660 additions and 258 deletions

View file

@ -5,12 +5,14 @@
# Default is the 'sbo' repository. # Default is the 'sbo' repository.
######################################################################## ########################################################################
# Note: Before using the repository, make sure you have read about it, # # Note: Before using the repository, make sure you have read about it. #
# some repositories are for -current only. # # Some repositories are for -current only. Change the mirror if #
# it is necessary. #
######################################################################## ########################################################################
[REPOSITORIES] [REPOSITORIES]
# Repository for slackware 15.0 stable.
SBO_REPO_NAME = "sbo" SBO_REPO_NAME = "sbo"
SBO_REPO_MIRROR = "https://slackbuilds.org/slackbuilds/15.0/" SBO_REPO_MIRROR = "https://slackbuilds.org/slackbuilds/15.0/"
SBO_REPO_SLACKBUILDS = "SLACKBUILDS.TXT" SBO_REPO_SLACKBUILDS = "SLACKBUILDS.TXT"
@ -18,6 +20,7 @@
SBO_REPO_TAR_SUFFIX = ".tar.gz" SBO_REPO_TAR_SUFFIX = ".tar.gz"
SBO_REPO_TAG = "_SBo" SBO_REPO_TAG = "_SBo"
# Repository for slackware -current.
PONCE_REPO_NAME = "ponce" PONCE_REPO_NAME = "ponce"
PONCE_REPO = false PONCE_REPO = false
PONCE_REPO_MIRROR = "https://cgit.ponce.cc/slackbuilds/plain/" PONCE_REPO_MIRROR = "https://cgit.ponce.cc/slackbuilds/plain/"
@ -25,6 +28,8 @@
PONCE_REPO_CHANGELOG = "ChangeLog.txt" PONCE_REPO_CHANGELOG = "ChangeLog.txt"
PONCE_REPO_TAG = "_SBo" PONCE_REPO_TAG = "_SBo"
# Repository for slackware 15.0 stable.
# Mirror for -current: http://slackware.uk/people/alien/sbrepos/current/x86_64/
ALIEN_REPO_NAME = "alien" ALIEN_REPO_NAME = "alien"
ALIEN_REPO = false ALIEN_REPO = false
ALIEN_REPO_MIRROR = "http://slackware.uk/people/alien/sbrepos/15.0/x86_64/" ALIEN_REPO_MIRROR = "http://slackware.uk/people/alien/sbrepos/15.0/x86_64/"
@ -33,6 +38,27 @@
ALIEN_REPO_CHECKSUMS = "CHECKSUMS.md5" ALIEN_REPO_CHECKSUMS = "CHECKSUMS.md5"
ALIEN_REPO_CHANGELOG = "ChangeLog.txt" ALIEN_REPO_CHANGELOG = "ChangeLog.txt"
# Repository for slackware 15.0 stable.
# Mirror for -current: https://slackware.nl/people/alien/multilib/current/
MULTILIB_REPO_NAME = "multilib"
MULTILIB_REPO = false
MULTILIB_REPO_MIRROR = "https://slackware.nl/people/alien/multilib/15.0/"
MULTILIB_REPO_CHANGELOG_MIRROR = "https://slackware.nl/people/alien/multilib/"
MULTILIB_REPO_PACKAGES = "PACKAGES.TXT"
MULTILIB_REPO_CHECKSUMS = "CHECKSUMS.md5"
MULTILIB_REPO_CHANGELOG = "ChangeLog.txt"
# Repository for slackware 15.0 stable.
# Mirror for -current: https://slackware.nl/people/alien/restricted_sbrepos/current/x86_64/
RESTRICTED_REPO_NAME = "restricted"
RESTRICTED_REPO = false
RESTRICTED_REPO_MIRROR = "https://slackware.nl/people/alien/restricted_sbrepos/15.0/x86_64/"
RESTRICTED_REPO_CHANGELOG_MIRROR = "https://slackware.nl/people/alien/restricted_sbrepos/"
RESTRICTED_REPO_PACKAGES = "PACKAGES.TXT"
RESTRICTED_REPO_CHECKSUMS = "CHECKSUMS.md5"
RESTRICTED_REPO_CHANGELOG = "ChangeLog.txt"
# Repository for slackware -current.
GNOME_REPO_NAME = "gnome" GNOME_REPO_NAME = "gnome"
GNOME_REPO = false GNOME_REPO = false
GNOME_REPO_MIRROR = "https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/" GNOME_REPO_MIRROR = "https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/"
@ -40,6 +66,16 @@
GNOME_REPO_CHECKSUMS = "CHECKSUMS.md5" GNOME_REPO_CHECKSUMS = "CHECKSUMS.md5"
GNOME_REPO_CHANGELOG = "ChangeLog.txt" GNOME_REPO_CHANGELOG = "ChangeLog.txt"
# Repository for slackware 15.0 stable.
MSB_REPO_NAME = "msb"
MSB_REPO = false
MSB_REPO_MIRROR = "https://slackware.uk/msb/15.0/1.26/x86_64/"
MSB_REPO_CHANGELOG_MIRROR = 'https://slackware.uk/msb/'
MSB_REPO_PACKAGES = "PACKAGES.TXT"
MSB_REPO_CHECKSUMS = "CHECKSUMS.md5"
MSB_REPO_CHANGELOG = "ChangeLog.txt"
# Repository for slackware -current.
CONRAID_REPO_NAME = "conraid" CONRAID_REPO_NAME = "conraid"
CONRAID_REPO = false CONRAID_REPO = false
CONRAID_REPO_MIRROR = "https://slack.conraid.net/repository/slackware64-current/" CONRAID_REPO_MIRROR = "https://slack.conraid.net/repository/slackware64-current/"
@ -47,9 +83,53 @@
CONRAID_REPO_CHECKSUMS = "CHECKSUMS.md5" CONRAID_REPO_CHECKSUMS = "CHECKSUMS.md5"
CONRAID_REPO_CHANGELOG = "ChangeLog.txt" CONRAID_REPO_CHANGELOG = "ChangeLog.txt"
# Repository for slackware 15.0 stable.
# Mirror for -current: https://packages.slackonly.com/pub/packages/current-x86_64/
SLACKONLY_REPO_NAME = "slackonly" SLACKONLY_REPO_NAME = "slackonly"
SLACKONLY_REPO = false SLACKONLY_REPO = false
SLACKONLY_REPO_MIRROR = "https://packages.slackonly.com/pub/packages/15.0-x86_64/" SLACKONLY_REPO_MIRROR = "https://packages.slackonly.com/pub/packages/15.0-x86_64/"
SLACKONLY_REPO_PACKAGES = "PACKAGES.TXT" SLACKONLY_REPO_PACKAGES = "PACKAGES.TXT"
SLACKONLY_REPO_CHECKSUMS = "CHECKSUMS.md5" SLACKONLY_REPO_CHECKSUMS = "CHECKSUMS.md5"
SLACKONLY_REPO_CHANGELOG = "ChangeLog.txt" SLACKONLY_REPO_CHANGELOG = "ChangeLog.txt"
# Repository for slackware 15.0 stable.
# Mirror for -current: https://ponce.cc/slackware/slackware64-current/packages/
PONCE_BIN_REPO_NAME = "ponce_bin"
PONCE_BIN_REPO = false
PONCE_BIN_REPO_MIRROR = "https://ponce.cc/slackware/slackware64-15.0/packages/"
PONCE_BIN_REPO_PACKAGES = "PACKAGES.TXT"
PONCE_BIN_REPO_CHECKSUMS = "CHECKSUMS.md5"
PONCE_BIN_REPO_CHANGELOG = "ChangeLog.txt"
# Repository for slackware 15.0 stable.
SALIXOS_REPO_NAME = "salixos"
SALIXOS_REPO = false
SALIXOS_REPO_MIRROR = "https://download.salixos.org/x86_64/slackware-15.0/"
SALIXOS_REPO_PACKAGES = "PACKAGES.TXT"
SALIXOS_REPO_CHECKSUMS = "CHECKSUMS.md5"
SALIXOS_REPO_CHANGELOG = "ChangeLog.txt"
# Repository for slackware 15.0 stable.
SALIXOS_EXTRA_REPO_NAME = "salixos_extra"
SALIXOS_EXTRA_REPO = false
SALIXOS_EXTRA_REPO_MIRROR = "https://download.salixos.org/x86_64/slackware-15.0/"
SALIXOS_EXTRA_REPO_PACKAGES_MIRROR = 'https://download.salixos.org/x86_64/slackware-15.0/extra/'
SALIXOS_EXTRA_REPO_PACKAGES = "PACKAGES.TXT"
SALIXOS_EXTRA_REPO_CHECKSUMS = "CHECKSUMS.md5"
SALIXOS_EXTRA_REPO_CHANGELOG = "ChangeLog.txt"
# Repository for slackware -current.
SLACKEL_REPO_NAME = "slackel"
SLACKEL_REPO = false
SLACKEL_REPO_MIRROR = "http://www.slackel.gr/repo/x86_64/slackware-current/"
SLACKEL_REPO_PACKAGES = "PACKAGES.TXT"
SLACKEL_REPO_CHECKSUMS = "CHECKSUMS.md5"
SLACKEL_REPO_CHANGELOG = "ChangeLog.txt"
# Repository for slackware 15.0 stable.
SLINT_REPO_NAME = "slint"
SLINT_REPO = false
SLINT_REPO_MIRROR = "https://slackware.uk/slint/x86_64/slint-15.0/"
SLINT_REPO_PACKAGES = "PACKAGES.TXT"
SLINT_REPO_CHECKSUMS = "CHECKSUMS.md5"
SLINT_REPO_CHANGELOG = "ChangeLog.txt"

View file

@ -11,7 +11,7 @@ slpkg [-h|-v] [-u, update] [-U, upgrade] [-c, check-updates] [-I, repo-info] [-g
[-D, clean-tmp] [-T, clean-data] [-b, build] [-i, install] [-d, download] [-D, clean-tmp] [-T, clean-data] [-b, build] [-i, install] [-d, download]
[-R, remove] [-f, find] [-w, view] [-s, search] [-e, dependees] [-t, tracking] -y, --yes, -j, --jobs, -o, --resolve-off, [-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, -r, --reinstall, -k, --skip-installed, -E, --full-reverse, -S, --search, -n, --no-silent, -p, --pkg-version, -z,
-G, --generate-only, -P, --parallel, -B, --bin-repo=[\fIPATH\fR], -z, --directory=[\fIPATH\fR] -G, --generate-only, -P, --parallel, -B, --bin-repo=[\fIREPO\fR], -z, --directory=[\fIPATH\fR]
.SH DESCRIPTION .SH DESCRIPTION
.P .P
Slpkg is a software package manager that installs, updates, and removes packages on Slackware based systems. Slpkg is a software package manager that installs, updates, and removes packages on Slackware based systems.
@ -34,12 +34,13 @@ Upgrade all the installed packages if the newer version exists in the repository
.P .P
.B -c, check-updates .B -c, check-updates
.RS .RS
Check if there is any news on the SlackBuild's ChangeLog.txt file. Check if there is any news on the repositories ChangeLog.txt file.
.RE .RE
.P .P
.B -I, repo-info .B -I, repo-info
.RS .RS
Prints the repositories information. View information related to repositories, such as which repositories are active, when they were upgraded,
and how many packages they contain.
.RE .RE
.P .P
.B -L, clean-logs .B -L, clean-logs
@ -131,7 +132,7 @@ Turns off dependency resolving. (to be used with: -U, upgrade, -b, build, -i, in
.B -r, --reinstall .B -r, --reinstall
.RS .RS
Use this option if you want to upgrade all packages even if the same version is already installed. 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) Do not skip installed packages. (to be used with: -U, upgrade, -i, install)
.RE .RE
.P .P
.B -k, --skip-installed .B -k, --skip-installed
@ -157,7 +158,7 @@ Example try: '\fIslpkg install python3 --search\fR' or '\fIslpkg download python
.B -n, --no-silent .B -n, --no-silent
.RS .RS
Disable silent mode, if it is enabled in the configuration file. (to be used with: -u, update, -U, upgrade, -b, build, 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) -i, install, -R, remove)
.RE .RE
.P .P
.B -p, --pkg-version .B -p, --pkg-version
@ -181,7 +182,8 @@ Download files in parallel to speed up the process.
.BI "-B," "" " \-\-bin-repo=[" REPO "] .BI "-B," "" " \-\-bin-repo=[" REPO "]
.RS .RS
Switch to binaries repositories and select a repository. Switch to binaries repositories and select a repository.
Example: '\fIslpkg -i audacity --bin=repo=alien\fR'. Example: '\fIslpkg -i audacity --bin-repo=alien\fR'. Options update, check, and search support the asterisk '*' to apply
it in all repositories, like search a package to all binaries repositories '\fIslpkg -s libreoffice --bin-repo='*'\fR'.
(to be used with: -u, update, -U, upgrade, -i, install, -d, download, -s, search, -t, tracking, -e, dependees) (to be used with: -u, update, -U, upgrade, -i, install, -d, download, -s, search, -t, tracking, -e, dependees)
.RE .RE
.P .P

View file

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

View file

@ -59,6 +59,8 @@ class Packages(Configs):
self.flag_no_silent: list = ['-n', '--no-silent'] self.flag_no_silent: list = ['-n', '--no-silent']
self.flag_resolve_off: list = ['-o', '--resolve-off'] self.flag_resolve_off: list = ['-o', '--resolve-off']
self.packages: list = self.utils.apply_package_pattern(self.flags, self.packages, self.repo)
def execute(self) -> None: def execute(self) -> None:
self.dependencies() self.dependencies()
@ -74,7 +76,7 @@ class Packages(Configs):
self.utils.finished_time(elapsed_time) self.utils.finished_time(elapsed_time)
def dependencies(self): def dependencies(self):
""" Creating te dependencies list and the order for install. """ """ Creating the dependencies list and the order for install. """
requires: list = [] requires: list = []
if not self.utils.is_option(self.flag_resolve_off, self.flags): if not self.utils.is_option(self.flag_resolve_off, self.flags):
@ -100,10 +102,7 @@ class Packages(Configs):
for pkg in self.install_order: for pkg in self.install_order:
skip_package: str = self.skip_installed_package(pkg) if self.continue_install(pkg):
if not skip_package:
mirror: str = BinQueries(pkg, self.repo).mirror() mirror: str = BinQueries(pkg, self.repo).mirror()
location: str = BinQueries(pkg, self.repo).location() location: str = BinQueries(pkg, self.repo).location()
package: str = BinQueries(pkg, self.repo).package_bin() package: str = BinQueries(pkg, self.repo).package_bin()
@ -111,9 +110,8 @@ class Packages(Configs):
pkg_urls.append(f'{mirror}{location}/{package}') pkg_urls.append(f'{mirror}{location}/{package}')
self.binary_packages.append(package) self.binary_packages.append(package)
self.utils.remove_file_if_exists(self.tmp_slpkg, package) self.utils.remove_file_if_exists(self.tmp_slpkg, package)
else: else:
version: str = self.utils.split_binary_pkg(skip_package)[1] version: str = BinQueries(pkg, self.repo).version()
self.view_message.view_skipping_packages(pkg, version) self.view_message.view_skipping_packages(pkg, version)
if pkg_urls: if pkg_urls:
@ -121,13 +119,16 @@ class Packages(Configs):
down.download() down.download()
print() print()
def skip_installed_package(self, package) -> str: def continue_install(self, name) -> bool:
""" Skip installed package when the option --skip-installed is applied. """ """ Skip installed package when the option --skip-installed is applied
installed_package: str = self.utils.is_package_installed(package) and continue to install if the package is upgradable or the --reinstall option
applied.
"""
if self.utils.is_option(self.flag_skip_installed, self.flags):
return False
if (installed_package and self.mode == 'upgrade' and not self.upgrade.is_package_upgradeable(package) if self.upgrade.is_package_upgradeable(name) or self.utils.is_option(self.flag_reinstall, self.flags):
or self.mode == 'install' and not self.utils.is_option(self.flag_reinstall, self.flags)): return True
return installed_package
def checksum(self) -> None: def checksum(self) -> None:
""" Packages checksums. """ """ Packages checksums. """
@ -152,6 +153,8 @@ class Packages(Configs):
if not self.utils.is_option(self.flag_resolve_off, self.flags): if not self.utils.is_option(self.flag_resolve_off, self.flags):
name: str = self.utils.split_binary_pkg(package[:-4])[0] name: str = self.utils.split_binary_pkg(package[:-4])[0]
if not self.utils.is_option(self.flag_resolve_off, self.flags):
self.logging_installed_dependencies(name) self.logging_installed_dependencies(name)
def logging_installed_dependencies(self, name: str) -> None: def logging_installed_dependencies(self, name: str) -> None:
@ -228,7 +231,7 @@ class Packages(Configs):
status: bool = False status: bool = False
repo_ver: str = BinQueries(package, self.repo).version() repo_ver: str = BinQueries(package, self.repo).version()
help_text: str = f'Package: {package}-{repo_ver}' help_text: str = f'Package: {package} {repo_ver}'
upgradable: bool = self.upgrade.is_package_upgradeable(package) upgradable: bool = self.upgrade.is_package_upgradeable(package)
if self.mode == 'upgrade' and upgradable: if self.mode == 'upgrade' and upgradable:

View file

@ -24,7 +24,15 @@ class BinQueries(Configs):
if self.name in self.black.packages(): if self.name in self.black.packages():
self.name: str = '' self.name: str = ''
def all_package_names(self) -> list: def count_packages(self):
""" Counts the number of the packages. """
count = self.session.query(
BinariesTable.id).where(
BinariesTable.repo == self.repo).count()
return count
def all_package_names_by_repo(self) -> list:
""" Returns all the names of the binaries packages. """ """ Returns all the names of the binaries packages. """
pkgs: tuple = self.session.query( pkgs: tuple = self.session.query(
BinariesTable.name).where( BinariesTable.name).where(
@ -32,7 +40,7 @@ class BinQueries(Configs):
return [pkg[0] for pkg in pkgs] return [pkg[0] for pkg in pkgs]
def all_binaries_packages(self) -> list: def all_binaries_packages_by_repo(self) -> list:
""" Returns all the binaries packages. """ """ Returns all the binaries packages. """
pkgs: tuple = self.session.query( pkgs: tuple = self.session.query(
BinariesTable.package).where( BinariesTable.package).where(
@ -40,17 +48,25 @@ class BinQueries(Configs):
return [pkg[0] for pkg in pkgs] return [pkg[0] for pkg in pkgs]
def all_package_name_with_repo(self) -> tuple: def all_package_names_from_repositories(self) -> tuple:
""" Returns the package name with the repo. """ """ Returns the package name with the repo. """
pkgs: tuple = self.session.query( pkgs: tuple = self.session.query(
BinariesTable.name, BinariesTable.repo).where( BinariesTable.name, BinariesTable.repo).where(
BinariesTable.repo == self.repo).all() BinariesTable.repo.in_(self.repos.bin_enabled_repos)).all()
if pkgs: if pkgs:
return pkgs return pkgs
return () return ()
def all_package_names_with_required(self) -> list:
""" Returns all package with the dependencies. """
required: list = self.session.query(
BinariesTable.name, BinariesTable.required).where(
BinariesTable.repo == self.repo).all()
return required
def repository(self) -> str: def repository(self) -> str:
""" Return the repository name fo the package. """ """ Return the repository name fo the package. """
repository: tuple = self.session.query( repository: tuple = self.session.query(
@ -197,11 +213,3 @@ class BinQueries(Configs):
if desc: if desc:
return desc[0] return desc[0]
return '' return ''
def all_pkg_and_required(self) -> list:
""" Returns all package with the dependencies. """
required: list = self.session.query(
BinariesTable.name, BinariesTable.required).where(
BinariesTable.repo == self.repo).all()
return required

View file

@ -1,6 +1,7 @@
#!/usr/bin/python3 #!/usr/bin/python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from slpkg.repositories import Repositories
from slpkg.binaries.queries import BinQueries from slpkg.binaries.queries import BinQueries
@ -11,24 +12,47 @@ class Required:
def __init__(self, name: str, repo: str): def __init__(self, name: str, repo: str):
self.name: str = name self.name: str = name
self.repo: str = repo self.repo: str = repo
self.repo_package_names: list = BinQueries(name, self.repo).all_package_names() self.repos = Repositories()
self.repo_package_names: list = BinQueries(
self.name, self.repo).all_package_names_by_repo()
self.special_repos: list = [
self.repos.salixos_repo_name,
self.repos.salixos_extra_repo_name,
self.repos.slackel_repo_name,
self.repos.slint_repo_name
]
def resolve(self) -> list: def resolve(self) -> list:
""" Resolve the dependencies. """ """ Resolve the dependencies. """
requires: list[str] = BinQueries(self.name, self.repo).required() required: list[str] = BinQueries(self.name, self.repo).required()
# Resolve dependencies for some special repos.
if self.repo in self.special_repos:
requires: list = []
for req in required:
if req in self.repo_package_names:
requires.append(req)
return requires
for req in required:
# Remove requirements that are included as dependencies,
# but are not included in the repository.
if req not in self.repo_package_names:
required.remove(req)
for req in requires:
if req: if req:
sub: list[str] = BinQueries(req, self.repo).required() sub_required: list[str] = BinQueries(req, self.repo).required()
for s in sub: for sub in sub_required:
requires.append(s) required.append(sub)
# Clean for dependencies not in the repository. # Clean for dependencies not in the repository.
for dep in requires: for dep in required:
if dep not in self.repo_package_names: if dep not in self.repo_package_names:
requires.remove(dep) required.remove(dep)
requires.reverse() required.reverse()
return list(dict.fromkeys(requires)) return list(dict.fromkeys(required))

View file

@ -44,11 +44,28 @@ class CheckUpdates(Configs):
self.repo_chg_txt: str = f'{self.repos.alien_repo_changelog_mirror}{self.repos.alien_repo_changelog}' self.repo_chg_txt: str = f'{self.repos.alien_repo_changelog_mirror}{self.repos.alien_repo_changelog}'
compare[self.repos.alien_repo_name] = self.compare_dates() compare[self.repos.alien_repo_name] = self.compare_dates()
if self.repos.multilib_repo and self.repo == self.repos.multilib_repo_name or self.repo == '*':
self.local_chg_txt: Path = Path(self.repos.multilib_repo_path, self.repos.multilib_repo_changelog)
self.repo_chg_txt: str = (f'{self.repos.multilib_repo_changelog_mirror}'
f'{self.repos.multilib_repo_changelog}')
compare[self.repos.multilib_repo_name] = self.compare_dates()
if self.repos.restricted_repo and self.repo == self.repos.restricted_repo_name or self.repo == '*':
self.local_chg_txt: Path = Path(self.repos.restricted_repo_path, self.repos.restricted_repo_changelog)
self.repo_chg_txt: str = (f'{self.repos.restricted_repo_changelog_mirror}'
f'{self.repos.restricted_repo_changelog}')
compare[self.repos.restricted_repo_name] = self.compare_dates()
if self.repos.gnome_repo and self.repo == self.repos.gnome_repo_name or self.repo == '*': if self.repos.gnome_repo and self.repo == self.repos.gnome_repo_name or self.repo == '*':
self.local_chg_txt: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_changelog) self.local_chg_txt: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_changelog)
self.repo_chg_txt: str = f'{self.repos.gnome_repo_mirror}{self.repos.gnome_repo_changelog}' self.repo_chg_txt: str = f'{self.repos.gnome_repo_mirror}{self.repos.gnome_repo_changelog}'
compare[self.repos.gnome_repo_name] = self.compare_dates() compare[self.repos.gnome_repo_name] = self.compare_dates()
if self.repos.msb_repo and self.repo == self.repos.msb_repo_name or self.repo == '*':
self.local_chg_txt: Path = Path(self.repos.msb_repo_path, self.repos.msb_repo_changelog)
self.repo_chg_txt: str = f'{self.repos.msb_repo_changelog_mirror}{self.repos.msb_repo_changelog}'
compare[self.repos.msb_repo_name] = self.compare_dates()
if self.repos.conraid_repo and self.repo == self.repos.conraid_repo_name or self.repo == '*': if self.repos.conraid_repo and self.repo == self.repos.conraid_repo_name or self.repo == '*':
self.local_chg_txt: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_changelog) self.local_chg_txt: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_changelog)
self.repo_chg_txt: str = f'{self.repos.conraid_repo_mirror}{self.repos.conraid_repo_changelog}' self.repo_chg_txt: str = f'{self.repos.conraid_repo_mirror}{self.repos.conraid_repo_changelog}'
@ -59,6 +76,33 @@ class CheckUpdates(Configs):
self.repo_chg_txt: str = f'{self.repos.slackonly_repo_mirror}{self.repos.slackonly_repo_changelog}' self.repo_chg_txt: str = f'{self.repos.slackonly_repo_mirror}{self.repos.slackonly_repo_changelog}'
compare[self.repos.slackonly_repo_name] = self.compare_dates() compare[self.repos.slackonly_repo_name] = self.compare_dates()
if self.repos.ponce_bin_repo and self.repo == self.repos.ponce_bin_repo_name or self.repo == '*':
self.local_chg_txt: Path = Path(self.repos.ponce_bin_repo_path, self.repos.ponce_bin_repo_changelog)
self.repo_chg_txt: str = f'{self.repos.ponce_bin_repo_mirror}{self.repos.ponce_bin_repo_changelog}'
compare[self.repos.ponce_bin_repo_name] = self.compare_dates()
if self.repos.salixos_repo and self.repo == self.repos.salixos_repo_name or self.repo == '*':
self.local_chg_txt: Path = Path(self.repos.salixos_repo_path, self.repos.salixos_repo_changelog)
self.repo_chg_txt: str = f'{self.repos.salixos_repo_mirror}{self.repos.salixos_repo_changelog}'
compare[self.repos.salixos_repo_name] = self.compare_dates()
if self.repos.salixos_extra_repo and self.repo == self.repos.salixos_extra_repo_name or self.repo == '*':
self.local_chg_txt: Path = Path(self.repos.salixos_extra_repo_path,
self.repos.salixos_extra_repo_changelog)
self.repo_chg_txt: str = (f'{self.repos.salixos_extra_repo_mirror}'
f'{self.repos.salixos_extra_repo_changelog}')
compare[self.repos.salixos_extra_repo_name] = self.compare_dates()
if self.repos.slackel_repo and self.repo == self.repos.slackel_repo_name or self.repo == '*':
self.local_chg_txt: Path = Path(self.repos.slackel_repo_path, self.repos.slackel_repo_changelog)
self.repo_chg_txt: str = f'{self.repos.slackel_repo_mirror}{self.repos.slackel_repo_changelog}'
compare[self.repos.slackel_repo_name] = self.compare_dates()
if self.repos.slint_repo and self.repo == self.repos.slint_repo_name or self.repo == '*':
self.local_chg_txt: Path = Path(self.repos.slint_repo_path, self.repos.slint_repo_changelog)
self.repo_chg_txt: str = f'{self.repos.slint_repo_mirror}{self.repos.slint_repo_changelog}'
compare[self.repos.slint_repo_name] = self.compare_dates()
else: else:
if self.repos.ponce_repo: if self.repos.ponce_repo:
self.local_chg_txt: Path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_changelog) self.local_chg_txt: Path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_changelog)

View file

@ -37,13 +37,14 @@ class Check(Configs):
def exists_in_the_database(self, packages: list, repo=None) -> None: def exists_in_the_database(self, packages: list, repo=None) -> None:
""" Checking if the slackbuild exists in the database. """ """ Checking if the slackbuild exists in the database. """
not_packages: list = [] not_packages: list = []
for pkg in packages: for pkg in packages:
if self.utils.is_option(self.flag_bin_repository, self.flags): if self.utils.is_option(self.flag_bin_repository, self.flags):
if not BinQueries(pkg, repo).package_name(): if not BinQueries(pkg, repo).package_name() and pkg != '*':
not_packages.append(pkg) not_packages.append(pkg)
elif not SBoQueries(pkg).slackbuild(): elif not SBoQueries(pkg).slackbuild() and pkg != '*':
not_packages.append(pkg) not_packages.append(pkg)
if not_packages: if not_packages:
@ -52,6 +53,7 @@ class Check(Configs):
def is_package_unsupported(self, slackbuilds: list) -> None: def is_package_unsupported(self, slackbuilds: list) -> None:
""" Checking for unsupported slackbuilds. """ """ Checking for unsupported slackbuilds. """
for sbo in slackbuilds: for sbo in slackbuilds:
if sbo != '*':
sources = SBoQueries(sbo).sources() sources = SBoQueries(sbo).sources()
if 'UNSUPPORTED' in sources: if 'UNSUPPORTED' in sources:
@ -84,5 +86,6 @@ class Check(Configs):
""" Checking for empty table and database file. """ """ Checking for empty table and database file. """
db = Path(self.db_path, self.database_name) db = Path(self.db_path, self.database_name)
if not self.session.query(self.repo_table).first() or not db.is_file(): if not self.session.query(self.repo_table).first() or not db.is_file():
self.utils.raise_error_message("You need to update the package lists first.\n" self.utils.raise_error_message("You need to update the package lists first, run:\n\n"
" Please run 'slpkg update'") " $ 'slpkg update'\n"
" $ 'slpkg update --bin-repo='*' for binaries")

View file

@ -8,6 +8,7 @@ from urllib.parse import unquote
from slpkg.views.ascii import Ascii from slpkg.views.ascii import Ascii
from slpkg.views.views import ViewMessage from slpkg.views.views import ViewMessage
from slpkg.utilities import Utilities
class Md5sum: class Md5sum:
@ -16,6 +17,7 @@ class Md5sum:
def __init__(self, flags: list): def __init__(self, flags: list):
self.flags: list = flags self.flags: list = flags
self.ascii = Ascii() self.ascii = Ascii()
self.utils = Utilities()
def check(self, path: Union[str, Path], source: str, checksum: str) -> None: def check(self, path: Union[str, Path], source: str, checksum: str) -> None:
""" Checksum the source. """ """ Checksum the source. """
@ -34,8 +36,10 @@ class Md5sum:
view = ViewMessage(self.flags) view = ViewMessage(self.flags)
view.question() view.question()
@staticmethod def read_file(self, filename: Union[str, Path]) -> bytes:
def read_file(filename: Union[str, Path]) -> bytes:
""" Reads the text file. """ """ Reads the text file. """
try:
with open(filename, 'rb') as f: with open(filename, 'rb') as f:
return f.read() return f.read()
except FileNotFoundError:
self.utils.raise_error_message(f"No such file or directory: '{filename}'")

View file

@ -42,6 +42,8 @@ class Dependees(Configs):
print(f"The list below shows the " print(f"The list below shows the "
f"packages that dependees on '{', '.join([p for p in self.packages])}':\n") f"packages that dependees on '{', '.join([p for p in self.packages])}':\n")
self.packages: list = self.utils.apply_package_pattern(self.flags, self.packages, repo)
for pkg in self.packages: for pkg in self.packages:
dependees: list = list(self.find_requires(pkg, repo)) dependees: list = list(self.find_requires(pkg, repo))
@ -53,7 +55,7 @@ class Dependees(Configs):
else: else:
version: str = SBoQueries(pkg).version() version: str = SBoQueries(pkg).version()
package: str = f'{self.byellow}{pkg}-{version}{self.endc}' package: str = f'{self.byellow}{pkg} {version}{self.endc}'
print(package) print(package)
@ -73,7 +75,7 @@ class Dependees(Configs):
else: else:
version: str = SBoQueries(dep[0]).version() version: str = SBoQueries(dep[0]).version()
dependency: str = (f'{self.cyan}{dep[0]}{self.endc}-{self.yellow}' dependency: str = (f'{self.cyan}{dep[0]}{self.endc} {self.yellow}'
f'{version}{self.endc}') f'{version}{self.endc}')
if i == 1: if i == 1:
@ -83,16 +85,16 @@ class Dependees(Configs):
if self.utils.is_option(self.flag_full_reverse, self.flags): if self.utils.is_option(self.flag_full_reverse, self.flags):
if i == len(dependees): if i == len(dependees):
print(" " * 4 + f' {self.llc}{self.hl} {self.violet}{dep[1]}{self.endc}') print(' ' * 4 + f' {self.llc}{self.hl} {self.violet}{dep[1]}{self.endc}')
else: else:
print(" " * 4 + f' {self.var}{self.hl} {self.violet}{dep[1]}{self.endc}') 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') print(f'\n{self.grey}{len(dependees)} dependees for {pkg}{self.endc}\n')
def find_requires(self, pkg: str, repo) -> Generator[str, None, None]: def find_requires(self, pkg: str, repo) -> Generator[str, None, None]:
""" Find requires that slackbuild dependees. """ """ Find requires that slackbuild dependees. """
if self.utils.is_option(self.flag_bin_repository, self.flags): if self.utils.is_option(self.flag_bin_repository, self.flags):
requires: list = BinQueries(pkg, repo).all_pkg_and_required() requires: list = BinQueries(pkg, repo).all_package_names_with_required()
else: else:
requires: list = SBoQueries('').all_sbo_and_requires() requires: list = SBoQueries('').all_sbo_and_requires()

View file

@ -32,6 +32,7 @@ class Download(Configs):
def packages(self, packages: list, repo=None) -> None: def packages(self, packages: list, repo=None) -> None:
""" Download the package only. """ """ Download the package only. """
packages: list = self.utils.apply_package_pattern(self.flags, packages, repo)
view = ViewMessage(self.flags, repo) view = ViewMessage(self.flags, repo)
view.download_packages(packages, self.directory) view.download_packages(packages, self.directory)
view.question() view.question()

View file

@ -7,7 +7,8 @@ from slpkg.configs import Configs
from slpkg.utilities import Utilities from slpkg.utilities import Utilities
from slpkg.repositories import Repositories from slpkg.repositories import Repositories
from slpkg.models.models import session as Session from slpkg.models.models import session as Session
from slpkg.models.models import SBoTable, PonceTable, BinariesTable from slpkg.models.models import (SBoTable, PonceTable,
BinariesTable, LastRepoUpdated)
class InstallData(Configs): class InstallData(Configs):
@ -24,6 +25,14 @@ class InstallData(Configs):
self.byellow: str = f'{self.bold}{self.yellow}' self.byellow: str = f'{self.bold}{self.yellow}'
self.endc: str = self.color['endc'] self.endc: str = self.color['endc']
def last_updated(self, repo_file: Path) -> str:
""" Reads the first date of the changelog file."""
lines: list = self.utils.read_file(repo_file)
days = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')
for line in lines:
if line.startswith(days):
return line.replace('\n', '')
def install_sbos_data(self) -> None: def install_sbos_data(self) -> None:
""" Install the data for SBo repository. """ """ Install the data for SBo repository. """
sbo_tags = [ sbo_tags = [
@ -39,11 +48,15 @@ class InstallData(Configs):
'SLACKBUILD SHORT DESCRIPTION:' 'SLACKBUILD SHORT DESCRIPTION:'
] ]
sbo_table = SBoTable sbo_table = SBoTable
path = Path(self.repos.sbo_repo_path, self.repos.sbo_repo_slackbuilds) sbo_name: str = self.repos.sbo_repo_name
path: Path = Path(self.repos.sbo_repo_path, self.repos.sbo_repo_slackbuilds)
path_changelog: Path = Path(self.repos.sbo_repo_path, self.repos.sbo_repo_changelog)
if self.repos.ponce_repo: if self.repos.ponce_repo:
sbo_table = PonceTable sbo_table = PonceTable
sbo_name: str = self.repos.ponce_repo_name
path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_slackbuilds) path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_slackbuilds)
path_changelog: Path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_changelog)
slackbuilds_txt: list = self.utils.read_file(path) slackbuilds_txt: list = self.utils.read_file(path)
@ -68,6 +81,10 @@ class InstallData(Configs):
cache: list = [] # reset cache after 11 lines cache: list = [] # reset cache after 11 lines
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=sbo_name, date=last_updated)
self.session.add(date)
print(f'{self.byellow}Done{self.endc}') print(f'{self.byellow}Done{self.endc}')
self.session.commit() self.session.commit()
@ -85,6 +102,7 @@ class InstallData(Configs):
] ]
path_packages: Path = Path(self.repos.alien_repo_path, self.repos.alien_repo_packages) path_packages: Path = Path(self.repos.alien_repo_path, self.repos.alien_repo_packages)
path_checksums: Path = Path(self.repos.alien_repo_path, self.repos.alien_repo_checksums) path_checksums: Path = Path(self.repos.alien_repo_path, self.repos.alien_repo_checksums)
path_changelog: Path = Path(self.repos.alien_repo_path, self.repos.alien_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages) packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums) checksums_md5: list = self.utils.read_file(path_checksums)
@ -116,7 +134,7 @@ class InstallData(Configs):
if line.startswith(pkg_tag[1]): if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip() package_location = line.replace(pkg_tag[1], '').strip()
cache.append(package_location[1:]) # Do not install (.) dot cache.append(package_location[2:]) # Do not install (.) dot
if line.startswith(pkg_tag[2]): if line.startswith(pkg_tag[2]):
package_size_comp = line.replace(pkg_tag[2], '').strip() package_size_comp = line.replace(pkg_tag[2], '').strip()
@ -154,23 +172,27 @@ class InstallData(Configs):
cache: list = [] # reset cache cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.alien_repo_name, date=last_updated)
self.session.add(date)
print(f'{self.byellow}Done{self.endc}') print(f'{self.byellow}Done{self.endc}')
self.session.commit() self.session.commit()
def install_gnome_data(self) -> None: def install_multilib_data(self) -> None:
""" Install the data for gnome repository. """ """ Install the data for multilib repository. """
checksums_dict: dict = {} checksums_dict: dict = {}
pkg_tag = [ pkg_tag = [
'PACKAGE NAME:', 'PACKAGE NAME:',
'PACKAGE MIRROR:',
'PACKAGE LOCATION:', 'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):', 'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):', 'PACKAGE SIZE (uncompressed):',
'PACKAGE DESCRIPTION:' 'PACKAGE DESCRIPTION:'
] ]
path_packages: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_packages) path_packages: Path = Path(self.repos.multilib_repo_path, self.repos.multilib_repo_packages)
path_checksums: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_checksums) path_checksums: Path = Path(self.repos.multilib_repo_path, self.repos.multilib_repo_checksums)
path_changelog: Path = Path(self.repos.multilib_repo_path, self.repos.multilib_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages) packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums) checksums_md5: list = self.utils.read_file(path_checksums)
@ -194,16 +216,182 @@ class InstallData(Configs):
cache.append(split_package[0]) # package name cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version cache.append(split_package[1]) # package version
cache.append(package_name) cache.append(package_name)
cache.append(self.repos.multilib_repo_mirror)
try: try:
cache.append(checksums_dict[package_name]) cache.append(checksums_dict[package_name])
except KeyError: except KeyError:
cache.append('error checksum') cache.append('error checksum')
if line.startswith(pkg_tag[1]): if line.startswith(pkg_tag[1]):
package_mirror = line.replace(pkg_tag[1], '').strip() package_location = line.replace(pkg_tag[1], '').strip()
if not package_mirror.endswith('/'): cache.append(package_location[2:]) # Do not install (./) dot
package_mirror: str = f'{package_mirror}/'
cache.append(package_mirror) if line.startswith(pkg_tag[2]):
package_size_comp = line.replace(pkg_tag[2], '').strip()
cache.append(f'{package_size_comp}B')
if line.startswith(pkg_tag[3]):
package_size_uncomp = line.replace(pkg_tag[3], '').strip()
cache.append(f'{package_size_uncomp}B')
if line.startswith(pkg_tag[4]):
package_description = line.replace(pkg_tag[4], '').strip()
cache.append(package_description)
if len(cache) == 9:
data: str = BinariesTable(
repo=self.repos.multilib_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
description=cache[8],
required=''
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.multilib_repo_name, date=last_updated)
self.session.add(date)
print(f'{self.byellow}Done{self.endc}')
self.session.commit()
def install_restricted_data(self) -> None:
""" Install the data for multilib repository. """
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.restricted_repo_path, self.repos.restricted_repo_packages)
path_checksums: Path = Path(self.repos.restricted_repo_path, self.repos.restricted_repo_checksums)
path_changelog: Path = Path(self.repos.restricted_repo_path, self.repos.restricted_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
print('Creating the database... ', end='', flush=True)
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
cache.append(self.repos.restricted_repo_mirror)
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip()
cache.append(package_location[2:]) # Do not install (./) dot
if line.startswith(pkg_tag[2]):
package_size_comp = line.replace(pkg_tag[2], '').strip()
cache.append(f'{package_size_comp}B')
if line.startswith(pkg_tag[3]):
package_size_uncomp = line.replace(pkg_tag[3], '').strip()
cache.append(f'{package_size_uncomp}B')
if line.startswith(pkg_tag[4]):
package_description = line.replace(pkg_tag[4], '').strip()
cache.append(package_description)
if len(cache) == 9:
data: str = BinariesTable(
repo=self.repos.restricted_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
description=cache[8],
required=''
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.restricted_repo_name, date=last_updated)
self.session.add(date)
print(f'{self.byellow}Done{self.endc}')
self.session.commit()
def install_gnome_data(self) -> None:
""" Install the data for gnome repository. """
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE MIRROR:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_packages)
path_checksums: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_checksums)
path_changelog: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
print('Creating the database... ', end='', flush=True)
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
cache.append(self.repos.gnome_repo_mirror)
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[2]): if line.startswith(pkg_tag[2]):
package_location = line.replace(pkg_tag[2], '').strip() package_location = line.replace(pkg_tag[2], '').strip()
@ -227,18 +415,108 @@ class InstallData(Configs):
name=cache[0], name=cache[0],
version=cache[1], version=cache[1],
package=cache[2], package=cache[2],
checksum=cache[3], mirror=cache[3],
mirror=cache[4], checksum=cache[4],
location=cache[5], location=cache[5],
size_comp=cache[6], size_comp=cache[6],
size_uncomp=cache[7], size_uncomp=cache[7],
description=cache[8] description=cache[8],
required=''
) )
self.session.add(data) self.session.add(data)
cache: list = [] # reset cache cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.gnome_repo_name, date=last_updated)
self.session.add(date)
print(f'{self.byellow}Done{self.endc}')
self.session.commit()
def install_msb_data(self) -> None:
""" Install the data for msb repository. """
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.msb_repo_path, self.repos.msb_repo_packages)
path_checksums: Path = Path(self.repos.msb_repo_path, self.repos.msb_repo_checksums)
path_changelog: Path = Path(self.repos.msb_repo_path, self.repos.msb_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
print('Creating the database... ', end='', flush=True)
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
cache.append(self.repos.msb_repo_mirror)
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip()
cache.append(package_location[2:]) # Do not install (./) dot
if line.startswith(pkg_tag[2]):
package_size_comp = line.replace(pkg_tag[2], '').strip()
cache.append(f'{package_size_comp}B')
if line.startswith(pkg_tag[3]):
package_size_uncomp = line.replace(pkg_tag[3], '').strip()
cache.append(f'{package_size_uncomp}B')
if line.startswith(pkg_tag[4]):
package_description = line.replace(pkg_tag[4], '').strip()
cache.append(package_description)
if len(cache) == 9:
data: str = BinariesTable(
repo=self.repos.msb_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
description=cache[8],
required=''
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.msb_repo_name, date=last_updated)
self.session.add(date)
print(f'{self.byellow}Done{self.endc}') print(f'{self.byellow}Done{self.endc}')
self.session.commit() self.session.commit()
@ -256,6 +534,7 @@ class InstallData(Configs):
] ]
path_packages: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_packages) path_packages: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_packages)
path_checksums: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_checksums) path_checksums: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_checksums)
path_changelog: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_changelog)
checksums_md5: list = self.utils.read_file(path_checksums) checksums_md5: list = self.utils.read_file(path_checksums)
packages_txt: list = self.utils.read_file(path_packages) packages_txt: list = self.utils.read_file(path_packages)
@ -280,17 +559,12 @@ class InstallData(Configs):
cache.append(split_package[0]) # package name cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version cache.append(split_package[1]) # package version
cache.append(package_name) cache.append(package_name)
cache.append(self.repos.conraid_repo_mirror)
try: try:
cache.append(checksums_dict[package_name]) cache.append(checksums_dict[package_name])
except KeyError: except KeyError:
cache.append('error checksum') cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_mirror: str = line.replace(pkg_tag[1], '').strip()
if not package_mirror.endswith('/'):
package_mirror: str = f'{package_mirror}/'
cache.append(package_mirror)
if line.startswith(pkg_tag[2]): if line.startswith(pkg_tag[2]):
package_location: str = line.replace(pkg_tag[2], '').strip() package_location: str = line.replace(pkg_tag[2], '').strip()
cache.append(package_location[2:]) # Do not install (./) dot cache.append(package_location[2:]) # Do not install (./) dot
@ -313,18 +587,23 @@ class InstallData(Configs):
name=cache[0], name=cache[0],
version=cache[1], version=cache[1],
package=cache[2], package=cache[2],
checksum=cache[3], mirror=cache[3],
mirror=cache[4], checksum=cache[4],
location=cache[5], location=cache[5],
size_comp=cache[6], size_comp=cache[6],
size_uncomp=cache[7], size_uncomp=cache[7],
description=cache[8] description=cache[8],
required='',
) )
self.session.add(data) self.session.add(data)
cache: list = [] # reset cache cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.conraid_repo_name, date=last_updated)
self.session.add(date)
print(f'{self.byellow}Done{self.endc}') print(f'{self.byellow}Done{self.endc}')
self.session.commit() self.session.commit()
@ -342,6 +621,7 @@ class InstallData(Configs):
] ]
path_packages: Path = Path(self.repos.slackonly_repo_path, self.repos.slackonly_repo_packages) path_packages: Path = Path(self.repos.slackonly_repo_path, self.repos.slackonly_repo_packages)
path_checksums: Path = Path(self.repos.slackonly_repo_path, self.repos.slackonly_repo_checksums) path_checksums: Path = Path(self.repos.slackonly_repo_path, self.repos.slackonly_repo_checksums)
path_changelog: Path = Path(self.repos.slackonly_repo_path, self.repos.slackonly_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages) packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums) checksums_md5: list = self.utils.read_file(path_checksums)
@ -373,7 +653,7 @@ class InstallData(Configs):
if line.startswith(pkg_tag[1]): if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip() package_location = line.replace(pkg_tag[1], '').strip()
cache.append(package_location[1:]) # Do not install (.) dot cache.append(package_location[2:]) # Do not install (./) dot
if line.startswith(pkg_tag[2]): if line.startswith(pkg_tag[2]):
package_size_comp = line.replace(pkg_tag[2], '').strip() package_size_comp = line.replace(pkg_tag[2], '').strip()
@ -411,6 +691,493 @@ class InstallData(Configs):
cache: list = [] # reset cache cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.slackonly_repo_name, date=last_updated)
self.session.add(date)
print(f'{self.byellow}Done{self.endc}')
self.session.commit()
def install_ponce_bin_data(self) -> None:
""" Install the data for ponce_bin repository. """
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE MIRROR:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.ponce_bin_repo_path, self.repos.ponce_bin_repo_packages)
path_checksums: Path = Path(self.repos.ponce_bin_repo_path, self.repos.ponce_bin_repo_checksums)
path_changelog: Path = Path(self.repos.ponce_bin_repo_path, self.repos.ponce_bin_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
print('Creating the database... ', end='', flush=True)
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
cache.append(self.repos.ponce_bin_repo_mirror)
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[2]):
package_location = line.replace(pkg_tag[2], '').strip()
cache.append(package_location[1:]) # Do not install (.) dot
if line.startswith(pkg_tag[3]):
package_size_comp = line.replace(pkg_tag[3], '').strip()
cache.append(f'{package_size_comp}B')
if line.startswith(pkg_tag[4]):
package_size_uncomp = line.replace(pkg_tag[4], '').strip()
cache.append(f'{package_size_uncomp}B')
if line.startswith(pkg_tag[5]):
package_description = line.replace(pkg_tag[5], '').strip()
cache.append(package_description)
if len(cache) == 9:
data: str = BinariesTable(
repo=self.repos.ponce_bin_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
description=cache[8],
required=''
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.ponce_bin_repo_name, date=last_updated)
self.session.add(date)
print(f'{self.byellow}Done{self.endc}')
self.session.commit()
def install_salixos_data(self) -> None:
""" Install the data for salixos repository. """
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE REQUIRED:',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.salixos_repo_path, self.repos.salixos_repo_packages)
path_checksums: Path = Path(self.repos.salixos_repo_path, self.repos.salixos_repo_checksums)
path_changelog: Path = Path(self.repos.salixos_repo_path, self.repos.salixos_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
print('Creating the database... ', end='', flush=True)
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
cache.append(self.repos.salixos_repo_mirror)
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip()
cache.append(package_location[2:]) # Do not install (./) dot
if line.startswith(pkg_tag[2]):
package_size_comp = line.replace(pkg_tag[2], '').strip()
cache.append(f'{package_size_comp}B')
if line.startswith(pkg_tag[3]):
package_size_uncomp = line.replace(pkg_tag[3], '').strip()
cache.append(f'{package_size_uncomp}B')
if line.startswith(pkg_tag[4]):
deps: list = []
required = line.replace(pkg_tag[4], '').strip()
for req in required.split(','):
dep = req.split('|')
if len(dep) > 1:
deps.append(dep[1])
else:
deps += dep
cache.append(' '.join(deps))
if line.startswith(pkg_tag[5]):
package_description = line.replace(pkg_tag[5], '').strip()
cache.append(package_description)
if len(cache) == 10:
data: str = BinariesTable(
repo=self.repos.salixos_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
required=cache[8],
description=cache[9]
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.salixos_repo_name, date=last_updated)
self.session.add(date)
print(f'{self.byellow}Done{self.endc}')
self.session.commit()
def install_salixos_extra_data(self) -> None:
""" Install the data for salixos_extra repository. """
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE REQUIRED:',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.salixos_extra_repo_path, self.repos.salixos_extra_repo_packages)
path_checksums: Path = Path(self.repos.salixos_extra_repo_path, self.repos.salixos_extra_repo_checksums)
path_changelog: Path = Path(self.repos.salixos_extra_repo_path,
self.repos.salixos_extra_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
print('Creating the database... ', end='', flush=True)
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
cache.append(self.repos.salixos_extra_repo_mirror)
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip()
cache.append(package_location[2:]) # Do not install (./) dot
if line.startswith(pkg_tag[2]):
package_size_comp = line.replace(pkg_tag[2], '').strip()
cache.append(f'{package_size_comp}B')
if line.startswith(pkg_tag[3]):
package_size_uncomp = line.replace(pkg_tag[3], '').strip()
cache.append(f'{package_size_uncomp}B')
if line.startswith(pkg_tag[4]):
deps: list = []
required = line.replace(pkg_tag[4], '').strip()
for req in required.split(','):
dep = req.split('|')
if len(dep) > 1:
deps.append(dep[1])
else:
deps += dep
cache.append(' '.join(deps))
if line.startswith(pkg_tag[5]):
package_description = line.replace(pkg_tag[5], '').strip()
cache.append(package_description)
if len(cache) == 10:
data: str = BinariesTable(
repo=self.repos.salixos_extra_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
required=cache[8],
description=cache[9]
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.salixos_extra_repo_name, date=last_updated)
self.session.add(date)
print(f'{self.byellow}Done{self.endc}')
self.session.commit()
def install_slackel_data(self) -> None:
""" Install the data for slackel repository. """
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE REQUIRED:',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.slackel_repo_path, self.repos.slackel_repo_packages)
path_checksums: Path = Path(self.repos.slackel_repo_path, self.repos.slackel_repo_checksums)
path_changelog: Path = Path(self.repos.slackel_repo_path, self.repos.slackel_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
print('Creating the database... ', end='', flush=True)
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
cache.append(self.repos.slackel_repo_mirror)
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip()
cache.append(package_location[2:]) # Do not install (./) dot
if line.startswith(pkg_tag[2]):
package_size_comp = line.replace(pkg_tag[2], '').strip()
cache.append(f'{package_size_comp}B')
if line.startswith(pkg_tag[3]):
package_size_uncomp = line.replace(pkg_tag[3], '').strip()
cache.append(f'{package_size_uncomp}B')
if line.startswith(pkg_tag[4]):
deps: list = []
required = line.replace(pkg_tag[4], '').strip()
for req in required.split(','):
dep = req.split('|')
if len(dep) > 1:
deps.append(dep[1])
else:
deps += dep
cache.append(' '.join(deps))
if line.startswith(pkg_tag[5]):
package_description = line.replace(pkg_tag[5], '').strip()
cache.append(package_description)
if len(cache) == 10:
data: str = BinariesTable(
repo=self.repos.slackel_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
required=cache[8],
description=cache[9]
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.slackel_repo_name, date=last_updated)
self.session.add(date)
print(f'{self.byellow}Done{self.endc}')
self.session.commit()
def install_slint_data(self) -> None:
""" Install the data for slint repository. """
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE REQUIRED:',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.slint_repo_path, self.repos.slint_repo_packages)
path_checksums: Path = Path(self.repos.slint_repo_path, self.repos.slint_repo_checksums)
path_changelog: Path = Path(self.repos.slint_repo_path, self.repos.slint_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
print('Creating the database... ', end='', flush=True)
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
cache.append(self.repos.slint_repo_mirror)
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip()
cache.append(package_location[2:]) # Do not install (./) dot
if line.startswith(pkg_tag[2]):
package_size_comp = line.replace(pkg_tag[2], '').strip()
cache.append(f'{package_size_comp}B')
if line.startswith(pkg_tag[3]):
package_size_uncomp = line.replace(pkg_tag[3], '').strip()
cache.append(f'{package_size_uncomp}B')
if line.startswith(pkg_tag[4]):
deps: list = []
required = line.replace(pkg_tag[4], '').strip()
for req in required.split(','):
dep = req.split('|')
if len(dep) > 1:
deps.append(dep[1])
else:
deps += dep
cache.append(' '.join(deps))
if line.startswith(pkg_tag[5]):
package_description = line.replace(pkg_tag[5], '').strip()
cache.append(package_description)
if len(cache) == 10:
data: str = BinariesTable(
repo=self.repos.slint_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
required=cache[8],
description=cache[9]
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.slint_repo_name, date=last_updated)
self.session.add(date)
print(f'{self.byellow}Done{self.endc}') print(f'{self.byellow}Done{self.endc}')
self.session.commit() self.session.commit()

View file

@ -199,8 +199,6 @@ class Argparse(Configs):
self.flag_short_yes, self.flag_short_yes,
self.flag_search, self.flag_search,
self.flag_short_search, self.flag_short_search,
self.flag_no_silent,
self.flag_short_no_silent,
self.flag_directory, self.flag_directory,
self.flag_short_directory, self.flag_short_directory,
self.flag_bin_repository, self.flag_bin_repository,
@ -283,11 +281,14 @@ class Argparse(Configs):
def check_for_bin_repositories(self) -> None: def check_for_bin_repositories(self) -> None:
""" Checks combination for binaries use repositories only and if repository exists. """ """ Checks combination for binaries use repositories only and if repository exists. """
if (self.utils.is_option(self.flag_binaries, self.flags) if self.utils.is_option(self.flag_binaries, self.flags):
and not self.utils.is_option(self.flag_binaries, self.flags)):
self.usage.help_minimal(f"{self.prog_name}: invalid options '{', '.join(self.flags)}'")
if self.binary_repo not in self.repos.binaries_repositories_dict.keys(): except_options: list = ['-s', 'search', '-u', 'update', '-c', 'check-updates']
if self.binary_repo == '*' and not self.utils.is_option(except_options, self.args):
self.usage.help_minimal(f"{self.prog_name}: invalid binary repository '{self.binary_repo}'")
elif self.binary_repo not in self.repos.bin_repos_names and self.binary_repo != '*':
self.usage.help_minimal(f"{self.prog_name}: invalid binary repository '{self.binary_repo}'") self.usage.help_minimal(f"{self.prog_name}: invalid binary repository '{self.binary_repo}'")
def invalid_options(self) -> None: def invalid_options(self) -> None:
@ -401,7 +402,7 @@ class Argparse(Configs):
repo_packages: list = SBoQueries('').sbos() repo_packages: list = SBoQueries('').sbos()
if self.utils.is_option(self.flag_binaries, self.flags): if self.utils.is_option(self.flag_binaries, self.flags):
repo_packages: list = BinQueries('', self.binary_repo).all_package_names() repo_packages: list = BinQueries('', self.binary_repo).all_package_names_by_repo()
installed: list = self.utils.installed_packages installed: list = self.utils.installed_packages
@ -453,9 +454,11 @@ class Argparse(Configs):
text: str = f'There are {len(choices)} packages:' text: str = f'There are {len(choices)} packages:'
code, tags = self.dialogbox.checklist(text, packages, title, height, code, tags = self.dialogbox.checklist(text, packages, title, height,
width, list_height, choices) width, list_height, choices)
os.system('clear') os.system('clear')
if code == 'cancel':
raise SystemExit()
if not tags: if not tags:
return packages return packages
@ -623,7 +626,6 @@ class Argparse(Configs):
if len(self.args) >= 2: if len(self.args) >= 2:
self.check.is_empty_database()
packages: list = self.is_file_list_packages() packages: list = self.is_file_list_packages()
if self.utils.is_option(self.flag_searches, self.flags): if self.utils.is_option(self.flag_searches, self.flags):
@ -697,7 +699,7 @@ class Argparse(Configs):
if self.utils.is_option(self.flag_searches, self.flags): if self.utils.is_option(self.flag_searches, self.flags):
packages: list = self.choose_packages(packages, command) packages: list = self.choose_packages(packages, command)
self.check.exists_in_the_database(packages) self.check.exists_in_the_database(packages, self.binary_repo)
dependees = Dependees(packages, self.flags) dependees = Dependees(packages, self.flags)
dependees.find(self.binary_repo) dependees.find(self.binary_repo)
@ -715,7 +717,7 @@ class Argparse(Configs):
if self.utils.is_option(self.flag_searches, self.flags): if self.utils.is_option(self.flag_searches, self.flags):
packages: list = self.choose_packages(packages, command) packages: list = self.choose_packages(packages, command)
self.check.exists_in_the_database(packages) self.check.exists_in_the_database(packages, self.binary_repo)
tracking = Tracking(self.flags) tracking = Tracking(self.flags)
tracking.packages(packages, self.binary_repo) tracking.packages(packages, self.binary_repo)
@ -725,8 +727,11 @@ class Argparse(Configs):
def help_for_commands(self) -> None: def help_for_commands(self) -> None:
""" Extra help information for commands. """ """ Extra help information for commands. """
if len(self.args) == 2: if len(self.args) == 2:
try:
flags = self.commands[self.args[1]] flags = self.commands[self.args[1]]
Help(self.args[1], flags).view() Help(self.args[1], flags).view()
except KeyError:
self.usage.help_minimal(f"{self.prog_name}: invalid argument '{''.join(self.args[1])}'")
else: else:
self.usage.help_short(1) self.usage.help_short(1)

View file

@ -90,4 +90,15 @@ class LogsDependencies(Base):
requires: str = Column(Text) requires: str = Column(Text)
@dataclass
class LastRepoUpdated(Base):
""" The table that saves the last updated date. """
__tablename__ = 'lastupdated'
id: int = Column(Integer, primary_key=True)
repo: str = Column(Text)
date: str = Column(Text)
Base.metadata.create_all(engine) Base.metadata.create_all(engine)

View file

@ -2,13 +2,14 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import shutil import shutil
from pathlib import Path
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.utilities import Utilities from slpkg.utilities import Utilities
from slpkg.sbos.queries import SBoQueries from slpkg.sbos.queries import SBoQueries
from slpkg.repositories import Repositories from slpkg.repositories import Repositories
from slpkg.binaries.queries import BinQueries from slpkg.binaries.queries import BinQueries
from slpkg.models.models import LastRepoUpdated
from slpkg.models.models import session as Session
class RepoInfo(Configs): class RepoInfo(Configs):
@ -20,6 +21,7 @@ class RepoInfo(Configs):
self.repos = Repositories() self.repos = Repositories()
self.color = self.colour() self.color = self.colour()
self.columns, self.rows = shutil.get_terminal_size() self.columns, self.rows = shutil.get_terminal_size()
self.session = Session
self.bold: str = self.color['bold'] self.bold: str = self.color['bold']
self.green: str = self.color['green'] self.green: str = self.color['green']
@ -32,48 +34,42 @@ class RepoInfo(Configs):
def info(self): def info(self):
""" Prints information about repositories. """ """ Prints information about repositories. """
total_packages: int = 0
enabled: int = 0
print('Repositories Information:') print('Repositories Information:')
print('=' * self.columns) print('=' * self.columns)
print(f"{'Name:':<18}{'Status:':<15}{'Last Updated:':<35}{'Packages:':>12}") print(f"{'Name:':<18}{'Status:':<15}{'Last Updated:':<35}{'Packages:':>12}")
print('=' * self.columns) print('=' * self.columns)
total_packages: int = 0
enabled: int = 0
for repo, value in self.repos.repos_dict.items(): for repo, value in self.repos.repos_dict.items():
count: int = 0 count: int = 0
status: str = 'Disabled' status: str = 'Disabled'
color: str = self.red color: str = self.red
if value[0]: if value[0]:
enabled += 1 enabled += 1
status: str = 'Enabled' status: str = 'Enabled'
color: str = self.green color: str = self.green
last: str = self.last_update(Path(value[1], value[2])) last: str = self.session.query(
LastRepoUpdated.date).where(
LastRepoUpdated.repo == repo).first()
packages: dict = { if last is None:
self.repos.sbo_repo_name: len(SBoQueries('').sbos()), last: tuple = ('',)
self.repos.ponce_repo_name: len(SBoQueries('').sbos()),
self.repos.alien_repo_name: len(BinQueries('', repo).all_package_names()),
self.repos.gnome_repo_name: len(BinQueries('', repo).all_package_names()),
self.repos.conraid_repo_name: len(BinQueries('', repo).all_package_names()),
self.repos.slackonly_repo_name: len(BinQueries('', repo).all_package_names())
}
if value[0]: if value[0]:
count: int = packages[repo] if repo in [self.repos.sbo_repo_name, self.repos.ponce_repo_name]:
count = int(SBoQueries('').count_packages())
else:
count = int(BinQueries('', repo).count_packages())
total_packages += count total_packages += count
print(f"{self.cyan}{repo:<18}{self.endc}{color}{status:<15}{self.endc}{last:<35}" print(f"{self.cyan}{repo:<18}{self.endc}{color}{status:<15}{self.endc}{last[0]:<35}"
f"{self.yellow}{count:>12}{self.endc}") f"{self.yellow}{count:>12}{self.endc}")
print('=' * self.columns) print('=' * self.columns)
print(f"{self.grey}Total of {enabled} repositories are enabled with {total_packages} packages available.") print(f"{self.grey}Total of {enabled}/{len(self.repos.repos_dict)} "
f"repositories are enabled with {total_packages} packages available.\n")
def last_update(self, repo_file: Path) -> str:
""" Reads the first date of the changelog file."""
lines: list = self.utils.read_file(repo_file)
days = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')
for line in lines:
if line.startswith(days):
return line.replace('\n', '')

View file

@ -22,57 +22,125 @@ class Repositories:
repos = {} repos = {}
binaries_repositories_dict = {} binaries_repositories_dict = {}
bin_enabled_repositories = [] bin_enabled_repos = []
sbo_enabled: bool = True sbo_enabled: bool = True
sbo_repo_name: str = 'sbo' sbo_repo_name: str = 'sbo'
sbo_repo_path: Path = Path(config.lib_path, 'repositories', sbo_repo_name) sbo_repo_path: Path = Path(config.lib_path, 'repositories', sbo_repo_name)
sbo_repo_mirror: str = "https://slackbuilds.org/slackbuilds/15.0/" sbo_repo_mirror: str = 'https://slackbuilds.org/slackbuilds/15.0/'
sbo_repo_slackbuilds: str = "SLACKBUILDS.TXT" sbo_repo_slackbuilds: str = 'SLACKBUILDS.TXT'
sbo_repo_changelog: str = "ChangeLog.txt" sbo_repo_changelog: str = 'ChangeLog.txt'
sbo_repo_tar_suffix: str = ".tar.gz" sbo_repo_tar_suffix: str = '.tar.gz'
sbo_repo_tag: str = "_SBo" sbo_repo_tag: str = '_SBo'
ponce_repo_name: str = 'ponce' ponce_repo_name: str = 'ponce'
ponce_repo: bool = False ponce_repo: bool = False
ponce_repo_path: Path = Path(config.lib_path, 'repositories', ponce_repo_name) ponce_repo_path: Path = Path(config.lib_path, 'repositories', ponce_repo_name)
ponce_repo_mirror: str = "https://cgit.ponce.cc/slackbuilds/plain/" ponce_repo_mirror: str = 'https://cgit.ponce.cc/slackbuilds/plain/'
ponce_repo_slackbuilds: str = "SLACKBUILDS.TXT" ponce_repo_slackbuilds: str = 'SLACKBUILDS.TXT'
ponce_repo_changelog: str = "ChangeLog.txt" ponce_repo_changelog: str = 'ChangeLog.txt'
ponce_repo_tag: str = "_SBo" ponce_repo_tag: str = '_SBo'
alien_repo_name: str = 'alien' alien_repo_name: str = 'alien'
alien_repo: bool = True alien_repo: bool = False
alien_repo_path: Path = Path(config.lib_path, 'repositories', alien_repo_name) alien_repo_path: Path = Path(config.lib_path, 'repositories', alien_repo_name)
alien_repo_mirror: str = "http://slackware.uk/people/alien/sbrepos/15.0/x86_64/" alien_repo_mirror: str = 'http://slackware.uk/people/alien/sbrepos/15.0/x86_64/'
alien_repo_changelog_mirror: str = "http://slackware.uk/people/alien/sbrepos/" alien_repo_changelog_mirror: str = 'http://slackware.uk/people/alien/sbrepos/'
alien_repo_packages: str = "PACKAGES.TXT" alien_repo_packages: str = 'PACKAGES.TXT'
alien_repo_checksums: str = "CHECKSUMS.md5" alien_repo_checksums: str = 'CHECKSUMS.md5'
alien_repo_changelog: str = "ChangeLog.txt" alien_repo_changelog: str = 'ChangeLog.txt'
multilib_repo_name: str = 'multilib'
multilib_repo: bool = False
multilib_repo_path: Path = Path(config.lib_path, 'repositories', multilib_repo_name)
multilib_repo_mirror: str = 'https://slackware.nl/people/alien/multilib/15.0/'
multilib_repo_changelog_mirror: str = 'https://slackware.nl/people/alien/multilib/'
multilib_repo_packages: str = 'PACKAGES.TXT'
multilib_repo_checksums: str = 'CHECKSUMS.md5'
multilib_repo_changelog: str = 'ChangeLog.txt'
restricted_repo_name: str = 'restricted'
restricted_repo: bool = False
restricted_repo_path: Path = Path(config.lib_path, 'repositories', restricted_repo_name)
restricted_repo_mirror: str = 'https://slackware.nl/people/alien/restricted_sbrepos/15.0/x86_64/'
restricted_repo_changelog_mirror: str = 'https://slackware.nl/people/alien/restricted_sbrepos/'
restricted_repo_packages: str = 'PACKAGES.TXT'
restricted_repo_checksums: str = 'CHECKSUMS.md5'
restricted_repo_changelog: str = 'ChangeLog.txt'
gnome_repo_name: str = 'gnome' gnome_repo_name: str = 'gnome'
gnome_repo: bool = True gnome_repo: bool = False
gnome_repo_path: Path = Path(config.lib_path, 'repositories', gnome_repo_name) gnome_repo_path: Path = Path(config.lib_path, 'repositories', gnome_repo_name)
gnome_repo_mirror: str = "https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/" gnome_repo_mirror: str = 'https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/'
gnome_repo_packages: str = "PACKAGES.TXT" gnome_repo_packages: str = 'PACKAGES.TXT'
gnome_repo_checksums: str = "CHECKSUMS.md5" gnome_repo_checksums: str = 'CHECKSUMS.md5'
gnome_repo_changelog: str = "ChangeLog.txt" gnome_repo_changelog: str = 'ChangeLog.txt'
msb_repo_name: str = 'msb'
msb_repo: bool = False
msb_repo_path: Path = Path(config.lib_path, 'repositories', msb_repo_name)
msb_repo_mirror: str = 'https://slackware.uk/msb/15.0/1.26/x86_64/'
msb_repo_changelog_mirror: str = 'https://slackware.uk/msb/'
msb_repo_packages: str = 'PACKAGES.TXT'
msb_repo_checksums: str = 'CHECKSUMS.md5'
msb_repo_changelog: str = 'ChangeLog.txt'
conraid_repo_name: str = 'conraid' conraid_repo_name: str = 'conraid'
conraid_repo: bool = True conraid_repo: bool = False
conraid_repo_path: Path = Path(config.lib_path, 'repositories', conraid_repo_name) conraid_repo_path: Path = Path(config.lib_path, 'repositories', conraid_repo_name)
conraid_repo_mirror: str = "https://reddoglinux.ddns.net/linux/conraid_43.x/x86_64/" conraid_repo_mirror: str = 'https://reddoglinux.ddns.net/linux/conraid_43.x/x86_64/'
conraid_repo_packages: str = "PACKAGES.TXT" conraid_repo_packages: str = 'PACKAGES.TXT'
conraid_repo_checksums: str = "CHECKSUMS.md5" conraid_repo_checksums: str = 'CHECKSUMS.md5'
conraid_repo_changelog: str = "ChangeLog.txt" conraid_repo_changelog: str = 'ChangeLog.txt'
slackonly_repo_name: str = 'slackonly' slackonly_repo_name: str = 'slackonly'
slackonly_repo: bool = True slackonly_repo: bool = False
slackonly_repo_path: Path = Path(config.lib_path, 'repositories', slackonly_repo_name) slackonly_repo_path: Path = Path(config.lib_path, 'repositories', slackonly_repo_name)
slackonly_repo_mirror: str = "https://packages.slackonly.com/pub/packages/15.0-x86_64/" slackonly_repo_mirror: str = 'https://packages.slackonly.com/pub/packages/15.0-x86_64/'
slackonly_repo_packages: str = "PACKAGES.TXT" slackonly_repo_packages: str = 'PACKAGES.TXT'
slackonly_repo_checksums: str = "CHECKSUMS.md5" slackonly_repo_checksums: str = 'CHECKSUMS.md5'
slackonly_repo_changelog: str = "ChangeLog.txt" slackonly_repo_changelog: str = 'ChangeLog.txt'
ponce_bin_repo_name: str = 'ponce_bin'
ponce_bin_repo: bool = False
ponce_bin_repo_path: Path = Path(config.lib_path, 'repositories', ponce_bin_repo_name)
ponce_bin_repo_mirror: str = 'https://ponce.cc/slackware/slackware64-15.0/packages/'
ponce_bin_repo_packages: str = 'PACKAGES.TXT'
ponce_bin_repo_checksums: str = 'CHECKSUMS.md5'
ponce_bin_repo_changelog: str = 'ChangeLog.txt'
salixos_repo_name: str = 'salixos'
salixos_repo: bool = False
salixos_repo_path: Path = Path(config.lib_path, 'repositories', salixos_repo_name)
salixos_repo_mirror: str = 'https://download.salixos.org/x86_64/slackware-15.0/'
salixos_repo_packages: str = 'PACKAGES.TXT'
salixos_repo_checksums: str = 'CHECKSUMS.md5'
salixos_repo_changelog: str = 'ChangeLog.txt'
salixos_extra_repo_name: str = 'salixos_extra'
salixos_extra_repo: bool = False
salixos_extra_repo_path: Path = Path(config.lib_path, 'repositories', salixos_extra_repo_name)
salixos_extra_repo_mirror: str = 'https://download.salixos.org/x86_64/slackware-15.0/'
salixos_extra_repo_packages_mirror: str = 'https://download.salixos.org/x86_64/slackware-15.0/extra/'
salixos_extra_repo_packages: str = 'PACKAGES.TXT'
salixos_extra_repo_checksums: str = 'CHECKSUMS.md5'
salixos_extra_repo_changelog: str = 'ChangeLog.txt'
slackel_repo_name: str = 'slackel'
slackel_repo: bool = False
slackel_repo_path: Path = Path(config.lib_path, 'repositories', slackel_repo_name)
slackel_repo_mirror: str = 'http://www.slackel.gr/repo/x86_64/slackware-current/'
slackel_repo_packages: str = 'PACKAGES.TXT'
slackel_repo_checksums: str = 'CHECKSUMS.md5'
slackel_repo_changelog: str = 'ChangeLog.txt'
slint_repo_name: str = 'slint'
slint_repo: bool = False
slint_repo_path: Path = Path(config.lib_path, 'repositories', slint_repo_name)
slint_repo_mirror: str = 'https://slackware.uk/slint/x86_64/slint-15.0/'
slint_repo_packages: str = 'PACKAGES.TXT'
slint_repo_checksums: str = 'CHECKSUMS.md5'
slint_repo_changelog: str = 'ChangeLog.txt'
# Default repository tag. # Default repository tag.
repo_tag: str = sbo_repo_tag repo_tag: str = sbo_repo_tag
@ -107,6 +175,22 @@ class Repositories:
alien_repo_checksums: str = repos['ALIEN_REPO_CHECKSUMS'] alien_repo_checksums: str = repos['ALIEN_REPO_CHECKSUMS']
alien_repo_changelog: str = repos['ALIEN_REPO_CHANGELOG'] alien_repo_changelog: str = repos['ALIEN_REPO_CHANGELOG']
multilib_repo_name: str = repos['MULTILIB_REPO_NAME']
multilib_repo: bool = repos['MULTILIB_REPO']
multilib_repo_mirror: str = repos['MULTILIB_REPO_MIRROR']
multilib_repo_changelog_mirror: str = repos['MULTILIB_REPO_CHANGELOG_MIRROR']
multilib_repo_packages: str = repos['MULTILIB_REPO_PACKAGES']
multilib_repo_checksums: str = repos['MULTILIB_REPO_CHECKSUMS']
multilib_repo_changelog: str = repos['MULTILIB_REPO_CHANGELOG']
restricted_repo_name: str = repos['RESTRICTED_REPO_NAME']
restricted_repo: bool = repos['RESTRICTED_REPO']
restricted_repo_mirror: str = repos['RESTRICTED_REPO_MIRROR']
restricted_repo_changelog_mirror: str = repos['RESTRICTED_REPO_CHANGELOG_MIRROR']
restricted_repo_packages: str = repos['RESTRICTED_REPO_PACKAGES']
restricted_repo_checksums: str = repos['RESTRICTED_REPO_CHECKSUMS']
restricted_repo_changelog: str = repos['RESTRICTED_REPO_CHANGELOG']
gnome_repo_name: str = repos['GNOME_REPO_NAME'] gnome_repo_name: str = repos['GNOME_REPO_NAME']
gnome_repo: bool = repos['GNOME_REPO'] gnome_repo: bool = repos['GNOME_REPO']
gnome_repo_mirror: str = repos['GNOME_REPO_MIRROR'] gnome_repo_mirror: str = repos['GNOME_REPO_MIRROR']
@ -114,6 +198,14 @@ class Repositories:
gnome_repo_checksums: str = repos['GNOME_REPO_CHECKSUMS'] gnome_repo_checksums: str = repos['GNOME_REPO_CHECKSUMS']
gnome_repo_changelog: str = repos['GNOME_REPO_CHANGELOG'] gnome_repo_changelog: str = repos['GNOME_REPO_CHANGELOG']
msb_repo_name: str = repos['MSB_REPO_NAME']
msb_repo: bool = repos['MSB_REPO']
msb_repo_mirror: str = repos['MSB_REPO_MIRROR']
msb_repo_changelog_mirror: str = repos['MSB_REPO_CHANGELOG_MIRROR']
msb_repo_packages: str = repos['MSB_REPO_PACKAGES']
msb_repo_checksums: str = repos['MSB_REPO_CHECKSUMS']
msb_repo_changelog: str = repos['MSB_REPO_CHANGELOG']
conraid_repo_name: str = repos['CONRAID_REPO_NAME'] conraid_repo_name: str = repos['CONRAID_REPO_NAME']
conraid_repo: bool = repos['CONRAID_REPO'] conraid_repo: bool = repos['CONRAID_REPO']
conraid_repo_mirror: str = repos['CONRAID_REPO_MIRROR'] conraid_repo_mirror: str = repos['CONRAID_REPO_MIRROR']
@ -128,26 +220,50 @@ class Repositories:
slackonly_repo_checksums: str = repos['SLACKONLY_REPO_CHECKSUMS'] slackonly_repo_checksums: str = repos['SLACKONLY_REPO_CHECKSUMS']
slackonly_repo_changelog: str = repos['SLACKONLY_REPO_CHANGELOG'] slackonly_repo_changelog: str = repos['SLACKONLY_REPO_CHANGELOG']
ponce_bin_repo_name: str = repos['PONCE_BIN_REPO_NAME']
ponce_bin_repo: bool = repos['PONCE_BIN_REPO']
ponce_bin_repo_mirror: str = repos['PONCE_BIN_REPO_MIRROR']
ponce_bin_repo_packages: str = repos['PONCE_BIN_REPO_PACKAGES']
ponce_bin_repo_checksums: str = repos['PONCE_BIN_REPO_CHECKSUMS']
ponce_bin_repo_changelog: str = repos['PONCE_BIN_REPO_CHANGELOG']
salixos_repo_name: str = repos['SALIXOS_REPO_NAME']
salixos_repo: bool = repos['SALIXOS_REPO']
salixos_repo_mirror: str = repos['SALIXOS_REPO_MIRROR']
salixos_repo_packages: str = repos['SALIXOS_REPO_PACKAGES']
salixos_repo_checksums: str = repos['SALIXOS_REPO_CHECKSUMS']
salixos_repo_changelog: str = repos['SALIXOS_REPO_CHANGELOG']
salixos_extra_repo_name: str = repos['SALIXOS_EXTRA_REPO_NAME']
salixos_extra_repo: bool = repos['SALIXOS_EXTRA_REPO']
salixos_extra_repo_mirror: str = repos['SALIXOS_EXTRA_REPO_MIRROR']
salixos_extra_repo_packages_mirror: str = repos['SALIXOS_EXTRA_REPO_PACKAGES_MIRROR']
salixos_extra_repo_packages: str = repos['SALIXOS_EXTRA_REPO_PACKAGES']
salixos_extra_repo_checksums: str = repos['SALIXOS_EXTRA_REPO_CHECKSUMS']
salixos_extra_repo_changelog: str = repos['SALIXOS_EXTRA_REPO_CHANGELOG']
slackel_repo_name: str = repos['SLACKEL_REPO_NAME']
slackel_repo: bool = repos['SLACKEL_REPO']
slackel_repo_mirror: str = repos['SLACKEL_REPO_MIRROR']
slackel_repo_packages: str = repos['SLACKEL_REPO_PACKAGES']
slackel_repo_checksums: str = repos['SLACKEL_REPO_CHECKSUMS']
slackel_repo_changelog: str = repos['SLACKEL_REPO_CHANGELOG']
slint_repo_name: str = repos['SLINT_REPO_NAME']
slint_repo: bool = repos['SLINT_REPO']
slint_repo_mirror: str = repos['SLINT_REPO_MIRROR']
slint_repo_packages: str = repos['SLINT_REPO_PACKAGES']
slint_repo_checksums: str = repos['SLINT_REPO_CHECKSUMS']
slint_repo_changelog: str = repos['SLINT_REPO_CHANGELOG']
except (tomli.TOMLDecodeError, KeyError) as error: except (tomli.TOMLDecodeError, KeyError) as error:
raise SystemExit(f"\n{config.prog_name} {bred}Error{endc}: {error}: in the configuration file " raise SystemExit(f'\n{config.prog_name} {bred}Error{endc}: {error}: in the configuration file '
f"'{repositories_file_toml}'.\n" f"'{repositories_file_toml}'.\n"
f"\nIf you have upgraded the '{config.prog_name}' probably you need to run:\n" f"\nIf you have upgraded the '{config.prog_name}' probably you need to run:\n"
f"'mv {repositories_file_toml}.new {repositories_file_toml}'.\n" f"'mv {repositories_file_toml}.new {repositories_file_toml}'.\n"
f"or '{cyan}slpkg_new-configs{endc}' command.\n") f"or '{cyan}slpkg_new-configs{endc}' command.\n")
# Dictionary with the binaries repositories. # Switch to ponce repository if is true.
binaries_repositories_dict = {
alien_repo_name: alien_repo,
gnome_repo_name: gnome_repo,
conraid_repo_name: conraid_repo,
slackonly_repo_name: slackonly_repo
}
# All enabled binaries repositories.
for repo, enable in binaries_repositories_dict.items():
if enable:
bin_enabled_repositories.append(repo)
if ponce_repo: if ponce_repo:
sbo_enabled_repository: str = ponce_repo_name sbo_enabled_repository: str = ponce_repo_name
repo_tag: str = ponce_repo_tag repo_tag: str = ponce_repo_tag
@ -158,7 +274,24 @@ class Repositories:
sbo_repo_name: [sbo_enabled, sbo_repo_path, sbo_repo_changelog], sbo_repo_name: [sbo_enabled, sbo_repo_path, sbo_repo_changelog],
ponce_repo_name: [ponce_repo, ponce_repo_path, ponce_repo_changelog], ponce_repo_name: [ponce_repo, ponce_repo_path, ponce_repo_changelog],
alien_repo_name: [alien_repo, alien_repo_path, alien_repo_changelog], alien_repo_name: [alien_repo, alien_repo_path, alien_repo_changelog],
multilib_repo_name: [multilib_repo, multilib_repo_path, multilib_repo_changelog],
restricted_repo_name: [restricted_repo, restricted_repo_path, restricted_repo_changelog],
gnome_repo_name: [gnome_repo, gnome_repo_path, gnome_repo_changelog], gnome_repo_name: [gnome_repo, gnome_repo_path, gnome_repo_changelog],
msb_repo_name: [msb_repo, msb_repo_path, msb_repo_changelog],
conraid_repo_name: [conraid_repo, conraid_repo_path, conraid_repo_changelog], conraid_repo_name: [conraid_repo, conraid_repo_path, conraid_repo_changelog],
slackonly_repo_name: [slackonly_repo, slackonly_repo_path, slackonly_repo_changelog] slackonly_repo_name: [slackonly_repo, slackonly_repo_path, slackonly_repo_changelog],
ponce_bin_repo_name: [ponce_bin_repo, ponce_bin_repo_path, ponce_bin_repo_changelog],
salixos_repo_name: [salixos_repo, salixos_repo_path, salixos_repo_changelog],
salixos_extra_repo_name: [salixos_extra_repo_name, salixos_extra_repo_path, salixos_extra_repo_changelog],
slackel_repo_name: [slackel_repo, slackel_repo_path, slackel_repo_changelog],
slint_repo_name: [slint_repo, slint_repo_path, slint_repo_changelog]
} }
# All the binary repositories names.
bin_repos_names = list(repos_dict.keys())[2:]
# All the enabled binary repositories names.
for repo, enabled in repos_dict.items():
if repo not in [sbo_repo_name, ponce_repo_name]:
if enabled[0]:
bin_enabled_repos.append(repo)

View file

@ -10,15 +10,23 @@ class Requires:
def __init__(self, name: str): def __init__(self, name: str):
self.name: str = name self.name: str = name
self.repo_slackbuilds_names: list = SBoQueries(self.name).sbos()
def resolve(self) -> list: def resolve(self) -> list:
""" Resolve the dependencies. """ """ Resolve the dependencies. """
requires: list[str] = SBoQueries(self.name).requires() # type: ignore requires: list[str] = SBoQueries(self.name).requires()
for req in requires: for req in requires:
# Remove requirements that are included as dependencies,
# but are not included in the repository.
if req not in self.repo_slackbuilds_names:
requires.remove(req)
if req: if req:
sub: list[str] = SBoQueries(req).requires() # type: ignore sub_requires: list[str] = SBoQueries(req).requires()
for s in sub: for sub in sub_requires:
requires.append(s) requires.append(sub)
requires.reverse() requires.reverse()

View file

@ -29,6 +29,13 @@ class SBoQueries(Configs):
if self.repos.ponce_repo: if self.repos.ponce_repo:
self.sbo_table = PonceTable self.sbo_table = PonceTable
def count_packages(self):
""" Counts the number of the packages. """
count = self.session.query(
self.sbo_table.id).count()
return count
def repo_name(self): def repo_name(self):
""" Returns the repo name by the table. """ """ Returns the repo name by the table. """
table = inspect(self.sbo_table) table = inspect(self.sbo_table)

View file

@ -7,7 +7,6 @@ import shutil
import subprocess import subprocess
from pathlib import Path from pathlib import Path
from typing import Literal
from collections import OrderedDict from collections import OrderedDict
from multiprocessing import Process, cpu_count from multiprocessing import Process, cpu_count
@ -64,15 +63,13 @@ class Slackbuilds(Configs):
self.flag_jobs: list = ['-j', '--jobs'] self.flag_jobs: list = ['-j', '--jobs']
self.flag_no_silent: list = ['-n', '--no-silent'] self.flag_no_silent: list = ['-n', '--no-silent']
self.slackbuilds: list = self.utils.apply_package_pattern(self.flags, self.slackbuilds)
def execute(self) -> None: def execute(self) -> None:
""" Starting build or install the slackbuilds. """ """ Starting build or install the slackbuilds. """
self.creating_dictionary() self.creating_dictionary()
if not self.utils.is_option(self.flag_resolve_off, self.flags):
self.creating_dependencies_for_build() self.creating_dependencies_for_build()
self.creating_main_for_build() self.creating_main_for_build()
self.view_before_build() self.view_before_build()
start: float = time.time() start: float = time.time()
@ -85,6 +82,9 @@ class Slackbuilds(Configs):
def creating_dictionary(self) -> None: def creating_dictionary(self) -> None:
""" Dictionary with the main slackbuilds and dependencies. """ """ Dictionary with the main slackbuilds and dependencies. """
for sbo in self.slackbuilds: for sbo in self.slackbuilds:
if self.utils.is_option(self.flag_resolve_off, self.flags):
self.sbos[sbo] = []
else:
self.sbos[sbo] = Requires(sbo).resolve() self.sbos[sbo] = Requires(sbo).resolve()
def creating_dependencies_for_build(self) -> None: def creating_dependencies_for_build(self) -> None:
@ -92,15 +92,6 @@ class Slackbuilds(Configs):
for deps in self.sbos.values(): for deps in self.sbos.values():
for dep in deps: for dep in deps:
# Checks if dependency exists in the ponce repository.
# Sometimes the dependency reference is in the .info file,
# but there is not exist in the repository as a folder.
if self.repos.ponce_repo:
location: str = SBoQueries(dep).location()
path_ponce_repo_package = Path(self.repos.ponce_repo_path, location, dep)
if not path_ponce_repo_package.is_dir():
continue
# Skip installed package when the option --skip-installed is applied. # Skip installed package when the option --skip-installed is applied.
if (self.utils.is_option(self.flag_skip_installed, self.flags) and if (self.utils.is_option(self.flag_skip_installed, self.flags) and
self.utils.is_package_installed(dep)): self.utils.is_package_installed(dep)):
@ -136,12 +127,19 @@ class Slackbuilds(Configs):
self.view_message.question() self.view_message.question()
def is_not_for_skipped(self, sbo: str) -> Literal[True]: def continue_build_or_install(self, name) -> bool:
""" Condition to check if slackbuild is for skipped. """ """ Skip installed package when the option --skip-installed is applied
return (not self.utils.is_package_installed(sbo) or and continue to install if the package is upgradable or the --reinstall option
self.upgrade.is_package_upgradeable(sbo) or applied.
self.mode == 'build' or """
self.utils.is_option(self.flag_reinstall, self.flags)) if self.mode == 'build':
return True
if self.utils.is_option(self.flag_skip_installed, self.flags):
return False
if self.upgrade.is_package_upgradeable(name) or self.utils.is_option(self.flag_reinstall, self.flags):
return True
def prepare_slackbuilds_for_build(self) -> None: def prepare_slackbuilds_for_build(self) -> None:
""" Downloads files and sources. """ """ Downloads files and sources. """
@ -150,7 +148,7 @@ class Slackbuilds(Configs):
for sbo in self.install_order: for sbo in self.install_order:
if self.is_not_for_skipped(sbo): if self.continue_build_or_install(sbo):
build_path: Path = Path(self.build_path, sbo) build_path: Path = Path(self.build_path, sbo)
@ -203,12 +201,12 @@ class Slackbuilds(Configs):
""" Build the slackbuilds and install. """ """ Build the slackbuilds and install. """
for sbo in self.install_order: for sbo in self.install_order:
if self.is_not_for_skipped(sbo): if self.continue_build_or_install(sbo):
self.build_the_script(self.build_path, sbo) self.build_the_script(self.build_path, sbo)
if not self.mode == 'build': if self.mode in ['install', 'upgrade']:
pkg: str = self.creating_package_for_install(sbo) pkg: str = self.package_for_install(sbo)
self.install_package(pkg) self.install_package(pkg)
if not self.utils.is_option(self.flag_resolve_off, self.flags): if not self.utils.is_option(self.flag_resolve_off, self.flags):
@ -271,9 +269,8 @@ class Slackbuilds(Configs):
self.multi_process(command, package, message) self.multi_process(command, package, message)
def creating_package_for_install(self, name: str) -> str: def package_for_install(self, name: str) -> str:
""" Creating a list with all the finished packages for """ Returns the package for install. """
installation. """
version: str = SBoQueries(name).version() version: str = SBoQueries(name).version()
pattern: str = f'{name}-{version}*{self.repos.repo_tag}*' pattern: str = f'{name}-{version}*{self.repos.repo_tag}*'

View file

@ -28,7 +28,7 @@ class SearchPackage(Configs):
self.flag_bin_repository: list = ['-B=', '--bin-repo='] self.flag_bin_repository: list = ['-B=', '--bin-repo=']
def package(self, packages: list, repo=None) -> None: def package(self, packages: list, repo=None) -> None:
""" Searching and print the matched slackbuilds. """ """ Searching and print the matched packages. """
matching: int = 0 matching: int = 0
repository: str = '' repository: str = ''
@ -37,7 +37,8 @@ class SearchPackage(Configs):
# Searching for binaries. # Searching for binaries.
if self.utils.is_option(self.flag_bin_repository, self.flags): if self.utils.is_option(self.flag_bin_repository, self.flags):
pkg_repo: tuple = BinQueries('', repo).all_package_name_with_repo() if repo == '*':
pkg_repo: tuple = BinQueries('', repo).all_package_names_from_repositories()
for pkg in packages: for pkg in packages:
for pr in pkg_repo: for pr in pkg_repo:
@ -53,6 +54,21 @@ class SearchPackage(Configs):
print(f'{repository}{self.cyan}{pr[0]}{self.endc}-{self.yellow}{version}{self.endc}' print(f'{repository}{self.cyan}{pr[0]}{self.endc}-{self.yellow}{version}{self.endc}'
f'{self.green}{desc}{self.endc}') f'{self.green}{desc}{self.endc}')
else:
pkg_repo: list = BinQueries('', repo).all_package_names_by_repo()
for pkg in packages:
for pr in pkg_repo:
if pkg in pr or pkg == '*':
matching += 1
desc: str = BinQueries(pr, repo).description()
version: str = BinQueries(pr, repo).version()
print(f'{repository}{self.cyan}{pr}{self.endc}-{self.yellow}{version}{self.endc}'
f'{self.green}{desc}{self.endc}')
else: else:
# Searching for slackbuilds. # Searching for slackbuilds.
names: list = SBoQueries('').sbos() names: list = SBoQueries('').sbos()

View file

@ -33,20 +33,23 @@ class Tracking(Configs):
def packages(self, packages: list, repo: str) -> None: def packages(self, packages: list, repo: str) -> None:
""" Prints the packages dependencies. """ """ Prints the packages dependencies. """
print(f"The list below shows the packages with dependencies:\n") print(f"The list below shows the packages '{', '.join([p for p in packages])}' with dependencies:\n")
packages: list = self.utils.apply_package_pattern(self.flags, packages, repo)
char: str = f' {self.llc}{self.hl}' char: str = f' {self.llc}{self.hl}'
sp: str = ' ' * 4 sp: str = ' ' * 4
for package in packages: for package in packages:
pkg = f'{self.yellow}{package}{self.endc}' pkg = f'{self.yellow}{package}{self.endc}'
if self.utils.is_option(self.flag_pkg_version, self.flags): if self.utils.is_option(self.flag_pkg_version, self.flags):
version: str = SBoQueries(package).version()
version: str = SBoQueries(package).version()
if self.utils.is_option(self.flag_bin_repository, self.flags): if self.utils.is_option(self.flag_bin_repository, self.flags):
version: str = BinQueries(package, repo).version() version: str = BinQueries(package, repo).version()
pkg = f'{self.yellow}{package}-{version}{self.endc}' pkg = f'{self.yellow}{package} {version}{self.endc}'
if self.utils.is_option(self.flag_bin_repository, self.flags): if self.utils.is_option(self.flag_bin_repository, self.flags):
requires: list = Required(package, repo).resolve() requires: list = Required(package, repo).resolve()
@ -55,24 +58,25 @@ class Tracking(Configs):
how_many: int = len(requires) how_many: int = len(requires)
if not requires:
requires: list = ['No dependencies']
print(pkg) print(pkg)
print(char, end='') print(char, end='')
if not requires:
print(f' {self.cyan}No dependencies{self.endc}')
else:
for i, req in enumerate(requires, start=1): for i, req in enumerate(requires, start=1):
require: str = f'{self.cyan}{req}{self.endc}' require: str = f'{self.cyan}{req}{self.endc}'
if self.utils.is_option(self.flag_pkg_version, self.flags): if self.utils.is_option(self.flag_pkg_version, self.flags):
version: str = f"-{self.yellow}{SBoQueries(req).version()}{self.endc}"
version: str = f" {self.yellow}{SBoQueries(req).version()}{self.endc}"
if self.utils.is_option(self.flag_bin_repository, self.flags): if self.utils.is_option(self.flag_bin_repository, self.flags):
version: str = f"-{self.yellow}{BinQueries(req, repo).version()}{self.endc}" version: str = f" {self.yellow}{BinQueries(req, repo).version()}{self.endc}"
require: str = f'{self.cyan}{req}{self.endc}{version}' require: str = f'{self.cyan}{req}{self.endc}{version}'
if i == 1: if i == 1:
print(f' {self.cyan}{requires[0]}{self.endc}') print(f' {require}')
else: else:
print(f'{sp}{require}') print(f'{sp}{require}')

View file

@ -15,7 +15,8 @@ from slpkg.repositories import Repositories
from slpkg.check_updates import CheckUpdates from slpkg.check_updates import CheckUpdates
from slpkg.models.models import session as Session from slpkg.models.models import session as Session
from slpkg.models.models import (Base, engine, SBoTable, from slpkg.models.models import (Base, engine, SBoTable,
PonceTable, BinariesTable) PonceTable, BinariesTable,
LastRepoUpdated)
class UpdateRepository(Configs): class UpdateRepository(Configs):
@ -56,14 +57,39 @@ class UpdateRepository(Configs):
if self.repo == self.repos.alien_repo_name or self.repo == '*': if self.repo == self.repos.alien_repo_name or self.repo == '*':
self.alien_repository() self.alien_repository()
if self.repo == self.repos.multilib_repo_name or self.repo == '*':
self.multilib_repository()
if self.repo == self.repos.restricted_repo_name or self.repo == '*':
self.restricted_repository()
if self.repo == self.repos.gnome_repo_name or self.repo == '*': if self.repo == self.repos.gnome_repo_name or self.repo == '*':
self.gnome_repository() self.gnome_repository()
if self.repo == self.repos.msb_repo_name or self.repo == '*':
self.msb_repository()
if self.repo == self.repos.conraid_repo_name or self.repo == '*': if self.repo == self.repos.conraid_repo_name or self.repo == '*':
self.conraid_repository() self.conraid_repository()
if self.repo == self.repos.slackonly_repo_name or self.repo == '*': if self.repo == self.repos.slackonly_repo_name or self.repo == '*':
self.slackonly_repository() self.slackonly_repository()
if self.repo == self.repos.ponce_bin_repo_name or self.repo == '*':
self.ponce_bin_repository()
if self.repo == self.repos.salixos_repo_name or self.repo == '*':
self.salixos_repository()
if self.repo == self.repos.salixos_extra_repo_name or self.repo == '*':
self.salixos_extra_repository()
if self.repo == self.repos.slackel_repo_name or self.repo == '*':
self.slackel_repository()
if self.repo == self.repos.slint_repo_name or self.repo == '*':
self.slint_repository()
else: else:
self.slackbuild_repositories() self.slackbuild_repositories()
@ -87,11 +113,66 @@ class UpdateRepository(Configs):
print() print()
self.delete_binaries_data(self.repos.alien_repo_name) self.delete_binaries_data(self.repos.alien_repo_name)
self.delete_last_updated(self.repos.alien_repo_name)
self.data.install_alien_data() self.data.install_alien_data()
print() print()
else: else:
self.not_enabled_message(self.repos.alien_repo_name) self.not_enabled_message(self.repos.alien_repo_name)
def multilib_repository(self):
if self.repos.multilib_repo:
urls: list = []
print('Updating the packages list...\n')
print(f"Downloading the '{self.green}{self.repos.multilib_repo_name}{self.endc}' "
f"repository, please wait...\n")
self.make_dirs(self.repos.multilib_repo_name)
urls.append(f'{self.repos.multilib_repo_mirror}{self.repos.multilib_repo_packages}')
urls.append(f'{self.repos.multilib_repo_changelog_mirror}{self.repos.multilib_repo_changelog}')
urls.append(f'{self.repos.multilib_repo_mirror}{self.repos.multilib_repo_checksums}')
self.utils.remove_file_if_exists(self.repos.multilib_repo_path, self.repos.multilib_repo_packages)
self.utils.remove_file_if_exists(self.repos.multilib_repo_path, self.repos.multilib_repo_changelog)
self.utils.remove_file_if_exists(self.repos.multilib_repo_path, self.repos.multilib_repo_checksums)
down = Downloader(self.repos.multilib_repo_path, urls, self.flags)
down.download()
print()
self.delete_binaries_data(self.repos.multilib_repo_name)
self.delete_last_updated(self.repos.multilib_repo_name)
self.data.install_multilib_data()
print()
else:
self.not_enabled_message(self.repos.multilib_repo_name)
def restricted_repository(self):
if self.repos.restricted_repo:
urls: list = []
print('Updating the packages list...\n')
print(f"Downloading the '{self.green}{self.repos.restricted_repo_name}{self.endc}' "
f"repository, please wait...\n")
self.make_dirs(self.repos.restricted_repo_name)
urls.append(f'{self.repos.restricted_repo_mirror}{self.repos.restricted_repo_packages}')
urls.append(f'{self.repos.restricted_repo_changelog_mirror}{self.repos.restricted_repo_changelog}')
urls.append(f'{self.repos.restricted_repo_mirror}{self.repos.restricted_repo_checksums}')
self.utils.remove_file_if_exists(self.repos.restricted_repo_path, self.repos.restricted_repo_packages)
self.utils.remove_file_if_exists(self.repos.restricted_repo_path, self.repos.restricted_repo_changelog)
self.utils.remove_file_if_exists(self.repos.restricted_repo_path, self.repos.restricted_repo_checksums)
down = Downloader(self.repos.restricted_repo_path, urls, self.flags)
down.download()
print()
self.delete_binaries_data(self.repos.restricted_repo_name)
self.delete_last_updated(self.repos.restricted_repo_name)
self.data.install_restricted_data()
print()
else:
self.not_enabled_message(self.repos.restricted_repo_name)
def gnome_repository(self): def gnome_repository(self):
if self.repos.gnome_repo: if self.repos.gnome_repo:
urls: list = [] urls: list = []
@ -112,11 +193,42 @@ class UpdateRepository(Configs):
print() print()
self.delete_binaries_data(self.repos.gnome_repo_name) self.delete_binaries_data(self.repos.gnome_repo_name)
self.delete_last_updated(self.repos.gnome_repo_name)
self.data.install_gnome_data() self.data.install_gnome_data()
print() print()
else: else:
self.not_enabled_message(self.repos.gnome_repo_name) self.not_enabled_message(self.repos.gnome_repo_name)
def msb_repository(self):
if self.repos.msb_repo:
urls: list = []
print('Updating the packages list...\n')
print(f"Downloading the '{self.green}{self.repos.msb_repo_name}{self.endc}' "
f"repository, please wait...\n")
self.make_dirs(self.repos.msb_repo_name)
urls.append(f'{self.repos.msb_repo_mirror}{self.repos.msb_repo_packages}')
urls.append(f'{self.repos.msb_repo_changelog_mirror}{self.repos.msb_repo_changelog}')
urls.append(f'{self.repos.msb_repo_mirror}{self.repos.msb_repo_checksums}')
self.utils.remove_file_if_exists(self.repos.msb_repo_path,
self.repos.msb_repo_packages)
self.utils.remove_file_if_exists(self.repos.msb_repo_path,
self.repos.msb_repo_changelog)
self.utils.remove_file_if_exists(self.repos.msb_repo_path,
self.repos.msb_repo_checksums)
down = Downloader(self.repos.msb_repo_path, urls, self.flags)
down.download()
print()
self.delete_binaries_data(self.repos.msb_repo_name)
self.delete_last_updated(self.repos.msb_repo_name)
self.data.install_msb_data()
print()
else:
self.not_enabled_message(self.repos.msb_repo_name)
def conraid_repository(self): def conraid_repository(self):
if self.repos.conraid_repo: if self.repos.conraid_repo:
urls: list = [] urls: list = []
@ -138,6 +250,7 @@ class UpdateRepository(Configs):
print() print()
self.delete_binaries_data(self.repos.conraid_repo_name) self.delete_binaries_data(self.repos.conraid_repo_name)
self.delete_last_updated(self.repos.conraid_repo_name)
self.data.install_conraid_data() self.data.install_conraid_data()
print() print()
else: else:
@ -164,11 +277,150 @@ class UpdateRepository(Configs):
print() print()
self.delete_binaries_data(self.repos.slackonly_repo_name) self.delete_binaries_data(self.repos.slackonly_repo_name)
self.delete_last_updated(self.repos.slackonly_repo_name)
self.data.install_slackonly_data() self.data.install_slackonly_data()
print() print()
else: else:
self.not_enabled_message(self.repos.slackonly_repo_name) self.not_enabled_message(self.repos.slackonly_repo_name)
def ponce_bin_repository(self):
if self.repos.ponce_bin_repo:
urls: list = []
print('Updating the packages list...\n')
print(f"Downloading the '{self.green}{self.repos.ponce_bin_repo_name}{self.endc}' "
f"repository, please wait...\n")
self.make_dirs(self.repos.ponce_bin_repo_name)
urls.append(f'{self.repos.ponce_bin_repo_mirror}{self.repos.ponce_bin_repo_packages}')
urls.append(f'{self.repos.ponce_bin_repo_mirror}{self.repos.ponce_bin_repo_changelog}')
urls.append(f'{self.repos.ponce_bin_repo_mirror}{self.repos.ponce_bin_repo_checksums}')
self.utils.remove_file_if_exists(self.repos.ponce_bin_repo_path, self.repos.ponce_bin_repo_packages)
self.utils.remove_file_if_exists(self.repos.ponce_bin_repo_path, self.repos.ponce_bin_repo_changelog)
self.utils.remove_file_if_exists(self.repos.ponce_bin_repo_path, self.repos.ponce_bin_repo_checksums)
down = Downloader(self.repos.ponce_bin_repo_path, urls, self.flags)
down.download()
print()
self.delete_binaries_data(self.repos.ponce_bin_repo_name)
self.delete_last_updated(self.repos.ponce_bin_repo_name)
self.data.install_ponce_bin_data()
print()
else:
self.not_enabled_message(self.repos.ponce_bin_repo_name)
def salixos_repository(self):
if self.repos.salixos_repo:
urls: list = []
print('Updating the packages list...\n')
print(f"Downloading the '{self.green}{self.repos.salixos_repo_name}{self.endc}' "
f"repository, please wait...\n")
self.make_dirs(self.repos.salixos_repo_name)
urls.append(f'{self.repos.salixos_repo_mirror}{self.repos.salixos_repo_packages}')
urls.append(f'{self.repos.salixos_repo_mirror}{self.repos.salixos_repo_changelog}')
urls.append(f'{self.repos.salixos_repo_mirror}{self.repos.salixos_repo_checksums}')
self.utils.remove_file_if_exists(self.repos.salixos_repo_path, self.repos.salixos_repo_packages)
self.utils.remove_file_if_exists(self.repos.salixos_repo_path, self.repos.salixos_repo_changelog)
self.utils.remove_file_if_exists(self.repos.salixos_repo_path, self.repos.salixos_repo_checksums)
down = Downloader(self.repos.salixos_repo_path, urls, self.flags)
down.download()
print()
self.delete_binaries_data(self.repos.salixos_repo_name)
self.delete_last_updated(self.repos.salixos_repo_name)
self.data.install_salixos_data()
print()
else:
self.not_enabled_message(self.repos.salixos_repo_name)
def salixos_extra_repository(self):
if self.repos.salixos_extra_repo:
urls: list = []
print('Updating the packages list...\n')
print(f"Downloading the '{self.green}{self.repos.salixos_extra_repo_name}{self.endc}' "
f"repository, please wait...\n")
self.make_dirs(self.repos.salixos_extra_repo_name)
urls.append(f'{self.repos.salixos_extra_repo_packages_mirror}{self.repos.salixos_extra_repo_packages}')
urls.append(f'{self.repos.salixos_extra_repo_mirror}{self.repos.salixos_extra_repo_changelog}')
urls.append(f'{self.repos.salixos_extra_repo_mirror}{self.repos.salixos_extra_repo_checksums}')
self.utils.remove_file_if_exists(self.repos.salixos_extra_repo_path,
self.repos.salixos_extra_repo_packages)
self.utils.remove_file_if_exists(self.repos.salixos_extra_repo_path,
self.repos.salixos_extra_repo_changelog)
self.utils.remove_file_if_exists(self.repos.salixos_extra_repo_path,
self.repos.salixos_extra_repo_checksums)
down = Downloader(self.repos.salixos_extra_repo_path, urls, self.flags)
down.download()
print()
self.delete_binaries_data(self.repos.salixos_extra_repo_name)
self.delete_last_updated(self.repos.salixos_extra_repo_name)
self.data.install_salixos_extra_data()
print()
else:
self.not_enabled_message(self.repos.salixos_extra_repo_name)
def slackel_repository(self):
if self.repos.slackel_repo:
urls: list = []
print('Updating the packages list...\n')
print(f"Downloading the '{self.green}{self.repos.slackel_repo_name}{self.endc}' "
f"repository, please wait...\n")
self.make_dirs(self.repos.slackel_repo_name)
urls.append(f'{self.repos.slackel_repo_mirror}{self.repos.slackel_repo_packages}')
urls.append(f'{self.repos.slackel_repo_mirror}{self.repos.slackel_repo_changelog}')
urls.append(f'{self.repos.slackel_repo_mirror}{self.repos.slackel_repo_checksums}')
self.utils.remove_file_if_exists(self.repos.slackel_repo_path, self.repos.slackel_repo_packages)
self.utils.remove_file_if_exists(self.repos.slackel_repo_path, self.repos.slackel_repo_changelog)
self.utils.remove_file_if_exists(self.repos.slackel_repo_path, self.repos.slackel_repo_checksums)
down = Downloader(self.repos.slackel_repo_path, urls, self.flags)
down.download()
print()
self.delete_binaries_data(self.repos.slackel_repo_name)
self.delete_last_updated(self.repos.slackel_repo_name)
self.data.install_slackel_data()
print()
else:
self.not_enabled_message(self.repos.slackel_repo_name)
def slint_repository(self):
if self.repos.slint_repo:
urls: list = []
print('Updating the packages list...\n')
print(f"Downloading the '{self.green}{self.repos.slint_repo_name}{self.endc}' "
f"repository, please wait...\n")
self.make_dirs(self.repos.slint_repo_name)
urls.append(f'{self.repos.slint_repo_mirror}{self.repos.slint_repo_packages}')
urls.append(f'{self.repos.slint_repo_mirror}{self.repos.slint_repo_changelog}')
urls.append(f'{self.repos.slint_repo_mirror}{self.repos.slint_repo_checksums}')
self.utils.remove_file_if_exists(self.repos.slint_repo_path, self.repos.slint_repo_packages)
self.utils.remove_file_if_exists(self.repos.slint_repo_path, self.repos.slint_repo_changelog)
self.utils.remove_file_if_exists(self.repos.slint_repo_path, self.repos.slint_repo_checksums)
down = Downloader(self.repos.slint_repo_path, urls, self.flags)
down.download()
print()
self.delete_binaries_data(self.repos.slint_repo_name)
self.delete_last_updated(self.repos.slint_repo_name)
self.data.install_slint_data()
print()
else:
self.not_enabled_message(self.repos.slint_repo_name)
def slackbuild_repositories(self): def slackbuild_repositories(self):
""" Update the slackbuild repositories. """ """ Update the slackbuild repositories. """
if self.repos.ponce_repo: if self.repos.ponce_repo:
@ -192,6 +444,7 @@ class UpdateRepository(Configs):
os.chdir(self.repos.ponce_repo_path) os.chdir(self.repos.ponce_repo_path)
gen_command: str = f'./gen_sbo_txt.sh > {self.repos.ponce_repo_slackbuilds}' gen_command: str = f'./gen_sbo_txt.sh > {self.repos.ponce_repo_slackbuilds}'
self.utils.process(gen_command) self.utils.process(gen_command)
self.delete_last_updated(self.repos.ponce_repo_name)
print('\n') print('\n')
else: else:
@ -205,6 +458,7 @@ class UpdateRepository(Configs):
lftp_command: str = (f'lftp {self.lftp_mirror_options} {self.repos.sbo_repo_mirror} ' lftp_command: str = (f'lftp {self.lftp_mirror_options} {self.repos.sbo_repo_mirror} '
f'{self.repos.sbo_repo_path}') f'{self.repos.sbo_repo_path}')
self.utils.process(lftp_command) self.utils.process(lftp_command)
self.delete_last_updated(self.repos.sbo_repo_name)
self.delete_sbo_data() self.delete_sbo_data()
self.data.install_sbos_data() self.data.install_sbos_data()
@ -277,6 +531,11 @@ class UpdateRepository(Configs):
self.session.query(BinariesTable).where(BinariesTable.repo == repo).delete() self.session.query(BinariesTable).where(BinariesTable.repo == repo).delete()
self.session.commit() self.session.commit()
def delete_last_updated(self, repo) -> None:
""" Deletes the last updated date. """
self.session.query(LastRepoUpdated).where(LastRepoUpdated.repo == repo).delete()
self.session.commit()
def drop_the_tables(self): def drop_the_tables(self):
""" Drop all the tables from the database. """ """ Drop all the tables from the database. """
print(f'\n{self.prog_name}: {self.bred}WARNING{self.endc}: All the data from the database will be deleted!') print(f'\n{self.prog_name}: {self.bred}WARNING{self.endc}: All the data from the database will be deleted!')
@ -285,7 +544,8 @@ class UpdateRepository(Configs):
tables: list = [ tables: list = [
PonceTable.__table__, PonceTable.__table__,
SBoTable.__table__, SBoTable.__table__,
BinariesTable.__table__ BinariesTable.__table__,
LastRepoUpdated.__table__
] ]
Base.metadata.drop_all(bind=engine, tables=tables) Base.metadata.drop_all(bind=engine, tables=tables)

View file

@ -25,7 +25,7 @@ class Upgrade(Configs):
def packages(self) -> Generator[str, None, None]: def packages(self) -> Generator[str, None, None]:
""" Compares version of packages and returns the maximum. """ """ Compares version of packages and returns the maximum. """
if self.utils.is_option(self.flag_bin_repository, self.flags): if self.utils.is_option(self.flag_bin_repository, self.flags):
repo_packages: list = BinQueries('', self.repo).all_package_names() repo_packages: list = BinQueries('', self.repo).all_package_names_by_repo()
else: else:
repo_packages: list = SBoQueries('').sbos() repo_packages: list = SBoQueries('').sbos()
@ -37,18 +37,20 @@ class Upgrade(Configs):
if self.is_package_upgradeable(inst_package): if self.is_package_upgradeable(inst_package):
yield inst_package yield inst_package
def is_package_upgradeable(self, package: str) -> bool: def is_package_upgradeable(self, name: str) -> bool:
""" Checks for installed and upgradeable packages. """ """ Checks for installed and upgradeable packages. """
inst_package: str = self.utils.is_package_installed(package) inst_package: str = self.utils.is_package_installed(name)
if inst_package:
inst_version: str = self.utils.split_binary_pkg(inst_package)[1] inst_version: str = self.utils.split_binary_pkg(inst_package)[1]
inst_build: str = self.utils.split_binary_pkg(inst_package)[3] inst_build: str = self.utils.split_binary_pkg(inst_package)[3]
if self.utils.is_option(self.flag_bin_repository, self.flags): if self.utils.is_option(self.flag_bin_repository, self.flags):
repo_package: str = BinQueries(package, self.repo).package_bin() repo_package: str = BinQueries(name, self.repo).package_bin()
return parse(repo_package[:-4]) > parse(inst_package) repo_version: str = BinQueries(name, self.repo).version()
repo_build: str = self.utils.split_binary_pkg(repo_package)[3]
else: else:
repo_version: str = SBoQueries(package).version() repo_version: str = SBoQueries(name).version()
repo_build: str = self.utils.read_sbo_build_tag(package) repo_build: str = self.utils.read_sbo_build_tag(name)
return parse(repo_version + repo_build) > parse(inst_version + inst_build) return parse(repo_version + repo_build) > parse(inst_version + inst_build)

View file

@ -6,12 +6,13 @@ import time
import shutil import shutil
import subprocess import subprocess
from pathlib import Path from pathlib import Path
from typing import Generator, Any, Union from typing import Generator, Union
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.blacklist import Blacklist from slpkg.blacklist import Blacklist
from slpkg.sbos.queries import SBoQueries from slpkg.sbos.queries import SBoQueries
from slpkg.repositories import Repositories from slpkg.repositories import Repositories
from slpkg.binaries.queries import BinQueries
class Utilities: class Utilities:
@ -29,6 +30,7 @@ class Utilities:
self.red: str = self.color['red'] self.red: str = self.color['red']
self.endc: str = self.color['endc'] self.endc: str = self.color['endc']
self.bred: str = f'{self.bold}{self.red}' self.bred: str = f'{self.bold}{self.red}'
self.flag_bin_repository: list = ['-B=', '--bin-repo=']
self.installed_packages: list = list(self.all_installed()) self.installed_packages: list = list(self.all_installed())
self.installed_package_names: list = list(self.all_installed_names()) self.installed_package_names: list = list(self.all_installed_names())
@ -122,9 +124,11 @@ class Utilities:
return ''.join(re.findall(r'\d+', line)) return ''.join(re.findall(r'\d+', line))
@staticmethod @staticmethod
def is_option(flag: list, flags: list) -> Any: def is_option(flag: list, flags: list) -> bool:
""" Checking for flags. """ """ Checking for flags. """
return [f for f in flag if f in flags] for f in flag:
if f in flags:
return True
def read_packages_from_file(self, file: Path) -> Generator: def read_packages_from_file(self, file: Path) -> Generator:
""" Reads packages from file and split these to list. """ """ Reads packages from file and split these to list. """
@ -140,13 +144,13 @@ class Utilities:
yield package yield package
except FileNotFoundError as err: except FileNotFoundError:
self.raise_error_message(str(err)) self.raise_error_message(f"No such file or directory: '{file}'")
@staticmethod @staticmethod
def read_file(file: Union[str, Path]) -> list: def read_file(file: Union[str, Path]) -> list:
""" Reads the text file. """ """ Reads the text file. """
with open(file, 'r', encoding='utf-8') as f: with open(file, 'r', encoding='utf-8', errors='replace') as f:
return f.readlines() return f.readlines()
@staticmethod @staticmethod
@ -178,3 +182,16 @@ class Utilities:
unit: str = 'GB' unit: str = 'GB'
return f'{str(round(file_size, 2))} {unit}' return f'{str(round(file_size, 2))} {unit}'
def apply_package_pattern(self, flags: list, packages: list, repo=None) -> list:
""" Apply the pattern. """
for pkg in packages:
if pkg == '*':
packages.remove(pkg)
if self.is_option(self.flag_bin_repository, flags):
packages += BinQueries('', repo).all_package_names_by_repo()
else:
packages += SBoQueries('').sbos()
return packages

View file

@ -51,7 +51,7 @@ class Ascii(Configs):
def draw_package_title_box(self, message: str, title: str) -> None: def draw_package_title_box(self, message: str, title: str) -> None:
""" Drawing package title box. """ """ Drawing package title box. """
middle_title: int = int((self.columns / 2) - len(title) + 6) middle_title: int = int((self.columns / 2) - len(title) + 10)
print(f'{self.bgreen}{self.upper_left_corner}' + f'{self.horizontal_line}' * (self.columns - 2) + print(f'{self.bgreen}{self.upper_left_corner}' + f'{self.horizontal_line}' * (self.columns - 2) +
f'{self.upper_right_corner}') f'{self.upper_right_corner}')

View file

@ -70,7 +70,7 @@ class Usage(Configs):
f' {self.cyan}-f, find{self.endc} [packages...] Find 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}-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}-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}-e, dependees{self.endc} [packages...] Show which packages depend on.\n'
f' {self.cyan}-t, tracking{self.endc} [packages...] Tracking the packages dependencies.\n' f' {self.cyan}-t, tracking{self.endc} [packages...] Tracking the packages dependencies.\n'
f'\n{self.bold}OPTIONS:{self.endc}\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}-y, --yes{self.endc} Answer Yes to all questions.\n'

View file

@ -25,7 +25,9 @@ class Help(Configs):
help_commands: dict = { help_commands: dict = {
'update': "Updates the package list and the database.", 'update': "Updates the package list and the database.",
'upgrade': "Upgrade all the installed packages if the newer version exists in the repository.", '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.", 'check-updates': "Check if there is any news on the repositories ChangeLog.txt file.",
'repo-info': "View information related to repositories, such as which repositories are active, "
"when they were upgraded, and how many packages they contain.",
'configs': "Edit the configuration '/etc/slpkg/slpkg.toml' file.", 'configs': "Edit the configuration '/etc/slpkg/slpkg.toml' file.",
'clean-logs': "Cleans dependencies log tracking. After that procedure you should remove dependencies " 'clean-logs': "Cleans dependencies log tracking. After that procedure you should remove dependencies "
"by hand.", "by hand.",
@ -42,13 +44,14 @@ class Help(Configs):
'find': "Find your installed packages on your system.", 'find': "Find your installed packages on your system.",
'view': "View information packages from the repository and get everything in your terminal.", 'view': "View information packages from the repository and get everything in your terminal.",
'search': "Search and match packages from the repository.", 'search': "Search and match packages from the repository.",
'dependees': "Show which SlackBuilds depend on.", 'dependees': "Show which packages depend on.",
'tracking': "Tracking the packages dependencies." 'tracking': "Tracking the packages dependencies."
} }
help_commands['-u'] = help_commands['update'] help_commands['-u'] = help_commands['update']
help_commands['-U'] = help_commands['upgrade'] help_commands['-U'] = help_commands['upgrade']
help_commands['-c'] = help_commands['check-updates'] help_commands['-c'] = help_commands['check-updates']
help_commands['-I'] = help_commands['repo-info']
help_commands['-g'] = help_commands['configs'] help_commands['-g'] = help_commands['configs']
help_commands['-L'] = help_commands['clean-logs'] help_commands['-L'] = help_commands['clean-logs']
help_commands['-D'] = help_commands['clean-tmp'] help_commands['-D'] = help_commands['clean-tmp']

View file

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

View file

@ -44,6 +44,8 @@ class ViewPackage(Configs):
red: str = color['red'] red: str = color['red']
endc: str = color['endc'] endc: str = color['endc']
packages: list = self.utils.apply_package_pattern(self.flags, packages)
for package in packages: for package in packages:
info: list = self.session.query( info: list = self.session.query(

View file

@ -207,7 +207,10 @@ class ViewMessage(Configs):
for pkg in packages: for pkg in packages:
upgradeable: bool = False
if option != 'remove':
upgradeable: bool = self.upgrade.is_package_upgradeable(pkg) upgradeable: bool = self.upgrade.is_package_upgradeable(pkg)
installed: str = self.utils.is_package_installed(pkg) installed: str = self.utils.is_package_installed(pkg)
if not installed: if not installed: