CPAN - CPANããã¢ã¸ã¥ã¼ã«ã¤ã³ã¹ãã¼ã«
Perl
›
ã¢ã¸ã¥ã¼ã«
›
here
ãCPANã¢ã¸ã¥ã¼ã«ã使ç¨ããã°CPANããã¢ã¸ã¥ã¼ã«ã¤ã³ã¹ãã¼ã«ãããã¨ãã§ãã¾ããCPANã¯ç¡æã§å©ç¨ã§ããã¢ã¸ã¥ã¼ã«ãããããéãããããµã¤ãã§ããCPANã¢ã¸ã¥ã¼ã«ã¯ã³ãã³ãã©ã¤ã³ããå©ç¨ãããã¨ãæ³å®ããã¦ãããcpanã³ãã³ãããå種æ©è½ãå©ç¨ãããã¨ãã§ãã¾ãã
ãã³ãã³ãã©ã¤ã³ã§cpanã³ãã³ããå®è¡ããã¨ã¢ã¸ã¥ã¼ã«ãã¤ã³ã¹ãã¼ã«ãããã¨ãã§ãã¾ãã
# ã¢ã¸ã¥ã¼ã«ã®ã¤ã³ã¹ãã¼ã«
cpan ã¢ã¸ã¥ã¼ã«å
ãã¾ãcpanã·ã§ã«ã¨å¼ã°ãã対話çã«ã¤ã³ã¹ãã¼ã«ãè¡ãæ©è½ãããã¾ããcpanã³ãã³ãã«å¼æ°ãæå®ããªããã°cpanã·ã§ã«ãèµ·åãã¾ãã(ActivePerlã§YAMLã¨ã©ã¼ãã§ãå ´åãããã¾ãã対å¦ã»ãã¯こちらã«ããã¾ãã)
# cpanã·ã§ã«ã®èµ·å cpan # ã¢ã¸ã¥ã¼ã«ã®ã¤ã³ã¹ãã¼ã«(cpanã·ã§ã«) install ã¢ã¸ã¥ã¼ã«å
ãcpanã·ã§ã«ãçµäºããã«ã¯exitã³ãã³ãã使ç¨ãã¾ãã
# cpanã·ã§ã«ã®çµäº(cpanã·ã§ã«) exit
ãããcpanãå®è¡ããã®ãå§ãã¦ã§ããã°ãååèµ·åæã«cpanã®è¨å®ãè¡ãå¿ è¦ãããã¾ããããããã®è¨å®ã«ã¤ãã¦èãããã®ã§é©ãã¦ãã¾ãããããã¾ããããEnterãæ¼ãã¦ããã©ã«ãã®è¨å®ãé²ãã¦ããã¾ããããå¾ã§è¨å®ãå¤æ´ãããã¨ãã§ãã¾ãã
ãæè¿ã®cpanã¯ãã¹ã¦ãèªåã§è¨å®ãã¦ãããããã«ãªã£ã¦ãã¾ãããå°ãå¤ããã®ã§ããã°ãä¸é¨æåã§è¨å®ããªããã°ãªããªãé ç®ãããã¾ãã
ãã©ã®ãã©ã¼ãµã¤ãããã¤ã³ã¹ãã¼ã«ãããã決ããé ç®ã§ããCPANã«ã¯ä¸çä¸ã«ãã©ã¼ãµã¤ããããã®ã§ä¸çªè¿ããã©ã¼ãµã¤ããé¸æãã¾ãããã
# CPANãã©ã¼ã®é¸æ 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) South America Select your continent (or several nearby continents) [] 2 (1) China (2) Hong Kong (3) Indonesia (4) Israel (5) Japan <----------ãããé¸æ (6) Saudi-Arabia (7) Singapore (8) South Korea (9) Taiwan (10) Thailand Select your country (or several nearby countries) [] 5 (1) ftp://ftp.dti.ad.jp/pub/lang/CPAN/ (2) ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/ (3) ftp://ftp.lab.kdd.co.jp/lang/perl/CPAN/ (4) ftp://ftp.meisei-u.ac.jp/pub/CPAN/ (5) ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/ <----- ã©ãã§ããããä»åã¯5ãé¸æ (6) ftp://mirror.nucba.ac.jp/mirror/Perl/ Select as many URLs as you like [] 5
ãcpanã®è¨å®ãããç´ãããå ´åã¯cpanã·ã§ã«ã§ão conf initãã³ãã³ãã使ç¨ãã¾ãã
# è¨å®ãããç´ã(cpanã·ã§ã«)
o conf init
capnã®è¨å®ã®å¤æ´
ãcpanã®è¨å®ãå¤æ´ããã«ã¯cpanã·ã§ã«ãèµ·åãã¦ããão confãã³ãã³ãã使ç¨ãã¾ãããã¹ã¦ã®è¨å®å¤ãè¦ãã«ã¯ão confãã¨ãã¾ãã
# ãã¹ã¦ã®è¨å®ãè¦ã(cpanã·ã§ã«)
o conf
ã次ã®ããã«è¨å®ã®ä¸è¦§ã表示ããã¾ãã
# cpanã®è¨å®ã®ä¸è¦§ applypatch [] auto_commit [0] build_cache [100] build_dir [/root/.cpan/build] . . (çç¥) . username undef wait_list undef wget [/usr/bin/wget] yaml_load_code [0] yaml_module [YAML]
ãè¨å®é ç®ã¯å¤æ´ãããã¨ãã§ãã¾ãã
# è¨å®ã®å¤æ´(cpanã·ã§ã«) o conf build_cache 200
ãè¨å®ããé ç®ã¯cpanã·ã§ã«ãèµ·åãã¦ããéã ãæå¹ã§ããè¨å®ãä¿åããããã«ã¯commitãå®è¡ããå¿ è¦ãããã¾ãã
# è¨å®ã®ä¿å(cpanã·ã§ã«)
o conf commit
ãè¨å®é ç®ããªã¹ãã®å ´åã¯unshift,push,pop,shiftã³ãã³ããå©ç¨ãããã¨ãã§ãã¾ãã
# å é ã«è¿½å o conf urllist unshift http://cpan.dev.local/CPAN # æ«å°¾ã«è¿½å o conf urllist push http://cpan.dev.local/CPAN # æ«å°¾ãåé¤ o conf urllist pop # å é ãåé¤ o conf urllist shift
CPANã¢ã¸ã¥ã¼ã«ã®ã¤ã³ã¹ãã¼ã«ã«å¤±æããå ´å
ãCPANã¢ã¸ã¥ã¼ã«ã®ã¤ã³ã¹ãã¼ã«ã失æãããã¨ã¯ããããã¾ããããããã®åå ãç¹å®ãããã¨ã¯é£ããã§ããèããããç¶æ³ãããã¤ãæ¸ãã¦ããã¾ãã
1. CPANãã©ã¼ãè½ã¡ã¦ãã
ã-> urllistã®å
é ã«å©ç¨ã§ããCPANãã©ã¼ã追å ãã
2. ã¢ã¸ã¥ã¼ã«ã巨大ãªã®ã§ã¢ã¸ã¥ã¼ã«ããã«ãããããã«ç¢ºä¿ãã¦ããé åã足ããªã
ã-> build_cache ã®å¤ã100Mãããã«å¢ããã¦ã¿ã
3. ã¢ã¸ã¥ã¼ã«ãUnixç°å¢ããæ³å®ãã¦ããªãããããã¯ãWindowsã§å¤±æãã試é¨ãå«ãã¦ããã
ã-> 試é¨ã失æãã¦ãããã¨ã ããåå ã§ããã¨æããªãã°ãå¼·å¶çã«ã¤ã³ã¹ãã¼ã«ãã¦ã¿ããã¨ãã§ããããå ±åãã¦ãããã®ãæã¾ããã
4. XSãå«ãã§ããã®ãgccã³ã³ãã¤ã©ããªãããã«ã¤ã³ã¹ãã¼ã«ã§ããªãã
ã-> gccã®ããã±ã¼ã¸ãLinuxã®å ´åã§ããã°ãyumãapt-getã§gccãã¤ã³ã¹ãã¼ã«ãWindowsã®å ´åã¯5.10.1以éã®ActivePerlã§ããã°MinGWã梱å
ããã¦ããgccç°å¢ãããã
5. ãããã·æ¥ç¶ã§ãããã¤ã³ã¿ã¼ããããå©ç¨ã§ããªãç°å¢ã«ãã
ãã->ä¼æ¥ãªã©ã®ãããã¯ã¼ã¯ã®å ´åã¯ãããã·ãµã¼ããä»ãã¦ãã¦ã¤ã³ã¿ã¼ãããã«æ¥ç¶ã§ããªãå ´åãããã§ãããããã®å ´åã«ã¯ãããã·ãè¨å®ãããã¨ãã§ãã¾ãããããã·ã®ãã¡ã¤ã³åã¨ãã¼ãçªå·ã¯èª¿ã¹ãå¿
è¦ãããã¾ããã
# ãããã·ã®è¨å® o conf http_proxy ftp_proxy=http://proxy.you.com:8000/ o conf ftp_proxy http_proxy=http://proxy.you.com:8000/
ãã¾ãå¤é¨ã«å¯¾ãã¦HTTPæ¥ç¶ãã許å¯ããã¦ããªãã®ã«ãurllistã«ftpã®URLãå«ã¾ãã¦ããã¨æ¥ç¶ã«å¤±æãã¦ãã¾ãã¾ããä¸è¨ã®URLã®ã©ãããurllistã®å é ã«å«ãã¾ãããã
# HTTPæ¥ç¶ã§ã¤ã³ã¹ãã¼ã«ããå ´å http://ftp.nara.wide.ad.jp/pub/CPAN/ http://ftp.jaist.ac.jp/pub/CPAN/ http://ftp.riken.jp/lang/CPAN/ http://ftp.yz.yamagata-u.ac.jp/pub/lang/cpan/
6. ã¢ã¸ã¥ã¼ã«ãä»ã®(Perlã§ã¯ãªã)ã©ã¤ãã©ãªã«ä¾åãã¦ãã
ã-> ãã¨ãã°XML::LibXMLã¯libxml2ã¨ããã©ã¤ãã©ãªã«ä¾åãã¦ãã¾ãããã®ã©ã¤ãã©ãªãã¤ã³ã¹ãã¼ã«ããã¦ããªãå ´åã¯CPANã§ã®ã¤ã³ã¹ãã¼ã«ã«å¤±æãã¾ããyumãapt-getãªã©ã®ã³ãã³ãã§libxml2ãå«ãããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ããå¿
è¦ãããã¾ãã
CPANã¢ã¸ã¥ã¼ã«ã«é¢ããFAQ
Q. ä¾åããã¢ã¸ã¥ã¼ã«ãã¤ã³ã¹ãã¼ã«ããã¨ãã«èªåçã«yesã¨çãããã¨ã¯ã§ãã¾ããã
A. ã¯ããã§ãã¾ããcpanã·ã§ã«ããprerequisites_policyãfollowã«è¨å®ãã¾ãã
# ä¾åããã¢ã¸ã¥ã¼ã«ãèªåçã«ã¤ã³ã¹ãã¼ã«
o conf prerequisites_policy follow
o conf commit
ãaskãæå®ããã¨ã¤ã³ã¹ãã¼ã«ãããã©ããã確èªãã¾ããignoreãæå®ããã¨ä¾åããã¢ã¸ã¥ã¼ã«ãã¤ã³ã¹ãã¼ã«ãã¾ããã
Q. CPANãã©ã¼ã®URLä¸è¦§ãæ²è¼ããã¦ãããµã¤ãã¯ããã¾ããã
A. ä¸è¨ã®ãµã¤ãã«ãªãã¾ãã
Q. Windowsã§ãcpanã¯å©ç¨ã§ãã¾ããã
A. ã¯ãã§ãã¾ãã以åã¯Windowsã§cpanãå©ç¨ããã«ã¯makeã³ãã³ãã®å¤ããã«ãªãnmakeã¨ããã³ãã³ããå¿
è¦ã§ãããç¾å¨ã§ã¯ãActivePerlã5.10.1以éã§ããã°MinGWã¨ããéçºç¨ã®ãã¼ã«ã梱å
ããã¦ãã¾ããããã«ã¯makeã³ãã³ãã®å¤ããã«ãªããã®ãCã®ã³ã³ãã¤ã©ãå«ã¾ãã¦ããã®ã§ãWindowsã§ãcpanããã¾ãå©ç¨ã§ããããã«ãªãã¾ããã
Q. ã¢ã¸ã¥ã¼ã«ã®ã¤ã³ã¹ãã¼ã«å±¥æ´ãè¦ããã¨ãã§ãã¾ãã?
A. perllocalã¨ããããã¥ã¡ã³ãã«ã¤ã³ã¹ãã¼ã«å±¥æ´ãè¨é²ããã¾ãã
# ã¤ã³ã¹ãã¼ã«å±¥æ´ãè¦ã
perldoc perllocal
ã次ã®ããã«ã¤ã³ã¹ãã¼ã«å±¥æ´ã表示ããã¾ãã
Tue Jun 8 20:15:01 2010: "Module" Mail::Address::MobileJp ã» "installed into: /usr/lib/perl5/site_perl/5.8.8" ã» "LINKTYPE: dynamic" ã» "VERSION: 0.09" ã» "EXE_FILES: " Tue Jun 8 20:24:46 2010: "Module" Business::CreditCard ã» "installed into: /usr/lib/perl5/site_perl/5.8.8" ã» "LINKTYPE: dynamic" ã» "VERSION: 0.31" ã» "EXE_FILES: "
Q. ã¤ã³ã¹ãã¼ã«ããã¦ããã¢ã¸ã¥ã¼ã«ã®ä¸è¦§ã®ååã ãã欲ããã§ãã
A. 次ã®ã¹ã¯ãªããã使ã£ã¦ãã ãããExtUtils::Installedãå©ç¨ã§ãã¾ãã
# ã¤ã³ã¹ãã¼ã«ããã¦ããã¢ã¸ã¥ã¼ã«åã®ä¸è¦§ use ExtUtils::Installed; print join "\n", ExtUtils::Installed->new->modules;
Q. ãããããç°å¢ã«ã¾ã¨ãã¦ã¢ã¸ã¥ã¼ã«ãã¤ã³ã¹ãã¼ã«ããã«ã¯ã©ãããã°ããã§ããããã
A. ä¸è¨ã§ä½æãããã¡ã¤ã«ãcpanã«é£ã¹ããã¦ãã ãããxargsã¨çµã¿åãããã¨ããã§ãããã
# CPANã¢ã¸ã¥ã¼ã«ãã¾ã¨ãã¦ã¤ã³ã¹ãã¼ã«ãã
cat installed.txt | xargs cpan
Q. ã¤ã³ã¹ãã¼ã«ããã¦ããã¢ã¸ã¥ã¼ã«ã®ãã£ã¹ããªãã¥ã¼ã·ã§ã³åãç¥ãããã§ãã
A. ãã£ã¹ããªãã¥ã¼ã·ã§ã³åã¯ãADAMK/DBD-SQLite-1.29.tar.gzãã®ãããª
ãä½è
å/ã¢ã¸ã¥ã¼ã«å-ãã¼ã¸ã§ã³.tar.gzãã®ãããªæ§æã«ãªãã¾ãã
ãããã¯ãcpan -aãã§ç¥ããã¨ãã§ãã¾ãã
# ã¤ã³ã¹ãã¼ã«ããã¦ããã¢ã¸ã¥ã¼ã«ã¨ãã£ã¹ããªãã¥ã¼ã·ã§ã³åã®è¡¨ç¤º cpan -a
ãã§ãããã¯ããããã®ã¢ã¸ã¥ã¼ã«ã®éè¤ãããã®ã§ãéè¤ããªããã«ã¯æ¬¡ã®ããã«ãã¾ããå°ãæéããããã¾ãã
cpan -a | awk '{print $4;}' | sort -u
Q. root権éãæã£ã¦ããªãã®ã§ããcpanãå©ç¨ãããã§ããã¦ã¼ã¶é åã«ã¤ã³ã¹ãã¼ã«ãããã¨ã¯ã§ãã¾ãã?
A. cpanã®ä»£ããã«cpanmã¨ãããã¼ã«ã使ãã®ãããã§ãããã
Q. 確å®ã«ä»ã®ç°å¢ã«CPANã¢ã¸ã¥ã¼ã«ããããã¤ããæ¹æ³ã¯ããã¾ããããå®åã§ç¢ºå®æ§ãæ±ãããã¦ãã¾ãã
A. cpanfileã¨ãããã¡ã¤ã«ã«å¿ è¦ãªã¢ã¸ã¥ã¼ã«ãè¨è¿°ãã¦cpanmã使ã£ã¦ã¤ã³ã¹ãã¼ã«ããã®ãããã§ãããã