UJP - 技術情報1

Life is fun and easy!

不正IP報告数

Okan Sensor
 
メイン
ログイン
ブログ カテゴリ一覧

CPANモジュールを設定する

CPANモジュールを設定する


0. 改訂履歴

  • 2008.07.10 新規作成
  • 2008.07.11 設定変更についてのヒントを追加

1. はじめに

 このドキュメントでは,Perlのモジュール管理の仕組みであるCPAN(Comprehensive Perl archive Network)のCPANモジュールを最初に起動した時に行う設定について,説明を行う.

 なお,今回の環境はCentOS 5.1で実行し,RedHat ES3, RedHat Enterprise Linux 5等で動作確認をしているが,プラットフォームによって大きな差異は無いと思われる.

2. CPANモジュールの基本設定

  • CPANモジュールを起動する.
[root@mars ~]# perl -MCPAN -e shell

/usr/lib/perl5/5.8.8/CPAN/Config.pm initialized.


CPAN is the world-wide archive of perl resources. It consists of about
100 sites that all replicate the same contents all 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, you have to configure it properly.
  • 次の様な表示になる.
If you do not want to enter a dialog now, you can answer 'no' to this
question and I'll try to autoconfigure. (Note: you can revisit this
dialog anytime later by typing 'o conf init' at the cpan prompt.)

Are you ready for manual configuration? [yes] 空リターン
  • 手動設定を行う準備ができているので,yes(空エンタキー)を選択する.
The following questions are intended to help you with the
configuration. The CPAN module needs a directory of its own to cache
important index files and maybe keep a temporary mirror of CPAN files.
This may be a site-wide directory or a personal directory.



First of all, I'd like to create this directory. Where?

CPAN build and cache directory? [/root/.cpan] 空リターン
  • CPANからダウンロードしたモジュール等を格納するディレクトリを指定する.
  • ここで指示された場所で問題ない.
If you want, I can keep the source files after a build in the cpan
home directory. If you choose so then future builds will take the
files from there. If you don't want to keep them, answer 0 to the
next question.



How big should the disk cache be for keeping the build directories
with all the intermediate files?

Cache size for build directory (in MB)? [10] 空リターン
  • ダウンロードしたソースファイルを保存しておく為のディスク容量を指定する.
  • 保存したくない場合は,0を入力する.
By default, each time the CPAN module is started, cache scanning
is performed to keep the cache size in sync. To prevent from this,
disable the cache scanning with 'never'.

Perform cache scanning (atstart or never)? [atstart] 空リターン
  • デフォルトでは,CPANモジュール(perl -MCPAN -e shell)を実行したときにネットワーク経由でモジュールの最新一覧を調べる様になる.
  • この処理を行いたくないときにはnever,起動時に行いたい場合はatstartを選ぶ事ができる.
  • チェックしたいので,atstartを選択する
To considerably speed up the initial CPAN shell startup, it is
possible to use Storable to create a cache of metadata. If Storable
is not available, the normal index mechanism will be used.

Cache metadata (yes/no)? [yes] 空リターン
  • メタデータを貯蔵(storable)する領域を使っていないので,利用するか選ぶことができる.
  • スピードアップに繋がるので,yesを選択する.
The next option deals with the charset your terminal supports. In
general CPAN is English speaking territory, thus the charset does not
matter much, but some of the aliens out there who upload their
software to CPAN bear names that are outside the ASCII range. If your
terminal supports UTF-8, you say no to the next question, if it
supports ISO-8859-1 (also known as LATIN1) then you say yes, and if it
supports neither nor, your answer does not matter, you will not be
able to read the names of some authors anyway. If you answer no, names
will be output in UTF-8.

Your terminal expects ISO-8859-1 (yes/no)? [yes] 空リターン
  • ターミナルも文字コードを選択する.デフォルトではISO-8859(Latin1:ヨーロッパ系言語)となっている.
  • 問題ないので,yesを選択する.
If you have one of the readline packages (Term::ReadLine::Perl,
Term::ReadLine::Gnu, possibly others) installed, the interactive CPAN
shell will have history support. The next two questions deal with the
filename of the history file and with its size. If you do not want to
set this variable, please hit SPACE RETURN to the following question.

