PC-UNIXに関する記事など
当サイトのblogのエントリーで検索ワードが多いのはCPANなんですがこの古い記事はperl5.6時代に書いた記事(多分10年近く前だと思う)で今時のperl使いにお勧めできるものではありません。
2010年2月にあの miyagawa さんが書いた cpanminus が非常に素晴らしいので CPAN::shell を捨てて App-cpanminus を積極的に利用しましょう。
と言うことでcpanに関連して新しい記事を書いてみました。
cpanmが登場する以前はCPAN::shellを使うかtarballを取ってきてmakeするしか方法がありませんでしたが誰がどう見てもcpanm使わないと損だよね。
$ mkdir bin && cd ~/bin $ curl -LOk http://xrl.us/cpanm $ chmod +x cpanm
cpanm と合わせて local::lib も入れておくと便利です
$ cpanm local::lib
現在作者のmiyagawaさんがもの凄い勢いでcpanmのupgradeを行ってますので頻繁に行うことになります
$ cpanm --self-upgrade
非常に多彩な方法で install ができます
モジュール名だけを指定するとCPANと同じ動作をします
直接 tarball を指定できるのは便利かも
cpanm Module cpanm MIYAGAWA/Plack-1.0000.tar.gz cpanm ~/mydists/MyCompany-Framework-1.0.tar.gz cpanm http://example.com/MyModule-0.1.tar.gz cpanm http://github.com/miyagawa/Tatsumaki/tarball/master cpanm --interactive Task::Kensho
# cpanm -h Usage: cpanm [options] Module [...] Options: -v,--verbose Turns on chatty output --interactive Turns on interactive configure (required for Task:: modules) -f,--force force install -n,--notest Do not run unit tests -S,--sudo sudo to run install commands --installdeps Only install dependencies --skip-installed Skip installation if you already have the latest version installed --disable-plugins Disable plugin loading Commands: --self-upgrade upgrades itself --look Download the tarball and open the directory with your shell --info Displays distribution info on CPAN --recent Show recently updated modules Examples: cpanm CGI # install CGI cpanm MIYAGAWA/Plack-0.99_05.tar.gz # full distribution name cpanm http://example.org/LDS/CGI.pm-3.20.tar.gz # install from URL cpanm ~/dists/MyCompany-Enterprise-1.00.tar.gz # install from a local file cpanm --interactive Task::Kensho # Configure interactively cpanm . # install from local directory cpanm --installdeps . # install all the deps for the current directory
rootでcpanmを使った場合
# tail -f /root/.cpanm/build.log
ユーザ権限でcpanmを使った場合
$ tail -f ~/.cpanm/build.log
ここでは
bash な方は .bash_profile 等に以下を追加
export PERL_CPANM_OPT="--local-lib=~/extlib" export PERL5LIB="$HOME/extlib/lib/perl5:$HOME/extlib/lib/perl5/i386-freebsd-64int:$PERL5LIB"
以降このユーザ権限でcpanm MODULE すると ~/extlib 以下に全てのモジュールがinstallされます
これ以外のディレクトリに入れたい場合は
$ cpanm -l /path/to/dirname MODULE
-lオプションで場所を指定する事で /path/to/dirname 以下に install できます
App-cpanminus の登場により CPAN::shell の役目はもう終えたと思われるので
perlに標準で付くようになるといいなぁ・・・
CPAN::shellいままでありがとう。
トラックバックURL: http://www.omakase.org/mt/mt-tb.cgi/36
コメントする