CPAN-RPM
view release on metacpan or search on metacpan
writefile($info->{spec}, $spec);
print("SPEC: $info->{spec}\n");
exit if $info->{"spec-only"};
}
#
# build the package
#
sub mk_rpm {
my $info = shift || $_; local $_;
if (-d $info->{dist}) {
# only include make-maker args if it wasn't auto-generated by cpan2rpm
# we should include make-maker args if it's given on the command line. example:
# --make-maker="--incpath='-I/tmp/lcb/include' --libpath='-L/tmp/lcb/lib'"
my $args = "";
$args = $info->{'make-maker'} if $info->{'make-maker'} !~ /%\{__perl\}/;
system("perl Makefile.PL $args && make") == 0 || die "mk_rpm(): $!"
unless ($info->{name} eq "cpan2rpm");
system("make dist") == 0 || die "mk_rpm('make dist'): $!";
cp($info->{tarball}, $RPMDIR{SOURCES})
|| die "mk_rpm(): cp [$info->{tarball}] - $!"
;
}
$info->{rpm} = sprintf("%s/%s-%s-%s.%s.rpm"
, "$RPMDIR{RPMS}/$info->{buildarch}"
, $info->{name}
, $info->{version}
, $info->{release}
, $info->{buildarch}
);
$info->{srpm} = sprintf("%s/%s-%s-%s.src.rpm"
, $RPMDIR{SRPMS}
, $info->{name}
, $info->{version}
, $info->{release}
);
my $ret = 0;
if (! -r $info->{rpm} || $info->{force}) {
print "Generating package\n";
my $bp = qx/$RPM -bp $info->{spec} 2>&1/;
warn("RPM test unpacking failed! [$RPM -bp $info->{spec}]\n$bp")
if $ret = $? >> 8;
if ($ret == 0) {
my @cmd = ($RPM, '-ba');
push @cmd, "--clean" unless $info->{"no-clean"};
push @cmd, $info->{spec};
debug(join " ", @cmd);
system(@cmd);
die "RPM build (@cmd) failed [$ret]" if $ret = $? >> 8;
if ($info->{sign} && -r $info->{rpm}) {
print "\n\nSigning package (passphrase required) ...\n\n";
sleep 2;
system "rpmsign", "--addsign", $info->{rpm};
}
}
}
print "RPM: $info->{rpm}\n" if -r $info->{rpm};
print "SRPM: $info->{srpm}\n" if -r $info->{srpm};
return $ret;
}
#
# if requested, will also install the resulting RPM
#
sub inst_rpm {
my $info = shift || $_; local $_;
return unless $info->{install};
print "Installing package\n";
my @cmd = (qw/rpm -Uvh/, $info->{rpm});
unshift @cmd, "sudo" if $<;
system(@cmd);
return $? >> 8;
}
# --- module retrieval functions ----------------------------------------------
sub get_cpan_api {
my $info = shift;
local $_ = http_get("$LATEST_MOD/$info->{dist}");
if (m{download_url.*?((\w)/(\2\w)/(\3\w*)/[\w\-\.\:\+]+)}) {
$info->{f} = "$CPAN_BASE/authors/id/$1";
$info->{version} = $1 if /"version"\s*:\s*"?([\d\.\_\-]+)"?/;
if (/"distribution"\s*:\s*"([\w\-\.\:\+]+)"/) {
my $base = $1;
$base =~ s/\-+/::/g;
$info->{dist} = $base;
}
return $info->{tarball} = write_url($RPMDIR{SOURCES}, $info->{f});
}
die "Unable to locate module $info->{dist}\n";
}
sub get_cpan_reg {
my $info = shift;
my $reg_file = $DETAILS_FILE =~ m{([^/]+)$} ? "$RPMDIR{SOURCES}/$1" : die "Module list stank";
my $reg_url = "$CPAN_BASE/$DETAILS_FILE";
if (!-s $reg_file or $info->{force}) {
print "Downloading registered module details with wget...\n";
system wget => -N => -P => $RPMDIR{SOURCES} => $reg_url;
}
if (!-s $reg_file) {
print "Downloading registered module details without preserving timestamp...\n";
write_url($RPMDIR{SOURCES}, $reg_url);
}
if (!-s $reg_file || !-r $reg_file) {
die "Unable to read module details: $reg_url\n";
}
open my $fh, "-|", gzip => -dc => $reg_file;
( run in 1.322 second using v1.01-cache-2.11-cpan-71847e10f99 )