File to save your history? [/root/.cpan/histfile] 空リターン
  • CPAN Shellにてコマンドヒストリ機能(↑キーを押してコマンド入力履歴を呼び出す等)を使い場合は,そのファイル名をい指定する.
  • デフォルトで良い.
Number of lines to save? [100] 空リターン 
  • ヒストリを何行分保存するかを選択する.デフォルトで良い.
The CPAN module can detect when a module that which you are trying to
build depends on prerequisites. If this happens, it can build the
prerequisites for you automatically ('follow'), ask you for
confirmation ('ask'), or just ignore them ('ignore'). Please set your
policy to one of the three values.

Policy on building prerequisites (follow, ask or ignore)? [ask] 空リターン
  • CPANモジュールでインストールを行う際に,依存関係(前提となる別のモジュールがインストールされている事が必要)なモ ジュールがああり,インストール先の環境にそれらが準備されていない場合がある.
  • そのような時に,自動的に取得してインストールを行う場合は,askを選択する.

3. 外部モジュールおよびコンパイルオプションの設定

  • モジュールを管理する際に必要な外部モジュールの指定や,make時の追加パラメータ設定等を行う.
The CPAN module will need a few external programs to work properly.
Please correct me, if I guess the wrong path for a program. Don't
panic if you do not have some of them, just press ENTER for those. To
disable the use of a download program, you can type a space followed
by ENTER.

Where is your gzip program? [/bin/gzip] 空リターン
  • CPANモジュールでは,いくつかの外部プログラムをを使う.
  • それらのプログラムが入っているパスを設定する.
Where is your tar program? [/bin/tar] 空リターン 
  • 空リターンを入力する.
Where is your unzip program? [/usr/bin/unzip] 空リターン 
  • 空リターンを入力する.
Where is your make program? [/usr/bin/make] 空リターン 
  • 空リターンを入力する.
Where is your links program? [/usr/bin/links] 空リターン 
  • linksとは,ellinksの事で,キャラクタ型Webブラウザlynxの事である.
  • 空リターンを入力する.
Where is your wget program? [/usr/bin/wget] 空リターン 
  • 空リターンを入力する.
Where is your ncftp program? [] 空リターン 
  • ncftpとは,FTPクライアントで,普通デフォルトではインストールされて,いない.
  • 空リターンで進むと,次の通り.
Warning: ncftpget not found in PATH
  • 大きな問題ではないので,次に進む.
Where is your ftp program? [/usr/kerberos/bin/ftp] 空リターン 
  • 普通のFTPコマンドを選択する.
Where is your gpg program? [/usr/bin/gpg] 空リターン 
  • GPGとは,GnuPGPで,暗号化を行うソフト.
What is your favorite pager program? [/usr/bin/less] 空リターン 
  • lessは,テキストファイルを読む時に使うコマンド.
What is your favorite shell? [/bin/bash] 空リターン 
  • 自分がいつも使っているシェルを設定する.
Every Makefile.PL is run by perl in a separate process. Likewise we
run 'make' and 'make install' in processes. If you have any
parameters (e.g. PREFIX, LIB, UNINST or the like) you want to pass
to the calls, please specify them here.

If you don't understand this question, just press ENTER.

Parameters for the 'perl Makefile.PL' command?
Typical frequently used settings:

PREFIX=~/perl non-root users (please see manual for more hints)

Your choice: [] 空リターン
  • perl Makefile.PLを実行する際に付け加えるライブラリへのパス等があれば,ここで指定する.
  • 例えば,MySQL関連ライブラリを使う際に,MySQL等のライブラリがインストールされているパスが,普通と違う場合は,こ こでパラメータを設定を追加しておけばよい.
    • パスが違う時は,install moduleを行う際にエラーになる場合があるが,その場合はCPANモジュールを使わずにPerl Makefile.PLでインストールを進めれば良い場合がある.(DBD::mysql等)
  • とりあえずは,空リターンとする.
Parameters for the 'make' command?
Typical frequently used setting:

