Alien-Build-Plugin-Fetch-Rewrite

 view release on metacpan or  search on metacpan

lib/Alien/Build/Plugin/Fetch/Rewrite.pm  view on Meta::CPAN

      if("$copy" ne "$orig")
      {
        $build->log("rewriting $orig as $copy");
        $url = "$copy";
      }
    }

    return $f->($build, $url);
  });
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Alien::Build::Plugin::Fetch::Rewrite - Alien::Build plugin to rewrite network requests to local resources

=head1 VERSION

version 0.03

=head1 SYNOPSIS

In your ~/.alienbuild/rc.pl:

 postload 'Fetch::Rewrite';
 
 sub rewrite {
   my($build, $uri) = @_;
 
   # $build isa Alien::Build
   # $uri isa URI
 
   if($uri->host eq 'ftp.gnu.org')
   {
     # if we see a request to ftp.gnu.org (either ftp or http)
     # we redirect it to the local mirror at
     # http://mirror.example.com/ftp.gnu.org
     $uri->scheme('http');
     $uri->host('mirror.example.com');
     $uri->host('/ftp.gnu.org' . $uri->path);
   }
 }
 
 1;

=head1 DESCRIPTION

This plugin allows you to rewrite the URLs for remote networked resources
to local resources.  This is useful if you are building CPAN modules that
rely on L<Alien> distributions where you do not have system packages.  It
may also seem useful if you do not trust the remote resources, although
please keep in mind that like a C<Makefile.PL> or C<Build.PL>, an L<alienfile>
is arbitrary Perl code, and should be appropriately vetted before being
used in an environment with security requirements.

=head1 CAVEATS

This plugin is only able to rewrite URLs that are fetched through the standard
L<Alien::Build> URL fetching interface, and only URLs that are supported by
L<LWP::UserAgent> and L<URI>.

=head1 SEE ALSO

=over 4

=item L<Alien::Build>

=back

=head1 AUTHOR

Graham Ollis <plicease@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2017-2022 by Graham Ollis.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut



( run in 2.663 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )