managing perl installations: a sysadmin's view
Post on 16-Jan-2015
3.915 Views
Preview:
DESCRIPTION
TRANSCRIPT
1
Managing Perl Installations: A SysAdmin’s View 1,2,3
Baden HughesDepartment of Computer Science and Software Engineering
The University of Melbournebadenh@csse.unimelb.edu.au
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
3
Overview
�Perl, Modules, CPAN�Problems and Objectives�The Sharp and Pointy Bits
�Module Management�Bundles�Working within User-space
�Conclusion
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
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. "CGI" or "Net::FTP" or "XML::Parser".
� 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.
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
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
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 �
9
Modules
�Which modules are on my system ?� Installing modules�Removing modules
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: "Module" Geo::GNIS
* "installed into: /usr/lib/perl5/site_perl/5.8.5"
* "LINKTYPE: dynamic"
* "VERSION: 0.01"
* "EXE_FILES: "
11
Q: Which modules are on my system ? A: ExtUtils::Installed
� Use the ExtUtils::Installed module
#!/usr/local/bin/perluse ExtUtils::Installed; my $instmod = ExtUtils::Installed->new(); foreach my $module ($instmod->modules()) {
my $version = $instmod->version($module) || "???";print "$module -- $version\n";
}
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
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's full path �pmvers - get a module version number �pmdesc - get a module description �pmall - get all installed modules pmdesc descriptions �pminst - find what's installed
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 CPANcpan > i $KEYWORD
14
Removing Modules (1)
� By using the ExtUtils::Installed and ExtUtils::Packlistmodules that come with Perl#!/usr/local/bin/perl -w use ExtUtils::Packlist; use ExtUtils::Installed; $ARGV[0] or die "Usage: $0 Module::Name\n"; my $mod = $ARGV[0]; my $inst = ExtUtils::Installed->new(); foreach my $item (sort($inst->files($mod))) { print "removing $item\n"; unlink $item; } my $packfile = $inst->packlist($mod)->packlist_file(); print "removing $packfile\n";
unlink $packfile;
15
Removing Modules (2)
�PPM can uninstall modulesshell>ppm remove $MODULE-NAME
�CPAN.pm doesn’t have a ‘remove’ option
16
Bundles
�What is a Bundle ?�Which Bundles exist ?�Making Bundles (single point of Perl
administration for multiple systems)
17
Q: What is a Bundle ?
� A bundle is "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't since it contains no code instead having a 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.
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 'b' at the prompt.
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 'b' a module argument it will list extended information about the bundle itself.
cpan> b Bundle::DBIBundle id = Bundle::DBICPAN_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 DBIINST_FILE /usr/local/lib/perl5/site_perl/5.005/sun4-
solaris/Bundle/DBI.pm INST_VERSION 1.03
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::ChristmasDate::Manip
� By default bundles are named "Snapshot_YYYY_MM_DD_HH_MM_SS.pm"
� The resultant file may then be used with the CPAN.pmperl -MCPAN -e 'install Bundle::Snapshot_2006_04_09_10_36_24.pm'
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
21
User-space Perl
�Alternative locations for Modules�Standard Perl plus Custom Modules�User-specific CPAN
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
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 elseuser@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
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
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
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 �
top related