#968559 libhdf5-openmpi-dev: hdf5-mpi.pc alternative sometimes goes missing

Package:
libhdf5-openmpi-dev
Source:
hdf5
Description:
HDF5 - development files - OpenMPI version
Submitter:
Drew Parsons
Date:
2021-12-23 20:51:02 UTC
Severity:
normal
Tags:
#968559#5
Date:
2020-08-17 11:23:05 UTC
From:
To:
We've set up libhdf5-openmpi-dev (and libhdf5-mpich-dev) to use the
alternatives mechanism to configure a symlink from a generic pkgconfig
file hdf5-mpi.pc to the specific hdf5-openmpi.pc (or hdf5-mpich.pc).
This allows client programs to get libs with 'pkg-config --libs hdf5-mpi'
without needing to know which specific MPI implementation is being
used.

It's a good and useful service, I think we should keep it.

But we should document (or fix if possible) that this alternatives
mechanism is a little fragile, and sometimes the link needs to be
refresh with
  sudo dpkg-reconfigure libhdf5-openmpi-dev

What I mean is that sometimes the link seem to just disappear, so we get
  $ pkg-config --libs hdf5-mpi
  Package hdf5-mpi was not found in the pkg-config search path.
  Perhaps you should add the directory containing `hdf5-mpi.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'hdf5-mpi' found

It gets restored by 'dpkg-reconfigure libhdf5-openmpi-dev'
(update-alternative --config hdf5-mpi would also enable it to be reset).

I'm not sure why exactly the link is being lost or if it's feasible to
make the mechanism for it more robust. I presume it happens when
openmpi gets updated (e.g. recently updated to openmpi 4.0.4).
libhdf5-openmpi-dev.postinst of course is setting the alternatives
link, though I don't understand why the link would be lost just
because openmpi got upgraded.

Filing this bug so we can document and keep watch on the problem.
Again, the workaround is to run

  sudo dpkg-reconfigure libhdf5-openmpi-dev

(or dpkg-reconfigure libhdf5-mpich-dev)

#968559#10
Date:
2020-11-05 18:09:28 UTC
From:
To:
Hi Drew,

Do you have a scenario leading to this alternative disparition?

Thanks,

_g.

#968559#17
Date:
2020-11-06 03:02:38 UTC
From:
To:
...


It's not completely clear to me.  But my suspicion is that it happens
when there is an upgrade to openmpi. Evidently then hdf5 needs to update
its alternatives against the updated openmpi.

It's a little strange though, since a simple openmpi update is not an
ABI update. The alternatives links would be the same after running
dpkg-reconfigure libhdf5-openmpi-dev. Not obvious why an openmpi update
would cause them to disappear.

#968559#22
Date:
2020-11-07 18:36:58 UTC
From:
To:
Drew Parsons a écrit le 06/11/2020 à 04:02 :

After a test into a clean chroot I can now confirm this hypothesis.

Thanks,

_g.

#968559#27
Date:
2020-11-07 19:08:47 UTC
From:
To:
Gilles Filippini a écrit le 07/11/2020 à 19:36 :

The loss of the alternative is easily triggered by the reinstallation of
openmpi-bin:

# pkg-config --libs hdf5-mpi
-L/usr/lib/x86_64-linux-gnu/hdf5/openmpi -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lhdf5 -lmpi
# apt-get install --reinstall ipenmpi-bin
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package ipenmpi-bin
(unstable-amd64-sbuild)root@pinibrem15:/tmp# pkg-config --libs hdf5-mpi
-L/usr/lib/x86_64-linux-gnu/hdf5/openmpi -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lhdf5 -lmpi
(unstable-amd64-sbuild)root@pinibrem15:/tmp# apt-get install --reinstall openmpi-bin
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 3 not upgraded.
Need to get 0 B/127 kB of archives.
After this operation, 0 B of additional disk space will be used.
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 18500 files and directories currently installed.)
Preparing to unpack .../openmpi-bin_4.0.5-7_amd64.deb ...
Unpacking openmpi-bin (4.0.5-7) over (4.0.5-7) ...
Setting up openmpi-bin (4.0.5-7) ...
update-alternatives: warning: forcing reinstallation of alternative /usr/bin/mpicc.openmpi because link group mpi is broken
# pkg-config --libs hdf5-mpi
Package hdf5-mpi was not found in the pkg-config search path.
Perhaps you should add the directory containing `hdf5-mpi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'hdf5-mpi' found

It happens when reinstalling mpich as well, if the mpi alternative was previously set to mpich.

I have no idea how to fix it, other than asking openmpi and mpich maintainers to take care of the hdf5-mpi.pc slave alternative when it exists. What do you think?

Thanks,
Note the warning notice above. Honestly I have no idea how this could be fixed.

#968559#32
Date:
2020-11-08 04:17:46 UTC
From:
To:
...
Probably we should check with the update-alternatives developers first,
they may have some ideas. Certainly they should be able to explain
exactly why installing openmpi-bin or mpich causes the hdf5-mpi
alternative to disappear.

There is a precedent for collecting dpkg triggers and running them all
at the same time late in a dpkg (or apt) run, e.g manpages, dkms.
Otherwise, could request it be done by the openmpi-bin and mpich
packages.

I thought it could be good leave the actual alternatives logic in hdf5,
and put into openmpi-bin.postinst something like

if dpkg -s libhdf5-openmpi-dev >/dev/null 2>&1; then
   dpkg-reconfigure libhdf5-openmpi-dev
fi

But at irc #debian-devel they pointed out that won't work: you can't run
dpkg-reconfigure inside postinst since the dpkg lock will be in place.

Another option is to just make a copy of the alternative logic in
libhdf5-openmpi-dev.postinst, copying it to openmpi-bin.postinst.  A bit
messy but might get the job done.  Figuring out how to set up dpkg
triggers might be tidier.

Drew

#968559#37
Date:
2020-11-08 09:59:48 UTC
From:
To:
Drew Parsons a écrit le 08/11/2020 à 05:17 :

Would you mind opening these discussions?

Thanks,

_g.

#968559#42
Date:
2021-12-23 20:31:00 UTC
From:
To:
Hello, I have just migrated from Buster to Bullseye.

The package libhdf5-mpi-dev was and is not installed on my box.
However `update-alternatives --display  hdf5.pc` outputs

hdf5.pc - auto mode
   link best version is /usr/lib/x86_64-linux-gnu/pkgconfig/hdf5-mpi.pc
   link currently points to /usr/lib/x86_64-linux-gnu/pkgconfig/hdf5-mpi.pc
   link hdf5.pc is /usr/lib/x86_64-linux-gnu/pkgconfig/hdf5.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/hdf5-mpi.pc - priority 35
/usr/lib/x86_64-linux-gnu/pkgconfig/hdf5-mpich.pc - priority 10
/usr/lib/x86_64-linux-gnu/pkgconfig/hdf5-serial.pc - priority 20

The disturbing thing is that /usr/lib/x86_64-linux-gnu/pkgconfig/hdf5-mpi.pc
points to /dev/null

I guess that this issue is related to this bug.

HTH,
Jerome