1# 2# This is a version of the 5.8.4 installperl script that has been modified to 3# work correctly as part of the ON build process. The changes are as follows: 4# * umask set to 022 5# * install locations modified to be relative to $ROOT 6# * check for 'make test' being run before install removed 7# * executables installed with mode 0555 8# * executables only overwritten if different from last build 9# * check for other versions of perl in $PATH removed 10# * .packlist entries cleaned of $ROOT prefix 11# * SCCS directories and .tstamp files ignored on install 12# * The contents of the additional contrib_bin directory are installed 13# 14 15BEGIN { 16 require 5.004; 17 chdir '..' if !-d 'lib' and -d '../lib'; 18 @INC = 'lib'; 19 $ENV{PERL5LIB} = 'lib'; 20} 21 22use strict; 23my ($Is_VMS, $Is_W32, $Is_OS2, $Is_Cygwin, $Is_Darwin, 24 $nonono, $dostrip, $versiononly, $silent, $verbose, $force, 25 $otherperls, $archname, $Is_NetWare, $nwinstall, $nopods); 26use vars qw /$depth/; 27 28BEGIN { 29 $Is_VMS = $^O eq 'VMS'; 30 $Is_W32 = $^O eq 'MSWin32'; 31 $Is_OS2 = $^O eq 'os2'; 32 $Is_Cygwin = $^O eq 'cygwin'; 33 $Is_Darwin = $^O eq 'darwin'; 34 if ($Is_VMS) { eval 'use VMS::Filespec;' } 35} 36 37my $scr_ext = ($Is_VMS ? '.Com' : $Is_W32 ? '.bat' : ''); 38 39use File::Find; 40use File::Compare; 41use File::Copy (); 42use File::Path (); 43use ExtUtils::Packlist; 44use Config; 45use subs qw(unlink link chmod); 46 47if ($Config{d_umask}) { 48 umask(022); # umasks like 077 aren't that useful for installations 49} 50 51$Is_NetWare = $Config{osname} eq 'NetWare'; 52if ($Is_NetWare) { 53 $Is_W32 = 0; 54 $scr_ext = '.pl'; 55} 56 57# override the ones in the rest of the script 58sub mkpath { 59 File::Path::mkpath(@_) unless $nonono; 60} 61 62my $mainperldir = "/usr/bin"; 63my $exe_ext = $Config{exe_ext}; 64 65# Allow ``make install PERLNAME=something_besides_perl'': 66my $perl = defined($ENV{PERLNAME}) ? $ENV{PERLNAME} : 'perl'; 67 68# This is the base used for versioned names, like "perl5.6.0". 69# It's separate because a common use of $PERLNAME is to install 70# perl as "perl5", if that's used as base for versioned files you 71# get "perl55.6.0". 72my $perl_verbase = defined($ENV{PERLNAME_VERBASE}) 73 ? $ENV{PERLNAME_VERBASE} 74 : $perl; 75my $dbg = ''; 76my $ndbg = ''; 77if ( $Is_VMS ) { 78 if ( defined $Config{usevmsdebug} ) { 79 if ( $Config{usevmsdebug} eq 'define' ) { 80 $dbg = 'dbg'; 81 $ndbg = 'ndbg'; 82 } 83 } 84} 85 86$otherperls = 1; 87my $destdir = ''; 88while (@ARGV) { 89 $nonono = 1 if $ARGV[0] eq '-n'; 90 $dostrip = 1 if $ARGV[0] eq '-s'; 91 $versiononly = 1 if $ARGV[0] eq '-v'; 92 $versiononly = 0 if $ARGV[0] eq '+v'; 93 $silent = 1 if $ARGV[0] eq '-S'; 94 $otherperls = 0 if $ARGV[0] eq '-o'; 95 $force = 1 if $ARGV[0] eq '-f'; 96 $verbose = 1 if $ARGV[0] eq '-V' || $ARGV [0] eq '-n'; 97 $archname = 1 if $ARGV[0] eq '-A'; 98 $nwinstall = 1 if $ARGV[0] eq '-netware'; 99 $nopods = 1 if $ARGV[0] eq '-p'; 100 $destdir = $1 if $ARGV[0] =~ /^-?-destdir=(.*)$/; 101 if ($ARGV[0] eq '-?' or $ARGV[0] =~ /^-?-h/) { 102 print <<"EOT"; 103Usage $0: [switches] 104 -n Don't actually run any commands; just print them. 105 -s Run strip on installed binaries. 106 -v Only install perl as a binary with the version number in the name. 107 (Override whatever config.sh says) 108 +v Install perl as "perl" and as a binary with the version number in 109 the name. (Override whatever config.sh says) 110 -S Silent mode. 111 -f Force installation (don't check if same version is there) 112 -o Skip checking for other copies of perl in your PATH. 113 -V Verbose mode. 114 -A Also install perl with the architecture's name in the perl binary's 115 name. 116 -p Don't install the pod files. [This will break use diagnostics;] 117 -netware Install correctly on a Netware server. 118 -destdir Prefix installation directories by this string. 119EOT 120 exit; 121 } 122 shift; 123} 124 125$versiononly = 1 if $Config{versiononly} && !defined $versiononly; 126my (@scripts, @tolink); 127open SCRIPTS, "utils.lst" or die "Can't open utils.lst: $!"; 128while (<SCRIPTS>) { 129 next if /^#/; 130 s/\s*#\s*pod\s*=.*//; # install script regardless of pod location 131 next if /a2p/; # a2p is binary, to be installed separately 132 chomp; 133 if (/(\S*)\s*#\s*link\s*=\s*(\S*)/) { 134 push @scripts, $1; 135 push @tolink, [$1, $2]; 136 } else { 137 push @scripts, $_; 138 } 139} 140close SCRIPTS; 141 142# Added for ON - install the scripts (if any) from contrib_bin. 143my $dh; 144if (opendir($dh, 'contrib_bin')) { 145 push(@scripts, 146 map("contrib_bin/$_", grep($_ !~ /^\./, readdir($dh)))); 147 closedir($dh); 148} 149 150if ($scr_ext) { @scripts = map { "$_$scr_ext" } @scripts; } 151 152my @pods = $nopods ? () : (<pod/*.pod>, 'x2p/a2p.pod'); 153 154# Specify here any .pm files that are actually architecture-dependent. 155# (Those included with XS extensions under ext/ are automatically 156# added later.) 157# Now that the default privlib has the full perl version number included, 158# we no longer have to play the trick of sticking version-specific .pm 159# files under the archlib directory. 160my %archpms = ( 161 Config => 1, 162 lib => 1, 163 Cwd => 1, 164); 165 166if ($^O eq 'dos') { 167 push(@scripts,'djgpp/fixpmain'); 168 $archpms{config} = $archpms{filehand} = 1; 169} 170 171if ((-e "testcompile") && (defined($ENV{'COMPILE'}))) { 172 push(@scripts, map("$_.exe", @scripts)); 173} 174 175find(sub { 176 if ("$File::Find::dir/$_" =~ m{^ext\b(.*)/([^/]+)\.pm$}) { 177 my($path, $modname) = ($1,$2); 178 179 # strip trailing component first 180 $path =~ s{/[^/]*$}{}; 181 182 # strip optional "/lib"; 183 $path =~ s{/lib\b}{}; 184 185 # strip any leading / 186 $path =~ s{^/}{}; 187 188 # reconstitute canonical module name 189 $modname = "$path/$modname" if length $path; 190 191 # remember it 192 $archpms{$modname} = 1; 193 } 194}, 'ext'); 195 196# print "[$_]\n" for sort keys %archpms; 197 198my $ver = $Config{version}; 199my $release = substr($],0,3); # Not used currently. 200my $patchlevel = substr($],3,2); 201die "Patchlevel of perl ($patchlevel)", 202 "and patchlevel of config.sh ($Config{'PERL_VERSION'}) don't match\n" 203 if $patchlevel != $Config{'PERL_VERSION'}; 204 205# Fetch some frequently-used items from %Config 206my $installbin = "$destdir$Config{installbin}"; 207my $installscript = "$destdir$Config{installscript}"; 208my $installprivlib = "$destdir$Config{installprivlib}"; 209my $installarchlib = "$destdir$Config{installarchlib}"; 210my $installsitelib = "$destdir$Config{installsitelib}"; 211my $installsitearch = "$destdir$Config{installsitearch}"; 212my $installman1dir = "$destdir$Config{installman1dir}"; 213my $man1ext = $Config{man1ext}; 214my $libperl = "$destdir$Config{libperl}"; 215# Shared library and dynamic loading suffixes. 216my $so = $Config{so}; 217my $dlext = $Config{dlext}; 218my $dlsrc = $Config{dlsrc}; 219if ($^O eq 'os390') { 220 my $pwd; 221 chomp($pwd=`pwd`); 222 my $archlibexp = $Config{archlibexp}; 223 my $usedl = $Config{usedl}; 224 if ($usedl eq 'define') { 225 `./$^X -pibak -e 's{$pwd\/libperl.x}{$archlibexp/CORE/libperl.x}' lib/Config.pm`; 226 } 227} 228 229if ($nwinstall) { 230 # This is required only if we are installing on a NetWare server 231 $installscript = $Config{installnwscripts}; 232 $installprivlib = $Config{installnwlib}; 233 $installarchlib = $Config{installnwlib}; 234 $installsitelib = $Config{installnwlib}; 235} 236 237my $d_dosuid = $Config{d_dosuid}; 238my $binexp = $Config{binexp}; 239 240if ($Is_VMS) { # Hang in there until File::Spec hits the big time 241 foreach ( \$installbin, \$installscript, \$installprivlib, 242 \$installarchlib, \$installsitelib, \$installsitearch, 243 \$installman1dir ) { 244 $$_ = unixify($$_); $$_ =~ s:/$::; 245 } 246} 247 248# Do some quick sanity checks. 249 250if (!$nonono && $d_dosuid && $>) { die "You must run as root to install suidperl\n"; } 251 252 $installbin || die "No installbin directory in config.sh\n"; 253-d $installbin || mkpath($installbin, $verbose, 0777); 254-d $installbin || $nonono || die "$installbin is not a directory\n"; 255-w $installbin || $nonono || die "$installbin is not writable by you\n" 256 unless $installbin =~ m#^/afs/# || $nonono; 257 258if (!$Is_NetWare) { 259if (!$Is_VMS) { 260-x 'perl' . $exe_ext || die "perl isn't executable!\n"; 261} 262else { 263-x $ndbg . 'perl' . $exe_ext || die "${ndbg}perl$exe_ext isn't executable!\n"; 264 if ($dbg) { 265 -x $dbg . 'perl' . $exe_ext || die "${dbg}perl$exe_ext isn't executable!\n"; 266 } 267} 268-x 'suidperl' . $exe_ext|| die "suidperl isn't executable!\n" if $d_dosuid; 269 270# Removed for ON 271#-f 't/rantests' || $Is_W32 272# || warn "WARNING: You've never run 'make test' or", 273# " some tests failed! (Installing anyway.)\n"; 274} #if (!$Is_NetWare) 275 276if (($Is_W32 and ! $Is_NetWare) or $Is_Cygwin) { 277 my $perldll; 278 279 if ($Is_Cygwin) { 280 $perldll = $libperl; 281 my $v_e_r_s = $ver; $v_e_r_s =~ tr/./_/; 282 $perldll =~ s/(\..*)?$/$v_e_r_s.$dlext/; 283 $perldll =~ s/^lib/cyg/; 284 if ($Config{useshrplib} eq 'true') { 285 # install ld2 and perlld as well 286 foreach ('ld2', 'perlld') { 287 safe_unlink("$installbin/$_"); 288 copy("$_", "$installbin/$_"); 289 chmod(0755, "$installbin/$_"); 290 }; 291 open (LD2, ">$installbin/ld2"); 292 print LD2 <<SHELL; 293#!/bin/sh 294# 295# ld wrapper, passes all args to perlld; 296# 297for trythis in $installbin/perl 298do 299 if [ -x \$trythis ] 300 then 301 \$trythis $installbin/perlld "\$\@" 302 exit \$? 303 fi 304done 305# hard luck! 306echo I see no perl executable around there 307echo perl is required to build dynamic libraries 308echo look if the path to perl in /bin/ld2 is correct 309exit 1 310SHELL 311 close LD2; 312 chmod(0755, "$installbin/ld2"); 313 }; 314 } else { 315 $perldll = 'perl58.' . $dlext; 316 } 317 318 if ($dlsrc ne "dl_none.xs") { 319 -f $perldll || die "No perl DLL built\n"; 320 } 321 322 # Install the DLL 323 safe_unlink("$installbin/$perldll"); 324 copy("$perldll", "$installbin/$perldll"); 325 chmod(0755, "$installbin/$perldll"); 326} # if (($Is_W32 and ! $Is_NetWare) or $Is_Cygwin) 327 328# This will be used to store the packlist 329my $packlist = ExtUtils::Packlist->new("$installarchlib/.packlist"); 330 331# First we install the version-numbered executables. 332 333if ($Is_VMS) { 334 safe_unlink("$installbin/perl_setup.com"); 335 copy("perl_setup.com", "$installbin/perl_setup.com"); 336 chmod(0755, "$installbin/perl_setup.com"); 337 safe_unlink("$installbin/$dbg$perl$exe_ext"); 338 copy("$dbg$perl$exe_ext", "$installbin/$dbg$perl$exe_ext"); 339 chmod(0755, "$installbin/$dbg$perl$exe_ext"); 340 safe_unlink("$installbin/$dbg${perl}shr$exe_ext"); 341 copy("$dbg${perl}shr$exe_ext", "$installbin/$dbg${perl}shr$exe_ext"); 342 chmod(0755, "$installbin/$dbg${perl}shr$exe_ext"); 343 if ($ndbg) { 344 safe_unlink("$installbin/$ndbg$perl$exe_ext"); 345 copy("$ndbg$perl$exe_ext", "$installbin/$ndbg$perl$exe_ext"); 346 chmod(0755, "$installbin/$ndbg$perl$exe_ext"); 347 safe_unlink("$installbin/${dbg}a2p$exe_ext"); 348 copy("x2p/${dbg}a2p$exe_ext", "$installbin/${dbg}a2p$exe_ext"); 349 chmod(0755, "$installbin/${dbg}a2p$exe_ext"); 350 } 351} 352elsif ($^O eq 'mpeix') { 353 # MPE lacks hard links and requires that executables with special 354 # capabilities reside in the MPE namespace. 355 safe_unlink("$installbin/perl$ver$exe_ext", $Config{perlpath}); 356 # Install the primary executable into the MPE namespace as perlpath. 357 copy("perl$exe_ext", $Config{perlpath}); 358 chmod(0755, $Config{perlpath}); 359 # Create a backup copy with the version number. 360 link($Config{perlpath}, "$installbin/perl$ver$exe_ext"); 361} 362elsif ($^O ne 'dos') { 363 if (!$Is_NetWare) { 364 if (copy_if_diff("perl$exe_ext", 365 "$installbin/$perl_verbase$ver$exe_ext")) { 366 strip("$installbin/$perl_verbase$ver$exe_ext"); 367 chmod(0555, "$installbin/$perl_verbase$ver$exe_ext"); 368 } 369 } 370 else { 371 # If installing onto a NetWare server 372 if ($nwinstall) { 373 # Copy perl.nlm, echo.nlm, type.nlm, a2p.nlm & cgi2perl.nlm 374 mkpath($Config{installnwsystem}, 1, 0777); 375 copy("netware\\".$ENV{'MAKE_TYPE'}."\\perl.nlm", $Config{installnwsystem}); 376 copy("netware\\testnlm\\echo\\echo.nlm", $Config{installnwsystem}); 377 copy("netware\\testnlm\\type\\type.nlm", $Config{installnwsystem}); 378 copy("x2p\\a2p.nlm", $Config{installnwsystem}); 379 chmod(0755, "$Config{installnwsystem}\\perl.nlm"); 380 mkpath($Config{installnwlcgi}, 1, 0777); 381 copy("lib\\auto\\cgi2perl\\cgi2perl.nlm", $Config{installnwlcgi}); 382 } 383 } #if (!$Is_NetWare) 384} 385else { 386 safe_unlink("$installbin/$perl.exe"); 387 copy("perl.exe", "$installbin/$perl.exe"); 388} 389 390safe_unlink("$installbin/s$perl_verbase$ver$exe_ext"); 391if ($d_dosuid) { 392 copy("suidperl$exe_ext", "$installbin/s$perl_verbase$ver$exe_ext"); 393 chmod(04711, "$installbin/s$perl_verbase$ver$exe_ext"); 394} 395 396# Install library files. 397 398my ($do_installarchlib, $do_installprivlib) = (0, 0); 399 400mkpath($installprivlib, $verbose, 0777); 401mkpath($installarchlib, $verbose, 0777); 402mkpath($installsitelib, $verbose, 0777) if ($installsitelib); 403mkpath($installsitearch, $verbose, 0777) if ($installsitearch); 404 405if (chdir "lib") { 406 $do_installarchlib = ! samepath($installarchlib, '.'); 407 $do_installprivlib = ! samepath($installprivlib, '.'); 408 $do_installprivlib = 0 if $versiononly && !($installprivlib =~ m/\Q$ver/); 409 410 if ($do_installarchlib || $do_installprivlib) { 411 find(\&installlib, '.'); 412 } 413 chdir ".." || die "Can't cd back to source directory: $!\n"; 414} 415else { 416 warn "Can't cd to lib to install lib files: $!\n"; 417} 418 419# Install header files and libraries. 420mkpath("$installarchlib/CORE", $verbose, 0777); 421my @corefiles; 422if ($Is_VMS) { # We did core file selection during build 423 my $coredir = "lib/$Config{archname}/$ver/CORE"; 424 $coredir =~ tr/./_/; 425 map { s|^$coredir/||i; } @corefiles = <$coredir/*.*>; 426} 427else { 428 # [als] hard-coded 'libperl' name... not good! 429 @corefiles = <*.h *.inc libperl*.* perl*$Config{lib_ext}>; 430 431 # AIX needs perl.exp installed as well. 432 push(@corefiles,'perl.exp') if $^O eq 'aix'; 433 if ($^O eq 'mpeix') { 434 # MPE needs mpeixish.h installed as well. 435 mkpath("$installarchlib/CORE/mpeix", $verbose, 0777); 436 push(@corefiles,'mpeix/mpeixish.h'); 437 } 438 # If they have built sperl.o... 439 push(@corefiles,'sperl.o') if -f 'sperl.o'; 440} 441foreach my $file (@corefiles) { 442 # HP-UX (at least) needs to maintain execute permissions 443 # on dynamically-loadable libraries. So we do it for all. 444 if (copy_if_diff($file,"$installarchlib/CORE/$file")) { 445 if ($file =~ /\.(\Q$so\E|\Q$dlext\E)$/) { 446 strip("-S", "$installarchlib/CORE/$file") if $^O =~ /^(rhapsody|darwin)$/; 447 chmod(0555, "$installarchlib/CORE/$file"); 448 } else { 449 chmod(0444, "$installarchlib/CORE/$file"); 450 } 451 } 452} 453 454# Switch in the 5.005-threads versions of he threadsafe queue and semaphore 455# modules if so needed. 456if ($Config{use5005threads}) { 457 for my $m (qw(Queue Semaphore)) { 458 my $t = "$installprivlib/Thread/$m.pm"; 459 unlink $t; 460 copy("ext/Thread/$m.pmx", $t); 461 chmod(0444, $t); 462 } 463} 464 465# Install main perl executables 466# Make links to ordinary names if installbin directory isn't current directory. 467 468if (! $versiononly && ! samepath($installbin, '.') && ($^O ne 'dos') && ! $Is_VMS && ! $Is_NetWare) { 469 safe_unlink("$installbin/$perl$exe_ext", "$installbin/suid$perl$exe_ext"); 470 if ($^O eq 'mpeix') { 471 # MPE doesn't support hard links, so use a symlink. 472 # We don't want another cloned copy. 473 symlink($Config{perlpath}, "$installbin/perl$exe_ext"); 474 } elsif ($^O eq 'vos') { 475 # VOS doesn't support hard links, so use a symlink. 476 symlink("$installbin/$perl_verbase$ver$exe_ext", 477 "$installbin/$perl$exe_ext"); 478 } else { 479 link("$installbin/$perl_verbase$ver$exe_ext", 480 "$installbin/$perl$exe_ext"); 481 } 482 link("$installbin/$perl_verbase$ver$exe_ext", 483 "$installbin/suid$perl$exe_ext") 484 if $d_dosuid; 485} 486 487# For development purposes it can be very useful to have multiple perls 488# build for different "architectures" (eg threading or not) simultaneously. 489if ($archname && ! samepath($installbin, '.') && ($^O ne 'dos') && ! $Is_VMS) { 490 my $archperl = "$perl_verbase$ver-$Config{archname}$exe_ext"; 491 safe_unlink("$installbin/$archperl"); 492 if ($^O eq 'mpeix') { 493 # MPE doesn't support hard links, so use a symlink. 494 # We don't want another cloned copy. 495 symlink($Config{perlpath}, "$installbin/$archperl"); 496 } elsif ($^O eq 'vos') { 497 # VOS doesn't support hard links, so use a symlink. 498 symlink("$installbin/$perl_verbase$ver$exe_ext", 499 "$installbin/$archperl"); 500 } else { 501 link("$installbin/$perl_verbase$ver$exe_ext", "$installbin/$archperl"); 502 } 503} 504 505# Offer to install perl in a "standard" location 506 507my $mainperl_is_instperl = 0; 508 509if ($Config{installusrbinperl} && $Config{installusrbinperl} eq 'define' && 510 !$versiononly && !$nonono && !$Is_W32 && !$Is_NetWare && !$Is_VMS && -t STDIN && -t STDERR 511 && -w $mainperldir && ! samepath($mainperldir, $installbin)) { 512 my($usrbinperl) = "$mainperldir/$perl$exe_ext"; 513 my($instperl) = "$installbin/$perl$exe_ext"; 514 my($expinstperl) = "$binexp/$perl$exe_ext"; 515 516 # First make sure $usrbinperl is not already the same as the perl we 517 # just installed. 518 if (-x $usrbinperl) { 519 # Try to be clever about mainperl being a symbolic link 520 # to binexp/perl if binexp and installbin are different. 521 $mainperl_is_instperl = 522 samepath($usrbinperl, $instperl) || 523 samepath($usrbinperl, $expinstperl) || 524 (($binexp ne $installbin) && 525 (-l $usrbinperl) && 526 ((readlink $usrbinperl) eq $expinstperl)); 527 } 528 if (! $mainperl_is_instperl) { 529 unlink($usrbinperl); 530 ( $Config{'d_link'} eq 'define' && 531 eval { CORE::link $instperl, $usrbinperl } ) || 532 eval { symlink $expinstperl, $usrbinperl } || 533 copy($instperl, $usrbinperl); 534 535 $mainperl_is_instperl = 1; 536 } 537} 538 539# Make links to ordinary names if installbin directory isn't current directory. 540if (!$Is_NetWare && $dbg eq '') { 541 if (! samepath($installbin, 'x2p')) { 542 my $base = 'a2p'; 543 $base .= $ver if $versiononly; 544 copy_if_diff("x2p/a2p$exe_ext", "$installbin/$base$exe_ext"); 545 strip("$installbin/$base$exe_ext"); 546 chmod(0555, "$installbin/$base$exe_ext"); 547 } 548} 549 550# cppstdin is just a script, but it is architecture-dependent, so 551# it can't safely be shared. Place it in $installbin. 552# Note that Configure doesn't build cppstin if it isn't needed, so 553# we skip this if cppstdin doesn't exist. 554if (! $versiononly && (-f 'cppstdin') && (! samepath($installbin, '.'))) { 555 safe_unlink("$installbin/cppstdin"); 556 copy("cppstdin", "$installbin/cppstdin"); 557 chmod(0555, "$installbin/cppstdin"); 558} 559 560sub script_alias { 561 my ($installscript, $orig, $alias, $scr_ext) = @_; 562 563 safe_unlink("$installscript/$alias$scr_ext"); 564 if ($^O eq 'dos' or $Is_VMS or $^O eq 'transit') { 565 copy("$installscript/$orig$scr_ext", 566 "$installscript/$alias$scr_ext"); 567 } elsif ($^O eq 'vos') { 568 symlink("$installscript/$orig$scr_ext", 569 "$installscript/$alias$scr_ext"); 570 } else { 571 link("$installscript/$orig$scr_ext", 572 "$installscript/$alias$scr_ext"); 573 } 574} 575 576# Install scripts. 577mkpath($installscript, $verbose, 0777); 578if ($versiononly) { 579 for (@scripts) { 580 (my $base = $_) =~ s#.*/##; 581 $base .= $ver; 582 if (copy_if_diff($_, "$installscript/$base")) { 583 chmod(0555, "$installscript/$base"); 584 } 585 } 586 587 for (@tolink) { 588 my ($from, $to) = map { "$_$ver" } @$_; 589 (my $frbase = $from) =~ s#.*/##; 590 (my $tobase = $to) =~ s#.*/##; 591 script_alias($installscript, $frbase, $tobase, $scr_ext); 592 } 593} else { 594 for (@scripts) { 595 (my $base = $_) =~ s#.*/##; 596 copy_if_diff($_, "$installscript/$base"); 597 chmod(0555, "$installscript/$base"); 598 } 599 600 for (@tolink) { 601 my ($from, $to) = @$_; 602 (my $frbase = $from) =~ s#.*/##; 603 (my $tobase = $to) =~ s#.*/##; 604 script_alias($installscript, $frbase, $tobase, $scr_ext); 605 } 606} 607 608# Install pod pages. Where? I guess in $installprivlib/pod 609# ($installprivlib/pods for cygwin). 610 611my $pod = ($Is_Cygwin || $Is_Darwin) ? 'pods' : 'pod'; 612if ( !$versiononly || ($installprivlib =~ m/\Q$ver/)) { 613 mkpath("${installprivlib}/$pod", $verbose, 0777); 614 615 # If Perl 5.003's perldiag.pod is there, rename it. 616 if (open POD, "${installprivlib}/$pod/perldiag.pod") { 617 read POD, $_, 4000; 618 close POD; 619 # Some of Perl 5.003's diagnostic messages ended with periods. 620 if (/^=.*\.$/m) { 621 my ($from, $to) = ("${installprivlib}/$pod/perldiag.pod", 622 "${installprivlib}/$pod/perldiag-5.003.pod"); 623 print " rename $from $to"; 624 rename($from, $to) 625 or warn "Couldn't rename $from to $to: $!\n" 626 unless $nonono; 627 } 628 } 629 630 for (@pods) { 631 # $_ is a name like pod/perl.pod 632 (my $base = $_) =~ s#.*/##; 633 if (copy_if_diff($_, "${installprivlib}/$pod/${base}")) { 634 chmod(0444, "${installprivlib}/$pod/${base}"); 635 } 636 } 637 638} 639 640# Check to make sure there aren't other perls around in installer's 641# path. This is probably UNIX-specific. Check all absolute directories 642# in the path except for where public executables are supposed to live. 643# Also skip $mainperl if the user opted to have it be a link to the 644# installed perl. 645 646# Note: Removed for ON. 647 648#if (!$versiononly && $otherperls) { 649# my ($path, @path); 650# my $dirsep = ($Is_OS2 || $Is_W32 || $Is_NetWare) ? ';' : ':' ; 651# ($path = $ENV{"PATH"}) =~ s:\\:/:g ; 652# @path = split(/$dirsep/, $path); 653# if ($Is_VMS) { 654# my $i = 0; 655# while (exists $ENV{'DCL$PATH' . $i}) { 656# my $dir = unixpath($ENV{'DCL$PATH' . $i}); $dir =~ s-/$--; 657# push(@path,$dir); 658# } 659# } 660# my @otherperls; 661# my %otherperls; 662# for (@path) { 663# next unless m,^/,; 664# # Use &samepath here because some systems have other dirs linked 665# # to $mainperldir (like SunOS) 666# next if samepath($_, $binexp); 667# next if ($mainperl_is_instperl && samepath($_, $mainperldir)); 668# my $otherperl = "$_/$perl$exe_ext"; 669# next if $otherperls{$otherperl}++; 670# push(@otherperls, $otherperl) 671# if (-x $otherperl && ! -d $otherperl); 672# } 673# if (@otherperls) { 674# warn "\nWarning: $perl appears in your path in the following " . 675# "locations beyond where\nwe just installed it:\n"; 676# for (@otherperls) { 677# warn " ", $_, "\n"; 678# } 679# warn "\n"; 680# } 681#} 682 683# Added for ON - remove $ROOT prefix from the packlist entries. 684my $pat = qr{^$destdir}; 685while (my ($k, $v) = each(%{$packlist})) { 686 delete($packlist->{$k}); 687 $k =~ s/$pat//; 688 if ($v->{type} eq 'link') { 689 my $l = delete($v->{from}); 690 $l =~ s/$pat//; 691 $v->{from} = $l; 692 } 693 $packlist->{$k} = $v; 694} 695if (! $nonono) { 696 $packlist->write("$installarchlib/.packlist.tmp"); 697 if (copy_if_diff("$installarchlib/.packlist.tmp", 698 "$installarchlib/.packlist")) { 699 chmod(0444, "$installarchlib/.packlist"); 700 } 701 safe_unlink("$installarchlib/.packlist.tmp"); 702} 703 704print " Installation complete\n" if $verbose; 705 706exit 0; 707 708############################################################################### 709 710sub yn { 711 my($prompt) = @_; 712 my($answer); 713 my($default) = $prompt =~ m/\[([yn])\]\s*$/i; 714 print STDERR $prompt; 715 chop($answer = <STDIN>); 716 $answer = $default if $answer =~ m/^\s*$/; 717 ($answer =~ m/^[yY]/); 718} 719 720sub unlink { 721 my(@names) = @_; 722 my($cnt) = 0; 723 724 return scalar(@names) if $Is_VMS; 725 726 foreach my $name (@names) { 727 next unless -e $name; 728 chmod 0777, $name if ($Is_OS2 || $Is_W32 || $Is_Cygwin || $Is_NetWare); 729 print " unlink $name\n" if $verbose; 730 ( CORE::unlink($name) and ++$cnt 731 or warn "Couldn't unlink $name: $!\n" ) unless $nonono; 732 } 733 return $cnt; 734} 735 736sub safe_unlink { 737 return if $nonono or $Is_VMS; 738 my @names = @_; 739 foreach my $name (@names) { 740 next unless -e $name; 741 chmod 0777, $name if ($Is_OS2 || $Is_W32 || $Is_NetWare); 742 print " unlink $name\n" if $verbose; 743 next if CORE::unlink($name); 744 warn "Couldn't unlink $name: $!\n"; 745 if ($! =~ /busy/i) { 746 print " mv $name $name.old\n" if $verbose; 747 safe_rename($name, "$name.old") 748 or warn "Couldn't rename $name: $!\n"; 749 } 750 } 751} 752 753sub safe_rename { 754 my($from,$to) = @_; 755 if (-f $to and not unlink($to)) { 756 my($i); 757 for ($i = 1; $i < 50; $i++) { 758 last if rename($to, "$to.$i"); 759 } 760 warn("Cannot rename to `$to.$i': $!"), return 0 761 if $i >= 50; # Give up! 762 } 763 link($from,$to) || return 0; 764 unlink($from); 765} 766 767sub link { 768 my($from,$to) = @_; 769 my($success) = 0; 770 771 my $xfrom = $from; 772 $xfrom =~ s/^\Q$destdir\E// if $destdir; 773 my $xto = $to; 774 $xto =~ s/^\Q$destdir\E// if $destdir; 775 print $verbose ? " ln $xfrom $xto\n" : " $xto\n" unless $silent; 776 eval { 777 CORE::link($from, $to) 778 ? $success++ 779 : ($from =~ m#^/afs/# || $to =~ m#^/afs/#) 780 ? die "AFS" # okay inside eval {} 781 : die "Couldn't link $from to $to: $!\n" 782 unless $nonono; 783 $packlist->{$xto} = { from => $xfrom, type => 'link' }; 784 }; 785 if ($@) { 786 warn "Replacing link() with File::Copy::copy(): $@"; 787 print $verbose ? " cp $from $xto\n" : " $xto\n" unless $silent; 788 print " creating new version of $xto\n" 789 if $Is_VMS and -e $to and !$silent; 790 unless ($nonono or File::Copy::copy($from, $to) and ++$success) { 791 # Might have been that F::C::c can't overwrite the target 792 warn "Couldn't copy $from to $to: $!\n" 793 unless -f $to and (chmod(0666, $to), unlink $to) 794 and File::Copy::copy($from, $to) and ++$success; 795 } 796 $packlist->{$xto} = { type => 'file' }; 797 } 798 $success; 799} 800 801sub chmod { 802 my($mode,$name) = @_; 803 804 return if ($^O eq 'dos'); 805 printf " chmod %o %s\n", $mode, $name if $verbose; 806 CORE::chmod($mode,$name) 807 || warn sprintf("Couldn't chmod %o %s: $!\n", $mode, $name) 808 unless $nonono; 809} 810 811sub copy { 812 my($from,$to) = @_; 813 814 my $xto = $to; 815 $xto =~ s/^\Q$destdir\E// if $destdir; 816 print $verbose ? " cp $from $xto\n" : " $xto\n" unless $silent; 817 print " creating new version of $xto\n" if $Is_VMS and -e $to and !$silent; 818 unless ($nonono or File::Copy::copy($from, $to)) { 819 # Might have been that F::C::c can't overwrite the target 820 warn "Couldn't copy $from to $to: $!\n" 821 unless -f $to and (chmod(0666, $to), unlink $to) 822 and File::Copy::copy($from, $to); 823 } 824 $packlist->{$xto} = { type => 'file' }; 825} 826 827sub samepath { 828 my($p1, $p2) = @_; 829 830 return (lc($p1) eq lc($p2)) if ($Is_W32 || $Is_NetWare); 831 832 if ($p1 ne $p2) { 833 my($dev1, $ino1, $dev2, $ino2); 834 ($dev1, $ino1) = stat($p1); 835 ($dev2, $ino2) = stat($p2); 836 ($dev1 == $dev2 && $ino1 == $ino2); 837 } 838 else { 839 1; 840 } 841} 842 843sub installlib { 844 my $dir = $File::Find::dir; 845 $dir =~ s#^\.(?![^/])/?##; 846 local($depth) = $dir ? "lib/$dir" : "lib"; 847 848 my $name = $_; 849 850 # Ignore version control directories and ON artifacts. 851 if (($name =~ /^(?:CVS|RCS|SCCS|\.svn)\z/ and -d $name) 852 or ($name eq '.tstamp' and -f $name)) { 853 $File::Find::prune = 1; 854 return; 855 } 856 857 # ignore patch backups, RCS files, emacs backup & temp files and the 858 # .exists files, .PL files, and test files. 859 return if $name =~ m{\.orig$|\.rej$|~$|^#.+#$|,v$|^\.exists|\.PL$|\.plc$|\.t$|^test\.pl$} || 860 $dir =~ m{/t(?:/|$)}; 861 862 # XXX xsubpp back out of the list. prove now integrated. Out of order, so 863 # p4 will conflict on the next update to the following lines: 864 865 # ignore the cpan script in lib/CPAN/bin, the instmodsh and xsubpp 866 # scripts in lib/ExtUtils, and the prove script in lib/Test/Harness 867 # (they're installed later with other utils) 868 return if $name =~ /^(?:cpan|instmodsh|prove)\z/; 869 870 # ignore the Makefiles 871 return if $name =~ /^makefile$/i; 872 # ignore the test extensions 873 return if $dir =~ m{ext/XS/(?:APItest|Typemap)/}; 874 875 $name = "$dir/$name" if $dir ne ''; 876 877 my $installlib = $installprivlib; 878 if ($dir =~ /^auto/ || 879 ($name =~ /^(.*)\.(?:pm|pod)$/ && $archpms{$1}) || 880 ($name =~ /^(.*)\.(?:h|lib)$/i && ($Is_W32 || $Is_NetWare)) 881 ) { 882 $installlib = $installarchlib; 883 return unless $do_installarchlib; 884 } else { 885 return unless $do_installprivlib; 886 } 887 888 if (-f $_) { 889 if (/\.(?:al|ix)$/ && !($dir =~ m[^auto/(.*)$] && $archpms{$1})) { 890 $installlib = $installprivlib; 891 #We're installing *.al and *.ix files into $installprivlib, 892 #but we have to delete old *.al and *.ix files from the 5.000 893 #distribution: 894 #This might not work because $archname might have changed. 895 unlink("$installarchlib/$name"); 896 } 897 my $xname = "$installlib/$name"; 898 $xname =~ s/^\Q$destdir\E// if $destdir; 899 $packlist->{$xname} = { type => 'file' }; 900 if ($force || compare($_, "$installlib/$name") || $nonono) { 901 unlink("$installlib/$name"); 902 mkpath("$installlib/$dir", $verbose, 0777); 903 # HP-UX (at least) needs to maintain execute permissions 904 # on dynamically-loaded libraries. 905 if ($Is_NetWare && !$nwinstall) { 906 # Don't copy .nlp,.nlm files, doesn't make sense on Windows and also 907 # if copied will give problems when building new extensions. 908 # Has to be copied if we are installing on a NetWare server and hence 909 # the check !$nwinstall 910 if (!(/\.(?:nlp|nlm|bs)$/)) { 911 copy_if_diff($_, "$installlib/$name") 912 and chmod($name =~ /\.(so|$dlext)$/o ? 0555 : 0444, 913 "$installlib/$name"); 914 } 915 } else { 916 if (copy_if_diff($_, "$installlib/$name")) { 917 if ($name =~ /\.(so|$dlext)$/o) { 918 strip("-S", "$installlib/$name") if $^O =~ /^(rhapsody|darwin)$/; 919 chmod(0555, "$installlib/$name"); 920 } else { 921 strip("-S", "$installlib/$name") 922 if ($name =~ /\.a$/o and $^O =~ /^(rhapsody|darwin)$/); 923 chmod(0444, "$installlib/$name"); 924 } 925 } 926 } #if ($Is_NetWare) 927 } 928 } 929} 930 931# Copy $from to $to, only if $from is different than $to. 932# Also preserve modification times for .a libraries. 933# On some systems, if you do 934# ranlib libperl.a 935# cp libperl.a /usr/local/lib/perl5/archlib/CORE/libperl.a 936# and then try to link against the installed libperl.a, you might 937# get an error message to the effect that the symbol table is older 938# than the library. 939# Return true if copying occurred. 940 941sub copy_if_diff { 942 my($from,$to)=@_; 943 return 1 if (($^O eq 'VMS') && (-d $from)); 944 my $xto = $to; 945 $xto =~ s/^\Q$destdir\E// if $destdir; 946 my $perlpodbadsymlink; 947 if ($from =~ m!^pod/perl[\w-]+\.pod$! && 948 -l $from && 949 ! -e $from) { 950 # Some Linux implementations have problems traversing over 951 # multiple symlinks (when going over NFS?) and fail to read 952 # the symlink target. Combine this with the fact that some 953 # of the pod files (the perl$OS.pod) are symlinks (to ../README.$OS), 954 # and you end up with those pods not getting installed. 955 $perlpodbadsymlink = 1; 956 } 957 -f $from || $perlpodbadsymlink || warn "$0: $from not found"; 958 $packlist->{$xto} = { type => 'file' }; 959 if ($force || compare($from, $to) || $nonono) { 960 safe_unlink($to); # In case we don't have write permissions. 961 if ($nonono) { 962 $from = $depth . "/" . $from if $depth; 963 } 964 if ($perlpodbadsymlink && $from =~ m!^pod/perl(.+)\.pod$!) { 965 $from = "README.$1"; 966 } 967 copy($from, $to); 968 # Restore timestamps if it's a .a library or for OS/2. 969 if (!$nonono && ($Is_OS2 || $to =~ /\.a$/)) { 970 my ($atime, $mtime) = (stat $from)[8,9]; 971 utime $atime, $mtime, $to; 972 } 973 1; 974 } 975} 976 977sub strip 978{ 979 my(@args) = @_; 980 981 return unless $dostrip; 982 983 my @opts; 984 while (@args && $args[0] =~ /^(-\w+)$/) { 985 push @opts, shift @args; 986 } 987 988 foreach my $file (@args) { 989 if (-f $file) { 990 if ($verbose) { 991 print " strip " . join(' ', @opts); 992 print " " if (@opts); 993 print "$file\n"; 994 } 995 system("strip", @opts, $file); 996 } else { 997 print "# file '$file' skipped\n" if $verbose; 998 } 999 } 1000} 1001