落穂拾い

Gleanings in my life

【Gentoo】libpng 1.4 → 1.5 へのアップグレード

2011年10月19日 00時02分26秒 | Linux

libpng が 1.4 系から 1.5系にアップグレードされた。

libpng は数多くのアプリケーションで使用されており、その影響は甚大である。迂闊に libpng だけをアップグレードして古いものを消してしまうと大変なことが発生してしまう。

というわけで、手順である。

最初に、普通に libpng をアップグレードする。

emerge -av libpng


これは普通に world のアップグレードとかで実施すればよい。
すると、次のようなメッセージが表示される。

 * Old versions of installed libraries were detected on your system.
* In order to avoid breaking packages that depend on these old libs,
* the libraries are not being removed. You need to run revdep-rebuild
* in order to remove these old dependencies. If you do not have this
* helper program, simply emerge the 'gentoolkit' package.
*
* # revdep-rebuild --library '/usr/lib64/libpng14.so.14'
*
* Once you've finished running revdep-rebuild, it should be safe to
* delete the old libraries. Here is a copy & paste for the lazy:
* # rm '/usr/lib64/libpng14.so.14'

libpng14 に依存しているアプリケーションを再コンパイルしたのちに、古いものを消去せよということだ。

しかし、上記の revdep-rebuild だけでは、必要なものを再コンパイルすることはできない!のである。これが面倒な点だ。同じ時期に libpng のアップグレードについての news が入っている。それを読んでみる。たとえば、

eselect news read 13

みたいな感じで読める。13は記事番号であり、これは eselect news list で調べられる。
内容は下記の通り。

2011-10-15-libpng15
Title Upgrade to libpng15
Author Samuli Suominen
Posted 2011-10-15
Revision 1
After upgrading from libpng14 to libpng15 it's important that you rebuild
cairo and gdk-pixbuf as soon as possible if they are installed.
Then you can proceed with rebuilding the rest of the software against the new
library:
# revdep-rebuild --library libpng14.so.14 -- --keep-going
Note: It might be necessary to run the previous command more than once.
If you find packages not building with the message "ld: cannot find -lpng14",
they are likely caused by broken libtool archives (.la) in your system.
You can identify those files with following one-liner:
# find /usr/ -name '*.la' -exec grep png14 {} +
Once you have identified the broken files, you can either delete them,
edit them in place and replace png14 with png15, or re-emerge the packages
they belong to.
More information and help is available at the following forum post:
http://forums.gentoo.org/viewtopic-t-894950.html

といった具合である。ポイントは、revdep-rebuild を --keep-going オプションで実行することだ。これは emerge に失敗しても、それを自動でスキップして続きを emerge してくれるオプションであり、revdep-rebuild での emerge に失敗する場合にのみ有効である。このオプションをわざわざ指定するようになっているということは、基本的に revdep-rebuild による emerge はかなりの頻度で失敗することを示唆している。実際、私の3つばかりの環境で試した範囲では、かなりのパッケージの emerge に失敗する。

emerge のエラーメッセージを見ると、

cannot find -lpng14

というエラーが多い。これについては上記の news に記述があるので、それを参考にすればよい。より具体的にはここのページが参考になる。簡単に言えば、.la ファイルの中に png14 という文字列を含んでいるパッケージを探しだし、それについて emerge すればよいとのことだ。

しかし、上記でもまだエラーが発生しうる。それは package config 関連。そこで

find /usr -name "*.pc" -exec grep -H png14 {} \; 

を実行し、再emerge をすれば解決である。


コメントを投稿