[flatpak] fix -> installation fails when there are multiple references for a given package

This commit is contained in:
Vinicius Moreira
2020-08-12 10:28:00 -03:00
parent d426397584
commit 12b7acc559
13 changed files with 61 additions and 9 deletions

View File

@@ -40,6 +40,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Flatpak
- downgrading crashing with version 1.8.X
- history: the top commit is returned as "(null)"
- installation fails when there are multiple references for a given package (e.g: openh264)
<p align="center">
<img src="https://raw.githubusercontent.com/vinifmor/bauh/staging/pictures/releases/0.9.7/flatpak_refs.png">
</p>
- UI
- crashing when nothing can be upgraded
- random C++ wrapper errors with some forms due to missing references

View File

@@ -65,7 +65,7 @@ class SimpleProcess:
def __init__(self, cmd: List[str], cwd: str = '.', expected_code: int = 0,
global_interpreter: bool = USE_GLOBAL_INTERPRETER, lang: str = DEFAULT_LANG, root_password: str = None,
extra_paths: Set[str] = None, error_phrases: Set[str] = None):
extra_paths: Set[str] = None, error_phrases: Set[str] = None, wrong_error_phrases: Set[str] = None):
pwdin, final_cmd = None, []
if root_password is not None:
@@ -77,6 +77,7 @@ class SimpleProcess:
self.instance = self._new(final_cmd, cwd, global_interpreter, lang, stdin=pwdin, extra_paths=extra_paths)
self.expected_code = expected_code
self.error_phrases = error_phrases
self.wrong_error_phrases = wrong_error_phrases
def _new(self, cmd: List[str], cwd: str, global_interpreter: bool, lang: str, stdin = None, extra_paths: Set[str] = None) -> subprocess.Popen:
@@ -182,11 +183,18 @@ class ProcessHandler:
success = proc.instance.returncode == proc.expected_code
string_output = output.read()
if proc.error_phrases:
if not success and proc.wrong_error_phrases:
for phrase in proc.wrong_error_phrases:
if phrase in string_output:
success = True
break
if success and proc.error_phrases:
for phrase in proc.error_phrases:
if phrase in string_output:
success = False
break
return success, string_output

View File

@@ -1,4 +1,5 @@
import os
import re
import traceback
from datetime import datetime
from math import floor
@@ -25,6 +26,7 @@ from bauh.gems.flatpak.model import FlatpakApplication
from bauh.gems.flatpak.worker import FlatpakAsyncDataLoader, FlatpakUpdateLoader
DATE_FORMAT = '%Y-%m-%dT%H:%M:%S.000Z'
RE_INSTALL_REFS = re.compile(r'\d+\)\s+(.+)')
class FlatpakManager(SoftwareManager):
@@ -387,9 +389,30 @@ class FlatpakManager(SoftwareManager):
if not self._make_exports_dir(handler.watcher):
return TransactionResult(success=False, installed=[], removed=[])
res = handler.handle(SystemProcess(subproc=flatpak.install(str(pkg.id), pkg.origin, pkg.installation), wrong_error_phrase='Warning'))
installed, output = handler.handle_simple(flatpak.install(str(pkg.id), pkg.origin, pkg.installation))
if res:
if not installed and 'error: No ref chosen to resolve matches' in output:
ref_opts = RE_INSTALL_REFS.findall(output)
if ref_opts and len(ref_opts) > 1:
view_opts = [InputOption(label=o, value=o.strip()) for o in ref_opts if o]
ref_select = SingleSelectComponent(type_=SelectViewType.RADIO, options=view_opts, default_option=view_opts[0], label='')
if watcher.request_confirmation(title=self.i18n['flatpak.install.ref_choose.title'],
body=self.i18n['flatpak.install.ref_choose.body'].format(bold(pkg.name)),
components=[ref_select],
confirmation_label=self.i18n['proceed'].capitalize(),
deny_label=self.i18n['cancel'].capitalize()):
ref = ref_select.get_selected()
installed, output = handler.handle_simple(flatpak.install(ref, pkg.origin, pkg.installation))
pkg.ref = ref
pkg.runtime = 'runtime' in ref
else:
watcher.print('Aborted by the user')
return TransactionResult.fail()
else:
return TransactionResult.fail()
if installed:
try:
fields = flatpak.get_fields(str(pkg.id), pkg.branch, ['Ref', 'Branch'])
@@ -399,7 +422,7 @@ class FlatpakManager(SoftwareManager):
except:
traceback.print_exc()
if res:
if installed:
new_installed = [pkg]
current_installed = flatpak.list_installed(flatpak_version)
current_installed_by_level = [p for p in current_installed if p['installation'] == pkg.installation] if current_installed else None
@@ -413,7 +436,7 @@ class FlatpakManager(SoftwareManager):
new_installed.append(self._map_to_model(app_json=p, installed=True,
disk_loader=disk_loader, internet=net_available))
return TransactionResult(success=res, installed=new_installed, removed=[])
return TransactionResult(success=installed, installed=new_installed, removed=[])
else:
return TransactionResult.fail()

