From: Galen Charlton Date: Tue, 18 Dec 2007 21:11:28 +0000 (-0600) Subject: installer: deal with permissions in fix-perl-path.PL X-Git-Tag: v3.00.00-alpha~383^2~1 X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=5b98031b6089ca98cf8ebd2552b66ad9efb34908;hp=06fb84f56632e976b1a97a98413c4064af935c0e;p=koha.git installer: deal with permissions in fix-perl-path.PL Files in blib generally are a-w on Unix platforms. Modified fix-perl-path.PL to temporarily set them o+w while file is being checked. --- diff --git a/fix-perl-path.PL b/fix-perl-path.PL index aa37161ce4..07bff66a37 100644 --- a/fix-perl-path.PL +++ b/fix-perl-path.PL @@ -71,6 +71,16 @@ sub fixshebang{ my @filearray; my $pathfile =$dir . '/' . $file; warn "Found a perl script named $pathfile\n" if $DEBUG; + + # At this point, file is in 'blib' and by default + # has mode a-w. Therefore, must change permission + # to make it writable. + my $old_perm; + if ($^O ne 'MSWin32') { + $old_perm = (stat $pathfile)[2] & 07777; + my $new_perm = $old_perm | 0200; + chmod $new_perm, $pathfile; + } tie @filearray, 'Tie::File', $pathfile or die $!; warn "First line of $file is $filearray[0]\n\n" if $DEBUG; if ( ( $filearray[0] =~ /#!.*perl/ ) && ( $filearray[0] !~ /$shebang|"$shebang -w"/ ) ) { @@ -78,19 +88,17 @@ sub fixshebang{ warn "\tOriginal shebang line: $filearray[0]\n" if $DEBUG; $filearray[0] =~ /-w$/ ? $filearray[0] = "$shebang -w" : $filearray[0] = $shebang; warn "\tNew shebang line is: $filearray[0]\n\n" if $DEBUG; - untie @filearray; - next; } elsif ( $filearray[0] =~ /$shebang|"$shebang -w"/ ) { warn "\n\tShebang line is correct.\n\n" if $DEBUG; - untie @filearray; - next; } else { warn "\n\tNo shebang line found in $pathfile\n\n" if $DEBUG; - untie @filearray; - next; } + untie @filearray; + if ($^O ne 'MSWin32') { + chmod $old_perm, $pathfile; + } } # handle directories elsif ( -d ($dir . '/' . $file) && $file !~ /^\.{1,2}/ ) {