Helmut Grohne <hel...@subdivi.de> writes:

> Such concern is unwarranted. When dpkg unpacks a .deb, it unpacks all
> the files with a .dpkg-tmp suffix appended. Hence, we also get a file
> /usr/bin/mksh.dpkg-tmp. Once all of these are synced, it issues a
> sequence of renames, including rename(/usr/bin/mksh.dpkg-tmp,
> /usr/bin/mksh). This will atomically replace mksh even though it was
> formerly /bin/mksh (but the same file via aliasing). At no time will
> looking up /bin/mksh yield -ENOENT.

That part I understand, and it's why there was never a window without
/bin/mksh before all of the moves.  What I was worried about is that here,
dpkg thinks the old package *also* has a file named /bin/mksh.  Presumably
dpkg deletes the files that were present in the old package but not
present in the new package at some point.  If it does that before the
renames, wouldn't it delete /bin/mksh (which happens to also be
/usr/bin/mksh), outside of a rename?

However, thank you very much for the turnkey experiment:

> mmdebstrap bookworm /dev/null --variant=apt --include=strace 
> --customize-hook='sed -i -e s/bookworm/trixie/ "$1/etc/apt/sources.list"' 
> --chrooted-customize-hook='apt-get update && apt-get -y install libc6 && 
> apt-get download dash' --chrooted-customize-hook=bash

> In there, strace dpkg -i dash_*.deb.

I can confirm that dpkg never unlinks /bin/dash.  I'm not sure why, but
hopefully this means dpkg somehow figures this out.  It does stat that
file a couple of times, so maybe it derives some information from that.

> dh_movetousr has nothing to do with protective diversions. It does not
> add nor remove diversions nor does it change any. All it changes is
> locations of files in the data.tar of a .deb. All of the protective
> diversions that we ever installed for DEP17 are managed in maintainer
> scripts and dh_movetousr does not touch maintainer scripts at all.

Ah!  Thank you.

> Your reasoning makes sense to me. I do not intend to work on this
> matter, because I am not interested in changing /bin/sh.

Sure, no problem.  I'll file a bug against dash.

-- 
Russ Allbery (r...@debian.org)              <https://www.eyrie.org/~eagle/>

Reply via email to