Use realpath of pacman cache directory
Despite the existence of CacheDir in pacman.conf, people insist on changing /var/cache/pacman/pkg/ to a symlink. Then the next time they update pacman they get the following when the symlink gets removed:
error: could not open file /var/cache/pacman/pkg/pacman-5.2.2-4-x86_64.pkg.tar.zst: No such file or directory
To avoid this, we should evaluate the realpath of any specified cache dir and use that throughout the transaction. This will not avoid the symlink being replaced with a directory, but it will ensure the transaction completes.
Flyspray references: