Opciones de Configuración

Lista de Opciones de Configuración

El comando o conf nos permite ver y modificar las opciones de configuración:

cpan> o conf
CPAN::Config options and /home/casiano/.cpan/CPAN/MyConfig.pm:
    commit             Commit changes to disk
    defaults           Reload defaults from disk
    init               Interactive setting of all options

    build_cache        1000
    build_dir          /scratch/casiano/build
    cache_metadata     1
    cpan_home          /scratch/casiano/.cpan
    dontload_hash
    ftp                /usr/bin/ftp
    ftp_proxy
    getcwd             cwd
    gpg                /usr/bin/gpg
    gzip               /bin/gzip
    histfile           /scratch/casiano/.cpan/histfile
    histsize           100
    http_proxy
    inactivity_timeout 0
    index_expire       1
    inhibit_startup_message 0
    keep_source_where  /scratch/casiano/.cpan/sources
    lynx               /usr/bin/lynx
    make               /usr/bin/make
    make_arg
    make_install_arg
    makepl_arg         PREFIX=/soft/perl5lib/
    ncftpget           /usr/bin/ncftpget
    no_proxy
    pager              /usr/bin/less
    prerequisites_policy ask
    scan_cache         atstart
    shell              /bin/bash
    tar                /bin/tar
    term_is_latin      1
    unzip              /usr/bin/unzip
    urllist
        ftp://cpan.ip.pt/pub/cpan/
        ftp://ftp.rediris.es/mirror/CPAN/
        ftp://ftp.etse.urv.es/pub/perl/
        ftp://ftp.ri.telefonica-data.net/CPAN
        http://cpan.imasd.elmundo.es/
    wget               /usr/bin/wget

Ayuda sobre o conf

El comando o conf help permite obtener una ayuda resumida:

cpan[14]> o conf help

Known options:
  commit    commit session changes to disk
  defaults  reload default config values from disk
  help      this help
  init      enter a dialog to set all or a set of parameters

Edit key values as in the following (the "o" is a literal letter o):
  o conf build_cache 15
  o conf build_dir "/foo/bar"
  o conf urllist shift
  o conf urllist unshift ftp://ftp.foo.bar/
  o conf inhibit_startup_message 1

Modificación de la Lista de Servidores CPAN

Es posible consultar una opción específica:

cpan> o conf urllist
    urllist
        ftp://archive.progeny.com/CPAN/
        ftp://cpan-sj.viaverio.com/pub/CPAN/
        ftp://cpan.calvin.edu/pub/CPAN
        ftp://cpan.cs.utah.edu/pub/CPAN/
        ftp://cpan.digisle.net/pub/CPAN
        ftp://cpan.erlbaum.net/
        ftp://cpan.llarian.net/pub/CPAN/
Y si nos conviene, modificarlas:

cpan> o conf urllist unshift ftp://ftp.rediris.es/mirror/CPAN/
cpan> o conf urllist
    urllist
        ftp://ftp.rediris.es/mirror/CPAN/
        ftp://archive.progeny.com/CPAN/
        ftp://cpan-sj.viaverio.com/pub/CPAN/
        ftp://cpan.calvin.edu/pub/CPAN
        ftp://cpan.cs.utah.edu/pub/CPAN/
        ftp://cpan.digisle.net/pub/CPAN
        ftp://cpan.erlbaum.net/
        ftp://cpan.llarian.net/pub/CPAN/
Type 'o conf' to view configuration edit options
Ahora al proceder a una instalación la URL insertada será la primera en ser consultada:
cpan> install Email::Find
Running install for module Email::Find
Running make for M/MI/MIYAGAWA/Email-Find-0.09.tar.gz
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
  ftp://ftp.rediris.es/mirror/CPAN/authors/id/M/MI/MIYAGAWA/Email-Find-0.09.tar.gz
....

Para ver el estado de los mirrors puede consultar cualquiera de estas direcciones:

Directorio en el que se Guardan las Distribuciones

El directorio en el que se guardan las distribuciones puede obtenerse asi:

cpan[10]> o conf keep_source_where
    keep_source_where  [/root/.cpan/sources]
Type 'o conf' to view all configuration items


