mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 00:04:15 +02:00
Merge branch 'fpakus' into fpakpart
# Conflicts: # bauh/gems/flatpak/flatpak.py # bauh/gems/flatpak/model.py
This commit is contained in:
@@ -135,7 +135,7 @@ class FlatpakManager(SoftwareManager):
|
||||
|
||||
watcher.change_progress(10)
|
||||
watcher.change_substatus(self.i18n['flatpak.downgrade.commits'])
|
||||
commits = flatpak.get_app_commits(pkg.ref, pkg.origin)
|
||||
commits = flatpak.get_app_commits(pkg.ref, pkg.origin, pkg.installation)
|
||||
|
||||
commit_idx = commits.index(pkg.commit)
|
||||
|
||||
@@ -147,7 +147,7 @@ class FlatpakManager(SoftwareManager):
|
||||
commit = commits[commit_idx + 1]
|
||||
watcher.change_substatus(self.i18n['flatpak.downgrade.reverting'])
|
||||
watcher.change_progress(50)
|
||||
success = ProcessHandler(watcher).handle(SystemProcess(subproc=flatpak.downgrade(pkg.ref, commit, root_password),
|
||||
success = ProcessHandler(watcher).handle(SystemProcess(subproc=flatpak.downgrade(pkg.ref, commit, pkg.installation, root_password),
|
||||
success_phrases=['Changes complete.', 'Updates complete.'],
|
||||
wrong_error_phrase='Warning'))
|
||||
watcher.change_progress(100)
|
||||
@@ -208,7 +208,7 @@ class FlatpakManager(SoftwareManager):
|
||||
|
||||
def get_history(self, pkg: FlatpakApplication) -> PackageHistory:
|
||||
pkg.commit = flatpak.get_commit(pkg.id, pkg.branch)
|
||||
commits = flatpak.get_app_commits_data(pkg.ref, pkg.origin)
|
||||
commits = flatpak.get_app_commits_data(pkg.ref, pkg.origin, pkg.installation)
|
||||
status_idx = 0
|
||||
|
||||
for idx, data in enumerate(commits):
|
||||
@@ -243,7 +243,7 @@ class FlatpakManager(SoftwareManager):
|
||||
return flatpak.is_installed()
|
||||
|
||||
def requires_root(self, action: str, pkg: FlatpakApplication):
|
||||
return action == 'downgrade'
|
||||
return action == 'downgrade' and pkg.installation == 'system'
|
||||
|
||||
def prepare(self):
|
||||
pass
|
||||
|
||||
@@ -97,6 +97,7 @@ def list_installed(version: str) -> List[dict]:
|
||||
'description': None,
|
||||
'origin': data[1],
|
||||
'runtime': runtime,
|
||||
'installation': 'user' if 'user' in data[5] else 'system',
|
||||
'version': ref_split[2] if runtime else None
|
||||
})
|
||||
|
||||
@@ -136,6 +137,7 @@ def list_installed(version: str) -> List[dict]:
|
||||
'description': data[4],
|
||||
'origin': data[5],
|
||||
'runtime': runtime,
|
||||
'installation': 'user' if 'user' in data[6] else 'system',
|
||||
'version': app_ver})
|
||||
return apps
|
||||
|
||||
@@ -159,11 +161,21 @@ def uninstall(app_ref: str):
|
||||
|
||||
|
||||
def list_updates_as_str(version: str) -> Dict[str, set]:
|
||||
updates = read_updates(version, 'system')
|
||||
user_updates = read_updates(version, 'user')
|
||||
|
||||
for attr in ('full', 'partial'):
|
||||
updates[attr].update(user_updates[attr])
|
||||
|
||||
return updates
|
||||
|
||||
|
||||
def read_updates(version: str, installation: str) -> Dict[str, set]:
|
||||
if version < '1.2':
|
||||
# TODO
|
||||
return run_cmd('{} update --no-related'.format(BASE_CMD), ignore_return_code=True)
|
||||
return run_cmd('{} update --no-related --{}'.format(BASE_CMD, installation), ignore_return_code=True)
|
||||
else:
|
||||
updates = new_subprocess([BASE_CMD, 'update']).stdout
|
||||
updates = new_subprocess([BASE_CMD, 'update', '--{}'.format(installation)]).stdout
|
||||
|
||||
reg = r'[0-9]+\.\s+.+' if version >= '1.5.0' else r'[0-9]+\.\s+(\w+|\.)+\s+\w+\s+(\w|\.)+'
|
||||
|
||||
@@ -189,12 +201,13 @@ def list_updates_as_str(version: str) -> Dict[str, set]:
|
||||
return res
|
||||
|
||||
|
||||
def downgrade(app_ref: str, commit: str, root_password: str) -> subprocess.Popen:
|
||||
return new_root_subprocess([BASE_CMD, 'update', '--no-related', '--commit={}'.format(commit), app_ref, '-y'], root_password)
|
||||
def downgrade(app_ref: str, commit: str, installation: str, root_password: str) -> subprocess.Popen:
|
||||
cmd = [BASE_CMD, 'update', '--no-related', '--commit={}'.format(commit), app_ref, '-y']
|
||||
return new_root_subprocess(cmd, root_password)
|
||||
|
||||
|
||||
def get_app_commits(app_ref: str, origin: str) -> List[str]:
|
||||
log = run_cmd('{} remote-info --log {} {}'.format(BASE_CMD, origin, app_ref))
|
||||
def get_app_commits(app_ref: str, origin: str, installation: str) -> List[str]:
|
||||
log = run_cmd('{} remote-info --log {} {} --{}'.format(BASE_CMD, origin, app_ref, installation))
|
||||
|
||||
if log:
|
||||
return re.findall(r'Commit+:\s(.+)', log)
|
||||
@@ -202,8 +215,8 @@ def get_app_commits(app_ref: str, origin: str) -> List[str]:
|
||||
raise NoInternetException()
|
||||
|
||||
|
||||
def get_app_commits_data(app_ref: str, origin: str) -> List[dict]:
|
||||
log = run_cmd('{} remote-info --log {} {}'.format(BASE_CMD, origin, app_ref))
|
||||
def get_app_commits_data(app_ref: str, origin: str, installation: str) -> List[dict]:
|
||||
log = run_cmd('{} remote-info --log {} {} --{}'.format(BASE_CMD, origin, app_ref, installation))
|
||||
|
||||
if not log:
|
||||
raise NoInternetException()
|
||||
|
||||
@@ -8,7 +8,8 @@ from bauh.gems.flatpak import ROOT_DIR
|
||||
class FlatpakApplication(SoftwarePackage):
|
||||
|
||||
def __init__(self, id: str = None, name: str = None, version: str = None, latest_version: str = None, description: str = None,
|
||||
branch: str = None, arch: str = None, origin: str = None, runtime: bool = False, ref: str = None, commit: str = None):
|
||||
branch: str = None, arch: str = None, origin: str = None, runtime: bool = False, ref: str = None, commit: str = None,
|
||||
installation: str = None):
|
||||
super(FlatpakApplication, self).__init__(id=id, name=name, version=version,
|
||||
latest_version=latest_version, description=description)
|
||||
self.ref = ref
|
||||
@@ -23,7 +24,7 @@ class FlatpakApplication(SoftwarePackage):
|
||||
if runtime:
|
||||
self.categories = ['runtime']
|
||||
|
||||
def is_incomplete(self) -> bool:
|
||||
def is_incomplete(self):
|
||||
return self.description is None and self.icon_url
|
||||
|
||||
def has_history(self) -> bool:
|
||||
@@ -71,9 +72,6 @@ class FlatpakApplication(SoftwarePackage):
|
||||
def get_publisher(self):
|
||||
return self.origin
|
||||
|
||||
def can_be_uninstalled(self) -> bool:
|
||||
return self.installed and not self.partial
|
||||
|
||||
def gen_partial(self, partial_id: str) -> "FlatpakApplication":
|
||||
partial = copy.deepcopy(self)
|
||||
partial.id = partial_id
|
||||
|
||||
Reference in New Issue
Block a user