2 BEGIN { @INC = ('lib') }
8 use File::Path qw(mkpath);
9 use ExtUtils::Packlist;
10 use subs qw(unlink chmod rename link);
11 use vars qw($packlist @modpods);
14 $ENV{SHELL} = 'sh' if $^O eq 'os2';
16 my $ver = $Config{version}; # Not used presently.
17 my $release = substr($],0,3); # Not used presently.
18 my $patchlevel = substr($],3,2);
19 die "Patchlevel of perl ($patchlevel)",
20 "and patchlevel of config.sh ($Config{'PERL_VERSION'}) don't match\n"
21 if $patchlevel != $Config{'PERL_VERSION'};
24 "Usage: installman --man1dir=/usr/wherever --man1ext=1
25 --man3dir=/usr/wherever --man3ext=3
26 --notify --verbose --silent --help
28 man1dir = $Config{'installman1dir'};
29 man1ext = $Config{'man1ext'};
30 man3dir = $Config{'installman3dir'};
31 man3ext = $Config{'man3ext'};
32 --notify (or -n) just lists commands that would be executed.
33 --verbose (or -V) report all progress.
34 --silent (or -S) be silent. Only report errors.\n";
38 qw( man1dir=s man1ext=s man3dir=s man3ext=s
39 notify n help silent S verbose V))
41 die $usage if $opts{help};
43 $opts{man1dir} = $Config{'installman1dir'}
44 unless defined($opts{man1dir});
45 $opts{man1ext} = $Config{'man1ext'}
46 unless defined($opts{man1ext});
47 $opts{man3dir} = $Config{'installman3dir'}
48 unless defined($opts{man3dir});
49 $opts{man3ext} = $Config{'man3ext'}
50 unless defined($opts{man3ext});
51 $opts{silent} ||= $opts{S};
52 $opts{notify} ||= $opts{n};
53 $opts{verbose} ||= $opts{V} || $opts{notify};
57 -x "./perl$Config{exe_ext}"
58 or warn "./perl$Config{exe_ext} not found! Have you run make?\n";
59 -d $Config{'installprivlib'}
60 || warn "Perl library directory $Config{'installprivlib'} not found.
61 Have you run make install?. (Installing anyway.)\n";
62 -x "t/perl$Config{exe_ext}" || warn "WARNING: You've never run 'make test'!!!",
63 " (Installing anyway.)\n";
65 $packlist = ExtUtils::Packlist->new("$Config{installarchlib}/.packlist");
67 # Install the main pod pages.
68 runpod2man('pod', $opts{man1dir}, $opts{man1ext});
70 # Install the pods for library modules.
71 runpod2man('lib', $opts{man3dir}, $opts{man3ext});
73 # Install the pods embedded in the installed scripts
74 runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'c2ph');
75 runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'h2ph');
76 runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'h2xs');
77 runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'perlcc');
78 runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'perldoc');
79 runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'perlbug');
80 runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'pl2pm');
81 runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'splain');
82 runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'dprofpp');
83 runpod2man('x2p', $opts{man1dir}, $opts{man1ext}, 's2p');
84 runpod2man('x2p', $opts{man1dir}, $opts{man1ext}, 'a2p.pod');
85 runpod2man('x2p', $opts{man1dir}, $opts{man1ext}, 'find2perl');
86 runpod2man('pod', $opts{man1dir}, $opts{man1ext}, 'pod2man');
87 runpod2man('pod', $opts{man1dir}, $opts{man1ext}, 'pod2html');
88 runpod2man('pod', $opts{man1dir}, $opts{man1ext}, 'pod2text');
89 runpod2man('pod', $opts{man1dir}, $opts{man1ext}, 'pod2usage');
90 runpod2man('pod', $opts{man1dir}, $opts{man1ext}, 'podchecker');
91 runpod2man('pod', $opts{man1dir}, $opts{man1ext}, 'podselect');
93 # It would probably be better to have this page linked
94 # to the c2ph man page. Or, this one could say ".so man1/c2ph.1",
95 # but then it would have to pay attention to $opts{man1dir} and $opts{man1ext}.
96 runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'pstruct');
98 runpod2man('lib/ExtUtils', $opts{man1dir}, $opts{man1ext}, 'xsubpp');
101 # $script is script name if we are installing a manpage embedded
102 # in a script, undef otherwise
103 my($poddir, $mandir, $manext, $script) = @_;
105 my($downdir); # can't just use .. when installing xsubpp manpage
108 $downdir =~ s:[^/]+:..:g;
109 my($builddir) = Cwd::getcwd();
111 if ($mandir eq ' ' or $mandir eq '') {
112 warn "Skipping installation of ",
113 ($script ? "$poddir/$script man page" : "$poddir man pages"), ".\n";
117 print "chdir $poddir\n" if $opts{verbose};
118 chdir $poddir || die "Unable to cd to $poddir directory!\n$!\n";
120 # We insist on using the current version of pod2man in case there
121 # are enhancements or changes from previous installed versions.
122 # The error message doesn't include the '..' because the user
123 # won't be aware that we've chdir to $poddir.
124 -r "$downdir/pod/pod2man" || die "Executable pod/pod2man not found.\n";
126 # We want to be sure to use the current perl. We can't rely on
127 # the installed perl because it might not be actually installed
128 # yet. (The user may have set the $install* Configure variables
129 # to point to some temporary home, from which the executable gets
130 # installed by occult means.)
131 my $pod2man = "$downdir/perl -I $downdir/lib $downdir/pod/pod2man --section=$manext --official";
133 mkpath($mandir, $opts{verbose}, 0777) unless $opts{notify}; # In File::Path
134 # Make a list of all the .pm and .pod files in the directory. We will
135 # always run pod2man from the lib directory and feed it the full pathname
136 # of the pod. This might be useful for pod2man someday.
138 @modpods = ($script);
142 File::Find::find(\&lsmodpods, '.');
144 foreach my $mod (@modpods) {
147 # Skip .pm files that have corresponding .pod files, and Functions.pm.
148 next if (($tmp = $mod) =~ s/\.pm$/.pod/ && -f $tmp);
149 next if ($mod eq 'Pod/Functions.pm'); #### Used only by pod itself
151 # Convert name from File/Basename.pm to File::Basename.3 format,
153 $manpage =~ s#\.p(m|od)$##;
154 if ($^O eq 'os2' || $^O eq 'amigaos' || $^O eq 'uwin' || $^O eq 'cygwin') {
158 $manpage =~ s#/#::#g;
160 $tmp = "${mandir}/${manpage}.tmp";
161 $manpage = "${mandir}/${manpage}.${manext}";
162 if (&cmd("$pod2man $mod > $tmp") == 0 && !$opts{notify} && -s $tmp) {
163 if (rename($tmp, $manpage)) {
164 $packlist->{$manpage} = { type => 'file' };
168 unless ($opts{notify}) {
172 chdir "$builddir" || die "Unable to cd back to $builddir directory!\n$!\n";
173 print " chdir $builddir\n" if $opts{verbose};
177 my $dir = $File::Find::dir;
178 my $name = $File::Find::name;
181 push(@modpods, $name) if ($name =~ /\.p(m|od)$/);
185 $packlist->write() unless $opts{notify};
186 print " Installation complete\n" if $opts{verbose};
191 ###############################################################################
192 # Utility subroutines from installperl
196 print " $cmd\n" if $opts{verbose};
197 unless ($opts{notify}) {
198 if ($Config{d_fork}) {
199 fork ? wait : exec $cmd; # Allow user to ^C out of command.
204 warn "Command failed!!\n" if $?;
213 foreach my $name (@names) {
214 next unless -e $name;
215 chmod 0777, $name if $^O eq 'os2';
216 print " unlink $name\n" if $opts{verbose};
217 ( CORE::unlink($name) and ++$cnt
218 or warn "Couldn't unlink $name: $!\n" ) unless $opts{notify};
227 print $opts{verbose} ? " ln $from $to\n" : " $to\n" unless $opts{silent};
229 CORE::link($from, $to)
231 : ($from =~ m#^/afs/# || $to =~ m#^/afs/#)
232 ? die "AFS" # okay inside eval {}
233 : warn "Couldn't link $from to $to: $!\n"
234 unless $opts{notify};
237 File::Copy::copy($from, $to)
239 : warn "Couldn't copy $from to $to: $!\n"
240 unless $opts{notify};
247 if (-f $to and not unlink($to)) {
249 for ($i = 1; $i < 50; $i++) {
250 last if CORE::rename($to, "$to.$i");
252 warn("Cannot rename to `$to.$i': $!"), return 0
253 if $i >= 50; # Give up!
255 link($from,$to) || return 0;
260 my($mode,$name) = @_;
262 printf " chmod %o %s\n", $mode, $name if $opts{verbose};
263 CORE::chmod($mode,$name) || warn sprintf("Couldn't chmod %o %s: $!\n",$mode,$name)
264 unless $opts{notify};
269 my($dev1, $ino1, $dev2, $ino2);
272 ($dev1, $ino1) = stat($p1);
273 ($dev2, $ino2) = stat($p2);
274 ($dev1 == $dev2 && $ino1 == $ino2);