18 #define _RPMGI_INTERNAL
19 #define _RPMTS_INTERNAL
77 if (!(fts_info >= 1 && fts_info <= 14))
101 fd =
Fopen(fn, fmode);
110 #if defined(POSIX_FADV_WILLNEED)
198 if (gi->argv !=
NULL && gi->argv[gi->i] !=
NULL) {
199 gi->keyp = gi->argv[gi->i];
225 if (gi->argv !=
NULL && gi->argv[gi->i] !=
NULL)
229 fn = gi->argv[gi->i];
236 rpmrc = (
rpmRC) gi->rc;
251 gi->argv[gi->i] =
NULL;
255 gi->argv[gi->i] =
fn;
333 if (gi->ftsp !=
NULL)
335 if (gi->walkPathFilter)
336 rpmrc = (*gi->walkPathFilter) (gi);
355 if (gi->stash !=
NULL)
356 (
void) (*gi->stash) (gi, gi->h);
371 for (se = s; *
se; se++) {
379 for (se = s; *
se; se++) {
408 while (argv[ac] !=
NULL)
419 while ((arg = *argv++) !=
NULL) {
449 fprintf(stderr,
"*** gi %p key %p[%d]\tmi %p\n", gi, gi->keyp, (
int)gi->keylen, gi->mi);
451 if (gi->argv !=
NULL)
452 for (av = (
const char **) gi->argv; *av !=
NULL; av++) {
462 if ((ae = strchr(a,
'=')) !=
NULL) {
478 fprintf(stderr,
"\tav %p[%d]: \"%s\" -> %s ~= \"%s\"\n", gi->argv, (
int)(av - gi->argv), *av,
tagName((
rpmTag)tag), pat);
502 gi->hdrPath =
_free(gi->hdrPath);
508 if (gi->ftsp !=
NULL) {
513 if (gi->fd !=
NULL) {
533 if (_rpmgiPool ==
NULL) {
539 memset(((
char *)gi)+
sizeof(gi->_item), 0,
sizeof(*gi)-
sizeof(gi->_item));
575 gi->walkPathFilter =
NULL;
594 fprintf(stderr,
"--> %s(%p) tag %s\n", __FUNCTION__, gi,
tagName(gi->tag));
599 gi->hdrPath =
_free(gi->hdrPath);
619 if (gi->mi !=
NULL) {
646 if (gi->mi !=
NULL) {
667 const char * teTypeString =
NULL;
679 case TR_ADDED: teTypeString =
"+++";
break;
682 sprintf(hnum,
"%u", (
unsigned)gi->i);
697 if (path ==
NULL || *path ==
'\0') {
701 gi->fd =
rpmgiOpen(path,
"rm%{?_rpmgio}");
705 if (gi->fd !=
NULL) {
707 const char item[] =
"Header";
726 sprintf(hnum,
"%u", (
unsigned)gi->i);
742 fprintf(stderr,
"*** gi %p\t%p[%d]: %s\n", gi, gi->argv, gi->i, gi->argv[gi->i]);
749 gi->hdrPath =
xstrdup(gi->argv[gi->i]);
752 if (gi->argv ==
NULL || gi->argv[0] ==
NULL)
756 gi->ftsp =
Fts_open((
char *
const *)gi->argv, gi->ftsOpts,
NULL);
771 gi->hdrPath =
xstrdup(gi->fts->fts_path);
817 xx = (*gi->tsOrder) (ts);
827 gi->hdrPath =
_free(gi->hdrPath);
833 fprintf(stderr,
"<-- %s(%p) rc %d\n", __FUNCTION__, gi, rpmrc);
844 return (gi !=
NULL ? gi->hdrPath :
NULL);
857 return (gi !=
NULL ? gi->ts :
NULL);
869 gi->ftsOpts = ftsOpts;
int rpmgiRc(rpmgi gi)
Return current iteration item(s) exit code.
FTS * Fts_open(char *const *argv, int options, int(*compar)(const FTSENT **, const FTSENT **))
Create a handle for file hierarchy traversal.
rpmlog(RPMLOG_ERR,"%s\n", buf)
struct rpmte_s * rpmte
An element of a transaction set, i.e.
rpmgiFlags rpmgiGetFlags(rpmgi gi)
Return current iteration flags.
Structures used for an "rpmte" transaction element.
char * xstrdup(const char *str)
FD_t Fopen(const char *path, const char *_fmode)
fopen(3) clone.
uint32_t rpmmiInstance(rpmmi mi)
Return header instance for current position of rpmdb iterator.
static char *size_t nb
fgets(3) analogue that reads \ continuations.
struct rpmts_s * rpmts
The RPM Transaction Set.
rpmdb rpmtsGetRdb(rpmts ts)
Get transaction set database handle.
rpmts rpmtsFree(rpmts ts)
Destroy transaction set, closing the database as well.
rpmgi rpmgiLink(rpmgi gi, const char *msg)
Reference a generalized iterator instance.
int argvAppend(ARGV_t *argvp, ARGV_t av)
Append one argv array to another.
Header rpmgiHeader(rpmgi gi)
Return current iteration header.
rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type)
Return next transaction element of type.
static const char * ftsInfoStrings[]
int Fadvise(FD_t fd, off_t offset, off_t length, int advice)
posix_fadvise(2) clone.
const char * rpmgiEscapeSpaces(const char *s)
Escape isspace(3) characters in string.
tsmStage rpmtsSetGoal(rpmts ts, tsmStage goal)
Set goal of transaction set.
static rpmRC rpmgiGlobArgv(rpmgi gi, ARGV_t argv)
Append globbed arg list to iterator.
rpmTag tagValue(const char *tagstr)
Return tag value from name.
sprintf(t," (%u)",(unsigned) dig->nbytes)
rpmdepFlags rpmtsSetDFlags(rpmts ts, rpmdepFlags depFlags)
Set dependency flags, i.e.
enum rpmRC_e rpmRC
RPM return codes.
memset(_r, 0, sizeof(*_r))
enum rpmElementType_e rpmElementType
Transaction element type.
int rpmGlob(const char *patterns, int *argcPtr, const char ***argvPtr)
Return URL path(s) from a (URL prefixed) pattern glob.
rpmts rpmtsLink(rpmts ts, const char *msg)
Reference a transaction set instance.
int rpmcliInstallOrder(rpmts ts)
Order package elements in a transaction set, reporting problems.
static const char * ftsInfoStr(int fts_info)
const char * Fstrerror(FD_t fd)
strerror(3) clone.
void * xcalloc(size_t nmemb, size_t size)
int rpmtsAddEraseElement(rpmts ts, Header h, uint32_t hdrNum)
Add package to be erased to transaction set.
rpmgi rpmgiNew(rpmts ts, int tag, const void *keyp, size_t keylen)
Return a generalized iterator.
rpmmi rpmmiFree(rpmmi mi)
Destroy rpm database iterator.
rpmioItem rpmioGetPool(rpmioPool pool, size_t size)
Get unused item from pool, or alloc a new item.
fprintf(stderr,"--> %s(%p,%p,%p) sig %p sigp %p\n", __FUNCTION__, dig, t, rsactx, sig, sigp)
static const char * _query_hdlist_path
enum rpmgiFlags_e rpmgiFlags
static rpmRC rpmgiInitFilter(rpmgi gi)
Return rpmdb match iterator with filters (if any) set.
ARGV_t argvFree(ARGV_t argv)
Destroy an argv array.
const char * tagName(rpmTag tag)
Return tag name from value.
Routines to expand a manifest containing glob expressions into an argv list.
rpmRC rpmReadPackageFile(rpmts ts, FD_t fd, const char *fn, Header *hdrp)
Return package header from file handle, verifying digests/signatures.
Header rpmmiNext(rpmmi mi)
Return next package header from iteration.
int rpmmiAddPattern(rpmmi mi, rpmTag tag, rpmMireMode mode, const char *pattern)
Add pattern to iterator selector.
rpmRC rpmgiSetArgs(rpmgi gi, ARGV_t argv, int ftsOpts, rpmgiFlags flags)
Load iterator args.
int rpmtsAddInstallElement(rpmts ts, Header h, fnpyKey key, int upgrade, rpmRelocation relocs)
Add package to be installed to transaction set.
The FD_t File Handle data structure.
FTSENT * Fts_read(FTS *sp)
Return next node in the file hierarchy traversal.
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
static rpmRC rpmgiWalkPathFilter(rpmgi gi)
Filter file tree walk path.
static rpmgi rpmgiGetPool(rpmioPool pool)
rpmRC rpmReadPackageManifest(FD_t fd, int *argcPtr, const char ***argvPtr)
Read manifest, glob items, and append to existing args.
rpmtsi rpmtsiFree(rpmtsi tsi)
Destroy transaction element iterator.
int Fclose(FD_t fd)
fclose(3) clone.
static FD_t rpmgiOpen(const char *path, const char *fmode)
Open a file after macro expanding path.
int Ferror(FD_t fd)
ferror(3) clone.
int rpmcliInstallSuggests(rpmts ts)
Report packages(if any) that satisfy unresolved dependencies.
return strcmp(ame->name, bme->name)
static void rpmgiFini(void *_gi)
static rpmRC rpmgiLoadReadHeader(rpmgi gi)
Read next header from package, lazily expanding manifests as found.
Methods to handle package elements.
rpmioPool rpmioNewPool(const char *name, size_t size, int limit, int flags, char *(*dbg)(void *item), void(*init)(void *item), void(*fini)(void *item))
Create a memory pool.
rpmts rpmgiTs(rpmgi gi)
Return current iteration transaction set.
static rpmRC rpmgiLoadNextKey(rpmgi gi)
Load next key from argv list.
rpmElementType rpmteType(rpmte te)
Retrieve type of transaction element.
int rpmcliInstallCheck(rpmts ts)
Check package element dependencies in a transaction set, reporting problems.
int Fts_close(FTS *sp)
Destroy a file hierarchy traversal handle.
Header rpmteHeader(rpmte te)
Retrieve header from transaction element.
rpmRC rpmgiNext(rpmgi gi)
Perform next iteration step.
static void
Print copy of spec file, filling in Group/Description/Summary from specspo.
Header rpmgiReadHeader(rpmgi gi, const char *path)
Return header from package.
const char * rpmgiHdrPath(rpmgi gi)
Return current header path.
rpmRC rpmpkgRead(const char *fn, FD_t fd, void *ptr, const char **msg)
Read item from file descriptor.
Access RPM indices using Berkeley DB interface(s).
static rpmRC rpmgiLoadManifest(rpmgi gi, const char *path)
Load manifest into iterator arg list.
rpmdepFlags rpmtsDFlags(rpmts ts)
Get dependency flags, i.e.
rpmmi rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)
Return transaction database iterator.
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
int rpmdbBlockDBI(rpmdb db, int tag)
Block access to a single database index.
enum rpmdepFlags_e rpmdepFlags
Bit(s) to control rpmtsCheck() and rpmtsOrder() operation.
struct rpmgi_s * rpmgi
Generalized iterator.
#define RPMDBI_PACKAGES
Pseudo-tags used by the rpmdb and rpmgi iterator API's.
rpmtsi rpmtsiInit(rpmts ts)
Create transaction element iterator.
static rpmRC rpmgiWalkReadHeader(rpmgi gi)
Read header from next package, lazily walking file tree.