[Rpm-maint] Rally: minor API requests
Maxim Udushlivy
udushlivy at mail.ru
Tue Nov 13 18:08:37 UTC 2007
Panu Matilainen wrote:
>> (1)
> Sounds entirely reasonable to me, there are a number of users
> (smartpm, apt-rpm ...) that would benefit. Whatever the
> implementation, it needs to abstract out any backend DB details (as
> rpm supports BDB and SQLite backends for the DB)
The implementation may look this way:
time_t rpmGetDbMtime(const char * root) {
time_t mtime= 0;
const char * path= rpmGenPath(root, "%{_dbpath}",
tagName(RPMDBI_PACKAGES));
struct stat buf;
if(path && Stat(path, &buf) == 0)
mtime= buf.st_mtime;
_free(path);
return mtime;
}
Sample usage:
void * lock= rpmtsAcquireLock(ts);
if(lock) {
if(cache_mtime != rpmGetDbMtime(NULL)) {
// retrieve installed package headers
// from RPM DB into application cache
}
rpmtsFreeLock(lock);
}
The remaining problem is that rpmlock.h is not public.
>> (2)
> There are a number of issues (API and other things) with rpm's public
> key handling that need addressing sooner or later .. concrete API
> suggestions welcome.
The API to supply a custom keyring for rpmts is sufficient to solve (2)
I think:
int rpmtsCustomKeyringAdd(rpmts ts, const byte * pkt, size_t pktlen);
int rpmtsCustomKeyringReset(rpmts ts);
Sample usage:
const byte * pkt= NULL;
size_t pktlen= 0;
pgpReadPkts(path_to_gpg_key, &pkt, &pktlen);
rpmtsCustomKeyringAdd(ts, pkt, pktlen);
_free(pkt);
rpmRC rc= rpmReadPackageFile(ts, fd, path_to_rpm, &header);
if(header && rc==RPMRC_OK) {
// package was read successfully using the supplied public key
}
More information about the Rpm-maint
mailing list