Re: dpkg, symlinks, directories
On 2012-09-29 12:47, Vincent Bernat wrote:
> ❦ 29 septembre 2012 12:35 CEST, Salvatore Bonaccorso <email@example.com> :
>>> In roundcube package, I am turning existing directories to symlinks and
>>> symlinks into directories. It seems that dpkg does not like that:
>>> symlinks are not replaced with the appropriate directories. I didn't
>>> find anything about this in the documentation. How should I handle such
>> This is indeed intentional, that dpkg never replaces directories with
>> symlinks if directory is present, see  and  (under 4.).
>> : http://bugs.debian.org/404850
>> : http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html#s-unpackphase
>> Andreas Beckmann recently is filling many of these bugs discovered by
>> piuparts runs (updating Squeeze -> Wheezy). Most common approach there
>> is to do the substitution in postinst, in case the directory is there.
>> See for example .
>> : http://bugs.debian.org/687859
>> Does this helps?
> Thanks for the pointers! I now understand why this does not
> work. Fixing in postinst is quite difficult since I have swapped
> symlinks and, from the bug reports, successive installs make the
> situation worst (things got installed in the wrong place).
> Well, I need to work a bit on this.
I think a working approach is:
* directory to symlink
fix it up in the postinst (at postinst, the directory should have
if [ -d $X ] && [ ! -L $X ]; then
rmdir $X # bombs if not empty
ln -s $target $X
* symlink to directory
remove symlinks in the preinst to avoid installing stuff at the wrong
test ! -L $X || rm $X
The whole process may not work properly on aborted upgrades (or even
downgrades, but these are not really supported anyway).