On måndagen den 9 maj 2011, you stated the following: > Hi, > > Yves-Alexis Perez wrote: > > as said on irc, it'd be nice if dpkg could handle package upgrade > > involving symlinks and directories a bit more nicely. > > See also [1], [2], and [3]. > > The intent of the current behavior is that the sysadmin is free to use > symlinks to cause files in one directory to appear on a different > partition, and dpkg will leave that alone rather than replacing it > with a directory. For symmetry, dpkg will not automatically replace a > directory with a symlink, either. > > Better semantics, implemented in maintainer scripts for many packages, > are: > > - after a directory changes to a symlink in the shipped package, > change the directory on disk to a symlink, if it is a directory and > is empty. If it is not empty, make a backup and then put a symlink > there. > > After a package has been unpacked, dpkg doesn't actually know which > files were originally directories or symlinks, so it can't currently > implement these semantics internally.
This symmetry argument doesn't strike me as very persuasive. The sysadmin may very well want to move a directory and put a symlink, pointing to the new location, in its place, but how often does one replace a symlink with a copy of the directory it points to? In the case that a package replaces a directory with a symlink, the package upgrade would normally leave us with an empty directory. I can't see how that could ever be considered the correct and desired result. Now, if there are unowned files or files from other packages in the directory it must of course not be removed - that's either something the sysadmin has to sort out, or an error. One technical problem seems to be that files which were in the old version of a package but not in the new are not removed until after the files in the new package have been unpacked (and after the point of no return; policy 6.6, step 5). dpkg will thus either have to determine ahead of that point what directories will disappear, or perform an extra step of replacing empty directories with symlinks. But in any case I don't think dpkg needs to know which files where previously directories but now should be symlinks. > - before a symlink changes to a directory in the shipped package, > check if there is a symlink to the shipped target there on disk. > If so, remove the symlink and replace it with a directory. (If > not, leave the symlink alone.) This opposite direction is clearly more complicated, but another sign that a symlink should be replaced with a separate directory is when otherwise files from different packages would overwrite each other. -- Magnus Holmgren holmg...@debian.org Debian Developer
signature.asc
Description: This is a digitally signed message part.