-j3 dual processor system

Your choice: [] 空リターン
  • makeコマンドを実行する際につけるオプションを指定する.
  • このテストマシンが2CPU搭載マシンなので,ここではdual processor systemのオプションが表示されている.
  • ほとんどの場合,付けることはない.
Parameters for the 'make install' command?
Typical frequently used setting:

UNINST=1 to always uninstall potentially conflicting files

Your choice: [] 空リターン
  • 同じく,make install実行時につけるパラメータがあれば,指定する.
  • ほとんどの場合,付けることはない.
Sometimes you may wish to leave the processes run by CPAN alone
without caring about them. As sometimes the Makefile.PL contains
question you're expected to answer, you can set a timer that will
kill a 'perl Makefile.PL' process after the specified time in seconds.

If you set this value to 0, these processes will wait forever. This is
the default and recommended setting.

Timeout for inactivity during Makefile.PL? [0] 空リターン
  • perl Makefile.PLを実行した際に,質問される事があるが,タイムアウト時間を設定することができる.
  • 0を指定するとタイムアウトしないが,0を設定する事が推奨されている.

4. ネットワーク設定

  • 次に,ネットワークの設定となる.
  • ここでは通信する際に通過するプロキシや,モジュールをダウンロードしてくる際にサイトの登録を行う.
If you're accessing the net via proxies, you can specify them in the
CPAN configuration or via environment variables. The variable in
the $CPAN::Config takes precedence.

Your ftp_proxy? 空リターン
  • CPANモジュールがFTPでモジュールを取得する際に,プロキシ経由で接続する場合は,プロキシを指定する.
    • 指定する場合は,"proxy.ujp.jp:8080" という具合となる.
  • このテスト環境を利用している環境ではプロキシを利用していないため,空リターンとする.
Your http_proxy? 空リターン 
  • 同じくHTTPの場合も,利用していればプロキシをしていする.
Your no_proxy? 
  • ここでは社外アクセスにはプロキシを使っている環境で,社内アクセスプロキシを使わないアクセスを行うサーバがある場合,指定す る.
You have no /root/.cpan/sources/MIRRORED.BY
I'm trying to fetch one
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
ftp://ftp.perl.org/pub/CPAN/MIRRORED.BY



Now we need to know where your favorite CPAN sites are located. Push
a few sites onto the array (just in case the first on the array won't
work). If you are mirroring CPAN to your local workstation, specify a
file: URL.

First, pick a nearby continent and country (you can pick several of
each, separated by spaces, or none if you just want to keep your
existing selections). Then, you will be presented with a list of URLs
of CPAN mirrors in the countries you selected, along with previously
selected URLs. Select some of those URLs, or just keep the old list.
Finally, you will be prompted for any extra URLs -- file:, ftp:, or
http: -- that host a CPAN mirror.

(1) Africa
(2) Asia
(3) Central America
(4) Europe
(5) North America
(6) Oceania
(7) South America
Select your continent (or several nearby continents) [] 2
  • モジュールをダウンロードしてくる際の,サイトを指定するが,地域をAsiaで選択する.
Sorry! since you don't have any existing picks, you must make a
geographic selection.

(1) China
(2) Hong Kong
(3) Indonesia
(4) Israel
(5) Japan
(6) Korea
(7) Pakistan
(8) Philippines
(9) Republic of Korea
(10) Saudi Arabia
(11) Singapore
(12) Taiwan
(13) Thailand
(14) Turkey
Select your country (or several nearby countries) [] 5
  • 国を選択する.
(1) ftp://ftp.dti.ad.jp/pub/lang/CPAN/
(2) ftp://ftp.jaist.ac.jp/pub/CPAN/
(3) ftp://ftp.kddilabs.jp/CPAN/
(4) ftp://ftp.nara.wide.ad.jp/pub/CPAN/
(5) ftp://ftp.riken.jp/lang/CPAN/
(6) ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/
(7) ftp://ftp.u-aizu.ac.jp/pub/CPAN
(8) ftp://ftp.yz.yamagata-u.ac.jp/pub/lang/cpan/
Select as many URLs as you like (by number),
put them on one line, separated by blanks, e.g. '1 4 5' [] 3 1 5
  • ダウンロードするFTPサイトを指定する.
  • 順番に3,1,5を指定してみた.(これは,好み)
    • 大学を避けて,プロバイダを指定してみた感じ.理研とKDD時代からのKDDIには,昔から世話になっている...
