Blame SOURCES/0002-versionlock-fix-multi-pkg-lock-RhBug2013324.patch

74214d
From e289904dcd9c93ad8e1c3b01878599e9d65fa2cc Mon Sep 17 00:00:00 2001
74214d
From: Nicola Sella <nsella@redhat.com>
74214d
Date: Mon, 1 Nov 2021 18:29:40 +0100
74214d
Subject: [PATCH] [versionlock] fix multi pkg lock (RhBug:2013324)
74214d
74214d
= changelog =
74214d
msg: [versionlock] Fix: Multiple package-name-spec arguments don't lock
74214d
correctly (RhBug:2001039)
74214d
type: bugfix
74214d
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2013324
74214d
---
74214d
 plugins/versionlock.py | 57 +++++++++++++++++++++++++++++++++------------------------
74214d
 1 file changed, 33 insertions(+), 24 deletions(-)
74214d
74214d
diff --git a/plugins/versionlock.py b/plugins/versionlock.py
74214d
index 19fbd8c..32c51da 100644
74214d
--- a/plugins/versionlock.py
74214d
+++ b/plugins/versionlock.py
74214d
@@ -171,25 +171,27 @@ class VersionLockCommand(dnf.cli.Command):
74214d
                 cmd = self.opts.subcommand
74214d
 
74214d
         if cmd == 'add':
74214d
-            (entry, entry_cmd) = _search_locklist(self.opts.package)
74214d
-            if entry == '':
74214d
-                _write_locklist(self.base, self.opts.package, self.opts.raw, True,
74214d
-                                "\n# Added lock on %s\n" % time.ctime(),
74214d
-                                ADDING_SPEC, '')
74214d
-            elif cmd != entry_cmd:
74214d
-                raise dnf.exceptions.Error(ALREADY_EXCLUDED.format(entry))
74214d
-            else:
74214d
-                logger.info("%s %s", EXISTING_SPEC, entry)
74214d
+            results = _search_locklist(self.opts.package)
74214d
+            for entry, entry_cmd in results:
74214d
+                if entry_cmd == '':
74214d
+                    _write_locklist(self.base, [entry], self.opts.raw, True,
74214d
+                                    "\n# Added lock on %s\n" % time.ctime(),
74214d
+                                    ADDING_SPEC, '')
74214d
+                elif cmd != entry_cmd:
74214d
+                    raise dnf.exceptions.Error(ALREADY_EXCLUDED.format(entry))
74214d
+                else:
74214d
+                    logger.info("%s %s", EXISTING_SPEC, entry)
74214d
         elif cmd == 'exclude':
74214d
-            (entry, entry_cmd) = _search_locklist(self.opts.package)
74214d
-            if entry == '':
74214d
-                _write_locklist(self.base, self.opts.package, self.opts.raw, False,
74214d
-                                "\n# Added exclude on %s\n" % time.ctime(),
74214d
-                                EXCLUDING_SPEC, '!')
74214d
-            elif cmd != entry_cmd:
74214d
-                raise dnf.exceptions.Error(ALREADY_LOCKED.format(entry))
74214d
-            else:
74214d
-                logger.info("%s %s", EXISTING_SPEC, entry)
74214d
+            results = _search_locklist(self.opts.package)
74214d
+            for entry, entry_cmd in results:
74214d
+                if entry_cmd == '':
74214d
+                    _write_locklist(self.base, [entry], self.opts.raw, False,
74214d
+                                    "\n# Added exclude on %s\n" % time.ctime(),
74214d
+                                    EXCLUDING_SPEC, '!')
74214d
+                elif cmd != entry_cmd:
74214d
+                    raise dnf.exceptions.Error(ALREADY_LOCKED.format(entry))
74214d
+                else:
74214d
+                    logger.info("%s %s", EXISTING_SPEC, entry)
74214d
         elif cmd == 'list':
74214d
             for pat in _read_locklist():
74214d
                 print(pat)
74214d
@@ -237,14 +239,21 @@ def _read_locklist():
74214d
 
74214d
 
74214d
 def _search_locklist(package):
74214d
+    results = []
74214d
     found = action = ''
74214d
     locked_specs = _read_locklist()
74214d
-    for ent in locked_specs:
74214d
-        if _match(ent, package):
74214d
-            found = ent
74214d
-            action = 'exclude' if ent.startswith('!') else 'add'
74214d
-            break
74214d
-    return (found, action)
74214d
+    for pkg in package:
74214d
+        match = False
74214d
+        for ent in locked_specs:
74214d
+            found = action = ''
74214d
+            if _match(ent, [pkg]):
74214d
+                found = ent
74214d
+                action = 'exclude' if ent.startswith('!') else 'add'
74214d
+                results.append((found, action))
74214d
+                match = True
74214d
+        if not match:
74214d
+            results.append((pkg, action))
74214d
+    return results
74214d
 
74214d
 
74214d
 def _write_locklist(base, args, raw, try_installed, comment, info, prefix):
74214d
--
74214d
libgit2 1.1.0
74214d