Greg Beaverのブログでpearコマンドが対象とするリポジトリのミラーサイトの設定をする方法が掲載されていました。
pearコマンドにはいくつかのオプションをつけることができます。
その中にconfig-get、config-set、config-showというオプションがあり、これはpearの環境設定を扱います(それぞれ設定値の取得、値の設定、設定の表示)。
config-getの説明(英文)
$ pear help config-get
pear config-get [options] <parameter> [layer]
Displays the value of one configuration parameter. The
first argument is the name of the parameter, an optional second argument
may be used to tell which configuration layer to look in. Valid configuration
layers are "user", "system" and "default". If no layer is specified, a value
will be picked from the first layer that defines the parameter, in the order
just specified. The configuration value will be retrieved for the channel
specified by the default_channel configuration variable.
Options:
-c CHAN, --channel=CHAN
show configuration variables for another channel
config-setの説明(英文)
$ pear help config-set
pear config-set [options] <parameter> <value> [layer]
Sets the value of one configuration parameter. The first argument is
the name of the parameter, the second argument is the new value. Some
parameters are subject to validation, and the command will fail with
an error message if the new value does not make sense. An optional
third argument may be used to specify in which layer to set the
configuration parameter. The default layer is "user". The
configuration value will be set for the current channel, which
is controlled by the default_channel configuration variable.
Options:
-c CHAN, --channel=CHAN
show configuration variables for another channel
config-showの説明(英文)
$ pear help config-show
pear config-show [options] [layer]
Displays all configuration values. An optional argument
may be used to tell which configuration layer to display. Valid
configuration layers are "user", "system" and "default". To display
configurations for different channels, set the default_channel
configuration variable and run config-show again.
Options:
-c CHAN, --channel=CHAN
show configuration variables for another channel
config-getの使用例
$ pear config-get temp_dir
/tmp/pear/temp
config-get、config-setの使用例
$ pear config-get temp_dir
/tmp/pear/temp
$ pear config-set temp_dir /tmp/php/pear/tmp
config-set succeeded
$ pear config-get temp_dir
/tmp/php/pear/tmp
config-showの使用例
$ pear config-show
Configuration (channel pear.php.net):
=====================================
Auto-discover new Channels auto_discover <not set>
Default Channel default_channel pear.php.net
HTTP Proxy Server Address http_proxy <not set>
PEAR server [DEPRECATED] master_server pear.php.net
Default Channel Mirror preferred_mirror pear.php.net
Remote Configuration File remote_config <not set>
PEAR executables directory bin_dir /usr/bin
PEAR documentation directory doc_dir /usr/share/php/pear/docs
PHP extension directory ext_dir /usr/lib/php5/extensions/
PEAR directory php_dir /usr/share/php/pear
Website directory web_dir /usr/share/php/pear
PEAR Installer cache directory cache_dir /tmp/pear/cache
PEAR data directory data_dir /usr/share/php/pear/data
PEAR Installer download download_dir /tmp/pear/cache
directory
PHP CLI/CGI binary php_bin /usr/bin/php
php.ini location php_ini <not set>
PEAR Installer temp directory temp_dir /tmp/pear/temp
PEAR test directory test_dir /usr/share/php/pear/tests
Cache TimeToLive cache_ttl 3600
Preferred Package State preferred_state devel
Unix file mask umask 2
Debug Log Level verbose 1
PEAR password (for password <not set>
maintainers)
Signature Handling Program sig_bin /usr/bin/gpg
Signature Key Directory sig_keydir /etc/php5/pearkeys
Signature Key Id sig_keyid <not set>
Package Signature Type sig_type gpg
PEAR username (for username <not set>
maintainers)
User Configuration File Filename /home/user/.pearrc
System Configuration File Filename /etc/php5/pear.conf
上記config-showが出力される中にpreferred_mirrorという項目があります。
この項目が今回の題材の「pear.php.netのミラーサイト」を表す項目になり、これを指定することでミラーサイトとしてpear.php.net以外を指定することができます。
さてじゃあミラーサイトはどこにあるのか? という話が出てくると思いますが、実はずっと前から<COUNTRY>.pear.php.netというFQDNが存在しており、これを指定するといいようです。
config-setでミラーサイトを登録する例
$ pear config-set preferred_mirror jp.pear.php.net
config-set succeeded
$ pear config-show
Configuration (channel pear.php.net):
=====================================
Auto-discover new Channels auto_discover <not set>
Default Channel default_channel pear.php.net
HTTP Proxy Server Address http_proxy <not set>
PEAR server [DEPRECATED] master_server pear.php.net
Default Channel Mirror preferred_mirror pear.php.net
Remote Configuration File remote_config <not set>
PEAR executables directory bin_dir /usr/bin
PEAR documentation directory doc_dir /usr/share/php/pear/docs
PHP extension directory ext_dir /usr/lib/php5/extensions/
PEAR directory php_dir /usr/share/php/pear
Website directory web_dir /usr/share/php/pear
PEAR Installer cache directory cache_dir /tmp/pear/cache
PEAR data directory data_dir /usr/share/php/pear/data
PEAR Installer download download_dir /tmp/pear/cache
directory
PHP CLI/CGI binary php_bin /usr/bin/php
php.ini location php_ini <not set>
PEAR Installer temp directory temp_dir /tmp/pear/temp
PEAR test directory test_dir /usr/share/php/pear/tests
Cache TimeToLive cache_ttl 3600
Preferred Package State preferred_state devel
Unix file mask umask 2
Debug Log Level verbose 1
PEAR password (for password <not set>
maintainers)
Signature Handling Program sig_bin /usr/bin/gpg
Signature Key Directory sig_keydir /etc/php5/pearkeys
Signature Key Id sig_keyid <not set>
Package Signature Type sig_type gpg
PEAR username (for username <not set>
maintainers)
User Configuration File Filename /home/user/.pearrc
System Configuration File Filename /etc/php5/pear.conf
残念ながら今現在pear.php.netとjp.pear.php.netは同じサーバーを指しているため、実質ミラーとしての役目を果たしていませんが、Gregの記事にあるようにus.pear.php.netとde.pear.php.netは別サーバーです(実はpear.php.netのさらに左のサブドメイン名はワイルドカードで、有効な名前であれば何を入れてもエラーはでないようです)。
つまり、「なるべく近いネットワークに接続する」という意味ではまだ有効活用できませんが、「pear.php.netが落ちているときにパッケージを取得したい」というときにはde.pear.php.netは有効です。
しかし日本のPEARユーザーの多くがde.pear.php.netをミラーとして登録することはあまり好ましくないかもしれません。
jp.pear.php.netが本当にできることを期待しつつこの設定を有効活用してみてください。