[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: RPM C API (and other fun acronyms)




On Sep 19, 2006, at 4:13 PM, R. Tyler Ballance wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Are you talking about package files or installed packages from the
local RPMDB?  The procedure is different for each one, but once you
have a "Header" object for the package in question, use something like
this to get the name, version, etc.:

    char *N, *E, *V, *R, *A;


Note that headerNEVRA() does not actually return the Epoch:.

    E = NULL;
headerNEVRA(hdr, (const char **) &N, (const char **) &E, (const char **) &V, (const char **) &R,
                (const char **) &A);
printf("Package: %s (%s:%s-%s) for %s\n", N, ((E)?(E):("0")), V, R, A);
    headerFreeData(N, RPM_STRING_TYPE);
    headerFreeData(E, RPM_STRING_TYPE);
    headerFreeData(V, RPM_STRING_TYPE);
    headerFreeData(R, RPM_STRING_TYPE);
    headerFreeData(A, RPM_STRING_TYPE);

NEVRA, now I get it :) That is what I was looking for. However, your snippets combined with Jeff's snippets don't work:


Hint: Using data structures other than Header is recommended, headers are way too bloaty to be used as the primary data structure for rpm (or anything using rpmlib).

E.g.
	ds = rpmdsThis(h, RPMTAG_PROVIDENAME, RPMSENSE_EQUAL);
        fprintf(stdout, "%s\n", rpmdsDNEVR(ds)+2);
	ds = rpmdsFree(ds);
is perhaps terser (but lacks the arch, and os, and ...).

headerSprintf() is the fastest and most convenient if you want strings from headers.

hth

73 de Jeff


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]