LWN.net Logo

Debian "sid" users beware of the dpkg 1.16.2 upload

From:  Guillem Jover <guillem-AT-debian.org>
To:  debian-devel-announce-AT-lists.debian.org
Subject:  Important information regarding upcoming dpkg 1.16.2 upload
Date:  Sat, 10 Mar 2012 09:35:39 +0100
Message-ID:  <20120310083539.GA15353@gaara.hadrons.org>
Archive-link:  Article, Thread

Hi,

I'll be uploading dpkg 1.16.2 targeting unstable, by the end of
this weekend or beginning of next week the latest (after some final
polishing). Some pretty important points follow, the first section
in particular.


On-disk db damage
-----------------

The previous multiarch in-core db layout was bogus, resulting in a
possible inconsistent or broken on-disk db. If you are running any
dpkg derived from code that has never been in the main git repo (this
includes dpkg from the jenkins test builds [T], dpkg from experimental,
dpkg from Ubuntu, one of the personal pu/ branches, etc), any of the
following might affect you.

  [T] <http://jenkins.grml.org/job/dpkg-test-source/>

With those dpkg versions, when installing a M-A:same instance of
package P arch A, when a previous non-M-A:same version of package P
arch B was present in a config-files state, the installation would
incorrectly remove the control files on the infodb for the arch B
instance. You should check for any packages in the status db w/o
matching files under /var/lib/dpkg/info/.

Another effect of the bogus in-core db layout affected the disappearing
logic, so if you have been running any such dpkg versions, you should
also check in the logs that no package has been improperly disappeared,
although the installed files should still be present.

And finally (well, these are just some of the effects I've explicitly
looked for after revealing them through code review, there could be more
related to this, but I've not bothered after having reworked the in-core
db layout), upgrading from those versions to the new dpkg 1.16.2 might
cause the status db to get messsed up in some conditions. Before
upgrading, you should either downgrade to a non-multiarch enabled dpkg, or
make sure there's no package present (i.e. with status >= config-files)
with a mix of M-A:same and non-M-A:same instances. If there's such package
with two instances, the new dpkg will consider that a “cross-grade” and
as such replace one of them with the other, depending on the order they
are parsed, but leaving any control files untouched; if there's more than
two instances the new dpkg will outright refuse to parse such bogus and
inconsistent status db.

Do not file any bug report if you upgraded from a system with a damaged
db, w/o first reproducing it on a clean system.


New and changed interfaces
--------------------------

