08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Managing Perl Installations: A SysAdmin's View
1. Managing Perl Installations:
A SysAdmin’s View 1,2,3
Baden Hughes
Department of Computer Science and Software Engineering
The University of Melbourne
badenh@csse.unimelb.edu.au
1
2. What the title really means …
Managing Perl Installations:
A SysAdmin’s View 1
Useful things a SysAdmin should know about Perl
Managing Perl Installations:
A SysAdmin’s View 2
What you can do if you actually RTFM
Managing Perl Installations:
A SysAdmin’s View 3
5327 other things you can do with CPAN
2
3. Overview
Perl, Modules, CPAN
Problems and Objectives
The Sharp and Pointy Bits
Module Management
Bundles
Working within User-space
Conclusion
3
4. Perl
http://www.perl.org
Perl is a dynamic procedural programming
language
Designed by Larry Wall, maintained as open
source project
First released in 1987
Perl borrows features from C, shell scripting
(sh), awk, sed, Lisp, and (to a lesser extent)
many other programming languages.
Ubiquitous
4
5. Perl Modules
A Perl module is a discrete component of
software for the Perl programming language.
Modules distinguished by a unique namespace,
e.g. quot;CGIquot; or quot;Net::FTPquot; or quot;XML::Parserquot;.
Convention of one module per file with a *.pm
extension.
Collection of one or more modules, with
accompanying documentation (yes, really) and
build scripts, compose a package.
5
6. CPAN
Comprehensive Perl Archive Network
http://cpan.org
A large collection of Perl software (modules,
packages and scripts) and associated
documentation
A Perl module (CPAN.pm)
perl –MCPAN –e shell
Used to download and install Perl software from
the CPAN archive
6
7. Scoping the Problem
On multi-user systems, particularly where there
are Perl-oriented developers of some flavour,
being responsible for Perl can be quite onerous
The defaults for maintaining Perl on a shared
system are typically
Every user compiles and runs their own version of Perl
Constant trickle of requests for Perl and/or module
upgrades and/or additions
Naturally neither of these are considered
desirable by typical sysadmins since they have
both system resource and human effort
constraints
7
8. Objectives
Get smarter: Perl itself can make managing a
Perl installation on a shared system much easier
Objectives
Demonstrate ways to manage Perl installations based
on commonly occurring tasks
Show ‘core Perl’ methods that work everywhere, not
distribution specific methods which only work on one
platform
Get users to help you, rather than the other way
around
8
10. Q: Which modules are on my system ?
A: perldoc perllocal
perldoc perllocal will identify a list of
modules, their version, location etc.
Tue Oct 4 17:00:07 2005: quot;Modulequot; Geo::GNIS
* quot;installed into: /usr/lib/perl5/site_perl/5.8.5quot;
* quot;LINKTYPE: dynamicquot;
* quot;VERSION: 0.01quot;
* quot;EXE_FILES: quot;
10
11. Q: Which modules are on my system ?
A: ExtUtils::Installed
Use the ExtUtils::Installed module
#!/usr/local/bin/perl
use ExtUtils::Installed;
my $instmod = ExtUtils::Installed->new();
foreach my $module ($instmod->modules())
{
my $version = $instmod->version($module) || quot;???quot;;
print quot;$module -- $versionnquot;;
}
produces a list of modules and their version(s)
ExtUtils::Installed is in the standard Perl installation, and uses the
installation generated files for modules to determine status
11
12. Q: Which modules are on my system ?
A: pmtools
The pmtools suite to help navigate and
manage Perl module installations
Obtain them at
http://language.perl.com/misc/pmtools-
1.00.tar.gz.
pmtools -- a suite of small programs to help
manage modules
pmpath - show the module' full path
s
pmvers - get a module version number
pmdesc - get a module description
pmall - get all installed modules pmdesc descriptions
pminst - find what' installed
s
12
13. Installing Modules
With CPAN.pm, installing a new module is
trivial:
perl -MCPAN -e 'install Esoteric::Module’
Finding which modules exist and their
versions can also be done directly via
CPAN
cpan > i $KEYWORD
13
14. Removing Modules (1)
By using the ExtUtils::Installed and ExtUtils::Packlist
modules that come with Perl
#!/usr/local/bin/perl -w
use ExtUtils::Packlist;
use ExtUtils::Installed;
$ARGV[0] or die quot;Usage: $0 Module::Namenquot;;
my $mod = $ARGV[0];
my $inst = ExtUtils::Installed->new();
foreach my $item (sort($inst->files($mod)))
{
print quot;removing $itemnquot;;
unlink $item;
}
my $packfile = $inst->packlist($mod)->packlist_file();
print quot;removing $packfilenquot;;
unlink $packfile;
14
15. Removing Modules (2)
PPM can uninstall modules
shell>ppm remove $MODULE-NAME
CPAN.pm doesn’t have a ‘remove’ option
15
16. Bundles
What is a Bundle ?
Which Bundles exist ?
Making Bundles (single point of Perl
administration for multiple systems)
16
17. Q: What is a Bundle ?
A bundle is quot;A group of related modules on CPAN (or
some repository“
A bundle can be any collection of modules, related or not.
Bundles are used by CPAN.pm to install a group of
modules quickly and easily.
A bundle is essentially a module in the Bundle::
namespace that has all the look and feel of a module but
really isn'since it contains no code instead having a
t
manifest of modules to be installed.
There are a number of existing module bundles that you
can view as examples to help in building your own.
17
18. Q: Which Bundles already exist ?
You can get a list of bundle distributions on search.cpan.org and CPAN.pm also lists
all currently available bundles when you type ' at the prompt.
b'
cpan> b Bundle
Bundle::ABH (A/AB/ABH/Bundle-ABH-1.04.tar.gz) Bundle
Bundle::AO::Base (I/IX/IX/AO-0.32.tar.gz) Bundle
Bundle::AO::Standard (I/IX/IX/AO-0.32.tar.gz) Bundle
Bundle::Apache (D/DO/DOUGM/mod_perl-1.25.tar.gz) Bundle
Bundle::Apache::ASP (C/CH/CHAMAS/Apache-ASP-2.09.tar.gz) Bundle
If you give ' a module argument it will list extended information about the bundle
b'
itself.
cpan> b Bundle::DBI
Bundle id = Bundle::DBI
CPAN_USERID TIMB (Tim Bunce <Tim.Bunce@pobox.com>)
CPAN_VERSION 1.03
CPAN_FILE T/TI/TIMB/DBI-1.15.tar.gz
MANPAGE Bundle::DBI - A bundle to install DBI and required
modules.
CONTAINS Storable Net::Daemon RPC::PlServer Getopt::Long DBI
INST_FILE /usr/local/lib/perl5/site_perl/5.005/sun4-
solaris/Bundle/DBI.pm
INST_VERSION 1.03
18
19. Q: How can I make a Bundle ?
Use the autobundle feature of CPAN.pm
autobundle will, if no arguments are given, inventory
all modules installed on the system and make a
systemwide bundle.
If you only want a few modules in the bundle you can
simply give it a list of modules and it will do the rest.
user@host /home/user/> perl -MCPAN -eshell cpan>
autobundle CGI Crypt::Rot13 Date::Christmas
Date::Manip
By default bundles are named
quot;Snapshot_YYYY_MM_DD_HH_MM_SS.pmquot;
The resultant file may then be used with the CPAN.pm
perl -MCPAN -e 'install Bundle::Snapshot_2006_04_09_10_36_24.pm'
19
20. Bundles and System Administration
Bundles are a very convenient way to
maintain homogeneous installations
across multiple systems, including across
architectures
Personal experience: create bundles for local
and external modules; store bundles in a
repository; checkout and install sequentially on
development, test and production servers;
single install experience, guaranteed
homogeneity
20
22. Working with Perl in User Space
Advanced users often want more control
over their Perl installation on shared
systems
SysAdmins are reluctant to let users “do
as they see fit” to system wide utilities
CPAN requires elevated privileges
Fortunately Perl offers several ways
around this problem
22
23. Installing Perl Modules in
Alternative Locations
Any manually installed Perl module can be trivially
installed in an alternative location, eg within ~/
Set PREFIX and LIB when you run the Makefile.PL to
install
LIB is where the module files will go
PREFIX is the stub directory for everything else
user@host$ perl Makefile.PL
LIB=/home/user/lib
PREFIX=/home/user/lib
The reason this works is because Perl has a standard
way of installing modules, called MakeMaker
23
24. Standard Perl + Custom Modules
Sometimes however, a user simply wants to
install a few modules but use the standard
system wide Perl installation
In this case, setting the PERL5LIB environment
variable can allow the inclusion of modules
installed in non-standard locations
PERL5LIB=${PERL5LIB:+$PERL5LIB:}$HOME/lib/perl5
24
25. User-space CPAN
CPAN can be configured differently for each
user, and can install modules to custom
locations on a system, eg ~/lib/perl5 and
~/share/man
MyConfig.pm is a base module for precisely
this purpose, and can be used in place of a
standard CPAN.pm
Allows users to directly use CPAN functionality,
with no run time environment variables required
25
26. Conclusion
Perl is ubiquitous
On shared systems, Perl has native tools
to reduce the administrative overhead
Users can be empowered to maintain their
own Perl infrastructure without significant
effort
RTFM’ing can actually be beneficial
26