Add minimal API for spec packages and sources
- Iterators for both (these could easily done as self-iteration over ->next but to keep the api similar to other rpm iterators...) - Minimal getters to satisfy python bindings needs
This commit is contained in:
parent
675bfca5cc
commit
f94d1507e5
|
@ -17,6 +17,8 @@ extern "C" {
|
|||
*/
|
||||
typedef struct Package_s * rpmSpecPkg;
|
||||
typedef struct Source * rpmSpecSrc;
|
||||
typedef struct rpmSpecIter_s * rpmSpecPkgIter;
|
||||
typedef struct rpmSpecIter_s * rpmSpecSrcIter;
|
||||
|
||||
enum rpmSourceFlags_e {
|
||||
RPMBUILD_ISSOURCE = (1 << 0),
|
||||
|
@ -45,6 +47,24 @@ typedef rpmFlags rpmSpecFlags;
|
|||
*/
|
||||
rpmSpec rpmSpecFree(rpmSpec spec);
|
||||
|
||||
/* Iterator for spec packages */
|
||||
rpmSpecPkgIter rpmSpecPkgIterInit(rpmSpec spec);
|
||||
rpmSpecPkg rpmSpecPkgIterNext(rpmSpecPkgIter iter);
|
||||
rpmSpecPkgIter rpmSpecPkgIterFree(rpmSpecPkgIter iter);
|
||||
|
||||
/* Getters for spec package attributes */
|
||||
Header rpmSpecPkgHeader(rpmSpecPkg pkg);
|
||||
|
||||
/* Iterator for spec sources */
|
||||
rpmSpecSrcIter rpmSpecSrcIterInit(rpmSpec spec);
|
||||
rpmSpecSrc rpmSpecSrcIterNext(rpmSpecSrcIter iter);
|
||||
rpmSpecSrcIter rpmSpecSrcIterFree(rpmSpecSrcIter iter);
|
||||
|
||||
/* Getters for spec source attributes */
|
||||
rpmSourceFlags rpmSpecSrcFlags(rpmSpecSrc src);
|
||||
int rpmSpecSrcNum(rpmSpecSrc src);
|
||||
const char * rpmSpecSrcFilename(rpmSpecSrc src, int full);
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Function to query spec file(s).
|
||||
* @param ts transaction set
|
||||
|
|
79
build/spec.c
79
build/spec.c
|
@ -331,6 +331,85 @@ rpmps rpmSpecCheckDeps(rpmts ts, rpmSpec spec)
|
|||
return probs;
|
||||
}
|
||||
|
||||
struct rpmSpecIter_s {
|
||||
void *next;
|
||||
};
|
||||
|
||||
#define SPEC_LISTITER_INIT(_itertype, _iteritem) \
|
||||
_itertype iter = NULL; \
|
||||
if (spec) { \
|
||||
iter = xcalloc(1, sizeof(*iter)); \
|
||||
iter->next = spec->_iteritem; \
|
||||
} \
|
||||
return iter
|
||||
|
||||
#define SPEC_LISTITER_NEXT(_valuetype) \
|
||||
_valuetype item = NULL; \
|
||||
if (iter) { \
|
||||
item = iter->next; \
|
||||
iter->next = (item) ? item->next : NULL; \
|
||||
} \
|
||||
return item
|
||||
|
||||
#define SPEC_LISTITER_FREE() \
|
||||
free(iter); \
|
||||
return NULL
|
||||
|
||||
|
||||
rpmSpecPkgIter rpmSpecPkgIterInit(rpmSpec spec)
|
||||
{
|
||||
SPEC_LISTITER_INIT(rpmSpecPkgIter, packages);
|
||||
}
|
||||
|
||||
rpmSpecPkgIter rpmSpecPkgIterFree(rpmSpecPkgIter iter)
|
||||
{
|
||||
SPEC_LISTITER_FREE();
|
||||
}
|
||||
|
||||
rpmSpecPkg rpmSpecPkgIterNext(rpmSpecPkgIter iter)
|
||||
{
|
||||
SPEC_LISTITER_NEXT(rpmSpecPkg);
|
||||
}
|
||||
|
||||
Header rpmSpecPkgHeader(rpmSpecPkg pkg)
|
||||
{
|
||||
return (pkg != NULL) ? pkg->header : NULL;
|
||||
}
|
||||
|
||||
rpmSpecSrcIter rpmSpecSrcIterInit(rpmSpec spec)
|
||||
{
|
||||
SPEC_LISTITER_INIT(rpmSpecSrcIter, sources);
|
||||
}
|
||||
|
||||
rpmSpecSrcIter rpmSpecSrcIterFree(rpmSpecSrcIter iter)
|
||||
{
|
||||
SPEC_LISTITER_FREE();
|
||||
}
|
||||
|
||||
rpmSpecSrc rpmSpecSrcIterNext(rpmSpecSrcIter iter)
|
||||
{
|
||||
SPEC_LISTITER_NEXT(rpmSpecSrc);
|
||||
}
|
||||
|
||||
rpmSourceFlags rpmSpecSrcFlags(rpmSpecSrc src)
|
||||
{
|
||||
return (src != NULL) ? src->flags : 0;
|
||||
}
|
||||
|
||||
int rpmSpecSrcNum(rpmSpecSrc src)
|
||||
{
|
||||
return (src != NULL) ? src->num : -1;
|
||||
}
|
||||
|
||||
const char * rpmSpecSrcFilename(rpmSpecSrc src, int full)
|
||||
{
|
||||
const char *source = NULL;
|
||||
if (src) {
|
||||
source = full ? src->fullSource : src->source;
|
||||
}
|
||||
return source;
|
||||
}
|
||||
|
||||
int rpmspecQuery(rpmts ts, QVA_t qva, const char * arg)
|
||||
{
|
||||
rpmSpec spec = NULL;
|
||||
|
|
Loading…
Reference in New Issue