CPANPLUS-Dist-Fedora
view release on metacpan or search on metacpan
lib/CPANPLUS/Dist/Fedora.pm view on Meta::CPAN
# Figure out if we're noarch or not
$status->is_noarch(do { first { /\.(c|xs)$/i } @files } ? 0 : 1);
my $rpmname = _mk_pkg_name($distname);
$status->rpmname( $rpmname );
# check whether package has been build.
if ( my $pkg = $self->_has_been_built($rpmname, $status->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::mdv 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.
$status->specpath("$dir/$rpmname.spec");
# Prepare our template
my $tmpl = Template->new({ EVAL_PERL => 1 });
my $spec_template = $self->_get_spec_template();
# Process template into spec
$tmpl->process(
\$spec_template,
{
status => $status,
module => $module,
buildreqs => $buildreqs,
date => strftime("%a %b %d %Y", localtime),
packager => $self->_get_packager(),
docfiles => join(' ', @docfiles),
rpm_req => sub {
my $br = shift;
return (($br eq 'perl') ? $br : "perl($br)");
},
packagervers => $VERSION,
# s/DISTEXTRA/join( "\n", @{ $status->extra_files || [] })/e;
# ... FIXME
},
$status->specpath,
);
if ( $intern->_callbacks->munge_dist_metafile ) {
print 'munging...';
my $orig_contents = _read_file( $status->specpath );
my $new_contents = $intern->_callbacks->munge_dist_metafile->($intern, $orig_contents);
_write_file( $status->specpath, $new_contents );
}
# copy package.
my $tarball = "$dir/" . basename $module->status->fetch;
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" );
return $status->dist;
}
msg( '--force in use, re-building anyway' );
}
RPMBUILD: {
# dry-run with makemaker: handle prereqs.
msg( 'dry-run build with makemaker...' );
$self->SUPER::create( %args );
my $spec = $status->specpath;
my $distname = $status->distname;
my $rpmname = $status->rpmname;
msg( "Building '$distname' from specfile $spec..." );
# dry-run, to see if we forgot some files
my ($buffer, $success);
my $dir = $status->rpmdir;
DRYRUN: {
local $ENV{LC_ALL} = 'C';
$success = run(
#command => "rpmbuild -ba --quiet $spec",
command =>
'rpmbuild -ba '
( run in 0.619 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )