Skip to content

Commit 31744f0

Browse files
author
Chris White
committed
pack: fix shebang; leave POD in the right place
Also, put the dependencies in Makefile.PL in alphabetical order for easier reading if the list grows.
1 parent 6554584 commit 31744f0

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

Makefile.PL

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ WriteMakefile(
3131
'ExtUtils::MakeMaker' => '0',
3232
},
3333
BUILD_REQUIRES => {
34-
'Test::More' => '0',
3534
'App::FatPacker' => '0',
3635
'IPC::Run3' => '0',
36+
'Test::More' => '0',
3737
},
3838
PREREQ_PM => {
39-
'Pod::Usage' => '0',
4039
'Getopt::Long' => '2.50', # Per issue #17
40+
'Pod::Usage' => '0',
4141
},
4242
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
4343
clean => { FILES => 'Text-PerlPP-* fatlib' },

pack.PL

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ sub main {
6767
my $packer = MyPacker->new;
6868
my $packed;
6969

70+
# ------------------------------------------
7071
say STDERR "Packing...";
7172
do {
7273
open my $savedstdout, '>&', STDOUT or die $!; # save stdout
@@ -80,46 +81,46 @@ sub main {
8081
};
8182
say STDERR "...done";
8283

83-
# Clean up, and move the Text::PerlPP pod where pod2usage can find it
84+
# ------------------------------------------
85+
# Clean up the fatpacked output
8486

8587
my @lines; # For the source
86-
my @podlines; # For the POD we're going to move
8788

88-
my ($in_getopt, $in_text, $in_doc);
89+
my $in_doc;
8990

9091
say STDERR "Cleanup...";
9192
open my $iter, '<', \$packed;
9293

94+
# Force the shebang for convenience in distributing the packed version
95+
if(defined(my $line = <$iter>)) {
96+
chomp $line;
97+
$line =~ s{^#!.*$}{#!/usr/bin/env perl};
98+
push @lines, $line;
99+
}
100+
101+
# Strip fatpacked POD to save space.
93102
while(<$iter>) {
94103
chomp;
95104
s/\s+$//;
96105

97-
$in_getopt = m{fatpacked\S+Getopt/Long} .. m{^GETOPT_LONG};
98-
$in_text = m{fatpacked\S+Text/PerlPP} .. m{^TEXT_PERLPP};
99-
$in_doc = /^ =head1 NAME/ .. /^ =cut/;
106+
$in_doc = /^ (=pod|=head1 NAME)/ .. /^ =cut/;
100107
# have to test indentation level because the POD for Getopt::Long
101-
# includes a quoted POD sample
108+
# includes a quoted POD sample, which we don't want to detect,
109+
# and because the bin/perlpp POD we want to keep is not indented.
102110

103-
#print STDERR "$in_getopt\t$in_text\t$in_doc\t$_\n";
104-
105-
next if $in_getopt && $in_doc; # no POD for Getopt::Long
106-
if($in_text && $in_doc && ($in_text !~ /E0$/)) {
107-
s/^ //;
108-
push @podlines, $_;
109-
} else {
110-
push @lines, $_ if $_;
111-
}
111+
push @lines, $_ unless $in_doc; # no embedded POD
112112
}
113113
close $iter;
114114
undef $packed;
115115
say STDERR "...done";
116116

117-
# Output in the appropriate order
117+
# ------------------------------------------
118+
# Output in the appropriate order. This is a separate pass from the
119+
# cleanup for historical reasons.
120+
118121
say STDERR "Generating blib/perlpp...";
119122
open my $fh, '>', 'blib/perlpp';
120-
print $fh "$_\n" for @lines;
121-
print $fh "__END__\n=pod\n\n";
122-
print $fh "$_\n" for @podlines;
123+
say $fh $_ for @lines;
123124
close $fh;
124125

125126
print STDERR "Done packing\n";

0 commit comments

Comments
 (0)