-----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;
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:
[tyler@localhost linux]$ ./a.out
error: no dbpath has been set
error: cannot open Packages database in
[tyler@localhost linux]$
With this code, any ideas?
int main(int argc, char **argv)
{
rpmts transaction = rpmtsCreate(); // create the redhat
database transaction handle
rpmdbMatchIterator iter = rpmtsInitIterator(transaction,
RPMTAG_PROVIDENAME, "bash", 0);
Header h;
while ((h = rpmdbNextIterator(iter)) != NULL)
{
char *N, *E, *V, *R, *A;
E = NULL;
headerNEVRA(h, (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);
}
h = headerFree(h);
iter = rpmdbFreeIterator(iter);
transaction = rpmtsFree(transaction);
return EXIT_SUCCESS;
}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)
iD8DBQFFEE+GqO6nEJfroRsRAqdQAJ9/ZIttbjYGI4ux+YnZ1raicgcMAwCeMvqP
BEexwekBrRQkSRA+ockorZs=
=wFfD
-----END PGP SIGNATURE-----
_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/rpm-list