App-CPANtoRPM

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

        be used which will replace an existing package, even if the same
        version is already installed.

    -y/--yum DIR
        If this option is given, the RPMs (both binary and source) will be
        copied to a local yum repository once they are built.

  Misc Options
    The following misc. options are also available:

    --gpg-path PATH
    --gpg-name NAME
        These options are used to set the path the the GPG directory (which
        contains the keyring) and the name of the key that will be used.

    --gpg-password PASSWORD
    --gpg-passfile FILE
        When signing a package, this script become interactive unless expect
        (or perl Expect) is available. If one of these is available, the
        password can be passed in at the command line (or a file containing
        the password) using one of these two commands.

    --env VAR=VAL
        Sets an environment variable before building the package. This
        option can be used any number of times.

OBTAIN THE PERL MODULE

README  view on Meta::CPAN

    RPM tool 'rpmbuild'.

    It uses the standard RPM file structure and creates both a source RPM
    and a binary RPM.

SIGN THE RPM PACKAGES
    This is an optional step. If can be used to embed a GPG signature in the
    package.

    In order sign a package, you must have a GPG key available. You must
    have the gpg package installed on your system and you must have at least
    one GPG key created.

    The path to the GPG directory be specified by one of the following:

       the value of the --gpg-path option

       the value of the %_gpg_path rpm macro

       the value determined by gpg using any currently
       set environment variables

    If no keyring is found, signing is not available.

    The key to use is specified by:

       the value of the --gpg-name option

       the value of the %_gpg_name rpm macro

       the only key in the keyring (if the keyring
       contains exactly one key)

    If the key cannot be uniquely determined, signing is not available.

    The rpm command to sign a package is interactive. In order to script
    everything, it is necessary to use a tool like expect. If such a tool is
    not available, and if you are signing packages, this script will be
    interactive. Currently, if the expect program is installed or the perl
    Expect module is available, signing can be done non-interactively if
    either the --gpg-passwd or --gpg-passfile options are passed in.

INSTALL THE RPM
    This is an optional step.

    After the RPM is successfully built, it can be installed on the system.
    This will be done in one of two ways. If you are running this as root,
    it will simply use the rpm command. Otherwise, it will use sudo to run
    the rpm command.

STORE THE RPM IN A LOCAL YUM REPOSITORY

README  view on Meta::CPAN

    In order to build the rpm, you need the rpmbuild program.

    This script also relies on the strace program. This is necessary because
    many Makefile.PL and Build.PL scripts are interactive so when you run
    them, they hang waiting for input. Unfortunately, I was not able to find
    any pure perl way to run a program as a child (or in a thread) and
    monitor it to see if it's still running because it's doing work, or
    still running because it's waiting on user input. Though somewhat crude,
    strace can be used to determine that.

    In order to sign packages, you must have the gpg program installed, and
    you must have a key set up to sign with. In order to do this
    non-interactively, you also need either the Expect module or the expect
    program installed.

    In order to install the package, you either must be running as root, or
    have the sudo program. The sudo command may be interactive, depending on
    how you have it set up.

    In order to install RPMs in a yum repository, the repository must exist.

bin/cpantorpm.pod  view on Meta::CPAN

copied to a local yum repository once they are built.

=back

=head2 Misc Options

The following misc. options are also available:

=over 4

=item B<--gpg-path PATH>

=item B<--gpg-name NAME>

These options are used to set the path the the GPG directory (which
contains the keyring) and the name of the key that will be used.

=item B<--gpg-password PASSWORD>

=item B<--gpg-passfile FILE>

When signing a package, this script become interactive unless B<expect>
(or perl B<Expect>) is available.  If one of these is available, the
password can be passed in at the command line (or a file containing the
password) using one of these two commands.

=item B<--env VAR=VAL>

Sets an environment variable before building the package.  This option
can be used any number of times.

bin/cpantorpm.pod  view on Meta::CPAN


It uses the standard RPM file structure and creates both a source RPM
and a binary RPM.

=head1 SIGN THE RPM PACKAGES

This is an optional step.  If can be used to embed a GPG signature in
the package.

In order sign a package, you must have a GPG key available.  You must
have the gpg package installed on your system and you must have at least
one GPG key created.

The path to the GPG directory be specified by one of the following:

   the value of the --gpg-path option

   the value of the %_gpg_path rpm macro

   the value determined by gpg using any currently
   set environment variables

If no keyring is found, signing is not available.

The key to use is specified by:

   the value of the --gpg-name option

   the value of the %_gpg_name rpm macro

   the only key in the keyring (if the keyring
   contains exactly one key)

If the key cannot be uniquely determined, signing is not available.

The rpm command to sign a package is interactive.  In order to script
everything, it is necessary to use a tool like expect.  If such a tool
is not available, and if you are signing packages, this script will be
interactive.  Currently, if the B<expect> program is installed or the
perl B<Expect> module is available, signing can be done non-interactively
if either the --gpg-passwd or --gpg-passfile options are passed in.

=head1 INSTALL THE RPM

This is an optional step.

After the RPM is successfully built, it can be installed on the system.
This will be done in one of two ways.  If you are running this as root,
it will simply use the rpm command.  Otherwise, it will use B<sudo> to
run the rpm command.

bin/cpantorpm.pod  view on Meta::CPAN

In order to build the rpm, you need the B<rpmbuild> program.

This script also relies on the B<strace> program.  This is necessary
because many Makefile.PL and Build.PL scripts are interactive so when
you run them, they hang waiting for input.  Unfortunately, I was not
able to find any pure perl way to run a program as a child (or in a
thread) and monitor it to see if it's still running because it's doing
work, or still running because it's waiting on user input.  Though
somewhat crude, B<strace> can be used to determine that.

In order to sign packages, you must have the B<gpg> program installed,
and you must have a key set up to sign with.  In order to do this
non-interactively, you also need either the B<Expect> module or the
B<expect> program installed.

In order to install the package, you either must be running as root, or
have the B<sudo> program.  The B<sudo> command may be interactive,
depending on how you have it set up.

In order to install RPMs in a yum repository, the repository must exist.

lib/App/CPANtoRPM.pm  view on Meta::CPAN

               'config_input' => [],
               'cpan'         => 'cpanplus',
               'cwd'          => '',
               'debug'        => 0,
               'description'  => '',
               'disttag'      => '%{?dist}',
               'env'          => {},
               'epoch'        => '',
               'extracted'    => '',
               'file_path'    => '',
               'gpg_name'     => '',
               'gpg_passfile' => '',
               'gpg_passwd'   => '',
               'gpg_path'     => '',
               'group'        => 'Development/Libraries',
               'inst_base'    => '',
               'inst_type'    => '',
               'install'      => '',
               'macros'       => 0,
               'mainpod'      => '',
               'mandir'       => '',
               'name'         => '',
               'no_clean'     => 0,
               'no_deps'      => 0,

lib/App/CPANtoRPM.pm  view on Meta::CPAN

                         it will install a new RPM, or upgrade an
                         existing one if the version changed).
      --install-new    : This will install the RPM if it is new, but
                         will not upgrade an existing version.
      --install-force  : This will install the RPM even if it already
                         is installed.
      -y/--yum DIR     : Copy the RPM to a local yum repository

   Misc. options:

      --gpg-path PATH  : The path to the GPG directory containing
                         the keyring.
      --gpg-name NAME  : The name of the user who's key should be
                         used to sign the package.
      --gpg-passwd PASSWORD
                       : The passphrase for the GPG key.
      --gpg-passfile FILE
                       : A file containing the passphrase for the GPG key.
      --env VAR=VAL    : Sets an environment variable before building
                         the package.  This option can be used any number
                         of times.

This takes a perl modules and creates an RPM version of it.

";
}

lib/App/CPANtoRPM.pm  view on Meta::CPAN

                                                         $_ eq '--macros');
      $$self{'spec_only'} = 1,                 next  if ($_ eq '--spec-only');
      $$self{'inst_type'} = shift(@a),         next  if ($_ eq '-T'  ||
                                                         $_ eq '--install-type');
      $$self{'inst_base'} = shift(@a),         next  if ($_ eq '-i'  ||
                                                         $_ eq '--install-base');
      $$self{'mandir'} = shift(@a),            next  if ($_ eq '--mandir');
      $$self{'no_clean'} = 1,                  next  if ($_ eq '--no-clean');
      $$self{'sign'} = 1,                      next  if ($_ eq '-s'  ||
                                                         $_ eq '--sign');
      $$self{'gpg_path'} = shift(@a),          next  if ($_ eq '--gpg-path');
      $$self{'gpg_name'} = shift(@a),          next  if ($_ eq '--gpg-name');
      $$self{'gpg_passwd'} = shift(@a),        next  if ($_ eq '--gpg-passwd');
      $$self{'gpg_passfile'} = shift(@a),      next  if ($_ eq '--gpg-passfile');
      $$self{'install'} = 'upg',               next  if ($_ eq '-I'  ||
                                                         $_ eq '--install');
      $$self{'install'} = 'new',               next  if ($_ eq '--install-new');
      $$self{'install'} = 'force',             next  if ($_ eq '--install-force');
      $$self{'yum'} = shift(@a),               next  if ($_ eq '-y'  ||
                                                         $_ eq '--yum');
      $$self{'script'} = shift(@a),            next  if ($_ eq '--script');
      $$self{'script_dir'} = shift(@a),        next  if ($_ eq '--script-dir');
      $$self{'patch'} = shift(@a),             next  if ($_ eq '--patch');
      $$self{'patch_dir'} = shift(@a),         next  if ($_ eq '--patch-dir');

lib/App/CPANtoRPM.pm  view on Meta::CPAN

###############################################################################

# This will sign a newly created RPM.  It may use the perl expect module,
# the expect executable, or it can do it interactively.

sub _sign_rpm {
   my($self) = @_;

   $self->_log_message('HEAD',"Signing RPM: $package{name}");

   my $gpg = $self->_find_exe('gpg');
   if (! $gpg) {
      $self->_log_message('ERR',"gpg program not found in path.");
   }

   #
   # First, let's get the value of the GPG path
   #

   my $path  = '';    # The gpg option to set the path to use (if not the default)
   my $macro = '';    # The value of the rpm macro.

   $macro    = `rpm --eval '%_gpg_path'`;
   chomp($macro);
   $macro    = ''  if ($macro eq '%_gpg_path');

   if ($$self{'gpg_path'}) {

      if (! -d $$self{'gpg_path'}) {
         $self->_log_message('ERR',
                             "GPG directory does not exist: $$self{gpg_path}");
      }

      if ($macro) {

         if ($$self{'gpg_path'} ne $macro) {
            # We're overriding a value set in the rpm macro file.

            $self->_log_message('WARN',
                        '--gpg-path option overriding value in RPM macro file',
                        "   --gpg-path = $$self{gpg_path}",
                        "   \%_gpg_path = $macro");
            $path = "--homedir $$self{'gpg_path'}";

            # We have to add it to the macros file.  We'll just tack
            # it on the end since this will effectively override the
            # value there.

            my $macros = "$ENV{HOME}/.rpmmacros";
            $$self->_add_macro($macros,'%_gpg_path',$$self{'gpg_path'});
         }
      }

   } elsif ($macro) {

      if (! -d $macro) {
         $self->_log_message('ERR',
                             "GPG directory from rpmmacros does not exist: $macro");
      }

   }

   $self->_log_message('INFO',"GPG path = $path");

   #
   # Next, let's get the value of the GPG user.
   #

   my $name  = '';   # The gpg option to set the user to use.
   $macro    = '';   # The value of the rpm macro.

   $macro    = `rpm --eval '%_gpg_name'`;
   chomp($macro);
   $macro    = ''  if ($macro eq '%_gpg_name');

   if ($$self{'gpg_name'}) {

      if ($macro) {

         if ($$self{'gpg_name'} ne $macro) {
            # We're overriding a value set in the rpm macro file.

            $self->_log_message('WARN',
                        '--gpg-name option overriding value in RPM macro file',
                        "   --gpg-name = $$self{gpg_name}",
                        "   \%_gpg_name = $macro");
            $name = "'$$self{'gpg_name'}'";

            # We have to add it to the macros file.  We'll just tack
            # it on the end since this will effectively override the
            # value there.

            my $macros = "$ENV{HOME}/.rpmmacros";
            $$self->_add_macro($macros,'%_gpg_name',$$self{'gpg_name'});
         }
      }
   }

   $name = "'$macro'"  if ($macro  &&  ! $name);

   $self->_log_message('INFO',"GPG name = $name");

   #
   # Now let's make sure that we actually have exactly one key.
   #

   my @out = `$gpg $path --list-keys $name | grep '^uid'`;
   if (! @out) {
      $self->_log_message('ERR',
                          'No keys found in this GPG keyring.',
                          'Use --gpg-path to specify an alternate GPG path',
                          'or create a key in this keyring.');
   }
   if (@out != 1) {
      $self->_log_message('ERR',
                          'Multiple keys found in this keyring',
                          'Use --gpg-user to specify a single user.');
   }

   #
   # Sign it.
   #

   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;
         }

lib/App/CPANtoRPM.pm  view on Meta::CPAN

      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

lib/App/CPANtoRPM.pm  view on Meta::CPAN

}

{
   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; } ],



( run in 0.921 second using v1.01-cache-2.11-cpan-df04353d9ac )