From 82d3e01bd4c884d55e53d846092d78f47844137b Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Wed, 19 Aug 2009 13:11:15 +0200 Subject: [PATCH] [entropy.spm] make SPM backend user configurable --- conf/entropy.conf | 15 +++++++++++++++ libraries/entropy/core.py | 15 +++++++++++---- libraries/entropy/spm/plugins/factory.py | 12 +++++++++++- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/conf/entropy.conf b/conf/entropy.conf index 9ba551348..79956e0e0 100644 --- a/conf/entropy.conf +++ b/conf/entropy.conf @@ -77,3 +77,18 @@ system-name|Sabayon Linux # # Entropy processes nice level # nice-level|0 + +# +# syntax for spm-backend: +# +# spm-backend: Change Entropy Source Package Manager backend interface. +# Currently supported is "portage". Pay attention to edit this +# parameter, it could cause your Entropy to fail loading! +# +# spm-backend|[supported backend identifier] +# +# example: +# spm-backend|portage +# +# Default SPM backend value: +# spm-backend|portage diff --git a/libraries/entropy/core.py b/libraries/entropy/core.py index 63ba12f7f..bd97dc4c1 100644 --- a/libraries/entropy/core.py +++ b/libraries/entropy/core.py @@ -1016,10 +1016,12 @@ class SystemSettings(Singleton): @rtype: dict """ - data = {} - data['proxy'] = etpConst['proxy'].copy() - data['name'] = etpConst['systemname'] - data['log_level'] = etpConst['entropyloglevel'] + data = { + 'proxy': etpConst['proxy'].copy(), + 'name': etpConst['systemname'], + 'log_level': etpConst['entropyloglevel'], + 'spm_backend': etpConst['spm']['backend'], + } etp_conf = self.__setting_files['system'] if not os.path.isfile(etp_conf) and \ @@ -1081,6 +1083,11 @@ class SystemSettings(Singleton): data['name'] = split_line[1].strip() + elif line.startswith("spm-backend|") and \ + (split_line_len == 2): + + data['spm_backend'] = split_line[1].strip() + elif line.startswith("nice-level|") and \ (split_line_len == 2): diff --git a/libraries/entropy/spm/plugins/factory.py b/libraries/entropy/spm/plugins/factory.py index aecf0a8eb..721e72d00 100644 --- a/libraries/entropy/spm/plugins/factory.py +++ b/libraries/entropy/spm/plugins/factory.py @@ -12,6 +12,8 @@ import os import sys from entropy.const import etpConst +from entropy.core import SystemSettings +from entropy.i18n import _ from entropy.spm.plugins.skel import SpmPlugin PLUGIN_SUFFIX = "_plugin" _AVAILABLE_CACHE = None @@ -70,10 +72,18 @@ def get_default_class(): """ Return currently configured Entropy Source Package Manager plugin class. """ - backend = etpConst['spm']['backend'] + settings = SystemSettings() + backend = settings['system'].get('spm_backend', etpConst['spm']['backend']) available = get_available_plugins() + klass = available.get(backend) + if klass is None: + import warnings + warnings.warn("%s: %s" % ( + _("selected SPM backend not available"), backend,)) + klass = available.get(etpConst['spm']['backend']) return available[backend] + def get_default_instance(output_interface): """ Return the currently configured Entropy SPM interface instance.