GentooサーバにPHPのPEAR-HTTP_Clientをインストール
このルートはフラグの立て方がポイントである。最低限のフラグを立てないと攻略はできない。
emerge がどういうコマンドなのかとか、USE フラグとはいったい何なのかは知っていることを前提とする。というか Gentoo に PHP をインストールしたなら知ってるはず。
攻略手順
portage tree を更新する。
~ $ sudo emerge sync
PEARパッケージを探す(いっぱいでてくるので less する)。
~ $ sudo emerge search PEAR | less
PEAR の HTTP/Client.php は php-dev/PEAR-HTTP_Client というパッケージだとわかるのでこれを emerge する。
~ $ sudo emerge PEAR-HTTP_Client * checking XML_RPC-1.5.1.tgz ;-) ... [ ok ] * checking PEAR-1.6.2.tgz ;-) ... [ ok ] * * Using dev-lang/php-5.2.6_rc3 * * * Using dev-lang/php-5.2.6_rc3 * * Checking for required PHP feature(s) ... * Discovered missing USE flag: xml * * dev-lang/php-5.2.6_rc3 needs to be re-installed with all of the following * USE flags enabled: * * cli pcre xml zlib * * * ERROR: dev-php/PEAR-PEAR-1.6.2-r1 failed. * Call stack: * ebuild.sh, line 49: Called pkg_setup * PEAR-PEAR-1.6.2-r1.ebuild, line 43: Called require_php_with_use 'pkg_setup' 'pkg_setup' 'pkg_setup' 'cli' * depend.php.eclass, line 285: Called die * The specific snippet of code: * die "Missing PHP USE flags found" * The die message: * Missing PHP USE flags found * * If you need support, post the topmost build error, and the call stack if relevant. * A complete build log is located at '/var/tmp/portage/dev-php/PEAR-PEAR-1.6.2-r1/temp/build.log'. * The ebuild environment file is located at '/var/tmp/portage/dev-php/PEAR-PEAR-1.6.2-r1/temp/die.env'. * * Messages for package dev-php/PEAR-PEAR-1.6.2-r1: * * dev-lang/php-5.2.6_rc3 needs to be re-installed with all of the following * USE flags enabled: * * cli pcre xml zlib * * * ERROR: dev-php/PEAR-PEAR-1.6.2-r1 failed. * Call stack: * ebuild.sh, line 49: Called pkg_setup * PEAR-PEAR-1.6.2-r1.ebuild, line 43: Called require_php_with_use 'pkg_setup' 'pkg_setup' 'pkg_setup' 'cli' * depend.php.eclass, line 285: Called die * The specific snippet of code: * die "Missing PHP USE flags found" * The die message: * Missing PHP USE flags found * * If you need support, post the topmost build error, and the call stack if relevant. * A complete build log is located at '/var/tmp/portage/dev-php/PEAR-PEAR-1.6.2-r1/temp/build.log'. * The ebuild environment file is located at '/var/tmp/portage/dev-php/PEAR-PEAR-1.6.2-r1/temp/die.env'. *
失敗する。dev-lang/php-5.2.6_rc3 の cli pcre xml zlib の USE フラグを立てて再インストールしろということらしい。指示通り /etc/make.conf を編集して USE フラグに cli pcre xml zlib を追加する。
~ $ sudo vim /etc/make.conf #--------------- ... USE="... cli pcre xml zlib" ...
PHP をいったん消す。
~ $ sudo emerge --unmerge php
PHP を入れる(dev-lang/php-5.2.6_rc4 が入った)。
~ $ sudo emerge php
PEAR-HTTP_Client を入れようとする。
~ $ sudo emerge PEAR-HTTP_Client
ここで何度か失敗した。どうも xml の USE フラグが立っていないらしい。調べてみたら /etc/portage/package.use
に以下のように書かれていた。
dev-lang/php -cgi -gd -mysql -xml
これで /etc/make.conf で立てた xml のフラグが折れたらしい。修正して気を取り直して PHP を再インストール。うまくフラグを立てたまま PEAR-HTTP_Client を入れる。
~ $ sudo emerge PEAR-HTTP_Client Calculating dependencies / !!! All ebuilds that could satisfy "dev-php/PEAR-HTTP_Client" have been masked. !!! One of the following masked packages is required to complete your request: - dev-php/PEAR-HTTP_Client-1.1.1 (masked by: ~x86 keyword) For more information, see MASKED PACKAGES section in the emerge man page or refer to the Gentoo Handbook.
どうやら駄目らしい。emerge の man 嫁と言っているので man を読む。
~ $ man emerge
MASKED PACKAGES セクション の KEYWORDS の項目。
KEYWORDS The KEYWORDS variable in an ebuild file is also used for masking a package still in testing. There are architecture-specific keywords for each package that let portage know which systems are compatible with the package. Packages which compile on an architecture, but have not been proven to be "stable", are masked with a tilde (~) in front of the architecture name. emerge examines the ACCEPT_KEYWORDS environment variable to allow or disallow the emerging of a package masked by KEYWORDS. To inform emerge that it should build these 'testing' versions of packages, you should update your /etc/portage/package.key- words file to list the packages you want the 'testing' version. See portage(5) for more information.
あるアーキテクチャによっては安全/安定かどうかわからないパッケージだけど使いたかったら /etc/portage/package.keywords になんか書いてねということなので書いてみる。dev-php/PEAR-HTTP_Client が masked by: ~x86 keyword らしいのでこんな感じで。
~ $ sudo vim /etc/portage/package.keywords #------------------------------ dev-php/PEAR-HTTP_Client ~x86
これでマスク解除できたので、改めてインストール。
~ $ sudo emerge PEAR-HTTP_Client
これで HTTP/Client.php が使えるようになりました。攻略完了。