mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 05:54:15 +02:00
[arch] feature -> new 'Check Snaps support' action
This commit is contained in:
@@ -20,6 +20,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
<p align="center">
|
||||
<img src="https://raw.githubusercontent.com/vinifmor/bauh-files/master/pictures/releases/0.9.7/unmark_pkgbuild.png">
|
||||
</p>
|
||||
- new "Check Snaps support" action: checks all system requirements for Snaps to work properly (only available if the 'snapd' package is installed)
|
||||
<p align="center">
|
||||
<img src="https://raw.githubusercontent.com/vinifmor/bauh-files/master/pictures/releases/0.9.7/unmark_pkgbuild.png">
|
||||
</p>
|
||||
|
||||
### Improvements
|
||||
- AppImage
|
||||
|
||||
@@ -4,7 +4,7 @@ import sys
|
||||
import time
|
||||
from io import StringIO
|
||||
from subprocess import PIPE
|
||||
from typing import List, Tuple, Set
|
||||
from typing import List, Tuple, Set, Dict
|
||||
|
||||
# default environment variables for subprocesses.
|
||||
from bauh.api.abstract.handler import ProcessWatcher
|
||||
@@ -298,3 +298,23 @@ def get_human_size_str(size) -> str:
|
||||
def run(cmd: List[str], success_code: int = 0) -> Tuple[bool, str]:
|
||||
p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
return p.returncode == success_code, p.stdout.decode()
|
||||
|
||||
|
||||
def check_active_services(*names: str) -> Dict[str, bool]:
|
||||
output = run_cmd('systemctl is-active {}'.format(' '.join(names)), print_error=False)
|
||||
|
||||
if not output:
|
||||
return {n: False for n in names}
|
||||
else:
|
||||
status = output.split('\n')
|
||||
return {s: status[i].strip().lower() == 'active' for i, s in enumerate(names) if s}
|
||||
|
||||
|
||||
def check_enabled_services(*names: str) -> Dict[str, bool]:
|
||||
output = run_cmd('systemctl is-enabled {}'.format(' '.join(names)), print_error=False)
|
||||
|
||||
if not output:
|
||||
return {n: False for n in names}
|
||||
else:
|
||||
status = output.split('\n')
|
||||
return {s: status[i].strip().lower() == 'enabled' for i, s in enumerate(names) if s}
|
||||
|
||||
@@ -25,7 +25,7 @@ from bauh.api.abstract.view import MessageType, FormComponent, InputOption, Sing
|
||||
ViewComponent, PanelComponent, MultipleSelectComponent, TextInputComponent, TextComponent, TextInputType, \
|
||||
FileChooserComponent
|
||||
from bauh.api.constants import TEMP_DIR
|
||||
from bauh.commons import user, internet
|
||||
from bauh.commons import user, internet, system
|
||||
from bauh.commons.category import CategoriesDownloader
|
||||
from bauh.commons.config import save_config
|
||||
from bauh.commons.html import bold
|
||||
@@ -203,7 +203,14 @@ class ArchManager(SoftwareManager):
|
||||
icon_path=get_icon_path(),
|
||||
requires_root=True,
|
||||
refresh=False,
|
||||
manager=self)
|
||||
manager=self),
|
||||
'setup_snapd': CustomSoftwareAction(i18n_label_key='arch.custom_action.setup_snapd',
|
||||
i18n_status_key='arch.custom_action.setup_snapd.status',
|
||||
manager_method='setup_snapd',
|
||||
icon_path=get_icon_path(),
|
||||
requires_root=False,
|
||||
refresh=False,
|
||||
manager=self),
|
||||
}
|
||||
self.index_aur = None
|
||||
self.re_file_conflict = re.compile(r'[\w\d\-_.]+:')
|
||||
@@ -2573,6 +2580,9 @@ class ArchManager(SoftwareManager):
|
||||
if bool(arch_config['repositories']):
|
||||
actions.append(self.custom_actions['sys_up'])
|
||||
|
||||
if pacman.is_snapd_installed():
|
||||
actions.append(self.custom_actions['setup_snapd'])
|
||||
|
||||
return actions
|
||||
|
||||
def fill_sizes(self, pkgs: List[ArchPackage]):
|
||||
@@ -2607,7 +2617,7 @@ class ArchManager(SoftwareManager):
|
||||
p.size = new_size - p.size
|
||||
|
||||
def upgrade_system(self, root_password: str, watcher: ProcessWatcher) -> bool:
|
||||
repo_map = pacman.map_repositories()
|
||||
# repo_map = pacman.map_repositories()
|
||||
installed = self.read_installed(limit=-1, only_apps=False, pkg_types=None, internet_available=internet.is_available(), disk_loader=None).installed
|
||||
|
||||
if not installed:
|
||||
@@ -2820,3 +2830,86 @@ class ArchManager(SoftwareManager):
|
||||
def disable_pkgbuild_edition(self, pkg: ArchPackage, root_password: str, watcher: ProcessWatcher):
|
||||
if self._remove_from_editable_pkgbuilds(pkg.name):
|
||||
pkg.pkgbuild_editable = False
|
||||
|
||||
def setup_snapd(self, root_password: str, watcher: ProcessWatcher) -> bool:
|
||||
# checking services
|
||||
missing_items = []
|
||||
for serv, active in system.check_enabled_services('snapd.service', 'snapd.socket').items():
|
||||
if not active:
|
||||
missing_items.append(InputOption(label=self.i18n['snap.custom_action.setup_snapd.service_disabled'].format("'{}'".format(serv)),
|
||||
value='enable:{}'.format(serv),
|
||||
read_only=True))
|
||||
|
||||
for serv, active in system.check_active_services('snapd.service', 'snapd.socket').items():
|
||||
if not active:
|
||||
missing_items.append(InputOption(label=self.i18n['snap.custom_action.setup_snapd.service_inactive'].format("'{}'".format(serv)),
|
||||
value='start:{}'.format(serv),
|
||||
read_only=True))
|
||||
|
||||
link = '/snap'
|
||||
link_dest = '/var/lib/snapd/snap'
|
||||
if not os.path.exists('/snap'):
|
||||
missing_items.append(InputOption(label=self.i18n['snap.custom_action.setup_snapd.missing_link'].format("'{}'".format(link), "'{}'".format(link_dest)),
|
||||
value='link:{}:{}'.format(link, link_dest),
|
||||
read_only=True))
|
||||
|
||||
if missing_items:
|
||||
actions = MultipleSelectComponent(label=self.i18n['snap.custom_action.setup_snapd.required_actions'],
|
||||
options=missing_items,
|
||||
default_options=set(missing_items),
|
||||
max_per_line=1,
|
||||
spaces=False)
|
||||
if watcher.request_confirmation(title=self.i18n['confirmation'].capitalize(),
|
||||
body='',
|
||||
components=[actions],
|
||||
confirmation_label=self.i18n['proceed'].capitalize(),
|
||||
deny_label=self.i18n['cancel'].capitalize()):
|
||||
|
||||
pwd, valid_pwd = watcher.request_root_password()
|
||||
|
||||
if valid_pwd:
|
||||
handler = ProcessHandler(watcher)
|
||||
for a in missing_items:
|
||||
action = a.value.split(':')
|
||||
|
||||
if action[0] == 'enable':
|
||||
msg = 'Enabling service {}'.format(action[1])
|
||||
watcher.print(msg)
|
||||
self.logger.info(msg)
|
||||
proc = SimpleProcess(['systemctl', 'enable', '--now', action[1]], root_password=pwd)
|
||||
elif action[0] == 'start':
|
||||
msg = 'Starting service {}'.format(action[1])
|
||||
watcher.print(msg)
|
||||
self.logger.info(msg)
|
||||
proc = SimpleProcess(['systemctl', 'start', action[1]], root_password=pwd)
|
||||
elif action[0] == 'link':
|
||||
msg = 'Creating symbolic link {} for {}'.format(action[1], action[2])
|
||||
watcher.print(msg)
|
||||
self.logger.info(msg)
|
||||
proc = SimpleProcess(['ln', '-s', action[2], action[1]], root_password=pwd)
|
||||
else:
|
||||
msg = "Wrong action '{}'".format(action)
|
||||
watcher.print(msg)
|
||||
self.logger.warning(msg)
|
||||
proc = None
|
||||
|
||||
if not proc:
|
||||
return False
|
||||
|
||||
success, output = handler.handle_simple(proc)
|
||||
|
||||
if not success:
|
||||
watcher.show_message(title=self.i18n['error'].capitalize(),
|
||||
body=output,
|
||||
type_=MessageType.ERROR)
|
||||
return False
|
||||
|
||||
watcher.show_message(title=self.i18n['snap.custom_action.setup_snapd.ready'],
|
||||
body=self.i18n['snap.custom_action.setup_snapd.ready.body'],
|
||||
type_=MessageType.INFO)
|
||||
return True
|
||||
else:
|
||||
watcher.show_message(title=self.i18n['snap.custom_action.setup_snapd.ready'],
|
||||
body=self.i18n['snap.custom_action.setup_snapd.ready.body'],
|
||||
type_=MessageType.INFO)
|
||||
return True
|
||||
|
||||
@@ -1113,3 +1113,7 @@ def get_packages_to_sync_first() -> Set[str]:
|
||||
return {s.strip() for s in to_sync_first[0].split(' ') if s and s.strip()}
|
||||
|
||||
return set()
|
||||
|
||||
|
||||
def is_snapd_installed() -> bool:
|
||||
return bool(run_cmd('pacman -Qq snapd', print_error=False))
|
||||
|
||||
@@ -68,6 +68,14 @@ arch.custom_action.refresh_mirrors.location.all.tip=If this option is checked, t
|
||||
arch.custom_action.refresh_mirrors.select_label=Check the desired locations
|
||||
arch.custom_action.refresh_mirrors.status.sorting=Sorting mirrors by speed
|
||||
arch.custom_action.refresh_mirrors.status.updating=Sorting mirrors by speed
|
||||
arch.custom_action.setup_snapd=Check Snaps support
|
||||
snap.custom_action.setup_snapd.missing_link=Create the link {} for {}
|
||||
arch.custom_action.setup_snapd.status=Checking Snaps support
|
||||
snap.custom_action.setup_snapd.ready=Ready!
|
||||
snap.custom_action.setup_snapd.ready.body=The system is ready to work with Snaps!
|
||||
snap.custom_action.setup_snapd.required_actions=Actions required for Snaps to work correctly
|
||||
snap.custom_action.setup_snapd.service_disabled=Enable the service {}
|
||||
snap.custom_action.setup_snapd.service_inactive=Start the service {}
|
||||
arch.custom_action.upgrade_system=Quick system upgrade
|
||||
arch.custom_action.upgrade_system.no_updates=There are no updates available
|
||||
arch.custom_action.upgrade_system.pkgs=The packages below will be upgraded
|
||||
|
||||
@@ -68,6 +68,14 @@ arch.custom_action.refresh_mirrors.location.all.tip=If this option is checked, t
|
||||
arch.custom_action.refresh_mirrors.select_label=Check the desired locations
|
||||
arch.custom_action.refresh_mirrors.status.sorting=Sorting mirrors by speed
|
||||
arch.custom_action.refresh_mirrors.status.updating=Sorting mirrors by speed
|
||||
arch.custom_action.setup_snapd=Check Snaps support
|
||||
snap.custom_action.setup_snapd.missing_link=Create the link {} for {}
|
||||
arch.custom_action.setup_snapd.status=Checking Snaps support
|
||||
snap.custom_action.setup_snapd.ready=Ready!
|
||||
snap.custom_action.setup_snapd.ready.body=The system is ready to work with Snaps!
|
||||
snap.custom_action.setup_snapd.required_actions=Actions required for Snaps to work correctly
|
||||
snap.custom_action.setup_snapd.service_disabled=Enable the service {}
|
||||
snap.custom_action.setup_snapd.service_inactive=Start the service {}
|
||||
arch.custom_action.upgrade_system=Quick system upgrade
|
||||
arch.custom_action.upgrade_system.no_updates=There are no updates available
|
||||
arch.custom_action.upgrade_system.pkgs=The packages below will be upgraded
|
||||
|
||||
@@ -69,6 +69,14 @@ arch.custom_action.refresh_mirrors.location.all.tip=If this option is checked, t
|
||||
arch.custom_action.refresh_mirrors.select_label=Check the desired locations
|
||||
arch.custom_action.refresh_mirrors.status.sorting=Sorting mirrors by speed
|
||||
arch.custom_action.refresh_mirrors.status.updating=Updating mirrors
|
||||
arch.custom_action.setup_snapd=Check Snaps support
|
||||
snap.custom_action.setup_snapd.missing_link=Create the link {} for {}
|
||||
arch.custom_action.setup_snapd.status=Checking Snaps support
|
||||
snap.custom_action.setup_snapd.ready=Ready!
|
||||
snap.custom_action.setup_snapd.ready.body=The system is ready to work with Snaps!
|
||||
snap.custom_action.setup_snapd.required_actions=Actions required for Snaps to work correctly
|
||||
snap.custom_action.setup_snapd.service_disabled=Enable the service {}
|
||||
snap.custom_action.setup_snapd.service_inactive=Start the service {}
|
||||
arch.custom_action.upgrade_system=Quick system upgrade
|
||||
arch.custom_action.upgrade_system.no_updates=There are no updates available
|
||||
arch.custom_action.upgrade_system.pkgs=The packages below will be upgraded
|
||||
|
||||
@@ -68,6 +68,14 @@ arch.custom_action.refresh_mirrors.location.all.tip=Si esta opción está marcad
|
||||
arch.custom_action.refresh_mirrors.select_label=Marcar las ubicaciones deseadas
|
||||
arch.custom_action.refresh_mirrors.status.sorting=Ordenando los espejos por velocidad
|
||||
arch.custom_action.refresh_mirrors.status.updating=Actualizando espejos
|
||||
arch.custom_action.setup_snapd=Verificar soporte de Snaps
|
||||
snap.custom_action.setup_snapd.missing_link=Crear el link {} para {}
|
||||
arch.custom_action.setup_snapd.status=Verificando soporte de Snaps
|
||||
snap.custom_action.setup_snapd.ready=¡Listo!
|
||||
snap.custom_action.setup_snapd.ready.body=¡El sistema está listo para trabajar con Snaps!
|
||||
snap.custom_action.setup_snapd.required_actions=Acciones necesarias para que los Snaps funcionen correctamente
|
||||
snap.custom_action.setup_snapd.service_disabled=Habilitar el servicio {}
|
||||
snap.custom_action.setup_snapd.service_inactive=Iniciar el servicio {}
|
||||
arch.custom_action.upgrade_system=Actualización rápida de sistema
|
||||
arch.custom_action.upgrade_system.no_updates=No hay actualizaciones disponibles
|
||||
arch.custom_action.upgrade_system.pkgs=Los paquetes abajo serán actualizados
|
||||
|
||||
@@ -68,6 +68,14 @@ arch.custom_action.refresh_mirrors.location.all.tip=If this option is checked, t
|
||||
arch.custom_action.refresh_mirrors.select_label=Check the desired locations
|
||||
arch.custom_action.refresh_mirrors.status.sorting=Sorting mirrors by speed
|
||||
arch.custom_action.refresh_mirrors.status.updating=Sorting mirrors by speed
|
||||
arch.custom_action.setup_snapd=Check Snaps support
|
||||
snap.custom_action.setup_snapd.missing_link=Create the link {} for {}
|
||||
arch.custom_action.setup_snapd.status=Checking Snaps support
|
||||
snap.custom_action.setup_snapd.ready=Ready!
|
||||
snap.custom_action.setup_snapd.ready.body=The system is ready to work with Snaps!
|
||||
snap.custom_action.setup_snapd.required_actions=Actions required for Snaps to work correctly
|
||||
snap.custom_action.setup_snapd.service_disabled=Enable the service {}
|
||||
snap.custom_action.setup_snapd.service_inactive=Start the service {}
|
||||
arch.custom_action.upgrade_system=Quick system upgrade
|
||||
arch.custom_action.upgrade_system.no_updates=There are no updates available
|
||||
arch.custom_action.upgrade_system.pkgs=The packages below will be upgraded
|
||||
|
||||
@@ -68,6 +68,14 @@ arch.custom_action.refresh_mirrors.location.all.tip=Se essa opção estiver marc
|
||||
arch.custom_action.refresh_mirrors.select_label=Marque as localizações desejadas
|
||||
arch.custom_action.refresh_mirrors.status.sorting=Ordenando os espelhos por velocidade
|
||||
arch.custom_action.refresh_mirrors.status.updating=Atualizando espelhos
|
||||
arch.custom_action.setup_snapd=Verificar suporte ao Snaps
|
||||
snap.custom_action.setup_snapd.missing_link=Criar o link {} para {}
|
||||
arch.custom_action.setup_snapd.status=Verificando suporte aos Snaps
|
||||
snap.custom_action.setup_snapd.ready=Pronto!
|
||||
snap.custom_action.setup_snapd.ready.body=O sistema está pronto para trabalhar com Snaps!
|
||||
snap.custom_action.setup_snapd.required_actions=Ações necessárias para que os Snaps funcionem corretamente
|
||||
snap.custom_action.setup_snapd.service_disabled=Habilitar o serviço {}
|
||||
snap.custom_action.setup_snapd.service_inactive=Iniciar o serviço {}
|
||||
arch.custom_action.upgrade_system=Atualização rápida de sistema
|
||||
arch.custom_action.upgrade_system.no_updates=Não há atualizações disponíveis
|
||||
arch.custom_action.upgrade_system.pkgs=Os pacotes abaixo serão atualizados
|
||||
|
||||
@@ -68,6 +68,14 @@ arch.custom_action.refresh_mirrors.location.all.tip=Если этот парам
|
||||
arch.custom_action.refresh_mirrors.select_label=Проверка предпочитаемых расположений
|
||||
arch.custom_action.refresh_mirrors.status.sorting=Sorting mirrors by speed
|
||||
arch.custom_action.refresh_mirrors.status.updating=Сортировка зеркал по скорости
|
||||
arch.custom_action.setup_snapd=Check Snaps support
|
||||
snap.custom_action.setup_snapd.missing_link=Create the link {} for {}
|
||||
arch.custom_action.setup_snapd.status=Checking Snaps support
|
||||
snap.custom_action.setup_snapd.ready=Ready!
|
||||
snap.custom_action.setup_snapd.ready.body=The system is ready to work with Snaps!
|
||||
snap.custom_action.setup_snapd.required_actions=Actions required for Snaps to work correctly
|
||||
snap.custom_action.setup_snapd.service_disabled=Enable the service {}
|
||||
snap.custom_action.setup_snapd.service_inactive=Start the service {}
|
||||
arch.custom_action.upgrade_system=Обновление системы
|
||||
arch.custom_action.upgrade_system.no_updates=Обновления отсутствуют
|
||||
arch.custom_action.upgrade_system.pkgs=Следующие пакеты будут обновлены
|
||||
|
||||
@@ -68,6 +68,14 @@ arch.custom_action.refresh_mirrors.location.all.tip=Bu seçenek işaretlenirse,
|
||||
arch.custom_action.refresh_mirrors.select_label=İstediğiniz konumları kontrol edin
|
||||
arch.custom_action.refresh_mirrors.status.sorting=Yansıları hıza göre sırala
|
||||
arch.custom_action.refresh_mirrors.status.updating=Yansılar güncelleniyor
|
||||
arch.custom_action.setup_snapd=Check Snaps support
|
||||
snap.custom_action.setup_snapd.missing_link=Create the link {} for {}
|
||||
arch.custom_action.setup_snapd.status=Checking Snaps support
|
||||
snap.custom_action.setup_snapd.ready=Ready!
|
||||
snap.custom_action.setup_snapd.ready.body=The system is ready to work with Snaps!
|
||||
snap.custom_action.setup_snapd.required_actions=Actions required for Snaps to work correctly
|
||||
snap.custom_action.setup_snapd.service_disabled=Enable the service {}
|
||||
snap.custom_action.setup_snapd.service_inactive=Start the service {}
|
||||
arch.custom_action.upgrade_system=Sistemi hızlı yükselt
|
||||
arch.custom_action.upgrade_system.no_updates=Güncelleme yok
|
||||
arch.custom_action.upgrade_system.pkgs=Aşağıdaki paketler yükseltilecek
|
||||
|
||||
Reference in New Issue
Block a user