CPAN-Packager
view release on metacpan or search on metacpan
lib/CPAN/Packager/Builder/RPM/Spec.pm view on Meta::CPAN
my $create = $options{create} || '';
my $email = $options{email} || $defaults{'email'};
my $requires = $options{requires} || [];
my $buildrequires = $options{buildrequires} || [];
my $outdir = $options{outdir} || $defaults{'outdir'};
my $tmpdir = $options{tmpdir} || $defaults{'tmpdir'};
my $noarch = $options{noarch} || '';
my $plat_perl_reqs = $options{'noperlreqs'} ? 0 : 1;
my $release = $options{'release'} || $defaults{'release'};
my $build_switch = 's';
my $use_module_build = 0;
my @docs = ();
$tmpdir = tempdir( CLEANUP => 1, DIR => $tmpdir );
#
# Set build arch - this is needed to find out where
# the binary rpm was placed, and copy it back to the
# current working directory.
my $build_arch;
if ( $options{'arch'} ) {
$build_arch = $options{'arch'};
}
elsif ( $options{'noarch'} ) {
$build_arch = 'noarch';
}
else {
$build_arch = get_default_build_arch();
if ( $build_arch eq '' ) {
print STDERR "Could not get default build arch!\n";
exit(1);
}
}
$build_switch = 'a' if ( defined( $options{'buildall'} ) );
$tarball =~ /^(.+)\-([^-]+)\.t(ar\.)?gz$/;
my $name = $options{name} || $1;
my $ver = $options{version} || $2;
my $tarball_top_dir = "$name-%{version}";
die "Module name/version not parsable from $tarball"
unless $name and $ver;
$name =~ s/::/-/g;
copy( $fullname, $tmpdir )
or die "copy $fullname: $!";
utime( ( stat($fullname) )[ 8, 9 ], "$tmpdir/$tarball" );
if ( my @files = Archive::Tar->list_archive("$tmpdir/$tarball") ) {
$use_module_build = 1 if grep {/Build\.PL$/} @files;
if ( not exists $options{noarch} ) {
$noarch = 1;
$noarch = 0 if grep {/\.(xs|c|cc|C)$/} @files;
}
my %prefixes;
foreach (@files) {
my @path_components = split m[/], $_;
$prefixes{ $path_components[0] }++;
if ( $path_components[-1] eq 'META.yml' ) {
my $tar = new Archive::Tar;
$tar->read( "$tmpdir/$tarball", 1 );
my $contents = $tar->get_content($_);
my $yaml;
eval { $yaml = Load($contents); };
unless ($@) {
while ( my ( $mod, $ver )
= each %{ $yaml->{build_requires} } )
{
push @build_requires, [ "perl($mod)", $ver ];
}
while ( my ( $mod, $ver ) = each %{ $yaml->{requires} } )
{
push @requires, [ "perl($mod)", $ver ];
}
}
}
# find docs
if (m,^${name}-${ver}/(
authors?|
change(log|s)|
credits|
copy(ing|right)|
licen[cs]e|
readme|
todo
)$,ix
)
{
push( @docs, $1 );
}
}
if ( scalar keys %prefixes == 1 ) {
($tarball_top_dir) = keys %prefixes;
$tarball_top_dir =~ s/$ver/%{version}/;
}
}
#
# Get patches copied into place
my $patchfile = '';
my @patchfiles = ();
my $patch = '';
if ( $options{patch} ) {
for $patch ( @{ $options{'patch'} } ) { ## no critic
copy( $patch, $tmpdir ) or die "copy ${patch}: $!";
utime(
( stat( $options{patch} ) )[ 8, 9 ],
"$tmpdir/" . basename( $options{patch} )
);
push @patchfiles, ( basename($patch) );
}
}
( run in 0.723 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )