#539133 dpkg: --predep-package doesn't handle dependencies of pre-dependencies

Package:
dpkg
Source:
dpkg
Description:
Debian package management system
Submitter:
Colin Watson
Date:
2015-08-21 19:42:04 UTC
Severity:
normal
#539133#5
Date:
2009-07-29 10:11:15 UTC
From:
To:
'dpkg --predep-package' can output pre-dependencies that are not
installable without also installing some other dependencies. This causes
problems for debootstrap which now uses --predep-package to help resolve
pre-dependencies of included packages that aren't in Priority: required.
(Ian said at DebConf that it was OK for debootstrap to use this, and
furthermore that the problem I'm seeing is a bug in --predep-package
that he'd like to fix.)

It's not entirely clear to me what the correct fix is, given the
possibility of circular Depends. I suspect that --predep-package needs
to output multiple Packages stanzas in some cases; this in turn would
require fixes in /usr/lib/dpkg/methods/disk/install since it expects
only a single stanza at the moment.

The attached available and status files demonstrate the problem. With
these, 'dpkg --predep-package' prints the Packages stanza for xml-core
(due to a Pre-Depends from docbook-xml), which depends on sgml-base
which is not installed.

If you want a more real-world reproduction case, see #487908 and use
revision 59820 of
svn://svn.debian.org/svn/d-i/trunk/packages/debootstrap with the
attached patch applied to remove the workaround I applied for this bug.
You can then run, as root:

  DEBOOTSTRAP_DIR=`pwd` ./debootstrap --include docbook-xml sid /chroot/dtest http://ftp.debian.org/debian `pwd`/scripts/debian/sid

The output will terminate with:

  W: Failure trying to run: chroot /chroot/dtest dpkg --force-overwrite --force-confold --skip-same-version --install /var/cache/apt/archives/xml-core_0.12_all.deb

By the way, I realise that this is a little-used feature of dpkg and
indeed that it's marked internal. However, it was remarkably useful to
avoid having to write a Pre-Depends resolver in debootstrap, so I'd
really appreciate it if it kept working!

Thanks,

#539133#10
Date:
2009-08-25 19:17:36 UTC
From:
To:
tags 539133 + patch
thanks

[This message was written a few weeks ago on a train and I'm just
 sending it now, having dug it out ...]

I have investigated #539133 and I think the patch below should fix it.

The previous algorithm for --predep-package made a number of
assumptions about the dependency structure which are no longer even
nearly true.  In particular, it assumed that no package would
Pre-Depend on an other package which would Depend on anything in
circumstances where this would matter.  Nowadays we even have Depends
cycles amongst the packages required to be configured for satisfying a
Pre-Depends and suchlike complications.  For example:
  docbook-xml P xml-core D sgml-base D perl D perl-modules D perl D libgdbm3
where P = Pre-Depends and D = Depends.

As a result of this it is no longer possible to satisfy
pre-dependencies by installing a single package at a time.  In the
example above, at the very least perl and perl-modules must be
configured in the same dpkg run to allow dpkg's dependency cyle
breaker to operate.

Therefore this revised --predep-package function can print _several_
Packages file stanzas.  If this happens you should feed dpkg _all_ of
the relevant .debs.

To avoid having to write a proper cycle detector I have made the
entirely arbitrary assumption that no more that 20 levels of
dependency (before cycles) will be relevant to a pre-dependency.  If
we exceed this limit someone should be shot.

This patch is against dpkg 1.14.25 (sorry).  I have tested it with the
test case available and status files supplied by Colin in the bug
report and also with a few other simple situations.

The arrangements with the goto in depcon.c are rather ugly; I wouldn't
really want to do it like that but I didn't want to make the match
more textually intrusive.  It would be better to do something like
  enum istobes depended_istobe(...appropriate arguments...) {
    if (itb == itb_preinstall)
      return dep->type == dep_predepends ? itb_normal : itb_installnew;
    return itb;
  }
and then call that in each of the two relevant places,
instead of switching directly on possi->ed->clientdata->istobe
and provider->up->up->clientdata->istobe.

Ian.

#539133#17
Date:
2009-08-25 21:07:48 UTC
From:
To:
Hi!

It seems you attached a patch for another package.

regards,
guillem

#539133#22
Date:
2009-10-25 16:26:18 UTC
From:
To:
tag 539133 - patch
thanks

Hi!

Removing the tag for now.

thanks,
guillem

#539133#29
Date:
2015-08-21 19:38:27 UTC
From:
To:
In 2009 it seems I attached the wrong file to my email.  Here is the
right file.