CPAN 初期設定
CPANを利用するための簡単な設定と、その変更方法
CPAN 起動
まっさらな環境で CPAN コマンドを利用しようとすると、初期設定が行われます。
$ su -
# cpan
古いチュートリアルでは、perl -MCPAN -e shell
などと打って cpan を起動しているかもしれませんが、cpan
と打つだけで、大丈夫です。
# cpan
CPAN is the world-wide archive of perl resources. It consists of about
300 sites that all replicate the same contents around the globe. Many
countries have at least one CPAN site already. The resources found on
CPAN are easily accessible with the CPAN.pm module. If you want to use
CPAN.pm, lots of things have to be configured. Fortunately, most of
them can be determined automatically. If you prefer the automatic
configuration, answer 'yes' below.
If you prefer to enter a dialog instead, you can answer 'no' to this
question and I'll let you configure in small steps one thing after the
other. (Note: you can revisit this dialog anytime later by typing 'o
conf init' at the cpan prompt.)
Would you like me to configure as much as possible automatically? [yes]
最近の CPAN コマンドだと、上記のように聞かれます。
「できる限り自動的に設定していいかな?」と言われているので、素直にyes とタイプするか、デフォルトyesなのでそのままエンターを押せばすべて自動的によしなに設定がされます。make がインストールされてないとかいう致命的な状態のサーバでない限り、はまることはあまりないと思うので、基本的に自動で大丈夫です。ただし、マニュアル設定したいこだわりのある人は no と入力すると、ひとつひとつ設定が可能。
ここでは、細かい設定項目についてはいったん省略します。
設定内容を確認する o conf コマンド
CPAN シェルで、o conf
というコマンドを発行すると、設定状況を一覧することができます。
# cpan
cpan shell -- CPAN exploration and modules installation (v1.9402)
Enter 'h' for help.
cpan[1]> o conf
$CPAN::Config options from '/usr/lib/perl5/5.8.8/CPAN/Config.pm':
commit [Commit changes to disk]
defaults [Reload defaults from disk]
help [Short help about 'o conf' usage]
init [Interactive setting of all options]
applypatch []
auto_commit [0]
build_cache [100]
build_dir [/root/.cpan/build]
build_dir_reuse [0]
build_requires_install_policy [ask/yes]
bzip2 [/usr/bin/bzip2]
cache_metadata [1]
check_sigs [0]
colorize_debug undef
colorize_output undef
colorize_print undef
colorize_warn undef
commandnumber_in_prompt [1]
commands_quote undef
connect_to_internet_ok [1]
cpan_home [/root/.cpan]
curl [/usr/bin/curl]
dontload_hash undef
dontload_list undef
ftp []
ftp_passive [1]
ftp_proxy []
ftpstats_period undef
ftpstats_size undef
getcwd [cwd]
gpg []
gzip [/bin/gzip]
halt_on_failure [0]
histfile [/root/.cpan/histfile]
histsize [100]
http_proxy []
inactivity_timeout [0]
index_expire [1]
inhibit_startup_message [0]
keep_source_where [/root/.cpan/sources]
load_module_verbosity [v]
lynx []
make [/usr/bin/make]
make_arg []
make_install_arg []
make_install_make_command [/usr/bin/make]
makepl_arg []
mbuild_arg []
mbuild_install_arg []
mbuild_install_build_command [./Build]
mbuildpl_arg []
ncftp []
ncftpget []
no_proxy []
pager [/usr/bin/less]
password undef
patch []
patches_dir undef
perl5lib_verbosity [v]
prefer_installer [MB]
prefs_dir [/root/.cpan/prefs]
prerequisites_policy [ask]
proxy_pass undef
proxy_user undef
randomize_urllist undef
scan_cache [atstart]
shell [/bin/bash]
show_unparsable_versions [0]
show_upload_date [0]
show_zero_versions [0]
tar [/bin/tar]
tar_verbosity [v]
term_is_latin [1]
term_ornaments [1]
test_report [0]
trust_test_report_history [0]
unzip [/usr/bin/unzip]
urllist
use_sqlite [0]
username undef
wait_list undef
wget [/usr/bin/wget]
yaml_load_code [0]
yaml_module [YAML]
cpan[2]>
項目ごとに見たい場合は、o conf
のあとに項目名をつけます。
cpan > o conf cpan_home
cpan_home [/root/.cpan]
CPAN の設定がある場所
o conf
の最初に書かれてあるとおり、cpan の設定は、/usr/lib/perl5/5.8.8/CPAN/Config.pm
にあります。
# vi /usr/lib/perl5/5.8.8/CPAN/Config.pm
cpan から落としてくるファイルやもろもろのデータは、cpan_home [/root/.cpan]
という設定の通り、/root/.cpna 以下に保存されます。
CPAN 設定をやり直す
CPAN の設定を最初からやり直したい!
そういう場合は、以下のように o conf init
すると、設定をやり直せます。
# cpan
cpan > o conf init
CPAN is the world-wide archive of perl resources. It consists of about
300 sites that all replicate the same contents around the globe. Many
countries have at least one CPAN site already. The resources found on
CPAN are easily accessible with the CPAN.pm module. If you want to use
CPAN.pm, lots of things have to be configured. Fortunately, most of
them can be determined automatically. If you prefer the automatic
configuration, answer 'yes' below.
If you prefer to enter a dialog instead, you can answer 'no' to this
question and I'll let you configure in small steps one thing after the
other. (Note: you can revisit this dialog anytime later by typing 'o
conf init' at the cpan prompt.)
Would you like me to configure as much as possible automatically? [yes]
項目ごとの設定を変更する
o conf
で確認した設定を、項目ごとに変更したい場合は、o conf
コマンドの後ろに項目名を書き、その後ろに設定内容を書きます。
cpan > o conf build_cache 15
cpan > o conf cpan_home "/root/dev/.cpan"
項目に設定内容が複数存在する場合は、shift
unshift
pop
push
によって操作できます。
cpan > o conf urllist push http://www.perl.com/CPAN/
設定ができたら、忘れず commit します(auto_commit を有効にしてれば不要です)。
cpan > o conf commit
commit: wrote '/usr/lib/perl5/5.8.8/CPAN/Config.pm'
設定項目の勘所
- urllist
地域と場所を選んで設定をするかと思いますが、個人的には CPAN/SITES から サーバの設置場所に近くて http なサイトを選んで3つくらいリストしています。 - make
サーバに make が入ってないと、CPANコマンドは動くがモジュールがまったくビルドできない。当たり前だが、その際に make がないよとは言ってくれないので(make ができない → make入ってない?と推測しないといけない)、ちょっと注意が必要。
設定項目のワンライン解説
applypatch path to external prg
auto_commit commit all changes to config variables to disk
build_cache size of cache for directories to build modules
build_dir locally accessible directory to build modules
build_dir_reuse boolean if distros in build_dir are persistent
build_requires_install_policy
to install or not to install when a module is
only needed for building. yes|no|ask/yes|ask/no
bzip2 path to external prg
cache_metadata use serializer to cache metadata
check_sigs if signatures should be verified
colorize_debug Term::ANSIColor attributes for debugging output
colorize_output boolean if Term::ANSIColor should colorize output
colorize_print Term::ANSIColor attributes for normal output
colorize_warn Term::ANSIColor attributes for warnings
commandnumber_in_prompt
boolean if you want to see current command number
commands_quote preferred character to use for quoting external
commands when running them. Defaults to double
quote on Windows, single tick everywhere else;
can be set to space to disable quoting
connect_to_internet_ok
whether to ask if opening a connection is ok before
urllist is specified
cpan_home local directory reserved for this package
curl path to external prg
dontload_hash DEPRECATED
dontload_list arrayref: modules in the list will not be
loaded by the CPAN::has_inst() routine
ftp path to external prg
ftp_passive if set, the envariable FTP_PASSIVE is set for downloads
ftp_proxy proxy host for ftp requests
ftpstats_period max number of days to keep download statistics
ftpstats_size max number of items to keep in the download statistics
getcwd see below
gpg path to external prg
gzip location of external program gzip
halt_on_failure stop processing after the first failure of queued
items or dependencies
histfile file to maintain history between sessions
histsize maximum number of lines to keep in histfile
http_proxy proxy host for http requests
inactivity_timeout breaks interactive Makefile.PLs or Build.PLs
after this many seconds inactivity. Set to 0 to
disable timeouts.
index_expire refetch index files after this many days
inhibit_startup_message
if true, suppress the startup message
keep_source_where directory in which to keep the source (if we do)
load_module_verbosity
report loading of optional modules used by CPAN.pm
lynx path to external prg
make location of external make program
make_arg arguments that should always be passed to 'make'
make_install_make_command
the make command for running 'make install', for
example 'sudo make'
make_install_arg same as make_arg for 'make install'
makepl_arg arguments passed to 'perl Makefile.PL'
mbuild_arg arguments passed to './Build'
mbuild_install_arg arguments passed to './Build install'
mbuild_install_build_command
command to use instead of './Build' when we are
in the install stage, for example 'sudo ./Build'
mbuildpl_arg arguments passed to 'perl Build.PL'
ncftp path to external prg
ncftpget path to external prg
no_proxy don't proxy to these hosts/domains (comma separated list)
pager location of external program more (or any pager)
password your password if you CPAN server wants one
patch path to external prg
patches_dir local directory containing patch files
perl5lib_verbosity verbosity level for PERL5LIB additions
prefer_installer legal values are MB and EUMM: if a module comes
with both a Makefile.PL and a Build.PL, use the
former (EUMM) or the latter (MB); if the module
comes with only one of the two, that one will be
used no matter the setting
prerequisites_policy
what to do if you are missing module prerequisites
('follow' automatically, 'ask' me, or 'ignore')
prefs_dir local directory to store per-distro build options
proxy_user username for accessing an authenticating proxy
proxy_pass password for accessing an authenticating proxy
randomize_urllist add some randomness to the sequence of the urllist
scan_cache controls scanning of cache ('atstart' or 'never')
shell your favorite shell
show_unparsable_versions
boolean if r command tells which modules are versionless
show_upload_date boolean if commands should try to determine upload date
show_zero_versions boolean if r command tells for which modules $version==0
tar location of external program tar
tar_verbosity verbosity level for the tar command
term_is_latin deprecated: if true Unicode is translated to ISO-8859-1
(and nonsense for characters outside latin range)
term_ornaments boolean to turn ReadLine ornamenting on/off
test_report email test reports (if CPAN::Reporter is installed)
trust_test_report_history
skip testing when previously tested ok (according to
CPAN::Reporter history)
unzip location of external program unzip
urllist arrayref to nearby CPAN sites (or equivalent locations)
use_sqlite use CPAN::SQLite for metadata storage (fast and lean)
username your username if you CPAN server wants one
wait_list arrayref to a wait server to try (See CPAN::WAIT)
wget path to external prg
yaml_load_code enable YAML code deserialisation via CPAN::DeferredCode
yaml_module which module to use to read/write YAML files