1#!./perl 2 3$mainperldir = "/usr/bin"; 4 5while (@ARGV) { 6 $nonono = 1 if $ARGV[0] eq '-n'; 7 $versiononly = 1 if $ARGV[0] eq '-v'; 8 shift; 9} 10 11umask 022; 12 13@scripts = ('cppstdin', 'h2ph', 'c2ph', 'pstruct', 'x2p/s2p', 'x2p/find2perl'); 14@manpages = ('perl.man', 'h2ph.man', 'x2p/a2p.man', 'x2p/s2p.man'); 15 16# Read in the config file. 17 18open(CONFIG, "config.sh") || die "You haven't run Configure yet!\n"; 19while (<CONFIG>) { 20 if (s/^(\w+=)/\$$1/) { 21 $accum =~ s/'undef'/undef/g; 22 eval $accum; 23 $accum = ''; 24 } 25 $accum .= $_; 26} 27close CONFIG; 28 29open(PERL_C, "perl.c"); 30while (<PERL_C>) { 31 last if /Revision:/; 32} 33close PERL_C; 34s/.*Revision: //; 35$major = $_ + 0; 36 37$ver = sprintf("%5.3f", $major + $PATCHLEVEL / 1000); 38$release = substr($ver,0,3); 39$patchlevel = substr($ver,3,2); 40 41# Do some quick sanity checks. 42 43if ($d_dosuid && $>) { die "You must run as root to install suidperl\n"; } 44 45 $installbin || die "No installbin directory in config.sh\n"; 46-d $installbin || die "$installbin is not a directory\n"; 47-w $installbin || die "$installbin is not writable by you\n" 48 unless $installbin =~ m#^/afs/#; 49 50-x 'perl' || die "perl isn't executable!\n"; 51-x 'taintperl' || die "taintperl isn't executable!\n"; 52-x 'suidperl' || die "suidperl isn't executable!\n" if $d_dosuid; 53 54-x 't/TEST' || warn "WARNING: You've never run 'make test'!!!", 55 " (Installing anyway.)\n"; 56 57# First we install the version-numbered executables. 58 59&unlink("$installbin/perl$ver"); 60&cmd("cp perl $installbin/perl$ver"); 61 62&unlink("$installbin/tperl$ver"); 63&cmd("cp taintperl $installbin/tperl$ver"); 64&chmod(0755, "$installbin/tperl$ver"); # force non-suid for security 65 66&unlink("$installbin/sperl$ver"); 67if ($d_dosuid) { 68 &cmd("cp suidperl $installbin/sperl$ver"); 69 &chmod(04711, "$installbin/sperl$ver"); 70} 71 72exit 0 if $versiononly; 73 74# Make links to ordinary names if installbin directory isn't current directory. 75 76($bdev,$bino) = stat($installbin); 77($ddev,$dino) = stat('.'); 78 79if ($bdev != $ddev || $bino != $dino) { 80 &unlink("$installbin/perl", "$installbin/taintperl", "$installbin/suidperl"); 81 &link("$installbin/perl$ver", "$installbin/perl"); 82 &link("$installbin/tperl$ver", "$installbin/taintperl"); 83 &link("$installbin/sperl$ver", "$installbin/suidperl") if $d_dosuid; 84} 85 86($bdev,$bino) = stat($installbin); 87($ddev,$dino) = stat('x2p'); 88 89if ($bdev != $ddev || $bino != $dino) { 90 &unlink("$installbin/a2p"); 91 &cmd("cp x2p/a2p $installbin/a2p"); 92 &chmod(0755, "$installbin/a2p"); 93} 94 95# Make some enemies in the name of standardization. :-) 96 97($udev,$uino) = stat($mainperldir); 98 99if (-w _ && ($udev != $bdev || $uino != $bino) && !$nonono) { 100 &unlink("$mainperldir/perl"); 101 eval 'link("$installbin/perl", "$mainperldir/perl")' || 102 eval 'symlink("$installbin/perl", "$mainperldir/perl")' || 103 &cmd("cp $installbin/perl $mainperldir"); 104} 105 106# Install scripts. 107 108&makedir($installscr); 109 110for (@scripts) { 111 &cmd("cp $_ $installscr"); 112 s#.*/##; &chmod(0755, "$installscr/$_"); 113} 114 115# BSD modification -- install them in makefile. 116 117# Install man pages. 118# 119#if ($mansrc ne '') { 120# &makedir($mansrc); 121# 122# ($mdev,$mino) = stat($mansrc); 123# if ($mdev != $ddev || $mino != $dino) { 124# for (@manpages) { 125# ($new = $_) =~ s/man$/$manext/; 126# $new =~ s#.*/##; 127# print STDERR " Installing $mansrc/$new\n"; 128# next if $nonono; 129# open(MI,$_) || warn "Can't open $_: $!\n"; 130# open(MO,">$mansrc/$new") || warn "Can't install $mansrc/$new: $!\n"; 131# print MO ".ds RP Release $release Patchlevel $patchlevel\n"; 132# while (<MI>) { 133# print MO; 134# } 135# close MI; 136# close MO; 137# } 138# } 139#} 140 141# Install library files. 142 143&makedir($installprivlib); 144if (chdir "lib") { 145 146 ($pdev,$pino) = stat($installprivlib); 147 ($ldev,$lino) = stat('.'); 148 149 if ($pdev != $ldev || $pino != $lino) { 150 foreach $file (<*.pl>) { 151 system "cmp", "-s", $file, "$privlib/$file"; 152 if ($?) { 153 &unlink("$installprivlib/$file"); 154 &cmd("cp $file $installprivlib"); 155 &chmod(0644, "$installprivlib/$file"); 156 } 157 } 158 } 159 chdir ".." || die "Can't cd back to source directory: $!\n"; 160} 161else { 162 warn "Can't cd to lib to install lib files: $!\n"; 163} 164 165&chmod(0755, "usub/mus"); 166 167print STDERR " Installation complete\n"; 168 169exit 0; 170 171############################################################################### 172 173sub unlink { 174 local(@names) = @_; 175 176 foreach $name (@names) { 177 next unless -e $name; 178 print STDERR " unlink $name\n"; 179 unlink($name) || warn "Couldn't unlink $name: $!\n" unless $nonono; 180 } 181} 182 183sub cmd { 184 local($cmd) = @_; 185 print STDERR " $cmd\n"; 186 unless ($nonono) { 187 system $cmd; 188 warn "Command failed!!!\n" if $?; 189 } 190} 191 192sub link { 193 local($from,$to) = @_; 194 195 print STDERR " ln $from $to\n"; 196 link($from,$to) || warn "Couldn't link $from to $to: $!\n" unless $nonono; 197} 198 199sub chmod { 200 local($mode,$name) = @_; 201 202 printf STDERR " chmod %o %s\n", $mode, $name; 203 chmod($mode,$name) || warn sprintf("Couldn't chmod %o %s: $!\n",$mode,$name) 204 unless $nonono; 205} 206 207sub makedir { 208 local($dir) = @_; 209 unless (-d $dir) { 210 local($shortdir) = $dir; 211 212 $shortdir =~ s#(.*)/.*#$1#; 213 &makedir($shortdir); 214 215 print STDERR " mkdir $dir\n"; 216 mkdir($dir, 0777) || warn "Couldn't create $dir: $!\n" unless $nonono; 217 } 218} 219