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