Recovering from a Bad FreeBSD Package

Previously for this blog I've described my reliance on precompiled FreeBSD packages, rather than building everything from source. Today that tendency bit me. I tried to run Thunderbird and Firefox after updating my packages and saw the following errors.

orr:/home/richard$ thunderbird
/libexec/ld-elf.so.1: /usr/local/lib/libplds4.so.1: Undefined symbol
"gethostbyname_r"
orr:/home/richard$ firefox
/libexec/ld-elf.so.1: /usr/local/lib/libplds4.so.1: Undefined symbol
"gethostbyname_r"

That's a pain, since researching the problem without Firefox could be clumsy. Luckily (or unluckily) I remembered encountering this exact problem earlier. This may indicate a problem that needs to be fixed on the package building systems, but I can show you how to recover.

First I figured out where /usr/local/lib/libplds4.so.1 originated.

orr:/var/db/pkg$ grep -R plds *
nspr-4.6.3_1/+CONTENTS:lib/libplds4.a
nspr-4.6.3_1/+CONTENTS:lib/libplds4.so
nspr-4.6.3_1/+CONTENTS:lib/libplds4.so.1
Binary file pkgdb.db matches

So, libplds4.so.1 was installed by nspr-4.6.3_1. Let me check my log of my ports upgrade to see what happened.