cpan[11]> ^Z                     # <-- ponemos el proceso en background ...
[1]+  Stopped                 cpan
nereida:~/src/perl/Nmap-scanner# ls -l /root/.cpan/sources
total 320
drwxr-xr-x 3 root root   4096 2008-05-09 07:07 authors
-rw-r--r-- 1 root root 163409 2006-03-13 13:57 MIRRORED.BY
-rw-r--r-- 1 root root 145453 2004-11-03 13:26 MIRRORED.BY.bak
drwxr-xr-x 2 root root   4096 2008-05-09 07:07 modules
nereida:~/src/perl/Nmap-scanner  # fg  <-- y lo volvemos a poner en "foreground"
cpan[11]>

Estructura del Directorio de Distribuciones

La estructura del directorio se organiza por autores:

~/.cpan/sources# tree
.
|-- MIRRORED.BY
|-- authors
|   |-- 01mailrc.txt.gz
|   |-- 01mailrc.txt.gz.bak
|   `-- id
|       |-- A
|       |   |-- AF
|       |   |   `-- AFERBER
|       |   |       |-- CHECKSUMS
|       |   |       `-- Thread-RWLock-1.02.tar.gz
|       |   |-- AM
|       |   |   `-- AMS
|       |   |       |-- CHECKSUMS
|       |   |       `-- Storable-2.13.tar.gz
|       |   `-- AR
|       |       `-- AREIBENS
|       |           |-- CHECKSUMS
|       |           `-- PDF-API2-0.3r77.tar.gz
|       |-- B
|       |   |-- BD
|       |   |   `-- BDARRAH
|       |   |       |-- CHECKSUMS
|       |   |       `-- Proc-ParallelLoop-0.5.tgz
............ etc.
|       |-- V
|       |   `-- VI
|       |       `-- VIPUL
|       |           |-- CHECKSUMS
|       |           |-- Class-Loader-2.02.tar.gz
|       |           |-- Convert-ASCII-Armour-1.4.tar.gz
|       |           |-- Crypt-Primes-0.50.tar.gz
|       |           |-- Crypt-RSA-1.50.tar.gz
|       |           |-- Crypt-Random-1.23.tar.gz
|       |           `-- Tie-EncryptedHash-1.21.tar.gz
|       |-- f
|       |   `-- f
|       |       `-- f
|       |           `-- ft
|       |               `-- ftp:
|       |                   `-- sunsite.rediris.es
|       |                       `-- mirror
|       |                           `-- CPAN
|       |                               `-- modules
|       |                                   `-- by-module
|       |                                       `-- Class
|       |                                           `-- Class-MethodMaker-2.04-1.tar
|       `-- t
|           `-- t
|               `-- t
|                   `-- tm
|                       `-- tmp
|                           `-- CPAN
`-- modules
    |-- 02packages.details.txt.gz
    |-- 02packages.details.txt.gz.bak
    |-- 03modlist.data.gz
    `-- 03modlist.data.gz.bak

Modificar la Configuración Inicial

En cualquier momento es posible reiniciar el diálogo de configuración mediante el commando o conf init:

cpan> o conf init

/etc/perl/CPAN/Config.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]    
...

Modificación Guiada de Opciones

También es posible especificar que opciones se quieren cambiar restringiendo el diálogo a estas:

cpan[1]>  o conf init makepl_arg mbuildpl_arg prefs_dir


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 or a personal directory.



CPAN.pm can store customized build environments based on regular
expressions for distribution names. These are YAML files where the
default options for CPAN.pm and the environment can be overridden and
dialog sequences can be stored that can later be executed by an
Expect.pm object. The CPAN.pm distribution comes with some prefab YAML
files that cover sample distributions that can be used as blueprints
to store one own prefs. Please check out the distroprefs/ directory of
the CPAN.pm distribution to get a quick start into the prefs system.

Directory where to store default options/environment/dialogs for
building modules that need some customization? [~/.cpan/prefs]


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:  [INSTALL_BASE=~/perl] INSTALL_BASE=~/personalmodules


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:  [--install_base ~/perl] --install_base ~/personalmodules


Please remember to call 'o conf commit' to make the config permanent!


cpan[2]> o conf commit
commit: wrote '/home/pp2/.cpan/CPAN/MyConfig.pm'


Las opciones INSTALL_BASE y -install_base

La opción INSTALL_BASE pasada a makefile.PL permite especificar en que lugar quedarán instalados los módulos. Esta opción es preferible a PREFIX pues es mas fácil predecir donde acabaran los módulos.

Al igual que PREFIX permite establecer varios atributos INSTALL* de una sola tacada. El patrón de instalación resultante sigue este esquema:

  INSTALLARCHLIB     INSTALL_BASE/lib/perl5/$Config{archname}
  INSTALLPRIVLIB     INSTALL_BASE/lib/perl5
  INSTALLBIN         INSTALL_BASE/bin
  INSTALLSCRIPT      INSTALL_BASE/bin
  INSTALLMAN1DIR     INSTALL_BASE/man/man1
  INSTALLMAN3DIR     INSTALL_BASE/man/man3

Observe la instalación de un módulo después de haber establecido INSTALL_BASE:

cpan[3]> install GRID::Machine
CPAN: Storable loaded ok (v2.15)
Going to read /home/pp2/.cpan/Metadata
  Database was generated on Sun, 18 May 2008 05:29:48 GMT
CPAN: YAML loaded ok (v0.66)
Going to read /home/pp2/.cpan/build/
............................................................................
  CPAN.pm: Going to build C/CA/CASIANO/GRID-Machine-0.091.tar.gz
Checking if your kit is complete...
Looks good
Writing Makefile for GRID::Machine
............................................................................
  CASIANO/GRID-Machine-0.091.tar.gz
  /usr/bin/make -- OK
Running make test
............................................................................
  /usr/bin/make test -- OK
Running make install
Installing /home/pp2/personalmodules/lib/perl5/GRID/Machine.pm
Installing /home/pp2/personalmodules/lib/perl5/GRID/Machine.pod
............................................................................
Installing /home/pp2/personalmodules/man/man1/remotetest.pl.1p
Installing /home/pp2/personalmodules/man/man3/GRID::Machine::Result.3pm
Installing /home/pp2/personalmodules/man/man3/GRID::Machine.3pm
............................................................................
Installing /home/pp2/personalmodules/bin/remotetest.pl
Writing /home/pp2/personalmodules/lib/perl5/i486-linux-gnu-thread-multi/auto/GRID/Machine/.packlist
Appending installation info to /home/pp2/personalmodules/lib/perl5/i486-linux-gnu-thread-multi/perllocal.pod
  CASIANO/GRID-Machine-0.091.tar.gz
  /usr/bin/make install  -- OK
cpan[4]>
Vemos que los módulos (p.ej. GRID::Machine) fueron instalados en /home/pp2/personalmodules/lib/perl5/, los manuales en /home/pp2/personalmodules/man/ y los guiones en /home/pp2/personalmodules/bin/.

Para tener operativo nuestro repositorio tendremos que añadir estos caminos a las correspondientes variables de entorno. Lo aconsejable es incluir estos comandos en .bashrc o en.cshrc, según sea nuestra shell, para que se ejecute cada vez que creamos una nueva shell:

La opción install_base juega un papel similar para el módulo alternativo a ExtUtils::MakeMaker mas usado: Module::Build.

El Módulo CPAN/Config.pm

Los valores por defecto vienen definidos en el fichero CPAN/Config.pm. El lugar en el que se guarda este módulo que contiene la configuración de CPAN viene dado por la opción cpan_home:

cpan[16]> o conf cpan_home
    cpan_home          [/root/.cpan]
