RPM4

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

t/03rpmlib.t
t/04spec.t
t/05transaction.t
t/06sign.t
t/07dep.t
t/07files.t
t/07changelogs.t
t/09hdlist.t
t/11media.t
t/gnupg/passphrase
t/gnupg/pubring.gpg
t/gnupg/secring.gpg
t/gnupg/trustdb.gpg
t/gnupg/test-key.gpg
bin/hrpmreb
bin/rpm_produced
bin/rpmresign
examples/hdinfo
examples/hdlistq
examples/hdrpmq
examples/specwillbuild
examples/hdlist2sdb
examples/hrpmreb-macros
META.yml                                 Module YAML meta-data (added by MakeMaker)

bin/hrpmreb  view on Meta::CPAN


my %status = (
    srpmdone => 0,
    srpmfailure => 0,
    srpmtotal => 0,
    steptime => time,
    currentsrpms => 'Preparing build',
    currentstep => '',
);
    
my $passphrase = RPM4::expand('%{?gpgpass}');

my @srcdir = split(':', RPM4::expand('%{?srcdir}'));
print RPM4::expand("Source dir: %{?srcdir}%{?!srcdir:(none)}\n") if ($batch);

!@srcdir && $batch and die "No src dir, please define \%srcdir\n";

my @bindir = split(':', RPM4::expand('%{?bindir}'));
if (RPM4::expandnumeric('%checkbinary')) {
    if (@bindir) {
        print RPM4::expand("Using binary dir: %{?bindir}%{?!bindir:(none)}\n");

bin/rpmresign  view on Meta::CPAN

=item B<--help>

Print help

=item B<--passwordfile>

Read passphrase from this file

=item B<--name>

Use this name as gpg identity

=item B<--macros>

Load this macros file before processing

=item B<--define>

Define a rpm macro. This option is similar to --define of rpm.

=item B<--path>

Set gpghome to this directory

=item B<-f>

Fastmode: don't check rpm md5sum signatures before processing

=back

=cut

foreach (@defines) {

lib/RPM4.pm  view on Meta::CPAN

    dumprc(*STDOUT);

=head2 dumpmacros(*FILE)

Dump rpm macros into file handle.
Ex:
    dumpmacros(*STDOUT);

=head2 rpmresign($passphrase, $rpmfile)

Resign a rpm using user settings. C<$passphrase> is the key's gpg/pgp
pass phrase.

Return 0 on success.
    
=head2 rpmvercmp(version1, version2)

Compare two version and return 1 if left argument is highter, -1 if
rigth argument is highter, 0 if equal.
Ex:
    rpmvercmp("1.1mdk", "2.1mdk"); # return -1.

lib/RPM4/Sign.pm  view on Meta::CPAN

    chomp($self->{passphrase});
    close($hpass);
    1;
}

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

    defined($self->{_signature}) and RPM4::add_macro("_signature $self->{_signature}");

    foreach my $macro (qw(_gpg_name _pgp_name)) {
        RPM4::add_macro("$macro $self->{name}") if (defined($self->{name}));
    }
    
    foreach my $macro (qw(_gpg_path _pgp_path)) {
        RPM4::add_macro("$macro $self->{path}") if (defined($self->{path}));
    }
}

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

    if (defined($self->{_signature})) { RPM4::del_macro('_signature'); }
    
    if (defined($self->{name})) {
        RPM4::del_macro('_gpg_name');
        RPM4::del_macro('_pgp_name');
    }

    if (defined($self->{path})) {
        RPM4::del_macro('_gpg_path');
        RPM4::del_macro('_pgp_path');
    }
}

sub getpubkey {
    my ($self) = @_;
    $self->adjustmacro();
    my $gpgcmd;
    if (RPM4::expand("%_signature") eq "gpg") {
        $gpgcmd = '%__gpg --homedir %_gpg_path --list-public-keys --with-colons \'%_gpg_name\'';
    }
    open(my $hgpg, RPM4::expand($gpgcmd) .'|') or return undef;
    while (my $l = <$hgpg>) {
        chomp($l);
        my @v = split(':', $l);
        if ($v[0] eq 'pub') {
           $self->{keyid} = $v[4];
           last;
        }
    }
    close($hgpg);
    $self->restoremacro();
}

sub rpmsign {
    my ($self, $rpm, $header) = @_;
    my $need = 1;

    $header or return -1;
    
    if (RPM4::expand("_signature") || "" eq "gpg") {
        my $sigid = $header->queryformat("%{SIGGPG:pgpsig}");
        ($sigid) = $sigid =~ m/Key ID (\S+)/;
        if ($sigid && lc($sigid) eq lc($self->{keyid} || "")) { $need = 0 }
    }
    
    if ($need > 0) {
        $self->adjustmacro();
        rpmresign($self->{passphrase}, $rpm) and $need = -1;
        $self->restoremacro();
    }

lib/RPM4/Sign.pm  view on Meta::CPAN

=head1 NAME

RPM4::Sign

=head1 SYNOPSIS

A container to massively resign packages

=head1 DESCRIPTION

This object retains gpg options and provides functions to easilly sign or
resign packages. It does not resign packages having already the proper
signature.

=head1 METHODS

=head2 new(%options)

Create a new RPM4::Sign object.

Options are:

=over 4

=item name

The gpg key identity to use

=item path

the gpg homedir where keys are located

=item password_file

Use passphrase contains in this files

=item passphrase

Use this passphrase to unlock the key

=item checkrpms

lib/RPM4/Spec.pm  view on Meta::CPAN

Create a C<RPM4::Spec> instance, only the file values is mandatory.

=over 4

=item file

The spec file from wich to create the object

=item passphrase

If specified, the passphrase will be used for gpg signing after build.

=item rootdir

If specified, root dir will be use root instead '/'.

=item cookies

the cookies is string rpm will put into RPMCOOKIES tag, a way to know if a rpm
has been built from a specific src. You get this value from L<installsrpm>.

t/04spec.t  view on Meta::CPAN

plan tests => $plan;

my %info = RPM4::moduleinfo();

my $testdir = tempdir(CLEANUP => 1);
mkdir("$testdir/$_") foreach qw(BUILD RPMS RPMS/noarch SRPMS);

RPM4::add_macro("_tmppath $testdir");
RPM4::add_macro("_builddir $testdir");
RPM4::add_macro("_topdir $testdir");
RPM4::add_macro("_signature gpg");
RPM4::add_macro("_gpg_name RPM4 test key");
RPM4::add_macro("_gpg_path $Bin/gnupg");

if (!$skip_freebsd9_3) {
ok((RPM4::installsrpm("$Bin/test-rpm-1.0-1mdk.src.rpm"))[0] =~ m/test-rpm\.spec$/, "installsrpms works");
like(RPM4::installsrpm("$Bin/test-rpm-1.0-1mdk.src.rpm"), '/test-rpm\.spec$/', "installsrpms works");
ok(!RPM4::installsrpm("$Bin/test-rpm-1.0-1mdk.noarch.rpm"), "installsrpms works");
}

my $spec;
if ($info{Hack} eq "Yes") {
    ok(defined(RPM4::Spec->new), "Create an empty spec object");

t/05transaction.t  view on Meta::CPAN

RPM4::add_macro("_dbpath $testdir");

ok(RPM4::rpmdbinit == 0 || -f "$testdir/Packages", "initdb works");
ok(RPM4::rpmdbrebuild == 0, "rebuild database");
ok(RPM4::rpmdbverify == 0, "Verify empty");

my $ts;
ok($ts = RPM4::Transaction->new, "Create a new transaction");
ok($ts->traverse(sub { print STDERR $_[0]->tag(1000) . "\n" }) != -1, "ts->traverse");

ok($ts->importpubkey("$Bin/gnupg/test-key.gpg") == 0, "Importing a public key");

my $hd = RPM4::rpm2header("$Bin/test-dep-1.0-1mdk.noarch.rpm");
ok($hd, "Reading the header works");

ok($ts->transadd($hd, "$Bin/test-dep-1.0-1mdk.noarch.rpm") == 0, "Adding a package to transaction works");
ok($ts->transcheck == 0, "Checking transaction works");
ok($ts->transorder == 0, "Run transaction order");

process_problems();

t/06sign.t  view on Meta::CPAN

}

my $passphrase = "RPM4";

my $testdir = tempdir(CLEANUP => 1);

RPM4::add_macro("_dbpath $testdir");

copy("$Bin/test-rpm-1.0-1mdk.noarch.rpm", $testdir);

RPM4::add_macro("_signature gpg");
RPM4::add_macro("_gpg_name RPM4 test key");
RPM4::add_macro("_gpg_path $Bin/gnupg");

#ok(RPM4::rpmresign($passphrase, "$testdir/test-rpm-1.0-1mdk.noarch.rpm") == 0, "can resign a rpm");

ok(my $db = RPM4::newdb(1), "Open a new database");

#ok($db->checkrpm("$testdir/test-rpm-1.0-1mdk.noarch.rpm") != 0, "checking a rpm, key is missing");
ok($db->checkrpm("$testdir/test-rpm-1.0-1mdk.noarch.rpm", [ "NOSIGNATURES" ]) == 0, "checking a rpm, no checking the key");

ok($db->importpubkey("$Bin/gnupg/test-key.gpg") == 0, "Importing a public key");

ok($db->checkrpm("$testdir/test-rpm-1.0-1mdk.noarch.rpm") == 0, "checking a rpm file");

$db = undef;



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