dpkg-realpath fails when /bin/sh isn't available

Currently, installing dash in debootstrap fails like this:

Setting up dash (0.5.11+git20210903+057cd650a4ed-4) ...
No diversion 'diversion of /bin/sh by bash', none removed.
Adding 'diversion of /bin/sh to /bin/sh.distrib by dash'
/var/lib/dpkg/info/dash.postinst: 24: dpkg-realpath: not found
dpkg: error processing package dash (--configure):
 installed dash package post-installation script subprocess returned error exit status 127

This is because dpkg-realpath is a script with /bin/sh shebang. When used inside replace_with_link then /bin/sh is unavailable. I fixed it here by running dpkg-realpath as /bin/dash /usr/bin/dpkg-realpath but another way to fix this would be to re-order the instructions and move the mv command further up and then touch the final file. Would you prefer that?

Secondly, the dpkg-realpath commit broke DPKG_ROOT support. The second commit in this MR fixes this.

Merge request reports

Loading