mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-18 10:26:29 +01:00
Updated for check all repos
This commit is contained in:
parent
0514d828b7
commit
f1f16c2dec
3 changed files with 87 additions and 68 deletions
|
@ -1,5 +1,9 @@
|
|||
## slpkg - ChangeLog
|
||||
|
||||
### 5.0.1 - 28/03/2024
|
||||
- Updated:
|
||||
* Updated to check upgrade packages against all repositories (slpkg upgrade --repository='*' --check)
|
||||
|
||||
### 5.0.0 - 24/03/2024
|
||||
- Updated:
|
||||
* Blacklist using regex pattern
|
||||
|
|
|
@ -283,7 +283,8 @@ class Menu(Configs):
|
|||
def check_for_repositories(self) -> None:
|
||||
""" Checks a combination for binaries use repositories only and if repository exists. """
|
||||
except_options: tuple = (
|
||||
'-s', 'search'
|
||||
'-s', 'search',
|
||||
'-U', 'upgrade'
|
||||
)
|
||||
if self.repository == '*' and not self.utils.is_option(except_options, self.args):
|
||||
self.usage.help_minimal(f"{self.prog_name}: invalid repository '{self.repository}'")
|
||||
|
@ -430,7 +431,8 @@ class Menu(Configs):
|
|||
self.data: dict = self.load_data.load(self.repository)
|
||||
upgrade = Upgrade(self.repository, self.data)
|
||||
upgrade.check_packages()
|
||||
else:
|
||||
|
||||
elif self.repository != '*':
|
||||
self.data: dict = self.load_data.load(self.repository)
|
||||
upgrade = Upgrade(self.repository, self.data)
|
||||
packages: list = list(upgrade.packages())
|
||||
|
@ -452,14 +454,15 @@ class Menu(Configs):
|
|||
|
||||
if self.repository not in [self.repos.sbo_repo_name, self.repos.ponce_repo_name]:
|
||||
install = Packages(
|
||||
self.repository, self.data, packages, self.flags, mode=command
|
||||
)
|
||||
self.repository, self.data, packages, self.flags, mode=command)
|
||||
install.execute()
|
||||
else:
|
||||
install = Slackbuilds(
|
||||
self.repository, self.data, packages, self.flags, mode=command
|
||||
)
|
||||
self.repository, self.data, packages, self.flags, mode=command)
|
||||
install.execute()
|
||||
else:
|
||||
self.usage.help_minimal(f"{self.prog_name}: invalid repository '{self.repository}'")
|
||||
|
||||
install.execute()
|
||||
raise SystemExit(0)
|
||||
self.usage.help_short(1)
|
||||
|
||||
|
@ -729,12 +732,13 @@ def main() -> None:
|
|||
'-t': menu.tracking
|
||||
}
|
||||
|
||||
try:
|
||||
arguments[args[0]]()
|
||||
except (KeyError, IndexError):
|
||||
usage.help_short(1)
|
||||
except KeyboardInterrupt:
|
||||
raise SystemExit(1)
|
||||
arguments[args[0]]()
|
||||
# try:
|
||||
# arguments[args[0]]()
|
||||
# except (KeyError, IndexError):
|
||||
# usage.help_short(1)
|
||||
# except KeyboardInterrupt:
|
||||
# raise SystemExit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
121
slpkg/upgrade.py
121
slpkg/upgrade.py
|
@ -72,70 +72,80 @@ class Upgrade(Configs):
|
|||
|
||||
def check_packages(self) -> None:
|
||||
found_packages: dict = {}
|
||||
self.load_installed_packages()
|
||||
if self.repository == '*':
|
||||
self.installed_packages: list = list(self.log_packages.glob('*'))
|
||||
else:
|
||||
self.load_installed_packages()
|
||||
self.data[self.repository] = self.data
|
||||
|
||||
for installed in self.installed_packages:
|
||||
name: str = self.utils.split_package(installed.name)['name']
|
||||
for repo, data in self.data.items():
|
||||
|
||||
if self.data.get(name):
|
||||
repo_package: str = self.data[name]['package'][:-4]
|
||||
for installed in self.installed_packages:
|
||||
name: str = self.utils.split_package(installed.name)['name']
|
||||
|
||||
if parse_version(repo_package) > parse_version(installed.name):
|
||||
self.id += 1
|
||||
self.sum_upgrade += 1
|
||||
inst_version: str = self.utils.split_package(installed.name)['version']
|
||||
inst_build: str = self.utils.split_package(installed.name)['build']
|
||||
repo_version: str = self.data[name]['version']
|
||||
repo_build: str = self.data[name]['build']
|
||||
if data.get(name):
|
||||
repo_package: str = data[name]['package'][:-4]
|
||||
|
||||
found_packages[self.id]: dict = {
|
||||
'name': name,
|
||||
'inst_version': inst_version,
|
||||
'inst_build': inst_build,
|
||||
'repo_version': repo_version,
|
||||
'repo_build': repo_build,
|
||||
'type': 'upgrade'
|
||||
}
|
||||
if parse_version(repo_package) > parse_version(installed.name):
|
||||
self.id += 1
|
||||
self.sum_upgrade += 1
|
||||
inst_version: str = self.utils.split_package(installed.name)['version']
|
||||
inst_build: str = self.utils.split_package(installed.name)['build']
|
||||
repo_version: str = data[name]['version']
|
||||
repo_build: str = data[name]['build']
|
||||
|
||||
if self.repository == self.repos.slack_repo_name and self.removed_packages:
|
||||
if name not in self.data.keys():
|
||||
self.id += 1
|
||||
self.sum_removed += 1
|
||||
inst_version: str = self.utils.split_package(installed.name)['version']
|
||||
inst_build: str = self.utils.split_package(installed.name)['build']
|
||||
repo_version: str = ''
|
||||
repo_build: str = ''
|
||||
found_packages[self.id]: dict = {
|
||||
'name': name,
|
||||
'inst_version': inst_version,
|
||||
'inst_build': inst_build,
|
||||
'repo_version': repo_version,
|
||||
'repo_build': repo_build,
|
||||
'repo': repo,
|
||||
'type': 'upgrade'
|
||||
}
|
||||
|
||||
found_packages[self.id]: dict = {
|
||||
'name': name + '_Removed.',
|
||||
'inst_version': inst_version,
|
||||
'inst_build': inst_build,
|
||||
'repo_version': repo_version,
|
||||
'repo_build': repo_build,
|
||||
'type': 'remove'
|
||||
}
|
||||
if repo == self.repos.slack_repo_name and self.removed_packages:
|
||||
if name not in data.keys():
|
||||
self.id += 1
|
||||
self.sum_removed += 1
|
||||
inst_version: str = self.utils.split_package(installed.name)['version']
|
||||
inst_build: str = self.utils.split_package(installed.name)['build']
|
||||
repo_version: str = ''
|
||||
repo_build: str = ''
|
||||
|
||||
if self.repository == self.repos.slack_repo_name and self.new_packages:
|
||||
for name in self.data.keys():
|
||||
# if not self.utils.is_package_installed(name):
|
||||
if name not in self.installed_names:
|
||||
self.id += 1
|
||||
self.sum_added += 1
|
||||
inst_version: str = ''
|
||||
inst_build: str = ''
|
||||
repo_version: str = self.data[name]['version']
|
||||
repo_build: str = self.data[name]['build']
|
||||
found_packages[self.id]: dict = {
|
||||
'name': name + '_Removed.',
|
||||
'inst_version': inst_version,
|
||||
'inst_build': inst_build,
|
||||
'repo_version': repo_version,
|
||||
'repo_build': repo_build,
|
||||
'repo': repo,
|
||||
'type': 'remove'
|
||||
}
|
||||
|
||||
found_packages[self.id]: dict = {
|
||||
'name': name,
|
||||
'inst_version': inst_version,
|
||||
'inst_build': inst_build,
|
||||
'repo_version': repo_version,
|
||||
'repo_build': repo_build,
|
||||
'type': 'add'
|
||||
}
|
||||
if repo == self.repos.slack_repo_name and self.new_packages:
|
||||
for name in data.keys():
|
||||
# if not self.utils.is_package_installed(name):
|
||||
if name not in self.installed_names:
|
||||
self.id += 1
|
||||
self.sum_added += 1
|
||||
inst_version: str = ''
|
||||
inst_build: str = ''
|
||||
repo_version: str = data[name]['version']
|
||||
repo_build: str = data[name]['build']
|
||||
|
||||
found_packages[self.id]: dict = {
|
||||
'name': name,
|
||||
'inst_version': inst_version,
|
||||
'inst_build': inst_build,
|
||||
'repo_version': repo_version,
|
||||
'repo_build': repo_build,
|
||||
'repo': self.repos.slack_repo_name,
|
||||
'type': 'add'
|
||||
}
|
||||
|
||||
if found_packages:
|
||||
print()
|
||||
title: str = f"{'packages':<18} {'Version':<15} {'Build':<6} {'Repository':<15} {'Build':<5} {'Repo':>15}"
|
||||
print(len(title) * '=')
|
||||
print(f'{self.bgreen}{title}{self.endc}')
|
||||
|
@ -147,6 +157,7 @@ class Upgrade(Configs):
|
|||
repo_build: str = data['repo_build']
|
||||
inst_version: str = data['inst_version']
|
||||
inst_build: str = data['inst_build']
|
||||
repo: str = data['repo']
|
||||
mode: str = data['type']
|
||||
|
||||
if len(name) > 17:
|
||||
|
@ -163,7 +174,7 @@ class Upgrade(Configs):
|
|||
color: str = self.cyan
|
||||
|
||||
print(f"{color}{name:<18}{self.endc} {inst_version:<15} {inst_build:<6} {repo_version:<15} "
|
||||
f"{repo_build:<5} {self.repository:>15}")
|
||||
f"{repo_build:<5} {repo:>15}")
|
||||
|
||||
print(len(title) * '=')
|
||||
print(f'{self.grey}Packages to upgrade {self.sum_upgrade}, packages to remove '
|
||||
|
|
Loading…
Reference in a new issue