Alternativamente, también podríamos hallar su ubicación con:
nereida:~> perl -MCPAN::Config -e 'print $INC{"CPAN/Config.pm"}."\n"'
/etc/perl/CPAN/Config.pm
Sigue un ejemplo de los contenidos de CPAN::Config.pm:
nereida:~> cat -n /etc/perl/CPAN/Config.pm
 1
 2  # This is CPAN.pm's systemwide configuration file. This file provides
 3  # defaults for users, and the values can be changed in a per-user
 4  # configuration file. The user-config file is being looked for as
 5  # ~/.cpan/CPAN/MyConfig.pm.
 6
 7  $CPAN::Config = {
 8    'build_cache' => q[10],
 9    'build_dir' => q[/root/.cpan/build],
10    'bzip2' => q[/usr/bin/bzip2],
11    'cache_metadata' => q[1],
12    'cpan_home' => q[/root/.cpan],
13    'cpan_version_check' => q[1],
14    'curl' => q[/usr/bin/curl],
15    'dontload_hash' => {  },
16    'ftp' => q[/usr/bin/ftp],
17    'ftp_passive' => q[1],
18    'ftp_proxy' => q[],
19    'getcwd' => q[cwd],
20    'gpg' => q[/usr/bin/gpg],
21    'gzip' => q[/bin/gzip],
22    'histfile' => q[/root/.cpan/histfile],
23    'histsize' => q[100],
24    'http_proxy' => q[],
25    'inactivity_timeout' => q[0],
26    'index_expire' => q[1],
27    'inhibit_startup_message' => q[0],
28    'keep_source_where' => q[/root/.cpan/sources],
29    'lynx' => q[/usr/bin/lynx],
30    'make' => q[/usr/bin/make],
31    'make_arg' => q[],
32    'make_install_arg' => q[],
33    'make_install_make_command' => q[/usr/bin/make],
34    'makepl_arg' => q[INSTALLDIRS=site],
35    'mbuild_arg' => q[],
36    'mbuild_install_arg' => q[],
37    'mbuild_install_build_command' => q[./Build],
38    'mbuildpl_arg' => q[],
39    'ncftpget' => q[/usr/bin/ncftpget],
40    'no_proxy' => q[],
41    'pager' => q[/usr/bin/less],
42    'prefer_installer' => q[EUMM],
43    'prerequisites_policy' => q[ask],
44    'scan_cache' => q[atstart],
45    'shell' => q[/bin/bash],
46    'show_upload_date' => q[1],
47    'tar' => q[/bin/tar],
48    'term_is_latin' => q[1],
49    'unzip' => q[/usr/bin/unzip],
50    'urllist' => [q[ftp://ftp.rediris.es/mirror/CPAN/], q[ftp://archive.progeny.com/CPAN/], q[ftp://cpan-sj.viaverio.com/pub/CPAN/], q[ftp://cpan.calvin.edu/pub/CPAN], q[ftp://cpan.cs.utah.edu/pub/CPAN/], q[ftp://cpan.digisle.net/pub/CPAN], q[ftp://cpan.erlbaum.net/], q[ftp://cpan.llarian.net/pub/CPAN/], q[ftp://ftp.ri.telefonica-data.net/CPAN], q[ftp://ftp.etse.urv.es/pub/perl/]],
51    'wait_list' => [q[wait://ls6.informatik.uni-dortmund.de]],
52    'wget' => q[/usr/bin/wget],
53  };
54  1;
55  __END__

De hecho una forma de modificar la configuración de CPAN es editando este fichero.

El Hash Anónimo $CPAN::Config

En la versión instalada en el ejemplo el hash anónimo $CPAN::Config contiene las siguientes claves:

Clave Significado
build_cache Tamaño de la cache para la construcción de los módulos
build_dir Directorio para la construcción de los módulos
index_expire Recargar el índice despueś del número de días indicado
cache_metadata Usar serializador para metadatos
cpan_home Directorio local para este paquete
cpan_version_check if true, warns you when the CPAN module is out of date.
dontload_hash anonymous hash: modules in the keys will not be
loaded by the CPAN::has_inst() routine
gzip location of external program gzip
histfile file to maintain history between sessions
histsize maximum number of lines to keep in histfile
inactivity_timeout breaks interactive Makefile.PLs after this
many seconds inactivity. Set to 0 to never break.
inhibit_startup_message if true, does not print the startup message
keep_source_where directory in which to keep the source (if we do)
make location of external make program
make_arg arguments that should always be passed to 'make'
make_install_arg same as make_arg for make install
makepl_arg arguments passed to perl Makefile.PL
pager location of external program more (or any pager)
prerequisites_policy what to do if you are missing module prerequisites
('follow' automatically, 'ask' me, or 'ignore')
proxy_user username for accessing an authenticating proxy
proxy_pass password for accessing an authenticating proxy
scan_cache controls scanning of cache ('atstart' or 'never')
tar location of external program tar
term_is_latin if true internal UTF-8 is translated to ISO-8859-1
(and nonsense for characters outside latin range)
unzip location of external program unzip
urllist arrayref to nearby CPAN sites (or equivalent locations)
wait_list arrayref to a wait server to try (See CPAN::WAIT)
ftp_proxy, the three usual variables for configuring
http_proxy, proxy requests. Both as CPAN::Config variables
no_proxy and as environment variables configurable.


Un CPAN/Config.pm de Usuario

Estos valores por defecto pueden ser sobreescritos usando un fichero CPAN/Config.pm específico para el usuario. Lo mas conveniente es dejar ese fichero en $HOME/.cpan/CPAN/MyConfig.pm ya que el directorio $HOME/.cpan es añadido al camino de búsqueda del módulo CPAN antes de la ejecución de las sentencias use y/o require.



Subsecciones
Casiano Rodríguez León
2009-10-04