View File

@@ -355,9 +355,10 @@ def search(version: str, word: str, installation: str, app_id: bool = False) ->
return found
def install(app_id: str, origin: str, installation: str):
return new_subprocess(cmd=['flatpak', 'install', origin, app_id, '-y', '--{}'.format(installation)],
extra_paths={EXPORTS_PATH})
def install(app_id: str, origin: str, installation: str) -> SimpleProcess:
return SimpleProcess(cmd=['flatpak', 'install', origin, app_id, '-y', '--{}'.format(installation)],
extra_paths={EXPORTS_PATH},
wrong_error_phrases={'Warning'})
def set_default_remotes(installation: str, root_password: str = None) -> SimpleProcess:

View File

@@ -48,6 +48,8 @@ flatpak.info.version=versió
flatpak.install.bad_install_level.body=Valor invàlid per a {field} al fitxer de configuració {file}
flatpak.install.install_level.body=S'ha d'instal·lar {} per a tots els usuaris del dispositiu ( sistema ) ?
flatpak.install.install_level.title=Tipus d'instal·lació
flatpak.install.ref_choose.title=Multiple references
flatpak.install.ref_choose.body=There are multiple references for {}. Select one to proceed:
flatpak.notification.disable=Si no voleu utilitzar aplicacions Flatpak, desmarqueu {} a {}
flatpak.notification.no_remotes=No hi ha dipòsits («remotes») del Flatpak configurats. No podreu cercar aplicacions Flatpak.
flatpak.remotes.system_flathub.error=No s'ha pogut afegir Flathub com a dipòsit del sistema ( remote )

View File

@@ -48,6 +48,8 @@ flatpak.info.version=Version
flatpak.install.bad_install_level.body=Ungültiger Wert für {field} in der Konfigurationsdatei {file}
flatpak.install.install_level.body=Sollte {} für alle Gerätebenutzer installiert werden ( system ) ?
flatpak.install.install_level.title=Installationstyp
flatpak.install.ref_choose.title=Multiple references
flatpak.install.ref_choose.body=There are multiple references for {}. Select one to proceed:
flatpak.notification.disable=Um keine Flatpak Anwendungen zu verwenden deaktiviere {} unter {}
flatpak.notification.no_remotes=Keine Flatpak Remotes sind konfiguriert. Die Suche nach Flatpak Apps ist nicht möglich.
flatpak.remotes.system_flathub.error=Flathub konnte nicht als System-Repository ( remote ) hinzugefügt werden

View File

@@ -48,6 +48,8 @@ flatpak.info.version=version
flatpak.install.bad_install_level.body=Invalid value for {field} in the configuration file {file}
flatpak.install.install_level.body=Should {} be installed for all the device users ( system ) ?
flatpak.install.install_level.title=Installation type
flatpak.install.ref_choose.title=Multiple references
flatpak.install.ref_choose.body=There are multiple references for {}. Select one to proceed:
flatpak.notification.disable=If you do not want to use Flatpak applications, uncheck {} in {}
flatpak.notification.no_remotes=No Flatpak remotes set. It will not be possible to search for Flatpak apps.
flatpak.remotes.system_flathub.error=It was not possible to add Flathub as a system repository ( remote )

View File

@@ -48,6 +48,8 @@ flatpak.info.version=versión
flatpak.install.bad_install_level.body=Valor inválido para {field} en el archivo de configuración {file}
flatpak.install.install_level.body=¿Debería {} estar instalado para todos los usuarios del dispositivo ( sistema )?
flatpak.install.install_level.title=Tipo de instalación
flatpak.install.ref_choose.title=Varias referencias
flatpak.install.ref_choose.body=Hay varias referencias para {}. Seleccione una para proceder:
flatpak.notification.disable=Si no desea usar aplicativos Flatpak, desmarque {} en {}
flatpak.notification.no_remotes=No hay repositorios (remotes) Flatpak configurados. No será posible buscar aplicativos Flatpak.
flatpak.remotes.system_flathub.error=No fue posible agregar Flathub como repositorio del sistema ( remote )

View File

@@ -48,6 +48,8 @@ flatpak.info.version=version
flatpak.install.bad_install_level.body=Valore non valido per {field} nel file di configurazione {file}
flatpak.install.install_level.body={} deve essere installato per tutti gli utenti del dispositivo ( sistema ) ?
flatpak.install.install_level.title=Tipo di installazione
flatpak.install.ref_choose.title=Multiple references
flatpak.install.ref_choose.body=There are multiple references for {}. Select one to proceed:
flatpak.notification.disable=Ise non si desidera utilizzare le applicazioni Flatpak, deselezionare {} in {}
flatpak.notification.no_remotes=Nessun set remoti Flatpak. Non sarà possibile cercare app Flatpak.
flatpak.remotes.system_flathub.error=Non è stato possibile aggiungere Flathub come repository di sistema ( remote )

View File

@@ -48,6 +48,8 @@ flatpak.info.version=versão
flatpak.install.bad_install_level.body=Valor inválido para {field} no arquivo de configuração {file}
flatpak.install.install_level.body={} deve ser instalado para todos os usuários desse dispositivo ( sistema ) ?
flatpak.install.install_level.title=Tipo de instalação
flatpak.install.ref_choose.title=Múltiplas referências
flatpak.install.ref_choose.body=Existem múltiplas referências para {}. Selecione uma para continuar:
flatpak.notification.disable=Se não deseja usar aplicativos Flatpak, desmarque {} em {}
flatpak.notification.no_remotes=Não há repositórios (remotes) Flatpak configurados. Não será possível buscar aplicativos Flatpak.
flatpak.remotes.system_flathub.error=Não foi possível adicionar o Flathub como um repositório do sistema ( remote )

View File

@@ -48,6 +48,8 @@ flatpak.info.version=Версия
flatpak.install.bad_install_level.body=Недопустимое значение для {field} в файле конфигурации {file}
flatpak.install.install_level.body=Должен ли {} быть установлен для всех пользователей устройства (системы)?
flatpak.install.install_level.title=Тип установки
flatpak.install.ref_choose.title=Multiple references
flatpak.install.ref_choose.body=There are multiple references for {}. Select one to proceed:
flatpak.notification.disable=Если вы не хотите использовать приложения Flatpak, снимите флажок {} в {}
flatpak.notification.no_remotes=Поддержка Flatpak не установлена. Поиск приложений Flatpak будет невозможен.
flatpak.remotes.system_flathub.error=Не удалось добавить Flathub в качестве системного репозитория (удаленного)

View File

@@ -48,6 +48,8 @@ flatpak.info.version=sürüm
flatpak.install.bad_install_level.body={file} yapılandırma dosyasında {field} için geçersiz değer
flatpak.install.install_level.body=Tüm cihaz kullanıcıları (sistem) için {} kurulmalı mı ?
flatpak.install.install_level.title=Kurulum türü
flatpak.install.ref_choose.title=Multiple references
flatpak.install.ref_choose.body=There are multiple references for {}. Select one to proceed:
flatpak.notification.disable=If you do not want to use Flatpak applications, uncheck {} in {}
flatpak.notification.no_remotes=Flatpak uygulamalarını kullanmak istemiyorsanız, {} içindeki {} işaretini kaldırın
flatpak.remotes.system_flathub.error=Flathub sistem havuzu (uzak) olarak eklenemedi

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB