📄 cpan.3
字号:
.IX Subsection "Configuration for individual distributions (Distroprefs)"(\fBNote:\fR This feature has been introduced in \s-1CPAN\s0.pm 1.8854 and isstill considered beta quality).PPDistributions on the \s-1CPAN\s0 usually behave according to what we call the\&\s-1CPAN\s0 mantra. Or since the event of Module::Build we should talk abouttwo mantras:.PP.Vb 4\& perl Makefile.PL perl Build.PL\& make ./Build\& make test ./Build test\& make install ./Build install.Ve.PPBut some modules cannot be built with this mantra. They try to getsome extra data from the user via the environment, extra arguments orinteractively thus disturbing the installation of large bundles likePhalanx100 or modules with many dependencies like Plagger..PPThe distroprefs system of \f(CW\*(C`CPAN.pm\*(C'\fR addresses this problem byallowing the user to specify extra informations and recipes in \s-1YAML\s0files to either.IP "\(bu" 4pass additional arguments to one of the four commands,.IP "\(bu" 4set environment variables.IP "\(bu" 4instantiate an Expect object that reads from the console, waits forsome regular expressions and enters some answers.IP "\(bu" 4temporarily override assorted \f(CW\*(C`CPAN.pm\*(C'\fR configuration variables.IP "\(bu" 4specify dependencies that the original maintainer forgot to specify.IP "\(bu" 4disable the installation of an object altogether.PPSee the \s-1YAML\s0 and Data::Dumper files that come with the \f(CW\*(C`CPAN.pm\*(C'\fRdistribution in the \f(CW\*(C`distroprefs/\*(C'\fR directory for examples..Sh "Filenames".IX Subsection "Filenames"The \s-1YAML\s0 files themselves must have the \f(CW\*(C`.yml\*(C'\fR extension, all otherfiles are ignored (for two exceptions see \fIFallback Data::Dumper andStorable\fR below). The containing directory can be specified in\&\f(CW\*(C`CPAN.pm\*(C'\fR in the \f(CW\*(C`prefs_dir\*(C'\fR config variable. Try \f(CW\*(C`o conf initprefs_dir\*(C'\fR in the \s-1CPAN\s0 shell to set and activate the distroprefssystem..PPEvery \s-1YAML\s0 file may contain arbitrary documents according to the \s-1YAML\s0specification and every single document is treated as an entity thatcan specify the treatment of a single distribution..PPThe names of the files can be picked freely, \f(CW\*(C`CPAN.pm\*(C'\fR always readsall files (in alphabetical order) and takes the key \f(CW\*(C`match\*(C'\fR (seebelow in \fILanguage Specs\fR) as a hashref containing match criteriathat determine if the current distribution matches the \s-1YAML\s0 documentor not..Sh "Fallback Data::Dumper and Storable".IX Subsection "Fallback Data::Dumper and Storable"If neither your configured \f(CW\*(C`yaml_module\*(C'\fR nor \s-1YAML\s0.pm is installed\&\s-1CPAN\s0.pm falls back to using Data::Dumper and Storable and looks forfiles with the extensions \f(CW\*(C`.dd\*(C'\fR or \f(CW\*(C`.st\*(C'\fR in the \f(CW\*(C`prefs_dir\*(C'\fRdirectory. These files are expected to contain one or more hashrefs.For Data::Dumper generated files, this is expected to be done with bydefining \f(CW$VAR1\fR, \f(CW$VAR2\fR, etc. The \s-1YAML\s0 shell would produce thesewith the command.PP.Vb 1\& ysh < somefile.yml > somefile.dd.Ve.PPFor Storable files the rule is that they must be constructed such that\&\f(CW\*(C`Storable::retrieve(file)\*(C'\fR returns an array reference and the arrayelements represent one distropref object each. The conversion from\&\s-1YAML\s0 would look like so:.PP.Vb 3\& perl \-MYAML=LoadFile \-MStorable=nstore \-e \*(Aq\& @y=LoadFile(shift);\& nstore(\e@y, shift)\*(Aq somefile.yml somefile.st.Ve.PPIn bootstrapping situations it is usually sufficient to translate onlya few \s-1YAML\s0 files to Data::Dumper for the crucial modules like\&\f(CW\*(C`YAML::Syck\*(C'\fR, \f(CW\*(C`YAML.pm\*(C'\fR and \f(CW\*(C`Expect.pm\*(C'\fR. If you prefer Storableover Data::Dumper, remember to pull out a Storable version that writesan older format than all the other Storable versions that will need toread them..Sh "Blueprint".IX Subsection "Blueprint"The following example contains all supported keywords and structureswith the exception of \f(CW\*(C`eexpect\*(C'\fR which can be used instead of\&\f(CW\*(C`expect\*(C'\fR..PP.Vb 10\& \-\-\-\& comment: "Demo"\& match:\& module: "Dancing::Queen"\& distribution: "^CHACHACHA/Dancing\-"\& perl: "/usr/local/cariba\-perl/bin/perl"\& perlconfig:\& archname: "freebsd"\& disabled: 1\& cpanconfig:\& make: gmake\& pl:\& args:\& \- "\-\-somearg=specialcase"\&\& env: {}\&\& expect:\& \- "Which is your favorite fruit"\& \- "apple\en"\&\& make:\& args:\& \- all\& \- extra\-all\&\& env: {}\&\& expect: []\&\& commendline: "echo SKIPPING make"\&\& test:\& args: []\&\& env: {}\&\& expect: []\&\& install:\& args: []\&\& env:\& WANT_TO_INSTALL: YES\&\& expect:\& \- "Do you really want to install"\& \- "y\en"\&\& patches:\& \- "ABCDE/Fedcba\-3.14\-ABCDE\-01.patch"\&\& depends:\& configure_requires:\& LWP: 5.8\& build_requires:\& Test::Exception: 0.25\& requires:\& Spiffy: 0.30.Ve.Sh "Language Specs".IX Subsection "Language Specs"Every \s-1YAML\s0 document represents a single hash reference. The valid keysin this hash are as follows:.IP "comment [scalar]" 4.IX Item "comment [scalar]"A comment.IP "cpanconfig [hash]" 4.IX Item "cpanconfig [hash]"Temporarily override assorted \f(CW\*(C`CPAN.pm\*(C'\fR configuration variables..SpSupported are: \f(CW\*(C`build_requires_install_policy\*(C'\fR, \f(CW\*(C`check_sigs\*(C'\fR,\&\f(CW\*(C`make\*(C'\fR, \f(CW\*(C`make_install_make_command\*(C'\fR, \f(CW\*(C`prefer_installer\*(C'\fR,\&\f(CW\*(C`test_report\*(C'\fR. Please report as a bug when you need another onesupported..IP "depends [hash] *** \s-1EXPERIMENTAL\s0 \s-1FEATURE\s0 ***" 4.IX Item "depends [hash] *** EXPERIMENTAL FEATURE ***"All three types, namely \f(CW\*(C`configure_requires\*(C'\fR, \f(CW\*(C`build_requires\*(C'\fR, and\&\f(CW\*(C`requires\*(C'\fR are supported in the way specified in the \s-1META\s0.ymlspecification. The current implementation \fImerges\fR the specifieddependencies with those declared by the package maintainer. In afuture implementation this may be changed to override the originaldeclaration..IP "disabled [boolean]" 4.IX Item "disabled [boolean]"Specifies that this distribution shall not be processed at all..IP "goto [string]" 4.IX Item "goto [string]"The canonical name of a delegate distribution that shall be installedinstead. Useful when a new version, although it tests \s-1OK\s0 itself,breaks something else or a developer release or a fork is alreadyuploaded that is better than the last released version..IP "install [hash]" 4.IX Item "install [hash]"Processing instructions for the \f(CW\*(C`make install\*(C'\fR or \f(CW\*(C`./Build install\*(C'\fRphase of the \s-1CPAN\s0 mantra. See below under \fIProcessiong Instructions\fR..IP "make [hash]" 4.IX Item "make [hash]"Processing instructions for the \f(CW\*(C`make\*(C'\fR or \f(CW\*(C`./Build\*(C'\fR phase of the\&\s-1CPAN\s0 mantra. See below under \fIProcessiong Instructions\fR..IP "match [hash]" 4.IX Item "match [hash]"A hashref with one or more of the keys \f(CW\*(C`distribution\*(C'\fR, \f(CW\*(C`modules\*(C'\fR,\&\f(CW\*(C`perl\*(C'\fR, and \f(CW\*(C`perlconfig\*(C'\fR that specify if a document is targeted at aspecific \s-1CPAN\s0 distribution or installation..SpThe corresponding values are interpreted as regular expressions. The\&\f(CW\*(C`distribution\*(C'\fR related one will be matched against the canonicaldistribution name, e.g. \*(L"AUTHOR/Foo\-Bar\-3.14.tar.gz\*(R"..SpThe \f(CW\*(C`module\*(C'\fR related one will be matched against \fIall\fR modulescontained in the distribution until one module matches..SpThe \f(CW\*(C`perl\*(C'\fR related one will be matched against \f(CW$^X\fR (but with theabsolute path)..SpThe value associated with \f(CW\*(C`perlconfig\*(C'\fR is itself a hashref that ismatched against corresponding values in the \f(CW%Config::Config\fR hashliving in the \f(CW\*(C` Config.pm \*(C'\fR module..SpIf more than one restriction of \f(CW\*(C`module\*(C'\fR, \f(CW\*(C`distribution\*(C'\fR, and\&\f(CW\*(C`perl\*(C'\fR is specified, the results of the separately computed matchvalues must all match. If this is the case then the hashrefrepresented by the \s-1YAML\s0 document is returned as the preferencestructure for the current distribution..IP "patches [array]" 4.IX Item "patches [array]"An array of patches on \s-1CPAN\s0 or on the local disk to be applied inorder via the external patch program. If the value for the \f(CW\*(C`\-p\*(C'\fRparameter is \f(CW0\fR or \f(CW1\fR is determined by reading the patchbeforehand..SpNote: if the \f(CW\*(C`applypatch\*(C'\fR program is installed and \f(CW\*(C`CPAN::Config\*(C'\fRknows about it \fBand\fR a patch is written by the \f(CW\*(C`makepatch\*(C'\fR program,then \f(CW\*(C`CPAN.pm\*(C'\fR lets \f(CW\*(C`applypatch\*(C'\fR apply the patch. Both \f(CW\*(C`makepatch\*(C'\fRand \f(CW\*(C`applypatch\*(C'\fR are available from \s-1CPAN\s0 in the \f(CW\*(C`JV/makepatch\-*\*(C'\fRdistribution..IP "pl [hash]" 4.IX Item "pl [hash]"Processing instructions for the \f(CW\*(C`perl Makefile.PL\*(C'\fR or \f(CW\*(C`perlBuild.PL\*(C'\fR phase of the \s-1CPAN\s0 mantra. See below under \fIProcessiongInstructions\fR..IP "test [hash]" 4.IX Item "test [hash]"Processing instructions for the \f(CW\*(C`make test\*(C'\fR or \f(CW\*(C`./Build test\*(C'\fR phaseof the \s-1CPAN\s0 mantra. See below under \fIProcessiong Instructions\fR..Sh "Processing Instructions".IX Subsection "Processing Instructions".IP "args [array]" 4.IX Item "args [array]"Arguments to be added to the command line.IP "commandline" 4.IX Item "commandline"A full commandline that will be executed as it stands by a systemcall. During the execution the environment variable \s-1PERL\s0 will is setto $^X (but with an absolute path). If \f(CW\*(C`commandline\*(C'\fR is specified,the content of \f(CW\*(C`args\*(C'\fR is not used..IP "eexpect [hash]" 4.IX Item "eexpect [hash]"Extended \f(CW\*(C`expect\*(C'\fR. This is a hash reference with four allowed keys,\&\f(CW\*(C`mode\*(C'\fR, \f(CW\*(C`timeout\*(C'\fR, \f(CW\*(C`reuse\*(C'\fR, and \f(CW\*(C`talk\*(C'\fR..Sp\&\f(CW\*(C`mode\*(C'\fR may have the values \f(CW\*(C`deterministic\*(C'\fR for the case where allquestions come in the order written down and \f(CW\*(C`anyorder\*(C'\fR for the casewhere the questions may come in any order. The default mode is\&\f(CW\*(C`deterministic\*(C'\fR..Sp\&\f(CW\*(C`timeout\*(C'\fR denotes a timeout in seconds. Floating point timeouts are\&\s-1OK\s0. In the case of a \f(CW\*(C`mode=deterministic\*(C'\fR the timeout denotes thetimeout per question, in the case of \f(CW\*(C`mode=anyorder\*(C'\fR it denotes thetimeout per byte received from the stream or questions..Sp\&\f(CW\*(C`talk\*(C'\fR is a reference to an array that contains alternating questionsand answers. Questions are regular expressions and answers are literalstrings. The Expect module will then watch the stream coming from theexecution of the external program (\f(CW\*(C`perl Makefile.PL\*(C'\fR, \f(CW\*(C`perlBuild.PL\*(C'\fR, \f(CW\*(C`make\*(C'\fR, etc.)..SpIn the case of \f(CW\*(C`mode=deterministic\*(C'\fR the \s-1CPAN\s0.pm will inject theaccording answer as soon as the stream matches the regular expression..SpIn the case of \f(CW\*(C`mode=anyorder\*(C'\fR \s-1CPAN\s0.pm will answer a question as soonas the timeout is reached for the next byte in the input stream. Inthis mode you can use the \f(CW\*(C`reuse\*(C'\fR parameter to decide what shallhappen with a question-answer pair after it has been used. In thedefault case (reuse=0) it is removed from the array, so it cannot beused again accidentally. In this case, if you want to answer thequestion \f(CW\*(C`Do you really want to do that\*(C'\fR several times, then it mustbe included in the array at least as often as you want this answer tobe given. Setting the parameter \f(CW\*(C`reuse\*(C'\fR to 1 makes this repetitionunnecessary..IP "env [hash]" 4.IX Item "env [hash]"Environment variables to be set during the command.IP "expect [array]" 4.IX Item "expect [array]"\&\f(CW\*(C`expect: <array>\*(C'\fR is a short notation for.Sp.Vb 4\& eexpect:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -