App-MechaCPAN

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

  - Make the binary download feature not the default for the time being
  - Improve the binary download process not to throw an error when not found
  - Move --build-reusable to a global option --build-reusable-perl

0.29  2023-04-18 23:32:58 EDT
  - Add support to install from a cpanfile without using Deploy
  - Add feature to download prebuilt binries for popular linux distros
  - Improve SSL handling
  - Fix bug where install couldn't handle modules with names starting with git
  - Fix bug where install couldn't handle modules starting with git
  - Fix bug that prevented reusable perls from being threaded

0.28  2021-08-12 23:26:06 EDT
  - Include core dependencies, because RedHat. Fixes GH#20
  - Be more forgiving of the limitations of the underlying OS
  - Don't fail a test because the optional --jobs option because make doesn't
    understand -h. Fixes GH#19

0.27  2021-08-10 22:53:01 EDT
  - Add the option to build and install relocatable binary perl archives
  - Add the --jobs option and try to detect if make doesn't support it

README  view on Meta::CPAN

 --directory=<path>

    Changes to a specified directory before any processing is done. This
    allows you to specify what directory you want local/ to be in. If this
    isn't provided, the current working directory is used instead.

 --build-reusable-perl

    Giving this options will override the mode of operation and generate a
    reusable, relocatable perl archive. This accepts the same parameters as
    the Perl command (i.e. "devel" and "threads") to generate the binary.
    Note that the lib/ directory is always included unless the --skip-lib
    option is included. The archive name will generally reflect what
    systems the resuling archive can run on. Because of the nature of how
    perl builds binaries, it cannot guarantee that it will work on any
    given system. This option will have the best luck if you use it with
    the same version of a distribution.

    Once you have a reusable binary archive, App::MechaCPAN::Perl can use
    that archive as a source file and install the binaries into the local
    directory. This can be handy if you are building a lot of identical

README  view on Meta::CPAN


    The exact parameters included in the archive name are:

      * The version built

      * The architecture name, as found in the first piece of
      $Config{archname}

      * The Operating System, as found in $Config{osname}

      * Optionally notes if it was built with threads

      * The name of the libc used

      * The version of the libc used

      * The so version of libraries used, with common libaries being
      abbreviated

    An example archive name would be
    perl-v5.36.0-x86_64-linux-glibc-2.35-y1.1n2.0u1.tar.xz

lib/App/MechaCPAN.pm  view on Meta::CPAN

=head2 --no-log

A log is normally outputted into the C<local/logs> directory. This option will prevent a log from being created.

=head2 --directory=<path>

Changes to a specified directory before any processing is done. This allows you to specify what directory you want C<local/> to be in. If this isn't provided, the current working directory is used instead.

=head2 --build-reusable-perl

Giving this options will override the mode of operation and generate a reusable, relocatable L<perl> archive. This accepts the same parameters as the L<Perl|App::MechaCPAN::Perl> command (i.e. L</devel> and L</threads>) to generate the binary. Note t...

Once you have a reusable binary archive, L<App::MechaCPAN::Perl> can use that archive as a source file and install the binaries into the local directory. This can be handy if you are building a lot of identical systems and only want to build L<perl> ...

The exact parameters included in the archive name are:

=over

=item * The version built

=item * The architecture name, as found in the first piece of $Config{archname}

=item * The Operating System, as found in $Config{osname}

=item * Optionally notes if it was built with threads

=item * The name of the libc used

=item * The version of the libc used

=item * The C<so> version of libraries used, with common libaries being abbreviated

=back

An example archive name would be C<perl-v5.36.0-x86_64-linux-glibc-2.35-y1.1n2.0u1.tar.xz>

lib/App/MechaCPAN/Perl.pm  view on Meta::CPAN

package App::MechaCPAN::Perl;

use v5.14;
use autodie;
use Config;
use FindBin;
use File::Spec;
use App::MechaCPAN qw/:go/;

our @args = (
  'threads!',
  'jobs=i',
  'skip-tests!',
  'skip-local!',
  'skip-lib!',
  'smart-tests!',
  'devel!',
  'shared-lib!',
  'source-only!',
);

