RPM4

 view release on metacpan or  search on metacpan

examples/hdlistq  view on Meta::CPAN

use Getopt::Long;

my $qf = "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n";
my $cond = undef;

my $go_res = GetOptions (
    "qf|queryformat=s" => \$qf,
    "c|cond=s" => \$cond,
    "qi" => sub {
        $qf = 
'Name        : %-27{NAME}  Relocations: %|PREFIXES?{[%{PREFIXES} ]}:{(not relocatable)}|
Version     : %-27{VERSION}       Vendor: %{VENDOR}
Release     : %-27{RELEASE}   Build Date: %{BUILDTIME:date}
Install Date: %|INSTALLTIME?{%-27{INSTALLTIME:date}}:{(not installed)         }|      Build Host: %{BUILDHOST}
Group       : %-27{GROUP}   Source RPM: %{SOURCERPM}
Size        : %-27{SIZE}%|LICENSE?{      License: %{LICENSE}}|
Signature   : %|DSAHEADER?{%{DSAHEADER:pgpsig}}:{%|RSAHEADER?{%{RSAHEADER:pgpsig}}:{%|SIGGPG?{%{SIGGPG:pgpsig}}:{%|SIGPGP?{%{SIGPGP:pgpsig}}:{(none)}|}|}|}|
%|PACKAGER?{Packager    : %{PACKAGER}\n}|%|URL?{URL         : %{URL}\n}|\Summary     : %{SUMMARY}
Description :\n%{DESCRIPTION}
';
    },

lib/RPM4.pm  view on Meta::CPAN

        };
        $p->{pb} eq "BADOS" and do {
            push @ret, N("package %s is intended for a different operating system", $p->{pkg});
            next;
        };
        $p->{pb} eq "PKG_INSTALLED" and do {
            push @ret, N("package %s is allready installed", $p->{pkg});
            next;
        };
        $p->{pb} eq "BADRELOCATE" and do {
            push @ret, N("path %s in package %s is not relocatable", $p->{path}, $p->{pkg});
            next;
        };
        $p->{pb} eq "NEW_FILE_CONFLICT" and do {
            push @ret, N("file %s conflicts between attempted installs of %s and %s", $p->{file}, $p->{pkg}, $p->{pkg2});
            next;
        };
        $p->{pb} eq "FILE_CONFLICT" and do {
            push @ret, N("file %s from install of %s conflicts with file from package %s", $p->{file}, $p->{pkg}, $p->{pkg2});
            next;
        };

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


Return 0 on success.

=head2 RPM4::Transaction->deleteheader($index)

Remove header from rpmdb locate at $index. This is not uninstalling a package,
this function only delete information from rpmdb.

Return 0 on success
    
=head2 RPM4::Transaction->transadd(header, filename, upgrade, relocation, force)

Add rpm headers for next transaction. This means this rpm are going to be
installed on the system.

- header is an Hdlist::Header object,

- filename, if given, is the rpm file you want to install, and should
of course match the header,

- upgrade is a boolean flag to indicate whether the rpm is going to be upgraded

src/RPM4.xs  view on Meta::CPAN

#endif

        }

void
Header_files(header, scaremem = O_SCAREMEM)
    Header header
    int scaremem
    PREINIT:
    rpmfi Files = NULL;
    rpmts ts = NULL;  /* NULL;  setting this to NULL skip path relocation
                       * maybe a good deal is Header::Files(header, Dep = NULL) */
    PPCODE:
#ifdef HDLISTDEBUG
    PRINTF_CALL;
#endif 
    Files = rpmfiNew(ts, header, RPMTAG_BASENAMES, scaremem);
    if (Files != NULL && (Files = rpmfiInit(Files, 0)) != NULL && rpmfiNext(Files) >= 0) {
        SPAGAIN;
        XPUSHs(sv_setref_pv(sv_newmortal(), bless_rpmfi, (void *)Files));
#ifdef HDRPMMEM

src/RPM4.xs  view on Meta::CPAN

    mi = rpmtsInitIterator(ts, RPMDBI_PACKAGES, &off, sizeof(off));
    if ((header = rpmdbNextIterator(mi)) != NULL) {
        mXPUSHs(sv_setref_pv(newSVpvs(""), bless_header, headerLink(header)));
#ifdef HDRPMMEM
        PRINTF_NEW(bless_header, header, header->nrefs);
#endif
    }
    rpmdbFreeIterator(mi);    

int
Ts_transadd(ts, header, key = NULL, upgrade = 1, sv_relocation = NULL, force = 0)
    rpmts ts
    Header header
    char * key
    int upgrade
    SV * sv_relocation
    int force
    PREINIT:
    rpmRelocation * relocations = NULL;
    HV * hv_relocation;
    HE * he_relocation;
    int i = 0;
    I32 len;
    
    CODE:

    if (key != NULL)
        key = strdup(key);

    /* Relocation settings */
    if (sv_relocation && SvOK(sv_relocation) && !force) {
/*        if (! (headerGetEntry(eiu->h, RPMTAG_PREFIXES, &pft,
                       (void **) &paths, &c) && (c == 1))) { */
        if (! headerIsEntry(header, RPMTAG_PREFIXES)) {
            rpmlog(RPMLOG_ERR,
                   _("package %s is not relocatable\n"), "");
            XPUSHi((IV)1);
            XSRETURN(1);
        }
        if (SvTYPE(sv_relocation) == SVt_PV) {
            /* String value, assume a prefix */
            relocations = malloc(2 * sizeof(*relocations));
            relocations[0].oldPath = NULL;
            relocations[0].newPath = SvPV_nolen(sv_relocation);
            relocations[1].oldPath = relocations[1].newPath = NULL;
        } else if (SvTYPE(SvRV(sv_relocation)) == SVt_PVHV) {
            hv_relocation = (HV*)SvRV(sv_relocation);
            hv_iterinit(hv_relocation);
            while ((he_relocation = hv_iternext(hv_relocation)) != NULL) {
                relocations = realloc(relocations, sizeof(*relocations) * (++i));
                relocations[i-1].oldPath = NULL;
                relocations[i-1].newPath = NULL;
                relocations[i-1].oldPath = hv_iterkey(he_relocation, &len);
                relocations[i-1].newPath = SvPV_nolen(hv_iterval(hv_relocation, he_relocation));
            }
            /* latest relocation is identify by NULL setting */
            relocations = realloc(relocations, sizeof(*relocations) * (++i));
            relocations[i-1].oldPath = relocations[i-1].newPath = NULL;
        } else {
            croak("latest argument is set but is not an array ref or a string");
        }
    }
    
    /* TODO fnpyKey: another value can be use... */
    RETVAL = rpmtsAddInstallElement(ts, header, (fnpyKey) key, upgrade, relocations);
    OUTPUT:
    RETVAL
        
int
Ts_transremove(ts, recOffset, header = NULL)
    rpmts ts
    int recOffset
    Header header
    PREINIT:
    rpmdbMatchIterator mi;

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

    }), "Running traverse");

ok($found == 0, "The previously removed rpm is not found");
};

ok($ts->transadd($h, "test-rpm-1.0-1mdk.noarch.rpm", 1, "/usr", 1) == 0, "Adding a package to transaction with prefix");
ok($ts->transorder == 0, "Run transaction order");
ok($ts->transcheck == 0, "Checking transaction works");
ok(!defined($ts->transreset), "Reseting current transaction");

ok($ts->transadd($h, "test-rpm-1.0-1mdk.noarch.rpm", 1, {"/etc" => "/usr" }, 1) == 0, "Adding a package to transaction with relocation works");
ok($ts->transorder == 0, "Run transaction order");
ok($ts->transcheck == 0, "Checking transaction works");
ok(!defined($ts->transreset), "Reseting current transaction");

{
my $spec = $ts->newspec("$Bin/test-rpm.spec");
isa_ok($spec, 'RPM4::Spec', 'ts->newspec');
}

$ts = undef; # explicitely calling DESTROY to close database



( run in 1.067 second using v1.01-cache-2.11-cpan-71847e10f99 )