Several inadequate interfaces (relative to the unofficial dpkg versions)
have been changed during the past several months, some of those to make
it possible to reliably cross-grade packages (including dpkg itself, even
when the world view of what's native changes between dpkg and frontend).

The upload to experimental had unfinished command-line interfaces, so
if you have relied on those or on the ones from other unofficial dpkg
versions, you will need to adapt to the final ones. Any package name
output from dpkg tools will be accepted by those as valid input during
the same transaction. For input you should always be able to arch-qualify
package names (as in “dpkg:amd64”), for singleton packages (those that
only have one installed instance present) you can simply use the package
name, for co-installed instances you always need to arch-qualify them.
Whenever dpkg tools take a package name, only one specific instance is
expected (as in “pkgname:arch” for multiple instances, “pkgname” or
“pkgname:arch” for singleton instances), if the command takes a pattern
then a simple package name will match any of its present instances (the
equivalent of “pkgname:*”), other accepted patterns are “*:arch”.
Current apt in unstable might not correctly arch-qualify packages when
needed and dpkg could fail due to that, apt from experimental should
work fine.

Any program or script parsing dpkg tools output should be adapted for
the possibility of arch-qualified package names or for multiple instance
output from a single package name.

The new dpkg-query virtual field (for internally generated values), that
allows package instances to be referred unambiguously (will arch-qualify
them when needed), has been renamed to not stomp on the valid field
namespace from binary packages, the new name for the field is
“binary:Package” (in line with substvars naming conventions).

Also as (another) side effect of the new in-core db layout, spurious
virtual packages do not get printed by dpkg-query any longer, so you
do not need to care for them any more.

The output from --print-foreign-architectures has changed from being
space separated to new-line separated, and as such old apt versions will
only “see” the first foreign architecture. apt from experimental should
work fine though.

Registering allowed architectures has changed from a command line option
to two commands to add and remove them to/from a new architecture db.
Those are --add-architecture and --remove-architecture. When cross-grading
dpkg, there's nothing needed to be done, as with this it will be able to
tell automatically what are the new switched native and foreign
architectures.

If you need to know if the current dpkg supports multiarch, for example
to check if it will accept arch-qualified input, there's a new
«dpkg --assert-multi-arch» command (please see the man page).

«dpkg --audit» now performs some checks related to the invalid
architectures.

dpkg-checkbuilddeps has grown a new -a option to specify the
architecture.


Maintainer scripts
------------------

Something that maintainers might have not considered when switching
packages to be multiarch aware is that maintainer scripts calling
dpkg tools might need to specify the precise package names to get the
correct results for the desired package instance(s). Please, check
your maintainer scripts. (All dpkg-divert calls should be fine as they
are.)

In line with the above, the DPKG_MAINTSCRIPT_ARCH environment variable is
set by dpkg for the maintainer script, to match the architecture of its
binary package. You might rely on it to be always present as it was
already introduced [M] in squeeze's dpkg with multiarch in mind.

  [M] <http://lists.debian.org/debian-devel-announce/2010/03/msg...>


On-disk db layout
-----------------

This is nothing new, but just as a reminder, the internal on-disk db
layout has changed, and although programs are *not* expected to be
messing around with it, there's some (exceptional) times when they might
need access to that data, if that's the case, then «dpkg-query -L»,
«dpkg-query -f '${Conffiles}' -W» or «dpkg-query --control-path»
(interface introduced long time ago [M] precisely for this reason) are
the “correct” things to use, do not assume any given on-disk db layout
(see dpkg-query man page for more details).


Cross-grading
-------------

Some weeks ago, after having set the foundation in place during the
past months, I implemented support for cross-grading in dpkg (and as
a side effect fixed all in-core db issues), so after installing the
needed dependencies you can cross-grade dpkg itself, and any other
package desired. Take into account though, that apt does *not* support
cross-grading, it also has problems with virtual package dependencies
across architectures (for example with a foreign mawk), and AIUI if it
does allow such action it will perform it by removing first the package
to be cross-graded, so you should not use apt for that, as it might
render your system unusable if it removes essential packages or
required shared libraries.

A normal session to perform a dpkg cross-grade would go like this:

  # dpkg --print-architecture
  i386
  # dpkg --add-architecture amd64
  # dpkg --print-foreign-architectures
  amd64
  # apt-get update
  # apt-get download gcc-4.6-base:amd64 libgcc1:amd64 libc6:amd64 \
            libselinux1:amd64 zlib1g:amd64 libbz2-1.0:amd64 dpkg:amd64
  # dpkg -i gcc-4.6-base*.deb libgcc*.deb libc*.deb libselinux*.deb \
            libbz2*.deb zlib*.deb dpkg*.deb
  # dpkg --print-architecture
  amd64
  # dpkg --print-foreign-architectures
  i386

Note though, that not all packages might be properly marked as Multi-Arch
same, foreign or allowed, so a full system cross-grade might not yet be
possible.


regards,
guillem


(Log in to post comments)

What does this have to do with sid?

Posted Mar 13, 2012 22:10 UTC (Tue) by HelloWorld (guest, #56129) [Link]

The current version in sid is 1.16.1.2, not 1.16.2. I guess the misleading heading is caused by someone confusing unstable (sid) and experimental.

Have you read the article?

Posted Mar 13, 2012 22:33 UTC (Tue) by khim (subscriber, #9252) [Link]

The current version in sid is 1.16.1.2, not 1.16.2. I guess the misleading heading is caused by someone confusing unstable (sid) and experimental.

Actually the heading is cased by someone who… gasp… have actually read the announce… Try it some time. The very first sentence in this specific case:

I'll be uploading dpkg 1.16.2 targeting unstable, by the end of this weekend or beginning of next week the latest (after some final polishing).

Have you read the article?

Posted Mar 13, 2012 22:56 UTC (Tue) by HelloWorld (guest, #56129) [Link]

Allright, my mistake.

What does this have to do with sid?

Posted Mar 13, 2012 22:35 UTC (Tue) by lordsutch (guest, #53) [Link]

The first paragraph makes it clear that Guillem is warning people in advance that dpkg 1.16.2 is going to be uploaded to sid Really Soon Now.

What does this have to do with sid?

Posted Mar 13, 2012 23:16 UTC (Tue) by alvieboy (subscriber, #51617) [Link]

And this will only affect those who tried to use preliminary versions of the new dpkg.

Guillem is doing the Right Thing, again. Although I'd expected some preinst sanitization scripts, just to avoid bad news. Many users just switch to experimental (or try third party debs) because it feels more Ubuntu like... and they do not actually follow any mailing list, not LWN.

Alvie

What does this have to do with sid?

Posted Mar 14, 2012 9:57 UTC (Wed) by hmh (subscriber, #3838) [Link]

Those users will learn very fast to not do it. You are not even supposed to use unstable without being subscribed to debian-devel-announce, let alone experimental.

What does this have to do with sid?

Posted Mar 20, 2012 22:40 UTC (Tue) by jlargentaye (guest, #75206) [Link]

I've used Unstable as my primary home OS for a little under a decade, and never had to reinstall it. I'm not and didn't know I should've subscribed to debian-devel-announce.

I have been occasionally reading Planet Debian and recently LWN.net though.

What does this have to do with sid?

Posted Mar 13, 2012 23:34 UTC (Tue) by nix (subscriber, #2304) [Link]

Quite. It's the 1.16.1.2 package that people should beware of.

(This was in last week's weekly edition as well.)

What does this have to do with sid?

Posted Mar 14, 2012 1:21 UTC (Wed) by jimparis (subscriber, #38647) [Link]

> Quite. It's the 1.16.1.2 package that people should beware of.

I don't think that's correct at all. I believe it's versions like 1.16.2~wipmultiarch, in experimental, that may cause problems.

Going from sid 1.16.1.2 to sid 1.16.2 should be fine. The case where you may run into problems is if you installed some non-official, experimental, or Ubuntu version in between the two sid versions.

Debian "sid" users beware of the dpkg 1.16.2 upload

Posted Mar 14, 2012 2:46 UTC (Wed) by geofft (subscriber, #59789) [Link]

As LWN has reported just a few days ago, Guillem has been pretty conservative about the multiarch dpkg branch, and about the released code based on that branch that's been running in Ubuntu. He's claiming that in addition to the version in experimental, all recent Ubuntu dpkg versions are also likely to exhibit massive breakage. I haven't been following the story (and certainly not the code) closely enough to determine whether he's right, or this is FUD.

He may well have a point and nobody knows the dpkg code better than he does, but there's been a lot of lack of transparency in how this branch was going to play out, and I generally trust the Ubuntu folks who snapshotted this branch to have been competent at code-reviewing it too.

But, in short, "Debian 'sid' users beware" is an incomplete summary of the claim in this article; "all Ubuntu Natty, Oneiric, and Precise users and all future users of those releases beware" is even more strongly claimed.

Debian "sid" users beware of the dpkg 1.16.2 upload

Posted Mar 14, 2012 9:36 UTC (Wed) by mtelleria (subscriber, #33878) [Link]

I also understand Guillem's fears and the possibility that his
conservatism and "overprotection" may have resulted in some
unintention FUD from his side. But given this we need to move to a
more constructive approach.

Analysing his announcement, Guillem has pinpointed the CAUSES of 3
possible problems and suggests 3 CHECKS to take before upgrading:

1. "You should check for any packages in the status db w/o
matching files under /var/lib/dpkg/info/" [having Multi-Arch: same
and coming from a new arch w.r.t. the previous non-multiarch arch].

2. You should also check in the logs that no package has been
improperly disappeared, although the installed files should still
be present.

3. Make sure there's no package present (i.e. with status >=
config-files) with a mix of M-A:same and non-M-A:same instances

This is a great outcome from Guillem's analysis, but what would be
"nice to have" now is that Guillem (or other dpkg specialist) takes the
3 checks above and proposes a script or gives some instructions for us
mere mortals and non-dpkg specialists to perform those checks
properly.

More precisely I would like someone to confirm my assumptions:

1. The first test I understand it consisits in parsing /var/lib
/dpkg/status, check the Status: and Multi-Arch fields and compare them
with files in /var/lib/dpkg/info

2. For the second test, which logs can we look at? In case there are
some orphan files "hanging around" I guess all we can do is wait
for conflicts to arrive (in future installs) and resolv them
manually with --force options in dpkg.

3. The third test also consists in parsing the status file and see if
a package appears more than once with different values of Multi-Arch:
header.

Then I would keep a backup copy of the status file (in case future problems
arise), downgrade to dpkg 1.16.1.2 and prepare for the final Sid upgrade.

Debian "sid" users beware of the dpkg 1.16.2 upload

Posted Mar 14, 2012 10:41 UTC (Wed) by angdraug (subscriber, #7487) [Link]

This script by Raphael Hertzog should help.

Debian "sid" users beware of the dpkg 1.16.2 upload

Posted Mar 15, 2012 6:54 UTC (Thu) by geofft (subscriber, #59789) [Link]

> Analysing his announcement, Guillem has pinpointed the CAUSES of 3 possible problems and suggests 3 CHECKS to take before upgrading:

If you read closely, Guillem pinpointed the cause of 3 possible problems out of quite possibly many more, and suggests 3 checks to take before upgrading, without guaranteeing that those checks are sufficient to make everything safe. In other words, if you ever ran the current common multiarch dpkg, you have no idea what may have possibly gone wrong. (He also explicitly does not want to have dpkg itself do these checks when being upgraded, on the grounds that the previously-widely-used multiarch implementation was unofficial, and is not interested in reports of what else breaks besides the issues he noticed.)

Perhaps, as he claims, the code has not been reviewed enough, and there are in fact more subtle bugs lurking. But perhaps this is FUD, and the fact that I haven't seen Ubuntu in two-and-a-half releases of this code find massive breakage on their users' systems makes me wonder whether they've been lucky or the code is actually quite fine. In the literal sense, there is fear about the so-called unreviewed code, uncertainty about its effects, and doubt as to whether your system is even recoverable.

As also mentioned by another commenter, the other active dpkg maintainer, Raphael, posted a script to debian-devel to check for the issues Guillem mentioned, along with a gentle complaint that Guillem sent this email to debian-devel-announce without coordinating with the rest of the dpkg team. Given that Raphael is also active in Ubuntu, I would expect that we'll find that a more polished version of his script gets run on Ubuntu upgrades to this dpkg version.

Debian "sid" users beware of the dpkg 1.16.2 upload

Posted Mar 15, 2012 9:22 UTC (Thu) by rhertzog (subscriber, #4671) [Link]

Just a few comments.

1/ Just installing the experimental package will not have created problems. You need to have tried multiarch by adding a supplementary architecture and installing packages form this foreign architecture.

2/ I don't know of any way to trigger the main problem that guillem is referring to... if you managed to install multiple instances of a foreign package it's because it has a Multi-Arch: same field. And that field is not dropped when you remove the package.

So while Guillem is certainly well-intended, imho this announce did not had to look like so scary.

-- Raphael Hertzog

Debian "sid" users beware of the dpkg 1.16.2 upload

Posted Mar 15, 2012 12:34 UTC (Thu) by Jonno (subscriber, #49613) [Link]

2/ While it is not possible to have different versions of a package installed, you could have more than one package configured, by simply first removing the old version without using --purge, and then installing the new version from another arch. If one of these versions are Multi-arch: same while the other isn't, you get the problem he describes.

Debian "sid" users beware of the dpkg 1.16.2 upload

Posted Mar 15, 2012 13:23 UTC (Thu) by rhertzog (subscriber, #4671) [Link]

Indeed, thank you, that's a way to get in the situation described.

But realistically for this to happen, it means that either have you have removed (without purging) the native version of the package while it wasn't multi-arch aware yet and you later installed a foreign version of the package once it has been converted to multi-arch.

Or you had only a foreign version of the package installed (before its conversion to multi-arch), that you removed and now you installed the native one after its conversion.

Because as soon as you have two versions co-installed at a given time, it means that the field was present.

Anyway, I just reproduced it here (need squeeze + wheezy in sources.list):
$ sudo apt-get install ftplib3:i386=3.1-1-8
$ sudo dpkg -r ftplib3:i386
$ sudo apt-get install ftplib3:amd64=3.1.1-9
$ ~/cleanup-multiarch.pl
INFO: Foreign package detected: ftplib3:amd64 (Multi-Arch: same)
PROBLEM: one instance of ftplib3 is not Multi-Arch: same
SOLUTION: dpkg -P ftplib3:i386
[...]
PROBLEM: ftplib3 has missing info files
SOLUTION: apt-get --reinstall install ftplib3

So the two problems are real even if relatively unlikely on a typical usage of multiarch.

Again thank you, at least I could test that my script was working as expected :-)

Debian "sid" users beware of the dpkg 1.16.2 upload

Posted Mar 21, 2012 23:49 UTC (Wed) by BenHutchings (subscriber, #37955) [Link]

I very quickly hit the 'disappeared' bug: #659505.

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds