From 502d9c8b9e19a29b980a49397ece49a973975686 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Tue, 5 Mar 2013 15:52:53 +0000 Subject: [PATCH] [entropy.client.package] add support for package.splitdebug.mask, see bug 3707 --- conf/packages/package.splitdebug.mask.example | 25 ++++++++++ lib/entropy/client/interfaces/package.py | 50 ++++++++++++++----- lib/entropy/core/settings/base.py | 24 +++++++-- 3 files changed, 83 insertions(+), 16 deletions(-) create mode 100644 conf/packages/package.splitdebug.mask.example diff --git a/conf/packages/package.splitdebug.mask.example b/conf/packages/package.splitdebug.mask.example new file mode 100644 index 000000000..1bb5f974a --- /dev/null +++ b/conf/packages/package.splitdebug.mask.example @@ -0,0 +1,25 @@ +# package.splitdebug example file +# +# In this file you can specify dependencies, one per line, for which you +# would like to have the splitdebug feature turned off. This means that +# if at least one valid entry is listed here, the installation of +# /usr/lib/debug files will be disabled only for it. +# These entries take the precedence over package.splitdebug. This +# configuration file can be used to create a blacklist (while +# package.splitdebug can be used to create a whitelist). + +# LINE CONSTRUCTION: +# +# See examples below +# NOTE: for inline comments, please use "##" instead of "#" + +# EXAMPLES: +# >=media-libs/foo-1.2.3 +# media-libs/foo +# =media-libs/foo-1.2.3#2.6.23-sabayon-r1 +# media-libs/foo::sabayon-repo +# +# :1 means package with SLOT="1" +# #2.6.23-sabayon-r1 means package with kernel tag = 2.6.23-sabayon-r1 diff --git a/lib/entropy/client/interfaces/package.py b/lib/entropy/client/interfaces/package.py index 987678881..f019a47c0 100644 --- a/lib/entropy/client/interfaces/package.py +++ b/lib/entropy/client/interfaces/package.py @@ -4297,24 +4297,20 @@ class Package: # generate metadata dictionary self._generate_metadata() - @staticmethod - def splitdebug_enabled(entropy_client, pkg_match): + @classmethod + def splitdebug_enabled(cls, entropy_client, pkg_match): """ Return whether splitdebug is enabled for package. """ settings = entropy_client.Settings() # this is a SystemSettings.CachingList object - split_data = settings['splitdebug'] - if not split_data: - # no entries, consider splitdebug always enabled - return True + splitdebug = settings['splitdebug'] + splitdebug_mask = settings['splitdebug_mask'] - pkg_id, pkg_repo = pkg_match - pkg_matches = split_data.get() - if pkg_matches is None: + def _generate_cache(lst_obj): # compute the package matching then pkg_matches = set() - for dep in settings['splitdebug']: + for dep in lst_obj: dep, repo_ids = entropy.dep.dep_get_match_in_repos(dep) if repo_ids is not None: if pkg_repo not in repo_ids: @@ -4323,10 +4319,38 @@ class Package: dep_matches, rc = entropy_client.atom_match( dep, multi_match=True, multi_repo=True) pkg_matches |= dep_matches + # set cache back - split_data.set(pkg_matches) - # determine if it's enabled then - enabled = pkg_match in pkg_matches + lst_obj.set(pkg_matches) + return pkg_matches + + enabled = False + if not splitdebug: + # no entries, consider splitdebug always enabled + enabled = True + else: + # whitelist support + pkg_id, pkg_repo = pkg_match + pkg_matches = splitdebug.get() + + if pkg_matches is None: + pkg_matches = _generate_cache(splitdebug) + + # determine if it's enabled then + enabled = pkg_match in pkg_matches + + # if it's enabled, check whether it's blacklisted + if enabled: + # blacklist support + pkg_id, pkg_repo = pkg_match + pkg_matches = splitdebug_mask.get() + + if pkg_matches is None: + # compute the package matching + pkg_matches = _generate_cache(splitdebug_mask) + + enabled = pkg_match not in pkg_matches + return enabled def _package_splitdebug_enabled(self, pkg_match): diff --git a/lib/entropy/core/settings/base.py b/lib/entropy/core/settings/base.py index 6e0b0f585..697d05275 100644 --- a/lib/entropy/core/settings/base.py +++ b/lib/entropy/core/settings/base.py @@ -298,6 +298,8 @@ class SystemSettings(Singleton, EntropyPluginStore): # selectively enable splitdebug for packages 'splitdebug': os.path.join( packages_dir, "package.splitdebug"), + 'splitdebug_mask': os.path.join( + packages_dir, "package.splitdebug.mask"), # masking configuration files 'license_mask': os.path.join( packages_dir, "license.mask"), @@ -328,8 +330,9 @@ class SystemSettings(Singleton, EntropyPluginStore): 'keywords', 'unmask', 'mask', 'license_mask', 'license_accept', 'system_mask', 'system_package_sets', 'system_dirs', 'system_dirs_mask', 'extra_ldpaths', - 'splitdebug', 'system', 'system_rev_symlinks', 'hw_hash', - 'broken_syms', 'broken_libs_mask', 'broken_links_mask' + 'splitdebug', 'splitdebug_mask', 'system', + 'system_rev_symlinks', 'hw_hash', 'broken_syms', + 'broken_libs_mask', 'broken_links_mask' ]) self.__setting_files_pre_run.extend(['repositories']) @@ -931,7 +934,7 @@ class SystemSettings(Singleton, EntropyPluginStore): """ Parser returning packages for which the splitdebug feature should be enabled. Splitdebug is about installing /usr/lib/debug - files into system. If no entries are listed in here and + files into the system. If no entries are listed in here and splitdebug is enabled in client.conf, the feature will be considered enabled for any package. @@ -941,6 +944,21 @@ class SystemSettings(Singleton, EntropyPluginStore): return self.__generic_parser(self.__setting_files['splitdebug'], comment_tag = self.__pkg_comment_tag) + def _splitdebug_mask_parser(self): + """ + Parser returning packages for which the splitdebug feature + should be always disabled. This takes the precedence over + package.splitdebug. + Splitdebug is about installing /usr/lib/debug files into the system. + If no entries are listed in here and splitdebug is enabled in + client.conf, the feature will be considered enabled for any package. + + @return: parsed metadata + @rtype: dict + """ + return self.__generic_parser(self.__setting_files['splitdebug_mask'], + comment_tag = self.__pkg_comment_tag) + def _license_mask_parser(self): """ Parser returning packages masked by license metadata read from