Blame SOURCES/BZ-1212519-exclude-installed.patch

d2a170
commit d875b67997356e7e1b4509607fec81ca8220c597
d2a170
Author: James Antill <james@and.org>
d2a170
Date:   Tue Mar 3 01:54:02 2015 -0500
d2a170
d2a170
    Add query_install_excludes conf./docs and use it for list/info/search/provides.
d2a170
d2a170
diff --git a/cli.py b/cli.py
d2a170
index f04fe63..cefc67e 100755
d2a170
--- a/cli.py
d2a170
+++ b/cli.py
d2a170
@@ -2299,7 +2299,8 @@ class YumOptionParser(OptionParser):
d2a170
             self.base.conf.disable_excludes = self._splitArg(opts.disableexcludes)
d2a170
             self.base.conf.disable_includes = self._splitArg(opts.disableincludes)
d2a170
 
d2a170
-            for exclude in self._splitArg(opts.exclude):
d2a170
+            self.base.cmdline_excludes = self._splitArg(opts.exclude)
d2a170
+            for exclude in self.base.cmdline_excludes:
d2a170
                 try:
d2a170
                     excludelist = self.base.conf.exclude
d2a170
                     excludelist.append(exclude)
d2a170
diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
d2a170
index e0f4c8b..62aa78e 100644
d2a170
--- a/docs/yum.conf.5
d2a170
+++ b/docs/yum.conf.5
d2a170
@@ -156,10 +156,20 @@ This is commonly used so a package isn't upgraded or installed accidentally, but
d2a170
 can be used to remove packages in any way that "yum list" will show packages.
d2a170
 Shell globs using wildcards (eg. * and ?) are allowed.
d2a170
 
d2a170
-Can be disabled using --disableexcludes.
d2a170
+Can be disabled using disable_excludes or --disableexcludes.
d2a170
 Command-line option: \fB\-x\fP
d2a170
 
d2a170
 .IP
d2a170
+\fBdisable_excludes\fR
d2a170
+A way to permanently set the --disableexcludes command line option.
d2a170
+
d2a170
+.IP
d2a170
+\fBquery_install_excludes\fR
d2a170
+This applies the command line exclude option (only, not the configuration
d2a170
+exclude above) to installed packages being shown in some query commands
d2a170
+(currently: list/info/search/provides).
d2a170
+
d2a170
+.IP
d2a170
 \fBinstallonlypkgs \fR
d2a170
 List of package provides that should only ever be installed, never updated.
d2a170
 Kernels in particular fall into this category. Defaults to kernel,
d2a170
diff --git a/output.py b/output.py
d2a170
index 2787d86..091b58e 100755
d2a170
--- a/output.py
d2a170
+++ b/output.py
d2a170
@@ -1330,6 +1330,13 @@ class YumOutput:
d2a170
         :param verbose: whether to output extra verbose information
d2a170
         :param highlight: highlighting options for the highlighted matches
d2a170
         """
d2a170
+        if (po.repo.id == "installed" and
d2a170
+            self.conf.query_install_excludes and self.cmdline_excludes):
d2a170
+            # Very similar to _cmdline_exclude from yumcommands
d2a170
+            e,m,u = yum.packages.parsePackages([po], self.cmdline_excludes)
d2a170
+            if e or m:
d2a170
+                return
d2a170
+
d2a170
         if self.conf.showdupesfromrepos:
d2a170
             msg = '%s : ' % po
d2a170
         else:
d2a170
diff --git a/yum/config.py b/yum/config.py
d2a170
index 02061ba..efe7be9 100644
d2a170
--- a/yum/config.py
d2a170
+++ b/yum/config.py
d2a170
@@ -821,6 +821,7 @@ class YumConf(StartupConf):
d2a170
     # XXX rpm_check_debug is unused, left around for API compatibility for now
d2a170
     rpm_check_debug = BoolOption(True)
d2a170
     disable_excludes = ListOption()    
d2a170
+    query_install_excludes = BoolOption(True)
d2a170
     skip_broken = BoolOption(False)
d2a170
     #  Note that "instant" is the old behaviour, but group:primary is very
d2a170
     # similar but better :).
d2a170
diff --git a/yumcommands.py b/yumcommands.py
d2a170
index e77d209..6fa11fa 100644
d2a170
--- a/yumcommands.py
d2a170
+++ b/yumcommands.py
d2a170
@@ -41,6 +41,7 @@ import errno
d2a170
 
d2a170
 import yum.config
d2a170
 from yum import updateinfo
d2a170
+from yum.packages import parsePackages
d2a170
 
d2a170
 def _err_mini_usage(base, basecmd):
d2a170
     if basecmd not in base.yum_cli_commands:
d2a170
@@ -584,6 +585,14 @@ def _list_cmd_calc_columns(base, ypl):
d2a170
     columns = base.calcColumns(data, remainder_column=1)
d2a170
     return (-columns[0], -columns[1], -columns[2])
d2a170
 
d2a170
+def _cmdline_exclude(pkgs, cmdline_excludes):
d2a170
+    """ Do an extra exclude for installed packages that match the cmd line. """
d2a170
+    if not cmdline_excludes:
d2a170
+        return pkgs
d2a170
+    e,m,u = parsePackages(pkgs, cmdline_excludes)
d2a170
+    excluded = set(e + m)
d2a170
+    return [po for po in pkgs if po not in excluded]
d2a170
+
d2a170
 class InfoCommand(YumCommand):
d2a170
     """A class containing methods needed by the cli to execute the
d2a170
     info command.
d2a170
@@ -682,6 +691,9 @@ class InfoCommand(YumCommand):
d2a170
             clin = base.conf.color_list_installed_newer
d2a170
             clir = base.conf.color_list_installed_reinstall
d2a170
             clie = base.conf.color_list_installed_extra
d2a170
+            if base.conf.query_install_excludes:
d2a170
+                ypl.installed = _cmdline_exclude(ypl.installed,
d2a170
+                                                 base.cmdline_excludes)
d2a170
             rip = base.listPkgs(ypl.installed, _('Installed Packages'), basecmd,
d2a170
                                 highlight_na=update_pkgs, columns=columns,
d2a170
                                 highlight_modes={'>' : clio, '<' : clin,