With the release of debian 12 that includes the usrmerge, this now breaks a lot of docker containers (see https://github.com/docker-library/official-images/pull/14960) that have the following pattern:
1) save list of manual installed packages (saved=$(apt-mark showmanual)) 2) install dev packages 3) restore list of manual installed packages (apt mark auto '.*'; apt mark manual $saved) 4) compile && install stuff 5) use ldd + dpkg-query -S to find packages containing library dependencies 6) mark these packages as manual installed (apt-mark manual $dependencies) 7) purge all packages only needed for compile (apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false) Reading through the existing comments here, I understand the issues (performance, not wanting to hardcode path mapping etc) .. but I think I have come up with a possible solution that should (hopefully) satisfy all: I propose to introduce a third matching mode (besides the existing path and pattern matching modes): realpath. This mode can only be triggered by adding the "--realpath" argument. The pseudo code for this mode looks like this: 1) try to lookup by given path; if found => return results; 2) if not found; try to lookup by realpath(givenpath); if found => return results; 3) if not found; do pattern lookup with the following pattern: "*/" + filename(realpath(givenpath)) 4) filter the results to only include the paths where realpath(foundpath) == realpath(givenpath) 5) return results Alternatively we could skip step 1&2 and directly start with the pattern lookup; but that depends on the costs of those lookups and the benefits of those early exits. This way the performance of the existing modes is not affected and you minimize the performance impact of the realpath calls by limiting it to a pattern where the filename matches the filename of the realpath. If there is interest in this; I could allocate some time to have a look at the implementation of this. -- Kind regards, Eric de Ruiter

