メインメニュー
ログイン
ユーザー名:

パスワード:


パスワード紛失

PukiWiki最新記事
[ リロード ]   [ ソース ]  [ トップ | インデックス | 単語検索 | ご意見、ご感想 ]

Counter: 11254, today: 1, yesterday: 4

ユーザーのディレクトリにcpanを使ってperlのモジュールをインストールする方法

通常は、root特権でperlモジュールのインストールを行いますが、root特権でインストールできない場合、個人ユーザのディレクトリにモジュールをインストールすることができます。

cpanを使用できるように設定

$ cd
$ mkdir perl
$ mkdir .cpan/CPAN/

.cpan/CPAN/MyConfig.pm (コンフィグファイル)を作成
 環境設定はたたみラボのブログを参考

$CPAN::Config->{cpan_home}  = undef;
$CPAN::Config->{makepl_arg} = 'PREFIX=~/perl';
$CPAN::Config->{histfile}   = "$ENV{HOME}/.cpan/histfile";
1;

cpanを起動

$ perl -MCPAN -e shell

> perl -MCPAN -e shell
CPAN: File::HomeDir loaded ok
Sorry, we have to rerun the configuration dialog for CPAN.pm due to
the following indispensable but missing parameters:

build_cache, build_dir, cache_metadata, cpan_home, ftp_proxy, gzip, http_proxy, index_expire, inhibit_startup_message, keep_source_where, make, make_arg, make_install_arg, mbuild_arg, mbuild_install_arg, mbuild_install_build_command, mbuildpl_arg, no_proxy, pager, prerequisites_policy, scan_cache, tar, unzip, urllist

/virtual/user/.cpan/CPAN/MyConfig.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]


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.



I see you already have a  directory
    /virtual/user/.cpan
Shall we use it as the general CPAN build and cache directory?

CPAN build and cache directory? [/virtual/user/.cpan]


If you like, I can cache the source files after I build them.  Doing
so means that, if you ever rebuild that module in the future, the
files will be taken from the cache. The tradeoff is that it takes up
space.  How much space would you like to allocate to this cache?  (If
you don't want me to keep a cache, answer 0.)



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

Cache size for build directory (in MB)? [100]


By default, each time the CPAN module is started, cache scanning is
performed to keep the cache size in sync. To prevent this, answer
'never'.

Perform cache scanning (atstart or never)? [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]


The next option deals with the charset (aka character set) your
terminal supports. In general, CPAN is English speaking territory, so
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 should say no to the next
question.  If it supports ISO-8859-1 (also known as LATIN1) then you
should say yes.  If it supports neither, your answer does not matter
because 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]


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? [/virtual/user/.cpan/histfile]
Number of lines to save? [100]


The 'd' and the 'm' command normally only show you information they
have in their in-memory database and thus will never connect to the
internet. If you set the 'show_upload_date' variable to true, 'm' and
'd' will additionally show you the upload date of the module or
distribution. Per default this feature is off because it may require a
net connection to get at the upload date.

Always try to show upload date with 'd' and 'm' command (yes/no)? [yes]


The CPAN module can detect when a module 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]


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 bzip2 program? [/usr/bin/bzip2]
Where is your gzip program? [/usr/bin/gzip]
Where is your tar program? [/bin/tar]
Where is your unzip program? [/usr/local/bin/unzip]
Where is your make program? [/usr/bin/make]
Where is your curl program? [/usr/local/bin/curl]
Where is your lynx program? [/usr/bin/lynx]
Where is your wget program? [/usr/local/bin/wget]
Where is your ncftpget program? [/usr/bin/ncftpget]
Where is your ftp program? [/usr/bin/ftp]
Where is your gpg program? [/usr/local/bin/gpg]
What is your favorite pager program? [less]
What is your favorite shell? [/bin/bash]


When you have Module::Build installed and a module comes with both a
Makefile.PL and a Build.PL, which shall have precedence? The two
installer modules we have are the old and well established
ExtUtils::MakeMaker (for short: EUMM) understands the Makefile.PL and
the next generation installer Module::Build (MB) works with the
Build.PL.

In case you could choose, which installer would you prefer (EUMM or MB)? [EUMM]


Every Makefile.PL is run by perl in a separate process. Likewise we
run 'make' and 'make install' in separate 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:  [PREFIX=~/perl]
Parameters for the 'make' command?
Typical frequently used setting:

    -j3              # dual processor system

Your choice:  []
Do you want to use a different make command for 'make install'?
Cautious people will probably prefer:

    su root -c make
or
    sudo make
or
    /path1/to/sudo -u admin_account /path2/to/make

or some such. Your choice:  [/usr/bin/make]
Parameters for the 'make install' command?
Typical frequently used setting:

    UNINST=1         # to always uninstall potentially conflicting files

Your choice:  []
our choice:  []


The next questions deal with Module::Build support.

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.

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

    --install_base /home/xxx             # different installation directory

Your choice:  []
Parameters for the './Build' command?
Setting might be:

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

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

or some such. Your choice:  [./Build]
Parameters for the './Build install' command?
Typical frequently used setting:

    --uninst 1                           # uninstall conflicting files

Your choice:  []

Sometimes you may wish to leave the processes run by CPAN alone
without caring about them. Because the Makefile.PL sometimes 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,Build}.PL? [0]


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?
Your http_proxy?
Your no_proxy?
You have no /virtual/user/.cpan/sources/MIRRORED.BY
  I'm trying to fetch one
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
  http://www.perl.org/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) Australasia
(4) Central America
(5) Europe
(6) North America
(7) Oceania
(8) South America
Select your continent (or several nearby continents) []2
Sorry! since you don't have any existing picks, you must make a
geographic selection.

(1) Hong Kong
(2) India
(3) Indonesia
(4) Japan
(5) Kazakhstan
(6) Republic of Korea
(7) Russia
(8) Singapore
(9) Taiwan
(10) Thailand
(11) Turkey
(12) Viet Nam
Select your country (or several nearby countries) [] 4
Sorry! since you don't have any existing picks, you must make a
geographic selection.

(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' []
2 4 7 8 

Enter another URL or RETURN to quit: []
New set of picks:
  ftp://ftp.jaist.ac.jp/pub/CPAN/
  ftp://ftp.nara.wide.ad.jp/pub/CPAN/
  ftp://ftp.u-aizu.ac.jp/pub/CPAN
  ftp://ftp.yz.yamagata-u.ac.jp/pub/lang/cpan/


commit: wrote '/virtual/user/.cpan/CPAN/MyConfig.pm'

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

cpan>

これでcpanの設定は終了。

モジュールのインストール

cpanのプロンプトでモジュール名をしていしてインストールコマンドを実行するだけで自動的にモジュールのインストールができます。

cpan> install モジュール名

インストールしたモジュールの使い方

モジュールを使用する前に以下の2行を追加する。

use lib '~/perl/lib/perl5';
use lib '~/perl/lib/perl5/site_perl';

   

ページコメント
投稿された内容の著作権はコメントの投稿者に帰属します。

トラックバック [ トラックバック(0) ]
トラックバック URL: http://myboom.mkch.net/modules/pukiwiki/tb/76