Enter another URL or RETURN to quit: [] 空リターン
  • 他のサイトがああれば,そのURLを記入する.
New set of picks:
ftp://ftp.kddilabs.jp/CPAN/
ftp://ftp.dti.ad.jp/pub/lang/CPAN/
ftp://ftp.riken.jp/lang/CPAN/


commit: wrote /usr/lib/perl5/5.8.8/CPAN/Config.pm
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.7602)
ReadLine support available (try 'install Bundle::CPAN')

cpan> quit
Terminal does not support GetHistory.
Lockfile removed.
[root@mars ~]#
  • これで設定できた.

5. CPANのアップデート

  • CPANモジュールを起動する.
[root@mars ~]# perl -MCPAN -e shell
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.7602)
ReadLine support available (try 'install Bundle::CPAN')

cpan>
  • CPANモジュール自体のインストールを行うよう,催促されているので実行する.
  • インストールを行う.
cpan> install Bundle::CPAN
CPAN: Storable loaded ok
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
ftp://ftp.kddilabs.jp/CPAN/authors/01mailrc.txt.gz


〜略〜

To ensure that you do not enter an invalid hostname, I can perform a
lookup on each hostname you enter. If your internet connection is via
a dialup line then you may not want me to perform these lookups, as
it will require you to be on-line.

Do you want me to perform hostname lookups (y|n) ? [yes] 空リターン
  • この表示が出るまで,かなり多くのモジュールがダウンロードされる.
  • ホスト名が不明なので名前解決する.
YAML-0.66/ysh

CPAN.pm: Going to build I/IN/INGY/YAML-0.66.tar.gz


*** WARNING ***

This release breaks compatibility with versions earlier than version 0.60 of
YAML::Syck and YAML.pm when serializing blessed references.

See the COMPATIBILITY file for more information.

Continue installing YAML.pm? [y] 空リターン
  • YAMLとは,構造化オブジェクトを文字列にシリアライズするデータ形式とそのライブラリ.
  • YAML のパーサとしてSyckを使う場合が多いみたいなので,インストールしておく.
CPAN: Term::ReadLine::Perl loaded ok
....................
20 subroutines in Term::ReadLine redefined

cpan shell -- CPAN exploration and modules installation (v1.7602)
ReadLine support enabled

cpan>
  • 問題なくインストール完了した.
  • いったんCPANモジュールを終了する.
cpan> quit 
Lockfile removed.
[root@mars ~]#

6. CPAMモジュールの設定再実行

  • CPANモジュールをアップデートした事によって,再度設定が必要となる.
  • CPANモジュールを実行する.
[root@mars ~]# perl -MCPAN -e shell
CPAN: File::HomeDir loaded ok (v0.80)
Sorry, we have to rerun the configuration dialog for CPAN.pm due to
some missing parameters...

Normally CPAN.pm keeps config variables in memory and changes need to
be saved in a separate 'o conf commit' command to make them permanent
between sessions. If you set the 'auto_commit' option to true, changes
to a config variable are always automatically committed to disk.

<auto_commit>
Always commit changes to config variables to disk? [no] 空リターン
  • CPAMの設定は,メモリに保存されて,保存する為に"o conf commit"コマンドを入力しないと保存されない.
  • 自動的確定して設定内容をディスクに書き込むかどうか,設定する.
  • ここでは,推奨の「自動保存しない」設定とする.
A Build.PL is run by perl in a separate process. Likewise we run
'./Build' and './Build install' in separate processes. If you have any
parameters you want to pass to the calls, please specify them here.

Typical frequently used settings:

--install_base /home/xxx # different installation directory

<mbuildpl_arg>
Parameters for the 'perl Build.PL' command? [] 空リターン
  • Build.PLを実行する際の,基本となるインストールディレクトリの変更を行う時は設定する.
