Inject Your Way Out Of Dependency Hell
Toronto Perl Mongers
April 28, 2005
What is CPAN::Mini::Inject?
continued...
What is CPAN::Mini::Inject?
continued...
What is CPAN::Mini::Inject?
- Based on CPAN::Mini
- Create a local mirror of current CPAN distributions
continued...
What is CPAN::Mini::Inject?
- Based on CPAN::Mini
- Create a local mirror of current CPAN distributions
- Insert your own modules into the CPAN mirror
continued...
What is CPAN::Mini::Inject?
- Based on CPAN::Mini
- Create a local mirror of current CPAN distributions
- Insert your own modules into the CPAN mirror
- Allows you to use standard CPAN.pm/CPANPLUS.pm for module management
The Problems
Using modules from CPAN can have problems in production environments.
Version control and Private modules
Keeping module versions consistent or installing private modules on multiple servers can be a hassle.
continued...
Version control and Private modules
Keeping module versions consistent or installing private modules on multiple servers can be a hassle.
- Designate one box as a CPAN server
- Create a new mirror
- Configure HTTP/FTP access to the mirror
- Configure CPANPLUS on other servers to use the new mirror
Distribution to customers
Distributing applications to your customers and making sure they have the proper prerequisite modules.
continued...
Distribution to customers
Distributing applications to your customers and making sure they have the proper prerequisite modules.
- Create a new mirror
- Inject your application modules
- Burn a CD
Testing distributions
Need to test a distribution on multiple platforms
continued...
Testing distributions
Need to test a distribution on multiple platforms
- Create a distribution with a development version (ends in _##)
- Inject the test distribution into the mirror
- use CPANPLUS to perform tests
Firewalled from the Internet
For whatever reason, systems can have little to no access to the Internet.
continued...
Firewalled from the Internet
For whatever reason, systems can have little to no access to the Internet.
continued...
Firewalled from the Internet
For whatever reason, systems can have little to no access to the Internet.
- Single system access
- Create a new mirror on the system with access
- Configure HTTP/FTP access to the mirror
- Point other systems CPAN/CPANPLUS configuration to the new mirror
continued...
Firewalled from the Internet
For whatever reason, systems can have little to no access to the Internet.
- Single system access
- Create a new mirror on the system with access
- Configure HTTP/FTP access to the mirror
- Point other systems CPAN/CPANPLUS configuration to the new mirror
continued...
Firewalled from the Internet
For whatever reason, systems can have little to no access to the Internet.
- Single system access
- Create a new mirror on the system with access
- Configure HTTP/FTP access to the mirror
- Point other systems CPAN/CPANPLUS configuration to the new mirror
- No Access
- Create a new mirror
- Burn the mirror to a CD
- Use the CD to install modules as required or use it to start a CPAN server
CPAN::Mini::Inject Terminology
continued...
CPAN::Mini::Inject Terminology
- local
- A directory to store a mini mirror of CPAN
continued...
CPAN::Mini::Inject Terminology
- local
- A directory to store a mini mirror of CPAN
- repository
- A directory to store modules that will be injected
Getting Started
CPAN::Mini::Inject includes a command line tool named mcpani
mcpani Command line options
continued...
mcpani Command line options
- add
- Add new modules to the repository
continued...
mcpani Command line options
- add
- Add new modules to the repository
- update
- Update local CPAN mirror and inject modules from repository
continued...
mcpani Command line options
- add
- Add new modules to the repository
- update
- Update local CPAN mirror and inject modules from repository
- mirror
continued...
mcpani Command line options
- add
- Add new modules to the repository
- update
- Update local CPAN mirror and inject modules from repository
- mirror
- inject
- Inject modules from the repository to the CPAN mirror
continued...
mcpani Command line options
- add
- Add new modules to the repository
- update
- Update local CPAN mirror and inject modules from repository
- mirror
- inject
- Inject modules from the repository to the CPAN mirror
There are more options to override those in the config file
Configuration files
mcpani searches the following locations for a configuration file
continued...
Configuration files
mcpani searches the following locations for a configuration file
- MCPANI_CONFIG environment variable
- $HOME/.mcpani/config
- /usr/local/etc/mcpani
- /etc/mcpani
Configuration Parameters
The configuration file is colon separated.
continued...
Configuration Parameters
The configuration file is colon separated.
- local (required option)
- location to store local CPAN::Mini mirror
continued...
Configuration Parameters
The configuration file is colon separated.
- local (required option)
- location to store local CPAN::Mini mirror
- remote (required option)
- CPAN site(s) to mirror from.
continued...
Configuration Parameters
The configuration file is colon separated.
- local (required option)
- location to store local CPAN::Mini mirror
- remote (required option)
- CPAN site(s) to mirror from.
- repository
- directory to store modules to be injected
continued...
Configuration Parameters
The configuration file is colon separated.
- local (required option)
- location to store local CPAN::Mini mirror
- remote (required option)
- CPAN site(s) to mirror from.
- repository
- directory to store modules to be injected
- passive
continued...
Configuration Parameters
The configuration file is colon separated.
- local (required option)
- location to store local CPAN::Mini mirror
- remote (required option)
- CPAN site(s) to mirror from.
- repository
- directory to store modules to be injected
- passive
- dirmode
- What permissions to set on created directories
Sample Configuration
local: /www/CPAN
remote : ftp://cpan.pair.com/
repository: /www/MYCPAN
dirmode: 0775
passive: yes
Updating the mirror
Updating the mirror is quite simple:
mcpani --update
continued...
Updating the mirror
Updating the mirror is quite simple:
mcpani --update
- Downloads the latest releases
- Deletes previous releases
- Injects modules from the repository
Adding modules
Modules are added to the repository with:
mcpani --add \
--authorid=SSORICHE \
--file My-New-Module-0.01.tar.gz
continued...
Adding modules
Modules are added to the repository with:
mcpani --add \
--authorid=SSORICHE \
--file My-New-Module-0.01.tar.gz
- mcpani will determine the module name and version from the given file name
Extensibility
CPAN::Mini::Inject was designed from the outset to be easily overridable.
- Each method returns the object itself
- Each method is broken into smaller methods
Where it's going
- Pluggable
- Multiuser
- Pruning