python-augeas may fail to load libaugeas0 in postinst script

Bug #1851675 reported by Alexander Thomas
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-augeas (Ubuntu)
New
Undecided
Unassigned

Bug Description

Seen on: Ubuntu 18.04.3 LTS
dpkg version: 1.19.0.5ubuntu2.3 (also in 1.19.0.5ubuntu2.2)

Regression compared to dpkg 1.19.0.5ubuntu2.1

To reproduce this:
1. You need a package that depends on a library for running a script in its postinst hook. For instance, the attached minimal package has `Depends: python-augeas`, and tries to do “from augeas import Augeas” in a script invoked from the postinst hook. (It does nothing else.)
2. Make sure the dependent library is not yet installed. In this example: libaugeas0, which is a dependency of python-augeas.
3. apt-get install the package. For the attached exmple, you can use `dpkg -i`, followed by `apt-get -f install`.

Result:

Setting up the-package (1.2.3ubuntu1-2-1) ...
Traceback (most recent call last):
  File "/usr/lib/the-package/setup-package.py", line 3, in <module>
    from augeas import Augeas
  File "/usr/lib/python2.7/dist-packages/augeas.py", line 78, in <module>
    class Augeas(object):
  File "/usr/lib/python2.7/dist-packages/augeas.py", line 82, in Augeas
    _libaugeas = _dlopen("augeas")
  File "/usr/lib/python2.7/dist-packages/augeas.py", line 75, in _dlopen
    raise ImportError("Unable to import lib%s!" % args[0])
ImportError: Unable to import libaugeas!
dpkg: error processing package the-package (--configure):
 installed the-package package post-installation script subprocess returned error exit status 1

Simply running apt-get -f install afterwards will succeed and run the postinst script.

The cause of this problem seems to be either that any invocations of `ldconfig` during the installation of the dependent libraries, do nothing at all, or rather that `ldconfig` is not invoked when it should be.

When adding `ldconfig -p >/tmp/ldconfig-output` to the postinst hook, one can see that neither libaugeas0 nor any other libraries that were just installed, are in the ldconfig cache at the moment the script is invoked.

Even when trying to perform an ugly workaround by adding an explicit `ldconfig` invocation in the postinst script before running the python script, it still fails.
Very curiously, calling `ldconfig -v >/dev/null` instead, somehow makes ldconfig work. This is probably because ldconfig calls are actively blocked in maintainer scripts, but adding the argument and redirect circumvents this block...

Revision history for this message
Alexander Thomas (doctor-lex) wrote :
Revision history for this message
Alexander Thomas (doctor-lex) wrote :

After some further investigation, this problem is probably not Ubuntu-specific but originated in upstream Debian and was cherry-picked as part of these changes:
http://launchpadlibrarian.net/433311114/dpkg_1.19.0.5ubuntu2.1_1.19.0.5ubuntu2.2.diff.gz

These changes include attempts to avoid trigger loops. One of the triggers is ldconfig (see /var/lib/dpkg/info/libc-bin.triggers). It seems that the changes have caused certain triggers to be postponed too much. If a package states it depends (directly or indirectly) on a library, one expects that this library is not just unpacked, but also available at the moment the package enters its setup phase.

We have also tried to move python-augeas to Pre-Depends: instead in the hopes of causing the ldconfig to be triggered before the postinst is invoked, but this makes no difference.

description: updated
description: updated
Revision history for this message
Alexander Thomas (doctor-lex) wrote :

This bug has now been filed upstream: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=944364

Revision history for this message
Alexander Thomas (doctor-lex) wrote :

Renamed the issue to “python-augeas may fail to load libaugeas0 in postinst script” because that proves to be the actual issue as shown in the Debian bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=944364

summary: - dpkg fails to properly invoke ldconfig
+ python-augeas may fail to load libaugeas0 in postinst script
affects: dpkg (Ubuntu) → python-augeas (Ubuntu)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.