clusterssh/bin_PL/_build_docs

48 lines
1.1 KiB
Text
Raw Normal View History

#!/usr/bin/env perl
use 5.008.004;
use strict;
use warnings;
use FindBin qw($Bin $Script);
use File::Basename;
2024-10-17 21:12:23 +01:00
my $bindir = "bin";
2024-10-17 21:12:23 +01:00
if ( !-d $bindir ) {
mkdir $bindir || die "Could not mkdir $bindir: $!";
}
2024-10-17 21:12:23 +01:00
print "Using perl binary: $^X", $/;
print "Using perl version $^V", $/;
2015-11-28 12:45:59 +00:00
for my $dest (@ARGV) {
2024-10-17 21:12:23 +01:00
my $source = $Bin . '/' . basename($dest);
2024-10-17 21:12:23 +01:00
next if ( $source =~ m/$Script/ );
next if ( $source =~ m/\.x$/ );
2024-10-17 21:12:23 +01:00
print "Generating: $source", $/;
2024-10-17 21:12:23 +01:00
if ( -f $dest ) {
chmod( 0755, $dest ) || die "Could not chmod $dest for removing: $!";
}
2024-10-17 21:12:23 +01:00
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);
2024-10-17 21:12:23 +01:00
if ( $source !~ m/clusterssh_bash_completion.dist/ ) {
print $dfh "\n\n__END__\n\n";
2024-10-17 21:12:23 +01:00
my $pod = qx{ $^X $source --generate-pod };
die "Failed to generate pod" if ($?);
print $dfh $pod;
}
close($dfh);
2024-10-17 21:12:23 +01:00
chmod( 0555, $dest ) || die "Could not chmod $dest: $!";
}