Skip to content

Commit 6554584

Browse files
author
Chris White
committed
Pack succesfully on 5.10.1
Pass @inc as PERL5LIB to the inner perl invocation in App::FatPacker::trace(). For some reason my 5.26.1 installation didn't require that, but my 5.10.1 installation does.
1 parent c066688 commit 6554584

File tree

3 files changed

+90
-45
lines changed

3 files changed

+90
-45
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ inc/
5151

5252
# Capture::Tiny
5353
DEBUG*
54+
55+
# App::FatPacker
56+
*.trace

pack.PL

Lines changed: 87 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
use strict;
66
use warnings;
7+
use 5.010001;
8+
9+
exit main();
710

811
#############################
912
# Custom packer that will only pack Text::PerlPP and Getopt::Long.
@@ -16,72 +19,112 @@ use warnings;
1619

1720
use parent 'App::FatPacker';
1821

22+
#sub trace {
23+
# my $self = shift;
24+
# say STDERR "Entering trace(); \@INC contains:\n", join("\n", @INC);
25+
# $self->SUPER::trace(@_);
26+
#}
27+
1928
sub collect_files {
2029
my ($self, $dir, $files) = @_;
2130

2231
my %innerfiles;
2332
$self->SUPER::collect_files($dir, \%innerfiles);
2433
my @filenames = grep { m{Text/PerlPP} || m{Getopt/Long} } keys %innerfiles;
2534
@{$files}{@filenames} = @innerfiles{@filenames};
26-
}
35+
} #MyPacker::collect_files()
2736

2837
#############################
29-
# Main routine
3038

3139
package main;
3240

33-
my $packer = MyPacker->new;
34-
my $packed;
41+
sub update_environment {
42+
# Make sure PERL5LIB has everything in @INC - somehow the lib directory
43+
# is getting lost on perl 5.10.1 (perlbrew, cygwin x86).
44+
#say STDERR "\@INC contains:\n", join("\n", @INC);
45+
#say STDERR "PERL5LIB is ", $ENV{PERL5LIB} // "<<undef>>";
46+
47+
my $path_sep;
48+
my $separ = qx{$^X -V:path_sep};
49+
$separ =~ s/^\$?/\$/;
50+
eval $separ; # updates $path_sep
51+
52+
my $paths = join($path_sep, @INC);
53+
unless($ENV{PERL5LIB}) {
54+
$ENV{PERL5LIB} = $paths;
55+
} else {
56+
$ENV{PERL5LIB} =~ s/$path_sep?$/$path_sep$paths/;
57+
}
58+
#say STDERR "PERL5LIB is now $ENV{PERL5LIB}";
59+
} #update_environment()
60+
61+
#############################
62+
# Main routine
3563

36-
do {
37-
open my $savedstdout, '>&', STDOUT or die $!; # save stdout
38-
close STDOUT;
64+
sub main {
65+
update_environment;
3966

40-
open STDOUT, '>>', \$packed; # capture packed text on stdout
41-
$packer->script_command_pack(['bin/perlpp']);
42-
close STDOUT;
67+
my $packer = MyPacker->new;
68+
my $packed;
4369

44-
open STDOUT, '>&', $savedstdout; # restore stdout
45-
};
70+
say STDERR "Packing...";
71+
do {
72+
open my $savedstdout, '>&', STDOUT or die $!; # save stdout
73+
close STDOUT;
4674

47-
# Clean up, and move the Text::PerlPP pod where pod2usage can find it
75+
open STDOUT, '>>', \$packed; # capture packed text on stdout
76+
$packer->script_command_pack(['bin/perlpp']);
77+
close STDOUT;
4878

49-
my @lines; # For the source
50-
my @podlines; # For the POD we're going to move
79+
open STDOUT, '>&', $savedstdout; # restore stdout
80+
};
81+
say STDERR "...done";
5182

52-
my ($in_getopt, $in_text, $in_doc);
53-
open my $iter, '<', \$packed;
83+
# Clean up, and move the Text::PerlPP pod where pod2usage can find it
5484

55-
while(<$iter>) {
56-
chomp;
57-
s/\s+$//;
85+
my @lines; # For the source
86+
my @podlines; # For the POD we're going to move
5887

59-
$in_getopt = m{fatpacked\S+Getopt/Long} .. m{^GETOPT_LONG};
60-
$in_text = m{fatpacked\S+Text/PerlPP} .. m{^TEXT_PERLPP};
61-
$in_doc = /^ =head1 NAME/ .. /^ =cut/;
62-
# have to test indentation level because the POD for Getopt::Long
63-
# includes a quoted POD sample
88+
my ($in_getopt, $in_text, $in_doc);
6489

65-
#print STDERR "$in_getopt\t$in_text\t$in_doc\t$_\n";
90+
say STDERR "Cleanup...";
91+
open my $iter, '<', \$packed;
6692

67-
next if $in_getopt && $in_doc; # no POD for Getopt::Long
68-
if($in_text && $in_doc && ($in_text !~ /E0$/)) {
69-
s/^ //;
70-
push @podlines, $_;
71-
} else {
72-
push @lines, $_ if $_;
93+
while(<$iter>) {
94+
chomp;
95+
s/\s+$//;
96+
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/;
100+
# have to test indentation level because the POD for Getopt::Long
101+
# includes a quoted POD sample
102+
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+
}
73112
}
74-
}
75-
close $iter;
76-
undef $packed;
77-
78-
# Output in the appropriate order
79-
open my $fh, '>', 'blib/perlpp';
80-
print $fh "$_\n" for @lines;
81-
print $fh "__END__\n=pod\n\n";
82-
print $fh "$_\n" for @podlines;
83-
close $fh;
84-
85-
print STDERR "Done packing\n";
113+
close $iter;
114+
undef $packed;
115+
say STDERR "...done";
116+
117+
# Output in the appropriate order
118+
say STDERR "Generating blib/perlpp...";
119+
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+
close $fh;
124+
125+
print STDERR "Done packing\n";
126+
127+
return 0;
128+
} #main()
86129

87130
# vi: set ts=4 sts=4 sw=4 et ai: #

t/06-macro.t

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use strict;
44
use warnings;
55
use Test::More 'no_plan';
66
use IPC::Run3;
7-
use Text::PerlPP;
87
use constant CMD => ($ENV{PERLPP_CMD} || 'perl -Iblib/lib blib/script/perlpp');
98

109
(my $whereami = __FILE__) =~ s/06-macro\.t$//;

0 commit comments

Comments
 (0)