source: trunk/essentials/dev-lang/perl/installman@ 3208

Last change on this file since 3208 was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 8.2 KB
Line 
1#!./perl -w
2BEGIN { @INC = qw(lib) }
3use strict;
4use Config;
5use Getopt::Long;
6use File::Find;
7use File::Copy;
8use File::Path qw(mkpath);
9use ExtUtils::Packlist;
10use Pod::Man;
11use subs qw(unlink chmod rename link);
12use vars qw($packlist);
13
14if ($Config{d_umask}) {
15 umask(022); # umasks like 077 aren't that useful for installations
16}
17
18$ENV{SHELL} = 'sh' if $^O eq 'os2';
19
20my $ver = $Config{version}; # Not used presently.
21my $release = substr($],0,3); # Not used presently.
22my $patchlevel = substr($],3,2);
23die "Patchlevel of perl ($patchlevel)",
24 "and patchlevel of config.sh ($Config{'PERL_VERSION'}) don't match\n"
25 if $patchlevel != $Config{'PERL_VERSION'};
26
27my $usage =
28"Usage: installman --man1dir=/usr/wherever --man1ext=1
29 --man3dir=/usr/wherever --man3ext=3
30 --batchlimit=40
31 --notify --verbose --silent --help
32 Defaults are:
33 man1dir = $Config{'installman1dir'};
34 man1ext = $Config{'man1ext'};
35 man3dir = $Config{'installman3dir'};
36 man3ext = $Config{'man3ext'};
37 --notify (or -n) just lists commands that would be executed.
38 --verbose (or -V) report all progress.
39 --silent (or -S) be silent. Only report errors.\n";
40
41my %opts;
42GetOptions( \%opts,
43 qw( man1dir=s man1ext=s man3dir=s man3ext=s batchlimit=i
44 destdir:s notify n help silent S verbose V))
45 || die $usage;
46die $usage if $opts{help};
47
48$opts{man1dir} = "$opts{destdir}$Config{'installman1dir'}"
49 unless defined($opts{man1dir});
50$opts{man1ext} = $Config{'man1ext'}
51 unless defined($opts{man1ext});
52$opts{man3dir} = "$opts{destdir}$Config{'installman3dir'}"
53 unless defined($opts{man3dir});
54$opts{man3ext} = $Config{'man3ext'}
55 unless defined($opts{man3ext});
56$opts{silent} ||= $opts{S};
57$opts{notify} ||= $opts{n};
58$opts{verbose} ||= $opts{V} || $opts{notify};
59
60#Sanity checks
61
62-x "./perl$Config{exe_ext}"
63 or warn "./perl$Config{exe_ext} not found! Have you run make?\n";
64-d "$opts{destdir}$Config{'installprivlib'}"
65 || warn "Perl library directory $Config{'installprivlib'} not found.
66 Have you run make install?. (Installing anyway.)\n";
67-x "t/perl$Config{exe_ext}" || warn "WARNING: You've never run 'make test'!!!",
68 " (Installing anyway.)\n";
69
70$packlist = ExtUtils::Packlist->new("$opts{destdir}$Config{installarchlib}/.packlist");
71
72
73# Install the main pod pages.
74pod2man('pod', $opts{man1dir}, $opts{man1ext});
75
76# Install the pods for library modules.
77pod2man('lib', $opts{man3dir}, $opts{man3ext});
78
79# Install the pods embedded in the installed scripts
80my $has_man1dir = $opts{man1dir} ne '' && -d $opts{man1dir};
81open UTILS, "utils.lst" or die "Can't open 'utils.lst': $!";
82while (<UTILS>) {
83 next if /^#/;
84 chomp;
85 $_ = $1 if /#.*pod\s*=\s*(\S+)/;
86 my ($where, $what) = m|^(\S*)/(\S+)|;
87 pod2man($where, $opts{man1dir}, $opts{man1ext}, $what);
88 if ($has_man1dir) {
89 if (my ($where2, $what2) = m|#.*link\s*=\s*(\S+)/(\S+)|) {
90 my $old = "$opts{man1dir}/$what.$opts{man1ext}";
91 my $new = "$opts{man1dir}/$what2.$opts{man1ext}";
92 unlink($new);
93 link($old, $new);
94 my $xold = $old;
95 $xold =~ s/^\Q$opts{'destdir'}\E// if $opts{'destdir'};
96 my $xnew = $new;