diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7fd00697..9d503cac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,6 +25,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Debian
- install: installation/download sizes order (to follow the upgrade dialog order)
- uninstall: dependencies dialog size
+ - settings: new property to enable "purge" as the default removal method
+
+
+
+
- General
- code refactoring
diff --git a/README.md b/README.md
index faa24bac..a2e6954c 100644
--- a/README.md
+++ b/README.md
@@ -305,6 +305,7 @@ prefer_repository_provider: true # when there is just one repository provider f
- `sync_pkgs.time`: time period (**in minutes**) in which the packages synchronization must be done on startup (default: `1440` -> 24 hours)
- `suggestions.exp`: it defines the period (**in hours**) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them.
- `pkg_sources.app`: it defines the application for managing the software sources. A `null` value detects one of the supported applications automatically.
+ - `remove.purge`: if the package configurations should be removed during the uninstallation process (purge). Default: false.
##### Flatpak
diff --git a/bauh/gems/debian/config.py b/bauh/gems/debian/config.py
index c2307ca1..1369d248 100644
--- a/bauh/gems/debian/config.py
+++ b/bauh/gems/debian/config.py
@@ -12,5 +12,6 @@ class DebianConfigManager(YAMLConfigManager):
'suggestions.exp': 24, # hours
'index_apps.exp': 1440, # 24 hours
'sync_pkgs.time': 1440, # 24 hours
- 'pkg_sources.app': None
+ 'pkg_sources.app': None,
+ 'remove.purge': False
}
diff --git a/bauh/gems/debian/controller.py b/bauh/gems/debian/controller.py
index 11c905f2..933893d6 100644
--- a/bauh/gems/debian/controller.py
+++ b/bauh/gems/debian/controller.py
@@ -59,12 +59,20 @@ class DebianPackageManager(SoftwareManager, SettingsController):
self._apps_index = {app.name: app for app in apps} if apps else dict()
def search(self, words: str, disk_loader: Optional[DiskCacheLoader], limit: int, is_url: bool) -> SearchResult:
+ config_ = dict()
+ fill_config = Thread(target=self._fill_config, args=(config_,))
+ fill_config.start()
+
res = SearchResult.empty()
if not is_url:
for pkg in self.aptitude.search(words):
if pkg.installed:
+ if fill_config.is_alive():
+ fill_config.join()
+
pkg.bind_app(self.apps_index.get(pkg.name))
+ pkg.global_purge = bool(config_.get('remove.purge', False))
res.installed.append(pkg)
else:
res.new.append(pkg)
@@ -86,21 +94,32 @@ class DebianPackageManager(SoftwareManager, SettingsController):
if line_clean:
output.add(line_clean)
+ def _fill_config(self, config_: dict):
+ config_.update(self.configman.get_config())
+
def read_installed(self, disk_loader: Optional[DiskCacheLoader], pkg_types: Optional[Set[Type[SoftwarePackage]]],
internet_available: bool, limit: int = -1, only_apps: bool = False,
names: Optional[Iterable[str]] = None) -> SearchResult:
+ config_ = dict()
+ fill_config = Thread(target=self._fill_config, args=(config_,))
+ fill_config.start()
+
ignored_updates = set()
fill_ignored_updates = Thread(target=self._fill_ignored_updates, args=(ignored_updates,))
fill_ignored_updates.start()
+ threads = (fill_config, fill_ignored_updates)
+
res = SearchResult(installed=[], new=None, total=0)
for pkg in self.aptitude.read_installed():
- if fill_ignored_updates.is_alive():
- fill_ignored_updates.join()
+ for t in threads:
+ if t.is_alive():
+ t.join()
pkg.bind_app(self.apps_index.get(pkg.name))
+ pkg.global_purge = bool(config_.get('remove.purge', False))
pkg.updates_ignored = bool(ignored_updates and pkg.name in ignored_updates)
res.installed.append(pkg)
@@ -128,9 +147,12 @@ class DebianPackageManager(SoftwareManager, SettingsController):
def uninstall(self, pkg: DebianPackage, root_password: str, watcher: ProcessWatcher,
disk_loader: Optional[DiskCacheLoader], purge: bool = False) -> TransactionResult:
+ config_ = self.configman.get_config()
+ purge_ = purge or config_.get('remove.purge', False)
+
watcher.change_substatus(self._i18n['debian.simulate_operation'])
- transaction = self.aptitude.simulate_removal((pkg.name,), purge=purge)
+ transaction = self.aptitude.simulate_removal((pkg.name,), purge=purge_)
if not transaction or not transaction.to_remove:
return TransactionResult.fail()
@@ -176,7 +198,7 @@ class DebianPackageManager(SoftwareManager, SettingsController):
to_remove = tuple(p.name for p in transaction.to_remove)
with self.output_handler.start(watcher=watcher, targets=to_remove, action=AptitudeAction.REMOVE) as handle:
removed, _ = handler.handle_simple(self.aptitude.remove(packages=to_remove, root_password=root_password,
- purge=purge),
+ purge=purge_),
output_handler=handle)
if not removed:
@@ -569,9 +591,22 @@ class DebianPackageManager(SoftwareManager, SettingsController):
Popen(final_cmd, shell=True)
def get_settings(self) -> Optional[Generator[SettingsView, None, None]]:
- deb_config = self.configman.get_config()
+ config_ = self.configman.get_config()
- sources_app = deb_config.get('pkg_sources.app')
+ purge_opts = [InputOption(label=self._i18n['yes'].capitalize(), value=True),
+ InputOption(label=self._i18n['no'].capitalize(), value=False)]
+
+ purge_current = tuple(o for o in purge_opts if o.value == bool(config_['remove.purge']))[0]
+ sel_purge = SingleSelectComponent(id_='remove.purge',
+ label=self._i18n['debian.config.remove.purge'],
+ tooltip=self._i18n['debian.config.remove.purge.tip'],
+ options=purge_opts,
+ default_option=purge_current,
+ type_=SelectViewType.RADIO,
+ max_width=200,
+ max_per_line=2)
+
+ sources_app = config_.get('pkg_sources.app')
if isinstance(sources_app, str) and sources_app not in self.known_sources_apps:
self._log.warning(f"'pkg_sources.app' ({sources_app}) is not supported. A 'None' value will be considered")
@@ -592,10 +627,10 @@ class DebianPackageManager(SoftwareManager, SettingsController):
max_width=200)
try:
- app_cache_exp = int(deb_config.get('index_apps.exp', 0))
+ app_cache_exp = int(config_.get('index_apps.exp', 0))
except ValueError:
self._log.error(f"Unexpected value form Debian configuration property 'index_apps.exp': "
- f"{deb_config['index_apps.exp']}. Zero (0) will be considered instead.")
+ f"{config_['index_apps.exp']}. Zero (0) will be considered instead.")
app_cache_exp = 0
ti_index_apps_exp = TextInputComponent(id_='index_apps.exp',
@@ -605,9 +640,9 @@ class DebianPackageManager(SoftwareManager, SettingsController):
max_width=60)
try:
- sync_pkgs_time = int(deb_config.get('sync_pkgs.time', 0))
+ sync_pkgs_time = int(config_.get('sync_pkgs.time', 0))
except ValueError:
- self._log.error(f"Unexpected value form Debian configuration property 'sync_pkgs.time': {deb_config['sync_pkgs.time']}. "
+ self._log.error(f"Unexpected value form Debian configuration property 'sync_pkgs.time': {config_['sync_pkgs.time']}. "
f"Zero (0) will be considered instead.")
sync_pkgs_time = 0
@@ -618,9 +653,9 @@ class DebianPackageManager(SoftwareManager, SettingsController):
max_width=60)
try:
- suggestions_exp = int(deb_config.get('suggestions.exp', 0))
+ suggestions_exp = int(config_.get('suggestions.exp', 0))
except ValueError:
- self._log.error(f"Unexpected value form Debian configuration property 'suggestions.exp': {deb_config['suggestions.exp']}. "
+ self._log.error(f"Unexpected value form Debian configuration property 'suggestions.exp': {config_['suggestions.exp']}. "
f"Zero (0) will be considered instead.")
suggestions_exp = 0
@@ -630,7 +665,8 @@ class DebianPackageManager(SoftwareManager, SettingsController):
value=str(suggestions_exp), only_int=True,
max_width=60)
- panel = PanelComponent([FormComponent([input_sources, ti_sync_pkgs, ti_index_apps_exp, ti_suggestions_exp])])
+ panel = PanelComponent([FormComponent([input_sources, sel_purge, ti_sync_pkgs, ti_index_apps_exp,
+ ti_suggestions_exp])])
yield SettingsView(self, panel)
def save_settings(self, component: PanelComponent) -> Tuple[bool, Optional[List[str]]]:
@@ -638,7 +674,8 @@ class DebianPackageManager(SoftwareManager, SettingsController):
container = component.get_component_by_idx(0, FormComponent)
- for prop, type_ in {'pkg_sources.app': SingleSelectComponent,
+ for prop, type_ in {'remove.purge': SingleSelectComponent,
+ 'pkg_sources.app': SingleSelectComponent,
'index_apps.exp': TextInputComponent,
'sync_pkgs.time': TextInputComponent,
'suggestions.exp': TextInputComponent}.items():
diff --git a/bauh/gems/debian/model.py b/bauh/gems/debian/model.py
index 1a0716e1..a4188843 100644
--- a/bauh/gems/debian/model.py
+++ b/bauh/gems/debian/model.py
@@ -39,26 +39,27 @@ class DebianApplication:
class DebianPackage(SoftwarePackage):
- __actions: Optional[Tuple[CustomSoftwareAction]] = None
+ __actions_purge: Optional[Tuple[CustomSoftwareAction, ...]] = None
@classmethod
- def custom_actions(cls) -> Tuple[CustomSoftwareAction]:
- if cls.__actions is None:
- cls.__actions = ((CustomSoftwareAction(i18n_label_key='debian.action.purge',
- i18n_status_key='debian.action.purge.status',
- i18n_description_key='debian.action.purge.desc',
- icon_path=resource.get_path('img/clean.svg', ROOT_DIR),
- manager_method='purge',
- requires_root=True,
- requires_confirmation=False),))
+ def actions_purge(cls) -> Tuple[CustomSoftwareAction, ...]:
+ if cls.__actions_purge is None:
+ cls.__actions_purge = (CustomSoftwareAction(i18n_label_key='debian.action.purge',
+ i18n_status_key='debian.action.purge.status',
+ i18n_description_key='debian.action.purge.desc',
+ icon_path=resource.get_path('img/clean.svg', ROOT_DIR),
+ manager_method='purge',
+ requires_root=True,
+ requires_confirmation=False),)
- return cls.__actions
+ return cls.__actions_purge
def __init__(self, name: str = None, version: Optional[str] = None, latest_version: Optional[str] = None,
description: Optional[str] = None, maintainer: Optional[str] = None, installed: bool = False,
update: bool = False, app: Optional[DebianApplication] = None, compressed_size: Optional[int] = None,
uncompressed_size: Optional[int] = None, categories: Tuple[str] = None,
- updates_ignored: Optional[bool] = None, transaction_size: Optional[float] = None):
+ updates_ignored: Optional[bool] = None, transaction_size: Optional[float] = None,
+ global_purge: bool = False):
super(DebianPackage, self).__init__(id=name, name=name, version=version, installed=installed,
description=description, update=update,
latest_version=latest_version if latest_version is not None else version)
@@ -70,6 +71,7 @@ class DebianPackage(SoftwarePackage):
self.bind_app(app)
self.updates_ignored = updates_ignored
self.transaction_size = transaction_size # size in bytes related to a transaction (install, upgrade, remove)
+ self.global_purge = global_purge # if global purge is already enabled
def bind_app(self, app: Optional[DebianApplication]):
self.app = app
@@ -121,8 +123,8 @@ class DebianPackage(SoftwarePackage):
return self.app.icon_path
def get_custom_actions(self) -> Optional[Iterable[CustomSoftwareAction]]:
- if self.installed:
- return self.custom_actions()
+ if self.installed and not self.global_purge:
+ return self.actions_purge()
def is_update_ignored(self) -> bool:
return bool(self.updates_ignored)
diff --git a/bauh/gems/debian/resources/locale/ca b/bauh/gems/debian/resources/locale/ca
index 299e9c93..efbe7fc8 100644
--- a/bauh/gems/debian/resources/locale/ca
+++ b/bauh/gems/debian/resources/locale/ca
@@ -19,6 +19,8 @@ debian.config.index_apps.exp.tip=Time period in MINUTES in which the installed a
debian.config.pkg_sources.app=Software sources
debian.config.pkg_sources.app.tip=Application for managing the software sources. {auto} detects one of the supported applications automatically.
debian.config.pkg_sources.app.auto=Auto
+debian.config.remove.purge=Complete removal
+debian.config.remove.purge.tip=If the package configurations should be removed during the uninstallation process
debian.config.suggestions.exp=Suggestions expiration
debian.config.suggestions.exp.tip=It defines the period (in hours) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them.
debian.config.sync_pkgs.time=Packages synchronization period
diff --git a/bauh/gems/debian/resources/locale/de b/bauh/gems/debian/resources/locale/de
index 402fb90c..1adcd6f7 100644
--- a/bauh/gems/debian/resources/locale/de
+++ b/bauh/gems/debian/resources/locale/de
@@ -19,6 +19,8 @@ debian.config.index_apps.exp.tip=Time period in MINUTES in which the installed a
debian.config.pkg_sources.app=Software sources
debian.config.pkg_sources.app.tip=Application for managing the software sources. {auto} detects one of the supported applications automatically.
debian.config.pkg_sources.app.auto=Auto
+debian.config.remove.purge=Complete removal
+debian.config.remove.purge.tip=If the package configurations should be removed during the uninstallation process
debian.config.suggestions.exp=Suggestions expiration
debian.config.suggestions.exp.tip=It defines the period (in hours) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them.
debian.config.sync_pkgs.time=Packages synchronization period
diff --git a/bauh/gems/debian/resources/locale/en b/bauh/gems/debian/resources/locale/en
index 402fb90c..401e485a 100644
--- a/bauh/gems/debian/resources/locale/en
+++ b/bauh/gems/debian/resources/locale/en
@@ -3,7 +3,7 @@ debian.action.index_apps.desc=Identifies all installed packages associated with
debian.action.purge=Remove completely
debian.action.purge.confirmation=The complete removal of {pkg} will erase the software files and also the configuration ones
debian.action.purge.desc=Removes all software and configuration files associated with the package
-debian.action.purge.status=Removing {} completely
+debian.action.purge.status=Removing {} completelydebian.config.pkg_sources.app.auto=
debian.action.sync_pkgs=Synchronize packages
debian.action.sync_pkgs.desc=Synchronizes the available software packages on the repositories
debian.action.sync_pkgs.status=Synchronizing packages
@@ -19,6 +19,8 @@ debian.config.index_apps.exp.tip=Time period in MINUTES in which the installed a
debian.config.pkg_sources.app=Software sources
debian.config.pkg_sources.app.tip=Application for managing the software sources. {auto} detects one of the supported applications automatically.
debian.config.pkg_sources.app.auto=Auto
+debian.config.remove.purge=Complete removal
+debian.config.remove.purge.tip=If the package configurations should be removed during the uninstallation process
debian.config.suggestions.exp=Suggestions expiration
debian.config.suggestions.exp.tip=It defines the period (in hours) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them.
debian.config.sync_pkgs.time=Packages synchronization period
diff --git a/bauh/gems/debian/resources/locale/es b/bauh/gems/debian/resources/locale/es
index 149c4989..0bfde98a 100644
--- a/bauh/gems/debian/resources/locale/es
+++ b/bauh/gems/debian/resources/locale/es
@@ -19,6 +19,8 @@ debian.config.index_apps.exp.tip=Periodo de tiempo en MINUTOS en que el cache de
debian.config.pkg_sources.app=Fuentes de software
debian.config.pkg_sources.app.tip=Aplicación para administrar las fuentes de software. {auto} detecta una de las aplicaciones compatibles automáticamente.
debian.config.pkg_sources.app.auto=Auto
+debian.config.remove.purge=Eliminación completa
+debian.config.remove.purge.tip=Si las configuraciones del paquete deben ser eliminadas durante el proceso de desinstalación
debian.config.suggestions.exp=Expiración de sugerencias
debian.config.suggestions.exp.tip=Define el período (en horas) en el que la sugerencias almacenadas en disco seran consideradas actualizadas. Use 0 si desea siempre actualizarlas.
debian.config.sync_pkgs.time=Período de sincronización de paquetes
diff --git a/bauh/gems/debian/resources/locale/fr b/bauh/gems/debian/resources/locale/fr
index 0a25b532..bfcf4b83 100644
--- a/bauh/gems/debian/resources/locale/fr
+++ b/bauh/gems/debian/resources/locale/fr
@@ -19,6 +19,8 @@ debian.config.index_apps.exp.tip=Time period in MINUTES in which the installed a
debian.config.pkg_sources.app=Software sources
debian.config.pkg_sources.app.tip=Application for managing the software sources. {auto} detects one of the supported applications automatically.
debian.config.pkg_sources.app.auto=Auto
+debian.config.remove.purge=Complete removal
+debian.config.remove.purge.tip=If the package configurations should be removed during the uninstallation process
debian.config.suggestions.exp=Suggestions expiration
debian.config.suggestions.exp.tip=It defines the period (in hours) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them.
debian.config.sync_pkgs.time=Packages synchronization period
diff --git a/bauh/gems/debian/resources/locale/it b/bauh/gems/debian/resources/locale/it
index 402fb90c..1adcd6f7 100644
--- a/bauh/gems/debian/resources/locale/it
+++ b/bauh/gems/debian/resources/locale/it
@@ -19,6 +19,8 @@ debian.config.index_apps.exp.tip=Time period in MINUTES in which the installed a
debian.config.pkg_sources.app=Software sources
debian.config.pkg_sources.app.tip=Application for managing the software sources. {auto} detects one of the supported applications automatically.
debian.config.pkg_sources.app.auto=Auto
+debian.config.remove.purge=Complete removal
+debian.config.remove.purge.tip=If the package configurations should be removed during the uninstallation process
debian.config.suggestions.exp=Suggestions expiration
debian.config.suggestions.exp.tip=It defines the period (in hours) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them.
debian.config.sync_pkgs.time=Packages synchronization period
diff --git a/bauh/gems/debian/resources/locale/pt b/bauh/gems/debian/resources/locale/pt
index bc7d4113..cb6276a2 100644
--- a/bauh/gems/debian/resources/locale/pt
+++ b/bauh/gems/debian/resources/locale/pt
@@ -19,6 +19,8 @@ debian.config.index_apps.exp.tip=Período de tempo em MINUTOS em que o cache das
debian.config.pkg_sources.app=Fontes de software
debian.config.pkg_sources.app.tip=Aplicação para gerenciamento de fontes de software. {auto} detecta uma das aplicações suportadas automaticamente.
debian.config.pkg_sources.app.auto=Auto
+debian.config.remove.purge=Remoção completa
+debian.config.remove.purge.tip=Se as configurações do pacote devem ser removidas durante o processo de desinstalação
debian.config.suggestions.exp=Validade de sugestões
debian.config.suggestions.exp.tip=Define o período (em horas) no qual as sugestões armazenadas em disco serão consideradas atualizadas. Use 0 se quiser que elas sempre sejam atualizadas.
debian.config.sync_pkgs.time=Período de sincronização de pacotes
diff --git a/bauh/gems/debian/resources/locale/ru b/bauh/gems/debian/resources/locale/ru
index 402fb90c..1adcd6f7 100644
--- a/bauh/gems/debian/resources/locale/ru
+++ b/bauh/gems/debian/resources/locale/ru
@@ -19,6 +19,8 @@ debian.config.index_apps.exp.tip=Time period in MINUTES in which the installed a
debian.config.pkg_sources.app=Software sources
debian.config.pkg_sources.app.tip=Application for managing the software sources. {auto} detects one of the supported applications automatically.
debian.config.pkg_sources.app.auto=Auto
+debian.config.remove.purge=Complete removal
+debian.config.remove.purge.tip=If the package configurations should be removed during the uninstallation process
debian.config.suggestions.exp=Suggestions expiration
debian.config.suggestions.exp.tip=It defines the period (in hours) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them.
debian.config.sync_pkgs.time=Packages synchronization period
diff --git a/bauh/gems/debian/resources/locale/tr b/bauh/gems/debian/resources/locale/tr
index 07da69a6..f4042c76 100644
--- a/bauh/gems/debian/resources/locale/tr
+++ b/bauh/gems/debian/resources/locale/tr
@@ -19,6 +19,8 @@ debian.config.index_apps.exp.tip=Time period in MINUTES in which the installed a
debian.config.pkg_sources.app=Software sources
debian.config.pkg_sources.app.tip=Application for managing the software sources. {auto} detects one of the supported applications automatically.
debian.config.pkg_sources.app.auto=Auto
+debian.config.remove.purge=Complete removal
+debian.config.remove.purge.tip=If the package configurations should be removed during the uninstallation process
debian.config.suggestions.exp=Suggestions expiration
debian.config.suggestions.exp.tip=It defines the period (in hours) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them.
debian.config.sync_pkgs.time=Packages synchronization period