lib/App/MechaCPAN/Perl.pm  view on Meta::CPAN

sub _build_configure
{
  my $perl_dir = shift;
  my $opts     = shift;

  my @config = (
    q[-des],
    qq[-Dprefix=$perl_dir],
  );

  if ( $opts->{threads} )
  {
    push @config, '-Dusethreads';
  }

  if ( $opts->{'shared-lib'} )
  {
    push @config, '-Duseshrplib';
  }

  if ( $opts->{devel} )
  {
    push @config, '-Dusedevel';

lib/App/MechaCPAN/Perl.pm  view on Meta::CPAN

  # Give perl more time to be silent during the make process than normal
  local $App::MechaCPAN::TIMEOUT = $App::MechaCPAN::TIMEOUT * 10;

  run $make, @jobs_cmd, @cmd;
}

sub slugline
{
  my $perl        = shift || File::Spec->canonpath($^X);
  my $version     = shift || '';
  my $use_threads = shift;

  my $script = <<'EOD';
  use strict;
  use Config;
  use File::Basename qw/basename/;
  use ExtUtils::Liblist;

  my $version    = $ARGV[0] || $^V;
  my $usethreads = defined $ARGV[1] ? $ARGV[1] : 0;
  my $libcname   = 'unknown';
  my $libcver    = 'ukn';
  my $archname   = ( split '-', $Config{archname} )[0];
  my $osname     = $Config{osname};
  my $threads    = $usethreads ? 'threads-' : '';

  if ( $Config{gnulibc_version} )
  {
    $libcname = 'glibc';
    $libcver  = $Config{gnulibc_version};
  }
  else
  {
    my $libc_re         = qr/libc (\W|$)/xms;
    my ($libc_basename) = grep {m/$libc_re/} split( / /, $Config{libsfiles} );

lib/App/MechaCPAN/Perl.pm  view on Meta::CPAN


  # Add the name of each lib found with Liblist
  my @short_libs;
  my @libs;

  my %rename = (

    # c, m and dl are assumed to be part of libc, which we already handle
    '-lc'       => '', '-lm'  => '',
    '-ldl'      => '', '-lld' => '',
    '-lpthread' => '',

    # Commonly found libraries can be shortened
    '-lsocket' => 's',  '-linet'  => 'i',
    '-lnsl'    => 'n',  '-lcrypt' => 'y',
    '-lutil'   => 'u',  '-lposix' => 'p',
    '-lgdbm'   => 'gd', '-ldbm'   => 'd',
  );

  foreach my $libs ( sort split ' ', $Config{libs} )
  {

lib/App/MechaCPAN/Perl.pm  view on Meta::CPAN

      next;
    }
    push @libs, "$n$ver";
  }

  my $libsver = join('', @short_libs, @libs);
  if ($libsver)
  {
    $libsver = "-$libsver";
  }
  print "perl-$version-$archname-$osname-$threads$libcname-$libcver$libsver";
EOD

  my $script_file = humane_tmpfile;
  $script_file->print($script);
  $script_file->close;

  my $slugline = run(
    $perl,
    "$script_file",
    $version,
    ( defined $use_threads ? ($use_threads) : () )
  );
  chomp $slugline;

  return $slugline;
}

sub _check_perl_binary
{
  my $perl_bin = shift;

lib/App/MechaCPAN/Perl.pm  view on Meta::CPAN

    q[-Accflags=-DAPPLLIB_EXP=\"] . join( ":", @otherlib ) . q[\"],
    q{-Dstartperl='#!/usr/bin/env\ perl'},
    q{-Dperlpath='/usr/bin/env\ perl'},
    qq{-Dinstallprefix=/v$version},
    qq{-Dprefix=/v$version},
    q{-Dman1dir=.../../man/man1},
    q{-Dman3dir=.../../man/man3},
    q{-Duserelocatableinc},
  );

  if ( $opts->{threads} )
  {
    push @config, '-Dusethreads';
  }

  local %ENV = %ENV;
  delete @ENV{qw(PERL5LIB PERL5OPT)};
  $ENV{DESTDIR} = $perl_dir;

  # Make sure no tomfoolery is happening with perl, like plenv shims
  $ENV{PATH} = $Config{binexp} . ":$ENV{PATH}";

  eval {

lib/App/MechaCPAN/Perl.pm  view on Meta::CPAN


  # Verify that the relocatable bits worked
  local $@;
  eval { _check_perl_binary("$perl_dir/v$version/bin/perl") };
  my $error = $@;
  if ($error)
  {
    die "The built relocatable binary appears broken: $error\n";
  }

  my $slugline = slugline("$perl_dir/v$version/bin/perl", undef, $opts->{threads});
  my $orig_dir = &get_project_dir;
  my $output   = "$slugline.tar.$compress";
  chdir $perl_dir;
  run("tar cf - v$version/ | $compress > $orig_dir/$output");

  success $verstr, "Created $verstr: $output";

  return 0;
}

lib/App/MechaCPAN/Perl.pm  view on Meta::CPAN

  return "$source_mirror/perl-5.$version.$minor.tar.gz";
}

sub _bin_url
{
  my $version = shift;
  my $minor   = shift;
  my $opts    = shift;

  my $fullver  = "v5.$version.$minor";
  my $slugline = slugline( undef, $fullver, $opts->{threads} );

  return "$binary_mirror/$slugline.tar.xz";
}

sub _get_targz
{
  my $src  = shift;
  my $opts = shift;

  # If there's no src, find the newest version.

lib/App/MechaCPAN/Perl.pm  view on Meta::CPAN

In the cases where a version is given, and the C<--no-source-only> option is given, C<App::MechaCPAN::Perl> will attempt to download a binary archive prebuilt for the operating system. This guess is made by looking at how the currently executing L<pe...

After an archive is retrieved, it will be checked to see if it is a binary or source package. This is accomplished by checking for an executable C<bin/perl> file in the archive. Basic tests are ran to make sure the binary is usable, notably by runnin...

=head2 Arguments

=head3 source-only

By default a source archive is attempted to be retreived and installed. If you want it to attempt to also retrieve a binary archive, you can use C<--no-source-only>. If you do not want C<App::MechaCPAN::Perl> to even attempt to use a binary archive, ...

=head3 threads

By default, perl is compiled without threads. If you'd like to enable threads, use this argument.

=head3 shared-lib

By default, perl will not generate a libperl.a file.  If you need libperl.so, then use this argument.

=head3 jobs

How many make jobs to use when running make. The code will guess if C<make> supports running multiple jobs, and as such, it may not work for all versions of make. Defaults to 2.

=head3 skip-tests

t/14_perl_opts.t  view on Meta::CPAN

like( $config_items{applib}, qr[$lib],      'lib is being set after mkdir' );

is( App::MechaCPAN::main( perl => $fakeperl, '--skip-local' ), 0, 'Can install "perl" from a tar.gz' );
unlike( $config_items{applib}, qr[$locallib], 'local/lib is not being set' );
like( $config_items{applib}, qr[$lib], 'lib is being set' );

is( App::MechaCPAN::main( perl => $fakeperl, '--skip-lib' ), 0, 'Can install "perl" from a tar.gz' );
like( $config_items{applib}, qr[$locallib], 'local/lib is being set' );
unlike( $config_items{applib}, qr[$lib], 'lib is not being set' );

is( App::MechaCPAN::main( perl => $fakeperl, '--threads' ), 0, 'Can install "perl" from a tar.gz' );
isnt( $config_items{other}, undef, 'threads does something' );
is( $config_items{empty}, undef, 'Did not have too many config options' );

is( App::MechaCPAN::main( perl => $fakeperl, '--devel' ), 0, 'Can install "perl" from a tar.gz' );
isnt( $config_items{other}, undef, 'devel does something' );
is( $config_items{empty}, undef, 'Did not have too many config options' );

chdir $pwd;
done_testing;



( run in 1.367 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )