[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Installing packages with a diverted hardlink


On Mon, 2011-04-18 at 13:41:32 +0200, Daniel Lobato wrote:
> Hi everyone! I am introducing myself to dpkg development and I am
> starting by trying to solve a bug, Steve Langasek purposed me to solve
> this old one http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=245322
> Basically the problem here is that once you have diverted the file
> (created with dpkg-divert /sbin/mkreiserfs in this particular case),
> dpkg is unable to unpack the package. I've been taking a look at the
> code at git://git.debian.org/git/dpkg/dpkg.git and I found that the
> error happens in
> "src/archives.c"
> error creating hardlink
> - its a case in a switch
> case tar_filetype_hardlink

You might want to provide a minimal test case for our functional test
suite at:


> So I've thought a workaround for this:
> > Dpkg could execute the command dpkg-divert --list | grep "thefile" and
> > if the file has been diverted, install it in the diverted location.
> > Problems? The only way that I know to save the output of that would be
> > by means of >, dpkg-divert --list | grep "thefile" > afiletolookin.
> > The main problem here would be that doing this for every single
> > package would result in a slower installation and hence in a worse
> > user experience, as creating a file , looking in it and deleting it is
> > a more or less 'costly' process.
> Unfortunately Steve told me that this is not feasible as dpkg should
> never call dpkg-divert; dpkg already has complete information about
> diverted files internally.

Well it would be feasible, but it would be wrong. :)

> He told me to take a look at the data structures within the dpkg code
> in order to find the information that dpkg is using currently to
> unpack the packages to diverted
> locations.


> So, after writing this long mail my question is.. if I cannot use
> dpkg-divert, where can I find in the code the information about what
> is doing dpkg when unpacking the packages to diverted locations? To
> solve this bug would be as simple as to look where is the diversion
> pointing to and unpack the package there, but it is a bit difficult to
> search for it in the code. So far I have been examining divertcmd.c,
> archives.c, errors.c with no avail. Any clues?

Check from src/filesdb.h “struct diversion”, src/help.c:namenodetouse()
and src/divertdb.c:ensure_diversions(). That should give you a start I

After skimming over the code, I think the fix is trivial, although
I've not verified this at all. So I'll let you guys to it. ;)


Reply to: