Added new option

This commit is contained in:
Dimitris Zlatanidis 2023-01-23 21:16:07 +02:00
parent 29f26b5ba8
commit 0f49359c4f
8 changed files with 50 additions and 26 deletions

View file

@ -6,7 +6,7 @@
.P
slpkg [-h|-v] [update] [upgrade] [check-updates] [configs] [clean-logs] [clean-tmp] [-b, build] [-i, install] [-d, download]
[-r, remove] [-f, find] [-w, view] [-s, search] [-e, dependees] [-t, tracking] --yes, --jobs, --resolve-off,
--reinstall, --skip-installed, --full-reverse, --search, --no-silent, --directory=PATH, --pkg-version
--reinstall, --skip-installed, --full-reverse, --search, --no-silent, --directory=PATH, --pkg-version, --file-pattern=
.SH DESCRIPTION
.P
Slpkg is a software package manager that installs, updates, and removes packages on Slackware based systems.
@ -154,6 +154,12 @@ The directory is the path where the files will be saved. (to be used with: -d, d
Print the repository package version. (to be used with: -e, dependees, -t, tracking)
.RE
.P
--file-pattern=PATTERN
.RS
Search for specific files with a pattern, such as: slpkg -f '' --file-pattern='*',
prints all installed packages, not only the SBo packages. (to be used with: -f, find)
.RE
.P
-h | --help
.RS
Show help information and exit.

View file

@ -19,10 +19,12 @@ class FindInstalled(Configs, Utilities):
self.endc = self.color['endc']
self.grey = self.color['grey']
def find(self, packages: list):
def find(self, packages: list, pattern):
""" Find the packages. """
matching = []
installed = self.all_installed()
if not pattern:
pattern = f'*{self.sbo_repo_tag}'
installed = self.all_installed(pattern)
print(f'The list below shows the installed packages '
f'that contains \'{", ".join([p for p in packages])}\' files:\n')
@ -37,9 +39,10 @@ class FindInstalled(Configs, Utilities):
""" Print the matched packages. """
if matching:
for package in matching:
pkg = self.split_installed_pkg(package)
print(f'{self.cyan}{pkg[0]}{self.endc}-{self.yellow}{pkg[1]}{self.endc}-{pkg[2]}-'
f'{self.blue}{pkg[3]}{self.endc}_{pkg[4]}')
# pkg = self.split_installed_pkg(package)
print(f'{self.cyan}{package}{self.endc}')
# print(f'{self.cyan}{pkg[0]}{self.endc}-{self.yellow}{pkg[1]}{self.endc}-{pkg[2]}-'
# f'{self.blue}{pkg[3]}{self.endc}_{pkg[4]}')
print(f'\n{self.grey}Total found {len(matching)} packages.{self.endc}')
else:
print('\nDoes not match any package.\n')

View file

@ -32,6 +32,7 @@ class Argparse(Configs):
self.args = args
self.flags = []
self.directory = None
self.pattern = None
self.dialogbox = DialogBox()
self.utils = Utilities()
self.usage = Usage()
@ -53,6 +54,7 @@ class Argparse(Configs):
self.flag_no_silent = '--no-silent'
self.flag_directory = '--directory='
self.flag_pkg_version = '--pkg-version'
self.flag_pattern = '--file-pattern='
self.is_dialog_enabled()
@ -65,7 +67,8 @@ class Argparse(Configs):
self.flag_search,
self.flag_no_silent,
self.flag_directory,
self.flag_pkg_version]
self.flag_pkg_version,
self.flag_pattern]
self.remove_flags()
@ -76,6 +79,10 @@ class Argparse(Configs):
self.directory = arg.split('=')[1]
self.args[self.args.index(arg)] = self.flag_directory
if arg.startswith(self.flag_pattern):
self.pattern = arg.split('=')[1]
self.args[self.args.index(arg)] = self.flag_pattern
for opt in self.options:
if opt in self.args:
self.args.remove(opt)
@ -137,7 +144,7 @@ class Argparse(Configs):
self.flag_search,
self.flag_no_silent
],
'find': [self.flag_search],
'find': [self.flag_search, self.flag_pattern],
'view': [
self.flag_search,
self.flag_pkg_version],
@ -181,7 +188,7 @@ class Argparse(Configs):
repo_packages = SBoQueries('').sbos()
# Grab all the installed packages
installed = self.utils.all_installed()
installed = self.utils.all_installed(pattern=f'*{self.sbo_repo_tag}')
if method in ['remove', 'find']:
@ -199,7 +206,7 @@ class Argparse(Configs):
if pkg == package:
repo_ver = SBoQueries(package).version()
inst_pkg = self.utils.is_installed(package)
inst_pkg = self.utils.is_installed(package, pattern=f'*{self.sbo_repo_tag}')
inst_ver = self.utils.split_installed_pkg(inst_pkg)[1]
choices += [(package, f'{inst_ver} -> {repo_ver}', True)]
@ -384,7 +391,7 @@ class Argparse(Configs):
self.check.database()
find = FindInstalled()
find.find(packages)
find.find(packages, self.pattern)
raise SystemExit()
self.usage.help(1)

View file

