CPANPLUS-Dist-Mageia
view release on metacpan or search on metacpan
lib/CPANPLUS/Dist/Mageia.pm view on Meta::CPAN
# * https://rt.cpan.org/Ticket/Display.html?id=86240
# * https://wiki.mageia.org/en/Perl_policy
push @reqs, 'Module::Build';
$distbuild = "%{__perl} Build.PL --installdirs=vendor\n";
$distmaker = "./Build";
$distinstall = "./Build install --destdir=%{buildroot}";
}
my $distbreqs = join "\n", map { "BuildRequires: perl($_)" }
grep { $_ ne "perl" } @reqs;
my @docfiles =
uniq
grep {
( /^[A-Z.]+$/ && !/^MANIFEST/ ) ||
m{^(Change(s|log)|META.(json|yml)|(ex|s)amples?|e[gx]|demos?)$}i
}
map { basename $_ }
grep { m!^[^/]+/[^/]+$! } # only interested in root files
@{ $module->status->files };
my $distarch =
defined( first { /\.(c|xs)$/i } @{ $module->status->files } )
? 'BuildRequires: perl-devel'
: 'BuildArch: noarch';
my $rpmname = _mk_pkg_name($distname);
$status->rpmname( $rpmname );
# check whether package has been build.
if ( my $pkg = $self->_has_been_build($rpmname, $distvers) ) {
my $modname = $module->module;
msg( "already created package for '$modname' at '$pkg'" );
if ( not $opts{force} ) {
msg( "won't re-spec package since --force isn't in use" );
# c::d::mga store
$status->rpmpath($pkg); # store the path of rpm
# cpanplus api
$status->prepared(1);
$status->created(1);
$status->dist($pkg);
return $pkg;
# XXX check if it works
}
msg( '--force in use, re-specing anyway' );
# FIXME: bump rpm version
} else {
msg( "writing specfile for '$distname'..." );
}
# compute & store path of specfile.
my $spec = "$RPMDIR{spec}/$rpmname.spec";
$status->specpath($spec);
my $vers = $module->version;
# writing the spec file.
my $tmpl = _template_spec_file_path();
open my $tmplfh, '<', $tmpl or die "can't open '$tmpl': $!";
POSIX::setlocale(&POSIX::LC_ALL, 'C');
my $specfh;
if ( not open $specfh, '>', $spec ) {
error( "can't open '$spec': $!" );
return;
}
while ( defined( my $line = <$tmplfh> ) ) {
last if $line =~ /^__END__$/;
$line =~ s/DISTNAME/$distname/;
$line =~ s/DISTVERS/$distvers/g;
$line =~ s/DISTSUMMARY/$distsummary/;
$line =~ s/DISTEXTENSION/$distext/;
$line =~ s/DISTBUILDBUILDER/$distbuild/;
$line =~ s/DISTINSTALL/$distinstall/;
$line =~ s/DISTARCH/$distarch/;
$line =~ s/DISTMAKER/$distmaker/;
$line =~ s/DISTBUILDREQUIRES/$distbreqs/;
$line =~ s/DISTDESCR/$distdescr/;
$line =~ s/DISTDOC/@docfiles ? "%doc @docfiles" : ''/e;
$line =~ s/DISTTOPLEVEL/$disttoplevel/;
$line =~ s/DISTEXTRA/join( "\n", @{ $status->extra_files || [] })/e;
$line =~ s/DISTDATE/POSIX::strftime("%a %b %d %Y", localtime())/e;
print $specfh $line;
}
close $specfh;
# copy package.
my $basename = basename $module->status->fetch;
my $tarball = "$RPMDIR{source}/$basename";
copy( $module->status->fetch, $tarball );
msg( "specfile for '$distname' written" );
# return success
$status->prepared(1);
return 1;
}
sub create {
my ($self, %args) = @_;
my $status = $self->status; # private hash
my $module = $self->parent; # CPANPLUS::Module
my $intern = $module->parent; # CPANPLUS::Internals
my $conf = $intern->configure_object; # CPANPLUS::Configure
my $distmm = $module->status->dist_cpan; # CPANPLUS::Dist::MM
# parse args.
my %opts = (
force => $conf->get_conf('force'), # force rebuild
perl => $^X,
verbose => $conf->get_conf('verbose'),
%args,
);
# check if we need to rebuild package.
if ( $status->created && defined $status->dist ) {
if ( not $opts{force} ) {
msg( "won't re-build package since --force isn't in use" );
( run in 0.907 second using v1.01-cache-2.11-cpan-ceb78f64989 )