[elbe-devel] [PATCH v2 1/2] rpcaptcache: Introduce removeprefix for get_fileindex
Bastian Germann
bage at linutronix.de
Tue Feb 21 09:52:47 CET 2023
Debian's UsrMerge causes files to show up with a /usr prefix or not,
depending on the actual package. For the comparison with the actually
installed files, removing /usr prefixes comes in handy.
Signed-off-by: Bastian Germann <bage at linutronix.de>
---
elbepack/rpcaptcache.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/elbepack/rpcaptcache.py b/elbepack/rpcaptcache.py
index 560fd01bab..2177498fc7 100644
--- a/elbepack/rpcaptcache.py
+++ b/elbepack/rpcaptcache.py
@@ -262,13 +262,21 @@ class RPCAPTCache(InChRootObject):
p.section == section and p.is_installed)]
return pl
- def get_fileindex(self):
+ def get_fileindex(self, removeprefix=None):
+ """
+ Returns a map filepath => packagename indexed by the filepath.
+ Use removeprefix to remove any prefix from the actual filepath.
+ """
index = {}
for p in self.cache:
if p.is_installed:
for f in p.installed_files:
- index[f] = p.name
+ if removeprefix and f.startswith(removeprefix):
+ unprefixed = f[len(removeprefix):]
+ else:
+ unprefixed = f
+ index[unprefixed] = p.name
return index
--
2.30.2
More information about the elbe-devel
mailing list