1#!/perl -w 2use 5.010; 3use strict; 4use Config; 5 6# This test checks that anything with an executable bit is 7# identified in Porting/exec-bit.txt to makerel will set 8# the exe bit in the release tarball 9# and that anything with an executable bit also has a shebang 10 11sub has_shebang { 12 my $fname = shift; 13 open my $fh, '<', $fname or die "Can't open '$fname': $!"; 14 my $line = <$fh>; 15 close $fh; 16 17 return $line =~ /^\#!\s*([A-Za-z0-9_\-\/\.])+\s?/ ? 1 : 0; 18} 19 20require './test.pl'; 21if ( $^O eq "MSWin32" ) { 22 skip_all( "-x on MSWin32 only indicates file has executable suffix. Try Cygwin?" ); 23} 24 25if ( $^O eq "VMS" ) { 26 skip_all( "Filename case may not be preserved and other porting issues." ); 27} 28 29if ( $^O eq "vos" ) { 30 skip_all( "VOS combines the read and execute permission bits." ); 31} 32 33if ( $^O eq "openbsd" ) { 34 skip_all( "OpenBSD CVS src tree execute permission bits do not match Perl distribution." ); 35} 36 37if ( $Config{usecrosscompile} ) { 38 skip_all( "Not all files are available during cross-compilation" ); 39} 40 41plan('no_plan'); 42 43use ExtUtils::Manifest qw(maniread); 44 45# Copied from Porting/makerel - these will get +x in the tarball 46# XXX refactor? -- dagolden, 2010-07-23 47my %exe_list = 48 map { $_ => 1 } 49 map { my ($f) = split; glob("../$f") } 50 grep { $_ !~ /\A#/ && $_ !~ /\A\s*\z/ } 51 map { split "\n" } 52 do { local (@ARGV, $/) = '../Porting/exec-bit.txt'; <> }; 53 54# Get MANIFEST 55$ExtUtils::Manifest::Quiet = 1; 56my @manifest = sort keys %{ maniread("../MANIFEST") }; 57 58# Check that +x files in repo get +x from makerel 59for my $f ( map { "../$_" } @manifest ) { 60 next unless -x $f; 61 62 ok( has_shebang($f), "File $f has shebang" ); 63 64 ok( $exe_list{$f}, "tarball will chmod +x $f" ) 65 or diag( "Remove the exec bit or add '$f' to Porting/exec-bit.txt" ); 66 67 delete $exe_list{$f}; # seen it 68} 69 70ok( ! %exe_list, "Everything in Porting/exec-bit.txt has +x in repo" ) 71 or diag( "Files missing exec bit:\n " . join("\n ", sort keys %exe_list) . "\n"); 72