5e1278ff0a
If e.g. /bin is a symbolic link, it is canonicalized into /usr/bin, so packages get auto-generated dependencies on paths like /usr/bin/sh and /usr/sbin/blkid. Here is an example error message: The following packages have unmet dependencies: chrooted: Depends: /usr/bin/sh but it is not installable PreDepends: /usr/bin/sh but it is not installable E: Broken packages hsh-install: Failed to calculate package file list. hsh-install: Failed to generate package file list. Try to work around this by replacing the current sorta-canonicalization written in shell with a small C program which implements an algorithm akin to realpath. It deviates from `realpath` and `readlink -e` in 3 following ways: * it allows all path components to be missing, like `readlink -m` and like the previous CanonPath impl); * it ignores the last path component even if it is present, like the previous CanonPath impl; * it reserves the right to not follow some symlinks as each path component is traversed: if the component is a symbolic link and is present in the ignore-list (we set it to /bin and /sbin for now), the link is not followed. Here are some observations on a merged-usr system: bash-5.2# readlink -vm -- /bin/sh /usr/bin/sh5 bash-5.2# /bin/sh -ec '. /usr/lib/rpm/functions; CanonPath /bin/sh' /usr/bin/sh bash-5.2# /usr/lib/rpm/remappath2 '/bin:/sbin' /bin/sh /bin/sh bash-5.2# readlink -vm -- /bin/ping /usr/libexec/ping/ping bash-5.2# /bin/sh -ec '. /usr/lib/rpm/functions; CanonPath /bin/ping' /usr/bin/ping bash-5.2# /usr/lib/rpm/remappath2 '/bin:/sbin' /bin/ping /bin/ping bash-5.2# readlink -vm -- /sbin/blkid /usr/sbin/blkid bash-5.2# /bin/sh -ec '. /usr/lib/rpm/functions; CanonPath /sbin/blkid' /usr/sbin/blkid bash-5.2# /usr/lib/rpm/remappath2 '/bin:/sbin' /sbin/blkid /sbin/blkid Also, explicitly add -D_FILE_OFFSET_BITS=64 to the remappath2 tool's cflags.