1 package Object::Remote::FatNode;
9 $text =~ /^(\s+)/ && $text =~ s/^$1//mg;
13 my %maybe_libs = map +($_ => 1), grep defined, (values %Config, '.');
15 my @extra_libs = grep not(ref($_) or $maybe_libs{$_}), @INC;
17 my $extra_libs = join '', map " -I$_\n", @extra_libs;
23 -mObject::Remote::Connector::STDIO
29 -mObject::Remote::ModuleLoader
30 -mObject::Remote::Node
31 -mMethod::Generate::BuildAll
32 -mMethod::Generate::DemolishAll
34 -e 'print join "\\n", \%INC'
39 chomp(my @inc = qx($command));
41 my %mods = reverse @inc;
43 #my @non_core = grep +(
45 # /^\Q$Config{privlibexp}/ or /^\Q$Config{archlibexp}/
49 my @non_core = keys %mods;
51 #my @core_non_arch = grep +(
52 # /^\Q$Config{privlibexp}/
53 #), grep !/\Q$Config{archname}/, grep !/\Q$Config{myarchname}/, keys %mods;
56 my $start = stripspace <<'END_START';
57 # This chunk of stuff was generated by Object::Remote::FatNode. To find
58 # the original file's code, look for the end of this BEGIN block or the
61 my (%fatpacked,%fatpacked_extra);
63 my $end = stripspace <<'END_END';
64 s/^ //mg for values %fatpacked, values %fatpacked_extra;
67 if ($_[1] eq 'XSLoader.pm') {
68 warn "XSLoader made it into the fat node";
72 if (my $fat = $_[0]->{$_[1]}) {
73 open my $fh, '<', \$fat;
77 #Uncomment this to find brokenness
78 #warn "Missing $_[1]";
82 unshift @INC, sub { load_from_hash(\%fatpacked, $_[1]) };
83 push @INC, sub { load_from_hash(\%fatpacked_extra, $_[1]) };
85 } # END OF FATPACK CODE
88 use Object::Remote::Node;
89 Object::Remote::Node->run;
92 my %files = map +($mods{$_} => scalar do { local (@ARGV, $/) = ($_); <> }),
93 @non_core, @core_non_arch;
95 sub generate_fatpack_hash {
96 my ($hash_name, $orig) = @_;
97 (my $stub = $orig) =~ s/\.pm$//;
98 my $name = uc join '_', split '/', $stub;
99 my $data = $files{$orig} or die $orig; $data =~ s/^/ /mg;
100 return '$'.$hash_name.'{'.perlstring($orig).qq!} = <<'${name}';\n!
101 .qq!${data}${name}\n!;
105 warn "Dumping list of shipped modules";
106 print STDERR "Core non-arch: ", Dumper(\@core_non_arch);
107 print STDERR "Non-core: ", Dumper(\@non_core);
110 map(generate_fatpack_hash('fatpacked', $_), sort map $mods{$_}, @non_core),
111 map(generate_fatpack_hash('fatpacked_extra', $_), sort map $mods{$_}, @core_non_arch),
114 our $DATA = join "\n", $start, @segments, $end;