@ -86,7 +86,7 @@ class Slackbuilds(Configs):
# Checks if the package was installed and skipped.
if (self.flag_skip_installed in self.flags and
self.utils.is_installed(dep)):
self.utils.is_installed(dep, pattern=f'*{self.sbo_repo_tag}')):
continue
self.dependencies.append(dep)
@ -121,7 +121,8 @@ class Slackbuilds(Configs):
def is_for_skipped(self, sbo):
""" Condition to check if slackbuild is for skipped. """
return (not self.utils.is_installed(sbo) or self.utils.is_repo_version_bigger(sbo) or
pattern = f'*{self.sbo_repo_tag}'
return (not self.utils.is_installed(sbo, pattern) or self.utils.is_repo_version_bigger(sbo) or
self.mode == 'build' or self.flag_reinstall in self.flags)
def download_slackbuilds(self):
@ -150,6 +151,8 @@ class Slackbuilds(Configs):
def build_and_install(self):
""" Build the slackbuilds and install. """
pattern = f'*{self.sbo_repo_tag}'
for sbo in self.install_order:
if self.is_for_skipped(sbo):
@ -164,7 +167,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)
package = self.utils.is_installed(sbo, pattern)
version = self.utils.split_installed_pkg(package)[1]
self.view_message.view_skipping_packages(sbo, version)
@ -203,11 +206,12 @@ 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}'
pkg = self.utils.split_installed_pkg(package)[0]
execute = self.installpkg
if (self.flag_reinstall in self.flags and
self.utils.is_installed(pkg)):
self.utils.is_installed(pkg, pattern)):
execute = self.reinstall
message = f'{self.cyan}Installing{self.endc}'
@ -328,8 +332,9 @@ class Slackbuilds(Configs):
for package in dependencies:
status = True
pattern = f'*{self.sbo_repo_tag}'
repo_ver = SBoQueries(package).version()
installed = self.utils.is_installed(package)
installed = self.utils.is_installed(package, pattern)
if installed:
status = False

View file

@ -19,7 +19,7 @@ class Upgrade:
black = Blacklist().get()
upgrade, requires = [], []
installed = self.utils.all_installed()
installed = self.utils.all_installed(f'*{self.sbo_repo_tag}')
for pkg in installed:
inst_pkg_name = self.utils.split_installed_pkg(pkg)[0]

View file

@ -23,9 +23,9 @@ class Utilities:
self.endc = self.color['endc']
self.black = Blacklist()
def is_installed(self, name: str) -> str:
def is_installed(self, name: str, pattern: str) -> str:
""" Returns the installed package name. """
installed = list(self.all_installed())
installed = list(self.all_installed(pattern))
for package in installed:
pkg = self.split_installed_pkg(package)[0]
@ -35,9 +35,9 @@ class Utilities:
return ''
def all_installed(self) -> list:
def all_installed(self, pattern) -> list:
""" Return all installed SBo packages from /val/log/packages folder. """
pattern = f'*{self.configs.sbo_repo_tag}'
# pattern = f'*{self.configs.sbo_repo_tag}'
var_log_packages = Path(self.configs.log_packages)
for file in var_log_packages.glob(pattern):

View file

@ -26,8 +26,8 @@ class Usage(Configs):
f' slpkg [{self.cyan}COMMAND{self.endc}] [-f, find, -w, view, -s, search, -e, dependees] <packages>\n'
f' slpkg [{self.cyan}COMMAND{self.endc}] [-t, tracking] <packages>\n'
f' slpkg [{self.yellow}OPTIONS{self.endc}] [--yes, --jobs, --resolve-off, --reinstall]\n'
f' slpkg [{self.yellow}OPTIONS{self.endc}] [--skip-installed, --full-reverse, --search]\n'
f' slpkg [{self.yellow}OPTIONS{self.endc}] [--no-silent, --directory=PATH, --pkg-version]\n'
f' slpkg [{self.yellow}OPTIONS{self.endc}] [--skip-installed, --full-reverse, --search, --no-silent]\n'
f' slpkg [{self.yellow}OPTIONS{self.endc}] [--directory=PATH, --pkg-version, --file-pattern]\n'
" \nIf you need more information please try 'slpkg --help'.")
print(args)
@ -66,6 +66,7 @@ class Usage(Configs):
f' {self.yellow}--no-silent{self.endc} Disable silent mode.\n'
f' {self.yellow}--directory={self.endc}PATH Download files to a specific path.\n'
f' {self.yellow}--pkg-version{self.endc} Print the repository package version.\n'
f' {self.yellow}--file-pattern={self.endc}PATTERN Search for specific files with pattern.\n'
'\n -h, --help Show this message and exit.\n'
' -v, --version Print version and exit.\n'
'\nEdit the configuration file in the /etc/slpkg/slpkg.toml \n'

View file

@ -141,9 +141,10 @@ class ViewMessage(Configs):
def _view_removed(self, name: str):
""" View and creates list with packages for remove. """
installed = self.utils.all_installed()
pattern = f'*{self.sbo_repo_tag}'
installed = self.utils.all_installed(pattern)
if self.utils.is_installed(name):
if self.utils.is_installed(name, pattern):
for package in installed:
pkg = self.utils.split_installed_pkg(package)[0]
if pkg == name:
@ -179,7 +180,8 @@ class ViewMessage(Configs):
install = upgrade = remove = 0
for sbo in slackbuilds:
installed = self.utils.is_installed(sbo)
pattern = f'*{self.sbo_repo_tag}'
installed = self.utils.is_installed(sbo, pattern)
if not installed:
install += 1