Parameters for the './Build' command? Setting might be:

--extra_linker_flags -L/usr/foo/lib # non-standard library location

<mbuild_arg>
Your choice: []
  • 同じく,ライブラリを変更する際には,設定する.
Do you want to use a different command for './Build install'? Sudo
users will probably prefer:

su root -c ./Build
or
sudo ./Build
or
/path1/to/sudo -u admin_account ./Build

<mbuild_install_build_command>
or some such. Your choice: [./Build] 空リターン
  • 別のコマンドを実行する事があれば,ここで追加する事ができる.
Parameters for the './Build install' command? Typical frequently used
setting:

--uninst 1 # uninstall conflicting files

<mbuild_install_arg>
Your choice: [] 空リターン
  • 頻繁に使う設定?があれば,指定する.
Please remember to call 'o conf commit' to make the config permanent!


cpan shell -- CPAN exploration and modules installation (v1.9205)
ReadLine support enabled

cpan[1]>
  • 設定した内容を保存するには,
cpan[1]> o conf commit 
Unknown config variable 'links'
commit: wrote '/usr/lib/perl5/5.8.8/CPAN/Config.pm'

cpan[2]>
  • CPANモジュールを終了し,再度接続する.
cpan[2]> quit 
Lockfile removed.
[root@mars ~]# perl -MCPAN -e shell
CPAN: File::HomeDir loaded ok (v0.80)

cpan shell -- CPAN exploration and modules installation (v1.9205)
ReadLine support enabled

cpan[1]>
  • ワーニングおよびエラーが出ていない事が確認で来たので,終了.

7.設定を確認したり変更する

  • CPANモジュールの初回起動時に行った設定は,以下の様に設定ファイルに記載されている.
[root@mars ujpadmin]# cat /usr/lib/perl5/5.8.8/CPAN/Config.pm

# This is CPAN.pm's systemwide configuration file. This file provides
# defaults for users, and the values can be changed in a per-user
# configuration file. The user-config file is being looked for as
# ~/.cpan/CPAN/MyConfig.pm.

$CPAN::Config = {
'auto_commit' => q[0],
'build_cache' => q[10],
'build_dir' => q[/root/.cpan/build],
'cache_metadata' => q[1],
'commandnumber_in_prompt' => q[1],
'cpan_home' => q[/root/.cpan],
'dontload_hash' => { },
'ftp' => q[/usr/kerberos/bin/ftp],
'ftp_passive' => q[1],
'ftp_proxy' => q[],
'getcwd' => q[cwd],
'gpg' => q[/usr/bin/gpg],
'gzip' => q[/bin/gzip],
'histfile' => q[/root/.cpan/histfile],
'histsize' => q[100],
'http_proxy' => q[],
'inactivity_timeout' => q[0],
'index_expire' => q[1],
'inhibit_startup_message' => q[0],
'keep_source_where' => q[/root/.cpan/sources],
'make' => q[/usr/bin/make],
'make_arg' => q[],
'make_install_arg' => q[],
'make_install_make_command' => q[/usr/bin/make],
'makepl_arg' => q[],
'mbuild_arg' => q[],
'mbuild_install_arg' => q[],
'mbuild_install_build_command' => q[./Build],
'mbuildpl_arg' => q[],
'ncftp' => q[],
'ncftpget' => q[],
'no_proxy' => q[],
'pager' => q[/usr/bin/less],
'prerequisites_policy' => q[ask],
'scan_cache' => q[atstart],
'shell' => q[/bin/bash],
'show_upload_date' => q[0],
'tar' => q[/bin/tar],
'term_is_latin' => q[1],
'term_ornaments' => q[1],
'unzip' => q[/usr/bin/unzip],
'urllist' => [q[ftp://ftp.kddilabs.jp/CPAN/], q[ftp://ftp.dti.ad.jp/pub/lang/
CPAN/], q[ftp://ftp.riken.jp/lang/CPAN/]],
'use_sqlite' => q[0],
'wget' => q[/usr/bin/wget],
};
1;
__END__
[root@mars ujpadmin]#


広告スペース
Google