---> Found a package of 'devel/nspr': /usr/ports/packages/All/nspr-4.6.3.tbz
(nspr-4.6.3)
---> Fetching the package(s) for 'nspr-4.6.4' (devel/nspr)
---> Fetching nspr-4.6.4
++ Will try the following sites in the order named:
ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6-stable/
...edited...
---> Fetching the latest package(s) for 'nspr' (devel/nspr)
---> Fetching nspr
++ Will try the following sites in the order named:
ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6-stable/
---> Invoking a command: /usr/bin/fetch -o '/var/tmp/portupgradeTcYEJHAt/nspr.tbz'
'ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6-stable/Latest/nspr.tbz'
/var/tmp/portupgradeTcYEJHAt/nspr.tbz 0% of 422 kB 0 Bps
---> Downloaded as nspr.tbz
---> Identifying the package /var/tmp/portupgradeTcYEJHAt/nspr.tbz
---> Saved as /usr/ports/packages/All/nspr-4.6.3_1.tbz
---> Listing the results (+:done / -:ignored / *:skipped / !:failed)
+ nspr@
---> Packages processed: 1 done, 0 ignored, 0 skipped and 0 failed
---> Found a package of 'devel/nspr': /usr/ports/packages/All/nspr-4.6.3_1.tbz
(nspr-4.6.3_1)
---> Located a package version 4.6.3_1 (/usr/ports/packages/All/nspr-4.6.3_1.tbz)
---> Using it anyway although it is not the latest version (4.6.4), since -PP/-
-use-packages-only is specified
---> Upgrade of devel/nspr started at: Mon, 01 Jan 2007 22:36:18 -0500
---> Upgrading 'nspr-4.6.3' to 'nspr-4.6.3_1' (devel/nspr) using a package
---> Updating dependency info
---> Modifying /var/db/pkg/firefox-1.5.0.7,1/+CONTENTS
---> Modifying /var/db/pkg/gaim-1.5.0_8/+CONTENTS
---> Modifying /var/db/pkg/nss-3.11.3/+CONTENTS
---> Modifying /var/db/pkg/thunderbird-1.5.0.7/+CONTENTS
---> Modifying /var/db/pkg/thunderbird-enigmail-0.94.1/+CONTENTS
---> Uninstallation of nspr-4.6.3 started at: Mon, 01 Jan 2007 22:36:25 -0500
---> Fixing up dependencies before creating a package
---> Backing up the old version
---> Uninstalling the old version
---> Deinstalling 'nspr-4.6.3'
---> Preserving /usr/local/lib/libnspr4.so.1 as /usr/local/lib/compat/pkg/libnspr4.so.1
---> Preserving /usr/local/lib/libplc4.so.1 as /usr/local/lib/compat/pkg/libplc4.so.1
---> Preserving /usr/local/lib/libplds4.so.1 as /usr/local/lib/compat/pkg/libplds4.so.1
pkg_delete: package 'nspr-4.6.3' is required by these other packages
and may not be deinstalled (but I'll delete it anyway):
firefox-1.5.0.7,1
nss-3.11.3
thunderbird-1.5.0.7
thunderbird-enigmail-0.94.1
pkg_delete: '/usr/local/lib/libplds4.so.1' fails original MD5 checksum -
deleted anyway.
[Updating the pkgdb in /var/db/pkg ... - 200 packages
found (-1 +0) (...) done]
---> Uninstallation of nspr-4.6.3 ended at: Mon, 01 Jan 2007 22:37:07 -0500
(consumed 00:00:42)
---> Installation of nspr-4.6.3_1 started at: Mon, 01 Jan 2007 22:37:08 -0500
---> Installing the new version via the package
---> Removing temporary files and directories
---> Removing old package'
---> Installation of nspr-4.6.3_1 ended at: Mon, 01 Jan 2007 22:37:11 -0500
(consumed 00:00:03)
---> Cleaning out obsolete shared libraries
[Updating the pkgdb in /var/db/pkg ... - 201 packages found
(-0 +1) . done]
---> Upgrade of devel/nspr ended at: Mon, 01 Jan 2007 22:37:17 -0500
(consumed 00:00:59)

Sure enough, nspr was updated to something that was broken. Let's fix that by removing the new version and reinstalling it via our own ports tree.

orr:/var/db/pkg# pkg_deinstall -f nspr-4.6.3_1/
---> Deinstalling 'nspr-4.6.3_1'
pkg_delete: package 'nspr-4.6.3_1' is required by these other packages
and may not be deinstalled (but I'll delete it anyway):
firefox-1.5.0.7,1
nss-3.11.3
thunderbird-1.5.0.7
thunderbird-enigmail-0.94.1
[Updating the pkgdb in /var/db/pkg ... - 200 packages found (-1 +0) (...) done]

Now find out where nspr lives, and build it.

orr:/var/db/pkg# cd /usr/ports
orr:/usr/ports# make search name=nspr
Port: nspr-4.6.4
Path: /usr/ports/devel/nspr
Info: A platform-neutral API for system level and libc like functions
Maint: gnome@FreeBSD.org
B-deps: gettext-0.14.5_2 gmake-3.81_1 libiconv-1.9.2_2
R-deps:
WWW: http://www.mozilla.org/projects/nspr/index.html

orr:/usr/ports# cd /usr/ports/devel/nspr
orr:/usr/ports/devel/nspr# make
=> nspr-4.6.4.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch from http://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v4.6.4/src/.
...edited...
orr:/usr/ports/devel/nspr# make install

When finished, Thunderbird and Firefox are fine.

Comments

Anonymous said…
One slight problem: You now have thunderbird and firefox registered as depending upon nspr-4.6.3_1, when they actually depend on nspr-4.6.4.

If you used portupgrade to do the upgrade, it would have fixed up those dependencies for you.
Anonymous said…
You could have used pkg_info -W instead of grepping /var/db/pkg/*/+CONTENTS.

wxs@syn ~ > pkg_info -W /usr/local/bin/zsh
/usr/local/bin/zsh was installed by package zsh-4.3.2_1
wxs@syn ~ >
Hi Colin,

I now see what you mean, but I don't understand how it happened.

I originally upgraded using

portupgrade -vaPP

with an environment variable of

setenv PACKAGESITE ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6-stable/Latest/

That resulted in nspr-4.6.3_1 being installed.

Why would that cause Firefox, etc., to expect nspr-4.6.4? Is it because that is the version in the ports tree?

Let's assume I did my package-based upgrade as happened. When I saw nspr-4.6.3_1 had a problem, should I have next run

portupgrade -v nspr

to rebuild and upgrade nspr from source?

Thank you.
Wesley, thanks for the tip!
Colin,

After taking another look at the issue, I don't see Firefox or Thunderbird as depending on nspr-4.6.3_1. For example:

orr:/home/richard$ pkg_tree firefox
firefox-1.5.0.7,1
|\__ expat-2.0.0_1
|\__ pkg-config-0.21
|\__ xorg-fonts-encodings-6.9.0_1
|\__ jpeg-6b_4
|\__ libiconv-1.9.2_2
|\__ gettext-0.14.5_2
|\__ png-1.2.12_1
|\__ perl-5.8.8
|\__ nspr-4.6.4
|\__ nss-3.11.3
|\__ glib-2.12.4
|\__ libxml2-2.6.26
|\__ libdrm-2.0.2
|\__ xorg-libraries-6.9.0
|\__ popt-1.7_1
|\__ tiff-3.8.2_1
|\__ bitstream-vera-1.10_2
|\__ shared-mime-info-0.19
|\__ libIDL-0.8.7
|\__ atk-1.12.3
|\__ xorg-fonts-truetype-6.9.0
|\__ libXft-2.1.7_1
|\__ desktop-file-utils-0.11
|\__ pango-1.14.8
\__ gtk-2.10.6_2

orr:/home/richard$ pkg_tree thunderbird
thunderbird-1.5.0.7
|\__ expat-2.0.0_1
|\__ pkg-config-0.21
|\__ xorg-fonts-encodings-6.9.0_1
|\__ jpeg-6b_4
|\__ libiconv-1.9.2_2
|\__ gettext-0.14.5_2
|\__ png-1.2.12_1
|\__ perl-5.8.8
|\__ nspr-4.6.4
|\__ nss-3.11.3
|\__ glib-2.12.4
|\__ libxml2-2.6.26
|\__ libdrm-2.0.2
|\__ xorg-libraries-6.9.0
|\__ popt-1.7_1
|\__ tiff-3.8.2_1
|\__ bitstream-vera-1.10_2
|\__ shared-mime-info-0.19
|\__ libIDL-0.8.7
|\__ atk-1.12.3
|\__ xorg-fonts-truetype-6.9.0
|\__ libXft-2.1.7_1
|\__ desktop-file-utils-0.11
|\__ pango-1.14.8
\__ gtk-2.10.6_2

Can you help me understand what you mean?
Anonymous said…
Richard,

If you run
# grep pkgdep /var/db/pkg/firefox*/+CONTENTS
you will (I think) have a line "@pkgdep nspr-4.6.3_1". Removing nspr-4.6.3_1 and installing nspr-4.6.4 doesn't change this -- fixing up dependencies like this is what portupgrade does (if you use it).

Yes, I would have run `portupgrade nspr` instead of removing and reinstalling nspr manually.
Why not use portupgrade -vaP? I think that will alleviate most of your problems without adding a significant amount of time to the upgrade process.

Popular posts from this blog

Zeek in Action Videos

New Book! The Best of TaoSecurity Blog, Volume 4

MITRE ATT&CK Tactics Are Not Tactics