-
Notifications
You must be signed in to change notification settings - Fork 79
/
README
2338 lines (1821 loc) · 101 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
NAME
CPAN - query, download and build perl modules from CPAN sites
SYNOPSIS
Interactive mode:
perl -MCPAN -e shell
--or--
cpan
Basic commands:
# Modules:
cpan> install Acme::Meta # in the shell
CPAN::Shell->install("Acme::Meta"); # in perl
# Distributions:
cpan> install NWCLARK/Acme-Meta-0.02.tar.gz # in the shell
CPAN::Shell->
install("NWCLARK/Acme-Meta-0.02.tar.gz"); # in perl
# module objects:
$mo = CPAN::Shell->expandany($mod);
$mo = CPAN::Shell->expand("Module",$mod); # same thing
# distribution objects:
$do = CPAN::Shell->expand("Module",$mod)->distribution;
$do = CPAN::Shell->expandany($distro); # same thing
$do = CPAN::Shell->expand("Distribution",
$distro); # same thing
DESCRIPTION
The CPAN module automates or at least simplifies the make and install of
perl modules and extensions. It includes some primitive searching
capabilities and knows how to use LWP, HTTP::Tiny, Net::FTP and certain
external download clients to fetch distributions from the net.
These are fetched from one or more mirrored CPAN (Comprehensive Perl
Archive Network) sites and unpacked in a dedicated directory.
The CPAN module also supports named and versioned *bundles* of modules.
Bundles simplify handling of sets of related modules. See Bundles below.
The package contains a session manager and a cache manager. The session
manager keeps track of what has been fetched, built, and installed in
the current session. The cache manager keeps track of the disk space
occupied by the make processes and deletes excess space using a simple
FIFO mechanism.
All methods provided are accessible in a programmer style and in an
interactive shell style.
CPAN::shell([$prompt, $command]) Starting Interactive Mode
Enter interactive mode by running
perl -MCPAN -e shell
or
cpan
which puts you into a readline interface. If "Term::ReadKey" and either
of "Term::ReadLine::Perl" or "Term::ReadLine::Gnu" are installed,
history and command completion are supported.
Once at the command line, type "h" for one-page help screen; the rest
should be self-explanatory.
The function call "shell" takes two optional arguments: one the prompt,
the second the default initial command line (the latter only works if a
real ReadLine interface module is installed).
The most common uses of the interactive modes are
Searching for authors, bundles, distribution files and modules
There are corresponding one-letter commands "a", "b", "d", and "m" for
each of the four categories and another, "i" for any of the mentioned
four. Each of the four entities is implemented as a class with
slightly differing methods for displaying an object.
Arguments to these commands are either strings exactly matching the
identification string of an object, or regular expressions matched
case-insensitively against various attributes of the objects. The
parser only recognizes a regular expression when you enclose it with
slashes.
The principle is that the number of objects found influences how an
item is displayed. If the search finds one item, the result is
displayed with the rather verbose method "as_string", but if more than
one is found, each object is displayed with the terse method
"as_glimpse".
Examples:
cpan> m Acme::MetaSyntactic
Module id = Acme::MetaSyntactic
CPAN_USERID BOOK (Philippe Bruhat (BooK) <[...]>)
CPAN_VERSION 0.99
CPAN_FILE B/BO/BOOK/Acme-MetaSyntactic-0.99.tar.gz
UPLOAD_DATE 2006-11-06
MANPAGE Acme::MetaSyntactic - Themed metasyntactic variables names
INST_FILE /usr/local/lib/perl/5.10.0/Acme/MetaSyntactic.pm
INST_VERSION 0.99
cpan> a BOOK
Author id = BOOK
EMAIL [...]
FULLNAME Philippe Bruhat (BooK)
cpan> d BOOK/Acme-MetaSyntactic-0.99.tar.gz
Distribution id = B/BO/BOOK/Acme-MetaSyntactic-0.99.tar.gz
CPAN_USERID BOOK (Philippe Bruhat (BooK) <[...]>)
CONTAINSMODS Acme::MetaSyntactic Acme::MetaSyntactic::Alias [...]
UPLOAD_DATE 2006-11-06
cpan> m /lorem/
Module = Acme::MetaSyntactic::loremipsum (BOOK/Acme-MetaSyntactic-0.99.tar.gz)
Module Text::Lorem (ADEOLA/Text-Lorem-0.3.tar.gz)
Module Text::Lorem::More (RKRIMEN/Text-Lorem-More-0.12.tar.gz)
Module Text::Lorem::More::Source (RKRIMEN/Text-Lorem-More-0.12.tar.gz)
cpan> i /berlin/
Distribution BEATNIK/Filter-NumberLines-0.02.tar.gz
Module = DateTime::TimeZone::Europe::Berlin (DROLSKY/DateTime-TimeZone-0.7904.tar.gz)
Module Filter::NumberLines (BEATNIK/Filter-NumberLines-0.02.tar.gz)
Author [...]
The examples illustrate several aspects: the first three queries
target modules, authors, or distros directly and yield exactly one
result. The last two use regular expressions and yield several
results. The last one targets all of bundles, modules, authors, and
distros simultaneously. When more than one result is available, they
are printed in one-line format.
"get", "make", "test", "install", "clean" modules or distributions
These commands take any number of arguments and investigate what is
necessary to perform the action. Argument processing is as follows:
known module name in format Foo/Bar.pm module
other embedded slash distribution
- with trailing slash dot directory
enclosing slashes regexp
known module name in format Foo::Bar module
If the argument is a distribution file name (recognized by embedded
slashes), it is processed. If it is a module, CPAN determines the
distribution file in which this module is included and processes that,
following any dependencies named in the module's META.yml or
Makefile.PL (this behavior is controlled by the configuration
parameter "prerequisites_policy"). If an argument is enclosed in
slashes it is treated as a regular expression: it is expanded and if
the result is a single object (distribution, bundle or module), this
object is processed.
Example:
install Dummy::Perl # installs the module
install AUXXX/Dummy-Perl-3.14.tar.gz # installs that distribution
install /Dummy-Perl-3.14/ # same if the regexp is unambiguous
"get" downloads a distribution file and untars or unzips it, "make"
builds it, "test" runs the test suite, and "install" installs it.
Any "make" or "test" is run unconditionally. An
install <distribution_file>
is also run unconditionally. But for
install <module>
CPAN checks whether an install is needed and prints *module up to
date* if the distribution file containing the module doesn't need
updating.
CPAN also keeps track of what it has done within the current session
and doesn't try to build a package a second time regardless of whether
it succeeded or not. It does not repeat a test run if the test has
been run successfully before. Same for install runs.
The "force" pragma may precede another command (currently: "get",
"make", "test", or "install") to execute the command from scratch and
attempt to continue past certain errors. See the section below on the
"force" and the "fforce" pragma.
The "notest" pragma skips the test part in the build process.
Example:
cpan> notest install Tk
A "clean" command results in a
make clean
being executed within the distribution file's working directory.
"readme", "perldoc", "look" module or distribution
"readme" displays the README file of the associated distribution.
"Look" gets and untars (if not yet done) the distribution file,
changes to the appropriate directory and opens a subshell process in
that directory. "perldoc" displays the module's pod documentation in
html or plain text format.
"ls" author
"ls" globbing_expression
The first form lists all distribution files in and below an author's
CPAN directory as stored in the CHECKSUMS files distributed on CPAN.
The listing recurses into subdirectories.
The second form limits or expands the output with shell globbing as in
the following examples:
ls JV/make*
ls GSAR/*make*
ls */*make*
The last example is very slow and outputs extra progress indicators
that break the alignment of the result.
Note that globbing only lists directories explicitly asked for, for
example FOO/* will not list FOO/bar/Acme-Sthg-n.nn.tar.gz. This may be
regarded as a bug that may be changed in some future version.
"failed"
The "failed" command reports all distributions that failed on one of
"make", "test" or "install" for some reason in the currently running
shell session.
Persistence between sessions
If the "YAML" or the "YAML::Syck" module is installed a record of the
internal state of all modules is written to disk after each step. The
files contain a signature of the currently running perl version for
later perusal.
If the configurations variable "build_dir_reuse" is set to a true
value, then CPAN.pm reads the collected YAML files. If the stored
signature matches the currently running perl, the stored state is
loaded into memory such that persistence between sessions is
effectively established.
The "force" and the "fforce" pragma
To speed things up in complex installation scenarios, CPAN.pm keeps
track of what it has already done and refuses to do some things a
second time. A "get", a "make", and an "install" are not repeated. A
"test" is repeated only if the previous test was unsuccessful. The
diagnostic message when CPAN.pm refuses to do something a second time
is one of *Has already been *"unwrapped|made|tested successfully" or
something similar. Another situation where CPAN refuses to act is an
"install" if the corresponding "test" was not successful.
In all these cases, the user can override this stubborn behaviour by
prepending the command with the word force, for example:
cpan> force get Foo
cpan> force make AUTHOR/Bar-3.14.tar.gz
cpan> force test Baz
cpan> force install Acme::Meta
Each *forced* command is executed with the corresponding part of its
memory erased.
The "fforce" pragma is a variant that emulates a "force get" which
erases the entire memory followed by the action specified, effectively
restarting the whole get/make/test/install procedure from scratch.
Lockfile
Interactive sessions maintain a lockfile, by default "~/.cpan/.lock".
Batch jobs can run without a lockfile and not disturb each other.
The shell offers to run in *downgraded mode* when another process is
holding the lockfile. This is an experimental feature that is not yet
tested very well. This second shell then does not write the history
file, does not use the metadata file, and has a different prompt.
Signals
CPAN.pm installs signal handlers for SIGINT and SIGTERM. While you are
in the cpan-shell, it is intended that you can press "^C" anytime and
return to the cpan-shell prompt. A SIGTERM will cause the cpan-shell
to clean up and leave the shell loop. You can emulate the effect of a
SIGTERM by sending two consecutive SIGINTs, which usually means by
pressing "^C" twice.
CPAN.pm ignores SIGPIPE. If the user sets "inactivity_timeout", a
SIGALRM is used during the run of the "perl Makefile.PL" or "perl
Build.PL" subprocess. A SIGALRM is also used during module version
parsing, and is controlled by "version_timeout".
CPAN::Shell
The commands available in the shell interface are methods in the package
CPAN::Shell. If you enter the shell command, your input is split by the
Text::ParseWords::shellwords() routine, which acts like most shells do.
The first word is interpreted as the method to be invoked, and the rest
of the words are treated as the method's arguments. Continuation lines
are supported by ending a line with a literal backslash.
autobundle
"autobundle" writes a bundle file into the
"$CPAN::Config->{cpan_home}/Bundle" directory. The file contains a list
of all modules that are both available from CPAN and currently installed
within @INC. Duplicates of each distribution are suppressed. The name of
the bundle file is based on the current date and a counter, e.g.
Bundle/Snapshot_2012_05_21_00.pm. This is installed again by running
"cpan Bundle::Snapshot_2012_05_21_00", or installing
"Bundle::Snapshot_2012_05_21_00" from the CPAN shell.
Return value: path to the written file.
hosts
Note: this feature is still in alpha state and may change in future
versions of CPAN.pm
This commands provides a statistical overview over recent download
activities. The data for this is collected in the YAML file
"FTPstats.yml" in your "cpan_home" directory. If no YAML module is
configured or YAML not installed, or if "ftpstats_size" is set to a
value "<=0", no stats are provided.
install_tested
Install all distributions that have been tested successfully but have
not yet been installed. See also "is_tested".
is_tested
List all build directories of distributions that have been tested
successfully but have not yet been installed. See also "install_tested".
mkmyconfig
mkmyconfig() writes your own CPAN::MyConfig file into your "~/.cpan/"
directory so that you can save your own preferences instead of the
system-wide ones.
r [Module|/Regexp/]...
scans current perl installation for modules that have a newer version
available on CPAN and provides a list of them. If called without
argument, all potential upgrades are listed; if called with arguments
the list is filtered to the modules and regexps given as arguments.
The listing looks something like this:
Package namespace installed latest in CPAN file
CPAN 1.94_64 1.9600 ANDK/CPAN-1.9600.tar.gz
CPAN::Reporter 1.1801 1.1902 DAGOLDEN/CPAN-Reporter-1.1902.tar.gz
YAML 0.70 0.73 INGY/YAML-0.73.tar.gz
YAML::Syck 1.14 1.17 AVAR/YAML-Syck-1.17.tar.gz
YAML::Tiny 1.44 1.50 ADAMK/YAML-Tiny-1.50.tar.gz
CGI 3.43 3.55 MARKSTOS/CGI.pm-3.55.tar.gz
Module::Build::YAML 1.40 1.41 DAGOLDEN/Module-Build-0.3800.tar.gz
TAP::Parser::Result::YAML 3.22 3.23 ANDYA/Test-Harness-3.23.tar.gz
YAML::XS 0.34 0.35 INGY/YAML-LibYAML-0.35.tar.gz
It suppresses duplicates in the column "in CPAN file" such that
distributions with many upgradeable modules are listed only once.
Note that the list is not sorted.
recent ***EXPERIMENTAL COMMAND***
The "recent" command downloads a list of recent uploads to CPAN and
displays them *slowly*. While the command is running, a $SIG{INT} exits
the loop after displaying the current item.
Note: This command requires XML::LibXML installed.
Note: This whole command currently is just a hack and will probably
change in future versions of CPAN.pm, but the general approach will
likely remain.
Note: See also smoke
recompile
recompile() is a special command that takes no argument and runs the
make/test/install cycle with brute force over all installed dynamically
loadable extensions (a.k.a. XS modules) with 'force' in effect. The
primary purpose of this command is to finish a network installation.
Imagine you have a common source tree for two different architectures.
You decide to do a completely independent fresh installation. You start
on one architecture with the help of a Bundle file produced earlier.
CPAN installs the whole Bundle for you, but when you try to repeat the
job on the second architecture, CPAN responds with a "Foo up to date"
message for all modules. So you invoke CPAN's recompile on the second
architecture and you're done.
Another popular use for "recompile" is to act as a rescue in case your
perl breaks binary compatibility. If one of the modules that CPAN uses
is in turn depending on binary compatibility (so you cannot run CPAN
commands), then you should try the CPAN::Nox module for recovery.
report Bundle|Distribution|Module
The "report" command temporarily turns on the "test_report" config
variable, then runs the "force test" command with the given arguments.
The "force" pragma reruns the tests and repeats every step that might
have failed before.
smoke ***EXPERIMENTAL COMMAND***
*** WARNING: this command downloads and executes software from CPAN to
your computer of completely unknown status. You should never do this
with your normal account and better have a dedicated well separated and
secured machine to do this. ***
The "smoke" command takes the list of recent uploads to CPAN as provided
by the "recent" command and tests them all. While the command is running
$SIG{INT} is defined to mean that the current item shall be skipped.
Note: This whole command currently is just a hack and will probably
change in future versions of CPAN.pm, but the general approach will
likely remain.
Note: See also recent
upgrade [Module|/Regexp/]...
The "upgrade" command first runs an "r" command with the given arguments
and then installs the newest versions of all modules that were listed by
that.
The four "CPAN::*" Classes: Author, Bundle, Module, Distribution
Although it may be considered internal, the class hierarchy does matter
for both users and programmer. CPAN.pm deals with the four classes
mentioned above, and those classes all share a set of methods. Classical
single polymorphism is in effect. A metaclass object registers all
objects of all kinds and indexes them with a string. The strings
referencing objects have a separated namespace (well, not completely
separated):
Namespace Class
words containing a "/" (slash) Distribution
words starting with Bundle:: Bundle
everything else Module or Author
Modules know their associated Distribution objects. They always refer to
the most recent official release. Developers may mark their releases as
unstable development versions (by inserting an underscore into the
module version number which will also be reflected in the distribution
name when you run 'make dist'), so the really hottest and newest
distribution is not always the default. If a module Foo circulates on
CPAN in both version 1.23 and 1.23_90, CPAN.pm offers a convenient way
to install version 1.23 by saying
install Foo
This would install the complete distribution file (say
BAR/Foo-1.23.tar.gz) with all accompanying material. But if you would
like to install version 1.23_90, you need to know where the distribution
file resides on CPAN relative to the authors/id/ directory. If the
author is BAR, this might be BAR/Foo-1.23_90.tar.gz; so you would have
to say
install BAR/Foo-1.23_90.tar.gz
The first example will be driven by an object of the class CPAN::Module,
the second by an object of class CPAN::Distribution.
Integrating local directories
Note: this feature is still in alpha state and may change in future
versions of CPAN.pm
Distribution objects are normally distributions from the CPAN, but there
is a slightly degenerate case for Distribution objects, too, of projects
held on the local disk. These distribution objects have the same name as
the local directory and end with a dot. A dot by itself is also allowed
for the current directory at the time CPAN.pm was used. All actions such
as "make", "test", and "install" are applied directly to that directory.
This gives the command "cpan ." an interesting touch: while the normal
mantra of installing a CPAN module without CPAN.pm is one of
perl Makefile.PL perl Build.PL
( go and get prerequisites )
make ./Build
make test ./Build test
make install ./Build install
the command "cpan ." does all of this at once. It figures out which of
the two mantras is appropriate, fetches and installs all prerequisites,
takes care of them recursively, and finally finishes the installation of
the module in the current directory, be it a CPAN module or not.
The typical usage case is for private modules or working copies of
projects from remote repositories on the local disk.
Redirection
The usual shell redirection symbols " | " and ">" are recognized by the
cpan shell only when surrounded by whitespace. So piping to pager or
redirecting output into a file works somewhat as in a normal shell, with
the stipulation that you must type extra spaces.
Plugin support ***EXPERIMENTAL***
Plugins are objects that implement any of currently eight methods:
pre_get
post_get
pre_make
post_make
pre_test
post_test
pre_install
post_install
The "plugin_list" configuration parameter holds a list of strings of the
form
Modulename=arg0,arg1,arg2,arg3,...
eg:
CPAN::Plugin::Flurb=dir,/opt/pkgs/flurb/raw,verbose,1
At run time, each listed plugin is instantiated as a singleton object by
running the equivalent of this pseudo code:
my $plugin = <string representation from config>;
<generate Modulename and arguments from $plugin>;
my $p = $instance{$plugin} ||= Modulename->new($arg0,$arg1,...);
The generated singletons are kept around from instantiation until the
end of the shell session. <plugin_list> can be reconfigured at any time
at run time. While the cpan shell is running, it checks all activated
plugins at each of the 8 reference points listed above and runs the
respective method if it is implemented for that object. The method is
called with the active CPAN::Distribution object passed in as an
argument.
CONFIGURATION
When the CPAN module is used for the first time, a configuration
dialogue tries to determine a couple of site specific options. The
result of the dialog is stored in a hash reference $CPAN::Config in a
file CPAN/Config.pm.
Default values defined in the CPAN/Config.pm file can be overridden in a
user specific file: CPAN/MyConfig.pm. Such a file is best placed in
"$HOME/.cpan/CPAN/MyConfig.pm", because "$HOME/.cpan" is added to the
search path of the CPAN module before the use() or require() statements.
The mkmyconfig command writes this file for you.
If you want to keep your own CPAN/MyConfig.pm somewhere else, you should
load it before loading CPAN.pm, e.g.:
perl -I/tmp/somewhere -MCPAN::MyConfig -MCPAN -eshell
--or--
perl -I/tmp/somewhere -MCPAN::MyConfig -S cpan
Once you are in the shell you can change your configuration as follows.
The "o conf" command has various bells and whistles:
completion support
If you have a ReadLine module installed, you can hit TAB at any
point of the commandline and "o conf" will offer you completion for
the built-in subcommands and/or config variable names.
displaying some help: o conf help
Displays a short help
displaying current values: o conf [KEY]
Displays the current value(s) for this config variable. Without KEY,
displays all subcommands and config variables.
Example:
o conf shell
If KEY starts and ends with a slash, the string in between is
treated as a regular expression and only keys matching this regexp
are displayed
Example:
o conf /color/
changing of scalar values: o conf KEY VALUE
Sets the config variable KEY to VALUE. The empty string can be
specified as usual in shells, with '' or ""
Example:
o conf wget /usr/bin/wget
changing of list values: o conf KEY SHIFT|UNSHIFT|PUSH|POP|SPLICE|LIST
If a config variable name ends with "list", it is a list. "o conf
KEY shift" removes the first element of the list, "o conf KEY pop"
removes the last element of the list. "o conf KEYS unshift LIST"
prepends a list of values to the list, "o conf KEYS push LIST"
appends a list of valued to the list.
Likewise, "o conf KEY splice LIST" passes the LIST to the
corresponding splice command.
Finally, any other list of arguments is taken as a new list value
for the KEY variable discarding the previous value.
Examples:
o conf urllist unshift http://cpan.dev.local/CPAN
o conf urllist splice 3 1
o conf urllist http://cpan1.local http://cpan2.local ftp://ftp.perl.org
reverting to saved: o conf defaults
Reverts all config variables to the state in the saved config file.
saving the config: o conf commit
Saves all config variables to the current config file
(CPAN/Config.pm or CPAN/MyConfig.pm that was loaded at start).
The configuration dialog can be started any time later again by issuing
the command " o conf init " in the CPAN shell. A subset of the
configuration dialog can be run by issuing "o conf init WORD" where WORD
is any valid config variable or a regular expression.
Config Variables
The following keys in the hash reference $CPAN::Config are currently
defined:
allow_installing_module_downgrades
allow or disallow installing module downgrades
allow_installing_outdated_dists
allow or disallow installing modules that are
indexed in the cpan index pointing to a distro
with a higher distro-version number
applypatch path to external prg
auto_commit commit all changes to config variables to disk
build_cache size of cache for directories to build modules
build_dir locally accessible directory to build modules
build_dir_reuse boolean if distros in build_dir are persistent
build_requires_install_policy
to install or not to install when a module is
only needed for building. yes|no|ask/yes|ask/no
bzip2 path to external prg
cache_metadata use serializer to cache metadata
check_sigs if signatures should be verified
cleanup_after_install
remove build directory immediately after a
successful install and remember that for the
duration of the session
colorize_debug Term::ANSIColor attributes for debugging output
colorize_output boolean if Term::ANSIColor should colorize output
colorize_print Term::ANSIColor attributes for normal output
colorize_warn Term::ANSIColor attributes for warnings
commandnumber_in_prompt
boolean if you want to see current command number
commands_quote preferred character to use for quoting external
commands when running them. Defaults to double
quote on Windows, single tick everywhere else;
can be set to space to disable quoting
connect_to_internet_ok
whether to ask if opening a connection is ok before
urllist is specified
cpan_home local directory reserved for this package
curl path to external prg
dontload_hash DEPRECATED
dontload_list arrayref: modules in the list will not be
loaded by the CPAN::has_inst() routine
ftp path to external prg
ftp_passive if set, the environment variable FTP_PASSIVE is set
for downloads
ftp_proxy proxy host for ftp requests
ftpstats_period max number of days to keep download statistics
ftpstats_size max number of items to keep in the download statistics
getcwd see below
gpg path to external prg
gzip location of external program gzip
halt_on_failure stop processing after the first failure of queued
items or dependencies
histfile file to maintain history between sessions
histsize maximum number of lines to keep in histfile
http_proxy proxy host for http requests
inactivity_timeout breaks interactive Makefile.PLs or Build.PLs
after this many seconds inactivity. Set to 0 to
disable timeouts.
index_expire refetch index files after this many days
inhibit_startup_message
if true, suppress the startup message
keep_source_where directory in which to keep the source (if we do)
load_module_verbosity
report loading of optional modules used by CPAN.pm
lynx path to external prg
make location of external make program
make_arg arguments that should always be passed to 'make'
make_install_make_command
the make command for running 'make install', for
example 'sudo make'
make_install_arg same as make_arg for 'make install'
makepl_arg arguments passed to 'perl Makefile.PL'
mbuild_arg arguments passed to './Build'
mbuild_install_arg arguments passed to './Build install'
mbuild_install_build_command
command to use instead of './Build' when we are
in the install stage, for example 'sudo ./Build'
mbuildpl_arg arguments passed to 'perl Build.PL'
ncftp path to external prg
ncftpget path to external prg
no_proxy don't proxy to these hosts/domains (comma separated list)
pager location of external program more (or any pager)
password your password if you CPAN server wants one
patch path to external prg
patches_dir local directory containing patch files
perl5lib_verbosity verbosity level for PERL5LIB additions
plugin_list list of active hooks (see Plugin support above
and the CPAN::Plugin module)
prefer_external_tar
per default all untar operations are done with
Archive::Tar; by setting this variable to true
the external tar command is used if available
prefer_installer legal values are MB and EUMM: if a module comes
with both a Makefile.PL and a Build.PL, use the
former (EUMM) or the latter (MB); if the module
comes with only one of the two, that one will be
used no matter the setting
prerequisites_policy
what to do if you are missing module prerequisites
('follow' automatically, 'ask' me, or 'ignore')
For 'follow', also sets PERL_AUTOINSTALL and
PERL_EXTUTILS_AUTOINSTALL for "--defaultdeps" if
not already set
prefs_dir local directory to store per-distro build options
proxy_user username for accessing an authenticating proxy
proxy_pass password for accessing an authenticating proxy
pushy_https use https to cpan.org when possible, otherwise use http
to cpan.org and issue a warning
randomize_urllist add some randomness to the sequence of the urllist
recommends_policy whether recommended prerequisites should be included
scan_cache controls scanning of cache ('atstart', 'atexit' or 'never')
shell your favorite shell
show_unparsable_versions
boolean if r command tells which modules are versionless
show_upload_date boolean if commands should try to determine upload date
show_zero_versions boolean if r command tells for which modules $version==0
suggests_policy whether suggested prerequisites should be included
tar location of external program tar
tar_verbosity verbosity level for the tar command
term_is_latin deprecated: if true Unicode is translated to ISO-8859-1
(and nonsense for characters outside latin range)
term_ornaments boolean to turn ReadLine ornamenting on/off
test_report email test reports (if CPAN::Reporter is installed)
trust_test_report_history
skip testing when previously tested ok (according to
CPAN::Reporter history)
unzip location of external program unzip
urllist arrayref to nearby CPAN sites (or equivalent locations)
urllist_ping_external
use external ping command when autoselecting mirrors
urllist_ping_verbose
increase verbosity when autoselecting mirrors
use_prompt_default set PERL_MM_USE_DEFAULT for configure/make/test/install
use_sqlite use CPAN::SQLite for metadata storage (fast and lean)
username your username if you CPAN server wants one
version_timeout stops version parsing after this many seconds.
Default is 15 secs. Set to 0 to disable.
wait_list arrayref to a wait server to try (See CPAN::WAIT)
wget path to external prg
yaml_load_code enable YAML code deserialisation via CPAN::DeferredCode
yaml_module which module to use to read/write YAML files
You can set and query each of these options interactively in the cpan
shell with the "o conf" or the "o conf init" command as specified below.
"o conf <scalar option>"
prints the current value of the *scalar option*
"o conf <scalar option> <value>"
Sets the value of the *scalar option* to *value*
"o conf <list option>"
prints the current value of the *list option* in MakeMaker's neatvalue
format.
"o conf <list option> [shift|pop]"
shifts or pops the array in the *list option* variable
"o conf <list option> [unshift|push|splice] <list>"
works like the corresponding perl commands.
interactive editing: o conf init [MATCH|LIST]
Runs an interactive configuration dialog for matching variables.
Without argument runs the dialog over all supported config variables.
To specify a MATCH the argument must be enclosed by slashes.
Examples:
o conf init ftp_passive ftp_proxy
o conf init /color/
Note: this method of setting config variables often provides more
explanation about the functioning of a variable than the manpage.
CPAN::anycwd($path): Note on config variable getcwd
CPAN.pm changes the current working directory often and needs to
determine its own current working directory. By default it uses
Cwd::cwd, but if for some reason this doesn't work on your system,
configure alternatives according to the following table:
cwd Calls Cwd::cwd
getcwd
Calls Cwd::getcwd
fastcwd
Calls Cwd::fastcwd
getdcwd
Calls Cwd::getdcwd
backtickcwd
Calls the external command cwd.
Note on the format of the urllist parameter
urllist parameters are URLs according to RFC 1738. We do a little
guessing if your URL is not compliant, but if you have problems with
"file" URLs, please try the correct format. Either:
file://localhost/whatever/ftp/pub/CPAN/
or
file:///home/ftp/pub/CPAN/
The urllist parameter has CD-ROM support
The "urllist" parameter of the configuration table contains a list of
URLs used for downloading. If the list contains any "file" URLs, CPAN
always tries there first. This feature is disabled for index files. So
the recommendation for the owner of a CD-ROM with CPAN contents is:
include your local, possibly outdated CD-ROM as a "file" URL at the end
of urllist, e.g.
o conf urllist push file://localhost/CDROM/CPAN
CPAN.pm will then fetch the index files from one of the CPAN sites that
come at the beginning of urllist. It will later check for each module to
see whether there is a local copy of the most recent version.
Another peculiarity of urllist is that the site that we could
successfully fetch the last file from automatically gets a preference
token and is tried as the first site for the next request. So if you add
a new site at runtime it may happen that the previously preferred site
will be tried another time. This means that if you want to disallow a
site for the next transfer, it must be explicitly removed from urllist.
Maintaining the urllist parameter
If you have YAML.pm (or some other YAML module configured in
"yaml_module") installed, CPAN.pm collects a few statistical data about
recent downloads. You can view the statistics with the "hosts" command
or inspect them directly by looking into the "FTPstats.yml" file in your
"cpan_home" directory.
To get some interesting statistics, it is recommended that
"randomize_urllist" be set; this introduces some amount of randomness
into the URL selection.
The "requires" and "build_requires" dependency declarations
Since CPAN.pm version 1.88_51 modules declared as "build_requires" by a
distribution are treated differently depending on the config variable
"build_requires_install_policy". By setting
"build_requires_install_policy" to "no", such a module is not installed.
It is only built and tested, and then kept in the list of tested but
uninstalled modules. As such, it is available during the build of the
dependent module by integrating the path to the "blib/arch" and
"blib/lib" directories in the environment variable PERL5LIB. If
"build_requires_install_policy" is set to "yes", then both modules
declared as "requires" and those declared as "build_requires" are
treated alike. By setting to "ask/yes" or "ask/no", CPAN.pm asks the
user and sets the default accordingly.
Configuration of the allow_installing_* parameters
The "allow_installing_*" parameters are evaluated during the "make"
phase. If set to "yes", they allow the testing and the installation of
the current distro and otherwise have no effect. If set to "no", they
may abort the build (preventing testing and installing), depending on
the contents of the "blib/" directory. The "blib/" directory is the
directory that holds all the files that would usually be installed in
the "install" phase.
"allow_installing_outdated_dists" compares the "blib/" directory with
the CPAN index. If it finds something there that belongs, according to
the index, to a different dist, it aborts the current build.
"allow_installing_module_downgrades" compares the "blib/" directory with
already installed modules, actually their version numbers, as determined
by ExtUtils::MakeMaker or equivalent. If a to-be-installed module would
downgrade an already installed module, the current build is aborted.
An interesting twist occurs when a distroprefs document demands the
installation of an outdated dist via goto while
"allow_installing_outdated_dists" forbids it. Without additional
provisions, this would let the "allow_installing_outdated_dists" win and
the distroprefs lose. So the proper arrangement in such a case is to
write a second distroprefs document for the distro that "goto" points to
and overrule the "cpanconfig" there. E.g.:
---
match:
distribution: "^MAUKE/Keyword-Simple-0.04.tar.gz"
goto: "MAUKE/Keyword-Simple-0.03.tar.gz"
---
match:
distribution: "^MAUKE/Keyword-Simple-0.03.tar.gz"
cpanconfig:
allow_installing_outdated_dists: yes
Configuration for individual distributions (*Distroprefs*)
(Note: This feature has been introduced in CPAN.pm 1.8854)
Distributions on CPAN usually behave according to what we call the CPAN
mantra. Or since the advent of Module::Build we should talk about two
mantras:
perl Makefile.PL perl Build.PL
make ./Build
make test ./Build test
make install ./Build install
But some modules cannot be built with this mantra. They try to get some
extra data from the user via the environment, extra arguments, or
interactively--thus disturbing the installation of large bundles like
Phalanx100 or modules with many dependencies like Plagger.
The distroprefs system of "CPAN.pm" addresses this problem by allowing
the user to specify extra informations and recipes in YAML files to
either
* pass additional arguments to one of the four commands,
* set environment variables
* instantiate an Expect object that reads from the console, waits for
some regular expressions and enters some answers
* temporarily override assorted "CPAN.pm" configuration variables
* specify dependencies the original maintainer forgot
* disable the installation of an object altogether
See the YAML and Data::Dumper files that come with the "CPAN.pm"
distribution in the "distroprefs/" directory for examples.
Filenames
The YAML files themselves must have the ".yml" extension; all other
files are ignored (for two exceptions see *Fallback Data::Dumper and
Storable* below). The containing directory can be specified in "CPAN.pm"
in the "prefs_dir" config variable. Try "o conf init prefs_dir" in the
CPAN shell to set and activate the distroprefs system.
Every YAML file may contain arbitrary documents according to the YAML
specification, and every document is treated as an entity that can
specify the treatment of a single distribution.
Filenames can be picked arbitrarily; "CPAN.pm" always reads all files
(in alphabetical order) and takes the key "match" (see below in
*Language Specs*) as a hashref containing match criteria that determine
if the current distribution matches the YAML document or not.
Fallback Data::Dumper and Storable
If neither your configured "yaml_module" nor YAML.pm is installed,
CPAN.pm falls back to using Data::Dumper and Storable and looks for
files with the extensions ".dd" or ".st" in the "prefs_dir" directory.
These files are expected to contain one or more hashrefs. For
Data::Dumper generated files, this is expected to be done with by
defining $VAR1, $VAR2, etc. The YAML shell would produce these with the
command
ysh < somefile.yml > somefile.dd
For Storable files the rule is that they must be constructed such that
"Storable::retrieve(file)" returns an array reference and the array
elements represent one distropref object each. The conversion from YAML
would look like so:
perl -MYAML=LoadFile -MStorable=nstore -e '
@y=LoadFile(shift);
nstore(\@y, shift)' somefile.yml somefile.st
In bootstrapping situations it is usually sufficient to translate only a
few YAML files to Data::Dumper for crucial modules like "YAML::Syck",
"YAML.pm" and "Expect.pm". If you prefer Storable over Data::Dumper,
remember to pull out a Storable version that writes an older format than
all the other Storable versions that will need to read them.
Blueprint
The following example contains all supported keywords and structures
with the exception of "eexpect" which can be used instead of "expect".
---
comment: "Demo"
match:
module: "Dancing::Queen"
distribution: "^CHACHACHA/Dancing-"
not_distribution: "\.zip$"
perl: "/usr/local/cariba-perl/bin/perl"
perlconfig:
archname: "freebsd"
not_cc: "gcc"
env:
DANCING_FLOOR: "Shubiduh"
disabled: 1
cpanconfig:
make: gmake
pl: