App-CPANtoRPM
view release on metacpan or search on metacpan
lib/App/CPANtoRPM.pm view on Meta::CPAN
SIGN:
{
if ($$self{'gpg_passwd'} || $$self{'gpg_passfile'}) {
my $err = $self->_load_module("Expect");
if (! $err) {
$err = $self->_sign_perlexpect();
if ($err) {
$self->_log_message('ERR','PGP passphrase incorrect');
}
last SIGN;
}
my $expect = $self->_find_exe('expect');
if ($expect) {
$err = $self->_sign_expect($expect);
if ($err) {
$self->_log_message('ERR','PGP passphrase incorrect');
}
last SIGN;
}
}
$self->_sign_interactive();
last SIGN;
}
}
sub _sign_expect {
my($self,$expect) = @_;
$self->_log_message('INFO',"Signing with non-interactive expect script");
my $pass;
if ($$self{'gpg_passwd'}) {
$pass = $$self{'gpg_passwd'};
} else {
$pass = `cat $$self{'gpg_passfile'}`;
chomp($pass);
}
my $out = new IO::File;
my $file = "$TMPDIR/cpantorpm-expect-sign-wrapper";
$out->open("> $file");
print $out <<"EOF";
#!$expect
spawn rpm --addsign $package{rpmfile} $package{srpmfile}
expect -exact "Enter pass phrase: "
send -- "$pass\\r"
expect {
"Pass phrase check failed" { puts "Failed" }
eof { puts "Success" }
}
EOF
$out->close();
chmod 0755,$file;
open(IN,"'$file' |");
my @out = <IN>;
close(IN);
unlink $file;
if ( grep /Failed/,@out ) {
return 1;
}
return 0;
}
{
my $flag;
sub _sign_perlexpect {
my($self) = @_;
$self->_log_message('INFO',"Signing with non-interactive perl Expect script");
my $pass;
if ($$self{'gpg_passwd'}) {
$pass = $$self{'gpg_passwd'};
} else {
$pass = `cat $$self{'gpg_passfile'}`;
chomp($pass);
}
my $exp = Expect->spawn('rpm','--addsign',
$package{rpmfile},$package{srpmfile});
$exp->expect(undef, "Enter pass phrase:");
$exp->send("$pass\n");
$exp->expect(undef,
[ "Pass phrase check failed" => sub { $flag = 1; } ],
[ "eof" => sub { $flag = 0; } ],
);
return $flag;
}
}
sub _sign_interactive {
my($self) = @_;
$self->_log_message('INFO',"Signing with interactive rpm command");
my @cmd = ('rpm','--addsign', $package{rpmfile}, $package{srpmfile});
my $cmd = join(' ',@cmd);
$self->_log_message('INFO',"Attempting system command: $cmd");
system(@cmd);
}
# This adds a macro to the rpmmacro file in such a way that at the end, it
# will be restored.
#
sub _add_macro {
my($self,$file,$macro,$val) = @_;
if (! -f $file) {
lib/App/CPANtoRPM.pm view on Meta::CPAN
# ... lines B ...
# <endif:VAR> This will include the A set of lines if $package{VAR} is true
# and the B set of lines otherwise.
#
__DATA__
#
# This SPEC file was automatically generated using the cpantorpm
# script.
#
# Package: <rpmname>
# Version: <version>
# cpantorpm version: <VERSION>
# Date: <date>
# Command:
# <command> <args>
#
Name: <rpmname>
Version: <version>
Release: <release><disttag>
Epoch: <skip:epoch>
Summary: <summary>
License: <license>
Group: <group>
URL: <url>
BugURL: <url>
BuildArch: <arch>
Source0: <name>-%{version}.tar.gz
#
# Unfortunately, the automatic provides and requires do NOT always work (it
# was broken on the very first platform I worked on). We'll get the list
# of provides and requires manually (using the RPM tools if they work, or
# by parsing the files otherwise) and manually specify them in this SPEC file.
#
AutoReqProv: no
AutoReq: no
AutoProv: no
Provides: <hash:true:provides> = <val>
Provides: <hash:false:provides>
<if:incl_deps>
Requires: <hash:true:runtime_req> >= <val>
Requires: <hash:false:runtime_req>
BuildRequires: <hash:true:build_req> >= <val>
BuildRequires: <hash:false:build_req>
<if:incl_compat>
Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
<endif:incl_compat>
<endif:incl_deps>
%description
<desc>
%prep
rm -rf %{_builddir}/<name>-%{version}
%setup -D -n <name>-<version>
chmod -R u+w %{_builddir}/<name>-%{version}
if [ -f pm_to_blib ]; then rm -f pm_to_blib; fi
%build
<config_cmd>
<build_cmd>
<list:post_build>
<if:incl_tests>
#
# This is included here instead of in the 'check' section because
# older versions of rpmbuild (such as the one distributed with RHEL5)
# do not do 'check' by default.
#
if [ -z "$RPMBUILD_NOTESTS" ]; then
<test_cmd>
fi
<endif:incl_tests>
%install
rm -rf <_buildroot>
<install_cmd>
find <_buildroot> -type f -name .packlist -exec rm -f {} \;
find <_buildroot> -type f -name '*.bs' -size 0 -exec rm -f {} \;
find <_buildroot> -depth -type d -exec rmdir {} 2>/dev/null \;
%{_fixperms} <_buildroot>/*
%clean
rm -rf <_buildroot>
%files
%defattr(-,root,root,-)
<if:bin_inst>
<bin_dir>/*
<endif:bin_inst>
<if:lib_inst>
<lib_dir>/*
<endif:lib_inst>
<if:arch_inst>
<arch_dir>/*
<endif:arch_inst>
<if:man1_inst>
<man1_dir>/*
<endif:man1_inst>
<if:man3_inst>
<man3_dir>/*
<endif:man3_inst>
%changelog
* <date> <packager> <version>-<release>
- Generated using cpantorpm
<eof>
# Local Variables:
# mode: cperl
( run in 1.227 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )