Skip to content

Commit

Permalink
rpcaptcache: Introduce removeprefix for get_fileindex
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Kurt Kanzenbach <[email protected]>
  • Loading branch information
Bastian Germann committed Feb 21, 2023
1 parent 3bfd726 commit aa6d55e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions elbepack/rpcaptcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,21 @@ def get_installed_pkgs(self, section='all'):
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

Expand Down

0 comments on commit aa6d55e

Please sign in to comment.