3 # Initialisation code and subroutines shared between installperl and installman
4 # Probably installhtml needs to join the club.
7 use vars qw($Is_VMS $Is_W32 $Is_OS2 $Is_Cygwin $Is_Darwin $Is_NetWare $Is_AmigaOS
9 use subs qw(unlink link chmod);
15 if ($Config::Config{userelocatableinc}) {
16 # This might be a considered a hack. Need to get information about the
17 # configuration from Config.pm *before* Config.pm expands any .../
20 # So we set $^X to pretend that we're the already installed perl, so
21 # Config.pm does its ... expansion off that location.
23 my $location = $Config::Config{initialinstalllocation};
24 die <<'OS' unless defined $location;
25 $Config{initialinstalllocation} is not defined - can't install a relocatable
28 $^X = "$location/perl";
29 # And then remove all trace of ever having loaded Config.pm, so that
30 # it will reload with the revised $^X
32 delete $INC{"Config.pm"};
33 delete $INC{"Config_heavy.pl"};
34 delete $INC{"Config_git.pl"};
35 # You never saw us. We weren't here.
42 if ($Config{d_umask}) {
43 umask(022); # umasks like 077 aren't that useful for installations
46 $Is_VMS = $^O eq 'VMS';
47 $Is_W32 = $^O eq 'MSWin32';
48 $Is_OS2 = $^O eq 'os2';
49 $Is_Cygwin = $^O eq 'cygwin';
50 $Is_Darwin = $^O eq 'darwin';
51 $Is_NetWare = $Config{osname} eq 'NetWare';
52 $Is_AmigaOS = $^O eq 'amigaos';
58 return scalar(@names) if $Is_VMS;
60 foreach my $name (@names) {
62 chmod 0777, $name if ($Is_OS2 || $Is_W32 || $Is_Cygwin || $Is_NetWare || $Is_AmigaOS);
63 print " unlink $name\n" if $opts{verbose};
64 ( CORE::unlink($name) and ++$cnt
65 or warn "Couldn't unlink $name: $!\n" ) unless $opts{notify};
75 $xfrom =~ s/^\Q$opts{destdir}\E// if $opts{destdir};
77 $xto =~ s/^\Q$opts{destdir}\E// if $opts{destdir};
78 print $opts{verbose} ? " ln $xfrom $xto\n" : " $xto\n"
80 my $link = $Is_AmigaOS ? \&CORE::symlink : \&CORE::link;
84 : ($from =~ m#^/afs/# || $to =~ m#^/afs/#)
85 ? die "AFS" # okay inside eval {}
86 : die "Couldn't link $from to $to: $!\n"
88 $packlist->{$xto} = { from => $xfrom, type => 'link' };
91 warn "Replacing link() with File::Copy::copy(): $@";
92 print $opts{verbose} ? " cp $from $xto\n" : " $xto\n"
94 print " creating new version of $xto\n"
95 if $Is_VMS and -e $to and !$opts{silent};
96 unless ($opts{notify} or File::Copy::copy($from, $to) and ++$success) {
97 # Might have been that F::C::c can't overwrite the target
98 warn "Couldn't copy $from to $to: $!\n"
99 unless -f $to and (chmod(0666, $to), unlink $to)
100 and File::Copy::copy($from, $to) and ++$success;
102 $packlist->{$xto} = { type => 'file' };
108 my($mode,$name) = @_;
110 return if ($^O eq 'dos');
111 printf " chmod %o %s\n", $mode, $name if $opts{verbose};
112 CORE::chmod($mode,$name)
113 || warn sprintf("Couldn't chmod %o %s: $!\n", $mode, $name)
114 unless $opts{notify};
120 return (lc($p1) eq lc($p2)) if ($Is_W32 || $Is_NetWare);
125 my ($dev1, $ino1) = stat $p1;
127 unless defined $dev1;
128 my ($dev2, $ino2) = stat $p2;
130 return $dev1 == $dev2 && $ino1 == $ino2;
135 if (-f $to and not unlink($to)) {
137 for ($i = 1; $i < 50; $i++) {
138 last if rename($to, "$to.$i");
140 warn("Cannot rename to '$to.$i': $!"), return 0
141 if $i >= 50; # Give up!
143 link($from,$to) || return 0;
148 File::Path::mkpath(shift , $opts{verbose}, 0777) unless $opts{notify};
153 my $unixpath = shift;
155 my @parts = split("/",$unixpath);
157 $isdir = 1 if substr($unixpath,-1) eq "/";
164 for($i = 0; $i <= $#parts;$i++)
166 next if $parts[$i] eq ".";
167 if($parts[$i] eq "..")
175 $amigapath .= $parts[$i + 1] . ":";
180 $amigapath .= $parts[$i];
183 $amigapath .= "/" unless $parts[$i] eq "/" ;
189 $amigapath .= "/" unless $parts[$i] eq "/" ;
199 my ($file,$bits) = @_;
200 print "PROTECT: File $file\n";
201 system("PROTECT $file $bits")
202 unless $opts{notify};