Added option to install

This commit is contained in:
Dimitris Zlatanidis 2023-01-23 22:46:53 +02:00
parent 8be6761d1b
commit 1ea4217db9
3 changed files with 24 additions and 14 deletions

View file

@ -157,7 +157,9 @@ Print the repository package version. (to be used with: -e, dependees, -t, track
--file-pattern=PATTERN
.RS
Search for specific installed files with a pattern, such as: slpkg -f 'python' --file-pattern='*',
prints all installed packages that include the name 'python', not only the SBo packages. (to be used with: -f, find)
prints all installed packages that include the name 'python', not only the SBo packages.
Also when you want to see packages that you have installed from other repositories, like:
slpkg -i podman --file-pattern='*alien'. (to be used with: -i, install, -f, find)
.RE
.P
-h | --help

View file

@ -130,7 +130,8 @@ class Argparse(Configs):
self.flag_reinstall,
self.flag_skip_installed,
self.flag_search,
self.flag_no_silent
self.flag_no_silent,
self.flag_pattern
],
'download': [
self.flag_yes,
@ -346,7 +347,10 @@ class Argparse(Configs):
self.check.exists(packages)
self.check.unsupported(packages)
install = Slackbuilds(packages, self.flags, mode=command)
if not self.file_pattern:
self.file_pattern = f'*{self.sbo_repo_tag}'
install = Slackbuilds(packages, self.flags, self.file_pattern, mode=command)
install.execute()
raise SystemExit()
self.usage.help(1)

View file

@ -25,10 +25,11 @@ from slpkg.models.models import session as Session
class Slackbuilds(Configs):
""" Download build and install the SlackBuilds. """
def __init__(self, slackbuilds: list, flags: list, mode: str):
def __init__(self, slackbuilds: list, flags: list, file_pattern, mode: str):
super(Configs, self).__init__()
self.slackbuilds = slackbuilds
self.flags = flags
self.file_pattern = file_pattern
self.mode = mode
self.install_order = []
self.dependencies = []
@ -81,14 +82,14 @@ class Slackbuilds(Configs):
def creating_dependencies_for_build(self):
""" List with the dependencies. """
pattern = f'*{self.sbo_repo_tag}'
# pattern = f'*{self.sbo_repo_tag}'
for deps in self.sbos.values():
for dep in deps:
# Checks if the package was installed and skipped.
if (self.flag_skip_installed in self.flags and
self.utils.is_installed(dep, pattern)):
self.utils.is_installed(dep, self.file_pattern)):
continue
self.dependencies.append(dep)
@ -123,8 +124,9 @@ class Slackbuilds(Configs):
def is_for_skipped(self, sbo):
""" Condition to check if slackbuild is for skipped. """
pattern = f'*{self.sbo_repo_tag}'
return (not self.utils.is_installed(sbo, pattern) or self.utils.is_repo_version_bigger(sbo) or
# pattern = f'*{self.sbo_repo_tag}'
return (not self.utils.is_installed(sbo, self.file_pattern) or self.utils.is_repo_version_bigger(sbo) or
self.mode == 'build' or self.flag_reinstall in self.flags)
def download_slackbuilds(self):
@ -153,7 +155,7 @@ class Slackbuilds(Configs):
def build_and_install(self):
""" Build the slackbuilds and install. """
pattern = f'*{self.sbo_repo_tag}'
# pattern = f'*{self.sbo_repo_tag}'
for sbo in self.install_order:
@ -169,7 +171,7 @@ class Slackbuilds(Configs):
if self.flag_resolve_off not in self.flags:
self.logging_installed_dependencies(sbo)
else:
package = self.utils.is_installed(sbo, pattern)
package = self.utils.is_installed(sbo, self.file_pattern)
version = self.utils.split_installed_pkg(package)[1]
self.view_message.view_skipping_packages(sbo, version)
@ -208,12 +210,13 @@ class Slackbuilds(Configs):
def install_package(self, package: str):
""" Install the packages that before created in the tmp directory. """
pattern = f'*{self.sbo_repo_tag}'
# pattern = f'*{self.sbo_repo_tag}'
pkg = self.utils.split_installed_pkg(package)[0]
execute = self.installpkg
if (self.flag_reinstall in self.flags and
self.utils.is_installed(pkg, pattern)):
self.utils.is_installed(pkg, self.file_pattern)):
execute = self.reinstall
message = f'{self.cyan}Installing{self.endc}'
@ -334,9 +337,10 @@ class Slackbuilds(Configs):
for package in dependencies:
status = True
pattern = f'*{self.sbo_repo_tag}'
# pattern = f'*{self.sbo_repo_tag}'
repo_ver = SBoQueries(package).version()
installed = self.utils.is_installed(package, pattern)
installed = self.utils.is_installed(package, self.file_pattern)
if installed:
status = False