1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#!/usr/bin/perl
use 5.008.004;
use strict;
use warnings;
use FindBin qw($Bin $Script);
use File::Basename;
my $bindir = "bin";
if ( !-d $bindir ) {
mkdir $bindir || die "Could not mkdir $bindir: $!";
}
print "Using perl binary: $^X", $/;
print "Using perl version $^V", $/;
for my $dest (@ARGV) {
my $source = $Bin . '/' . basename($dest);
next if ( $source =~ m/$Script/ );
next if ( $source =~ m/\.x$/ );
print "Generating: $source", $/;
if ( -f $dest ) {
chmod( 0755, $dest ) || die "Could not chmod $dest for removing: $!";
}
open( my $sfh, '<', $source )
|| die "Could not open $source for reading: $!";
open( my $dfh, '>', $dest ) || die "Could not open $dest for writing: $!";
print $dfh $_ while (<$sfh>);
close($sfh);
if ( $source !~ m/clusterssh_bash_completion.dist/ ) {
print $dfh "\n\n__END__\n\n";
my $pod = qx{ $^X $source --generate-pod };
die "Failed to generate pod" if ($?);
print $dfh $pod;
}
close($dfh);
chmod( 0555, $dest ) || die "Could not chmod $dest: $!";
}
|