From 5b98031b6089ca98cf8ebd2552b66ad9efb34908 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 18 Dec 2007 15:11:28 -0600 Subject: [PATCH] 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. --- fix-perl-path.PL | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) 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}/ ) { -- 2.20.1