16 #define _RPMFI_INTERNAL 19 #define _RPMTE_INTERNAL 34 GENfree(sharedFileInfo)
57 p->fd =
fdFree(p->fd,
"delTE");
61 p->arch =
_free(p->arch);
62 p->epoch =
_free(p->epoch);
63 p->name =
_free(p->name);
64 p->version =
_free(p->version);
65 p->release =
_free(p->release);
66 #ifdef RPM_VENDOR_MANDRIVA 67 p->distepoch =
_free(p->distepoch);
69 p->NEVR =
_free(p->NEVR);
70 p->NEVRA =
_free(p->NEVRA);
71 p->pkgid =
_free(p->pkgid);
72 p->hdrid =
_free(p->hdrid);
73 p->sourcerpm =
_free(p->sourcerpm);
75 p->replaced =
_free(p->replaced);
77 p->flink.NEVRA =
argvFree(p->flink.NEVRA);
78 p->flink.Pkgid =
argvFree(p->flink.Pkgid);
79 p->flink.Hdrid =
argvFree(p->flink.Hdrid);
80 p->blink.NEVRA =
argvFree(p->blink.NEVRA);
81 p->blink.Pkgid =
argvFree(p->blink.Pkgid);
82 p->blink.Hdrid =
argvFree(p->blink.Hdrid);
84 assert(p->txn == NULL);
117 assert(he->
p.
str != NULL);
118 p->NEVR = (xx ? he->
p.
str :
xstrdup(
"?N-?V-?R.?A"));
122 p->name = (xx ? he->
p.
str :
xstrdup(
"?RPMTAG_NAME?"));
125 p->version = (
char *)(xx ? he->
p.
str :
xstrdup(
"?RPMTAG_VERSION?"));
128 p->release = (
char *)(xx ? he->
p.
str :
xstrdup(
"?RPMTAG_RELEASE?"));
134 if (he->
p.
ui8p != NULL) {
135 static const char hex[] =
"0123456789abcdef";
139 p->pkgid = t = (
char *)
xmalloc((2*he->
c) + 1);
140 for (i = 0 ; i < he->
c; i++) {
141 *t++ = hex[ (unsigned)((he->
p.
ui8p[i] >> 4) & 0x0f) ];
142 *t++ = hex[ (unsigned)((he->
p.
ui8p[i] ) & 0x0f) ];
151 p->hdrid = (xx ? he->
p.
str :
xstrdup(
"?RPMTAG_HDRID?"));
155 p->sourcerpm = (xx ? he->
p.
str : NULL);
159 p->arch = (xx ? he->
p.
str :
xstrdup(
"?RPMTAG_ARCH?"));
173 if (he->
p.
ui32p != NULL) {
174 p->epoch = (
char *)
xmalloc(20);
175 sprintf(p->epoch,
"%u", he->
p.
ui32p[0]);
180 #ifdef RPM_VENDOR_MANDRIVA 183 if (he->
p.
str != NULL) {
184 p->distepoch = (
char*)(xx ? he->
p.
str :
xstrdup(
"?RPMTAG_DISTEPOCH?"));
192 p->autorelocatex = -1;
200 memset(p->originTid, 0,
sizeof(p->originTid));
201 memset(p->originTime, 0,
sizeof(p->originTime));
235 if (_rpmtePool == NULL) {
241 memset(((
char *)te)+
sizeof(te->_item), 0,
sizeof(*te)-
sizeof(te->_item));
258 addTE(ts, p, h, key, relocs);
261 p->u.addedKey = pkgKey;
263 p->pkgFileSize = 96 + 256;
267 p->pkgFileSize += *he->
p.
ui32p;
271 p->u.addedKey = pkgKey;
272 p->u.removed.dboffset = dboffset;
281 return (te != NULL ? te->db_instance : 0);
288 te->db_instance = instance;
294 return (te != NULL && te->h != NULL ?
headerLink(te->h) : NULL);
318 return (te != NULL ? te->name : NULL);
323 return (te != NULL ? te->epoch : NULL);
328 return (te != NULL ? te->version : NULL);
333 return (te != NULL ? te->release : NULL);
338 #ifdef RPM_VENDOR_MANDRIVA 339 return (te != NULL ? te->distepoch : NULL);
347 return (te != NULL ? te->arch : NULL);
352 return (te != NULL ? te->os : NULL);
357 return (te != NULL ? te->isSource : 0);
362 return (te != NULL ? te->color : 0);
377 return (te != NULL ? te->pkgFileSize : 0);
382 return te->originTid;
387 return te->originTime;
392 return (te != NULL ? te->depth : 0);
407 return (te != NULL ? te->depth : 0);
414 obreadth = te->breadth;
415 te->breadth = nbreadth;
422 return (te != NULL ? te->npreds : 0);
437 return (te != NULL ? te->tree : 0);
452 return (te != NULL ? te->parent : NULL);
469 return (te != NULL ? te->degree : 0);
476 odegree = te->degree;
477 te->degree = ndegree;
491 if (te != NULL &&
rpmteTSI(te) != NULL) {
495 while ((tsi =
rpmteTSI(te)->tsi_next) != NULL) {
496 rpmteTSI(te)->tsi_next = tsi->tsi_next;
497 tsi->tsi_next = NULL;
500 te->tsi =
_free(te->tsi);
524 opkgKey = te->u.addedKey;
525 te->u.addedKey = npkgKey;
533 return (te != NULL ? te->u.removed.dboffset : 0);
538 return (te != NULL ? te->NEVR : NULL);
543 return (te != NULL ? te->NEVRA : NULL);
548 return (te != NULL ? te->pkgid : NULL);
553 return (te != NULL ? te->hdrid : NULL);
558 return (te != NULL ? te->sourcerpm : NULL);
564 return (te != NULL ? te->fd : NULL);
570 return (te != NULL ? te->key : NULL);
643 nb = Count *
sizeof(*colors);
645 nb = Count *
sizeof(*refs);
658 mydt = (char)((ix >> 24) & 0xff);
662 assert ((
int)ix < Count);
685 const char * blinkNEVRA = NULL;
686 const char * blinkPkgid = NULL;
687 const char * blinkHdrid = NULL;
694 assert(he->
p.
str != NULL);
695 blinkNEVRA = he->
p.
str;
704 if (xx && he->
p.
ui8p != NULL) {
705 static const char hex[] =
"0123456789abcdef";
709 blinkPkgid = t = (
char *)
xmalloc((2*he->
c) + 1);
710 for (i = 0 ; i < he->
c; i++) {
711 *t++ = hex[ ((he->
p.
ui8p[i] >> 4) & 0x0f) ];
712 *t++ = hex[ ((he->
p.
ui8p[i] ) & 0x0f) ];
721 blinkHdrid = he->
p.
str;
725 fprintf(stderr,
"%s argvAdd(&q->flink.NEVRA, \"%s\")\n", msg, p->NEVRA);
726 xx =
argvAdd(&q->flink.NEVRA, p->NEVRA);
728 fprintf(stderr,
"%s argvAdd(&p->blink.NEVRA, \"%s\")\n", msg, blinkNEVRA);
729 xx =
argvAdd(&p->blink.NEVRA, blinkNEVRA);
731 fprintf(stderr,
"%s argvAdd(&q->flink.Pkgid, \"%s\")\n", msg, p->pkgid);
732 if (p->pkgid != NULL)
733 xx =
argvAdd(&q->flink.Pkgid, p->pkgid);
735 fprintf(stderr,
"%s argvAdd(&p->blink.Pkgid, \"%s\")\n", msg, blinkPkgid);
736 if (blinkPkgid != NULL)
737 xx =
argvAdd(&p->blink.Pkgid, blinkPkgid);
739 fprintf(stderr,
"%s argvAdd(&q->flink.Hdrid, \"%s\")\n", msg, p->hdrid);
740 if (p->hdrid != NULL)
741 xx =
argvAdd(&q->flink.Hdrid, p->hdrid);
743 fprintf(stderr,
"%s argvAdd(&p->blink.Hdrid, \"%s\")\n", msg, blinkHdrid);
744 if (blinkHdrid != NULL)
745 xx =
argvAdd(&p->blink.Hdrid, blinkHdrid);
748 blinkNEVRA =
_free(blinkNEVRA);
749 blinkPkgid =
_free(blinkPkgid);
750 blinkHdrid =
_free(blinkHdrid);
781 if (_rpmtsiPool == NULL) {
787 memset(((
char *)tsi)+
sizeof(tsi->_item), 0,
sizeof(*tsi)-
sizeof(tsi->_item));
800 tsi->ocsave = tsi->oc;
817 if (tsi == NULL || tsi->ts == NULL ||
rpmtsNElements(tsi->ts) <= 0)
821 if (tsi->oc >= 0) oc = tsi->oc--;
836 if (type == 0 || (te->type & type) != 0)
860 if (te->fd != NULL) {
886 if (te == NULL || ts == NULL)
903 te->fi = getFI(te, ts, h);
907 static int scareMem = 0;
924 if (te == NULL || ts == NULL)
929 if (te->fd != NULL) {
947 return (te != NULL) ? te->linkFailed : -1;
952 rpmfi fi = (te ? te->fi : NULL);
960 rc = (fi->pretrans || fi->pretransprog) ? 1 : 0;
964 rc = (fi->posttrans || fi->posttransprog) ? 1 : 0;
980 if (rpmteDependsOn(p) == te) {
990 return te ? te->probs : NULL;
993 rpmfs rpmteGetFileStates(
rpmte te) {
998 rpmfs fs = (rpmfs)
xmalloc(
sizeof(*fs));
1000 fs->replaced = NULL;
1003 fs->states = (sharedFileInfo)
xmalloc(
sizeof(*fs->states) * fs->fc);
1006 fs->actions = (rpmFIleAction *)
xmalloc(fc *
sizeof(*fs->actions));
1007 memset(fs->actions,
FA_UNKNOWN, fc *
sizeof(*fs->actions));
1008 fs->numReplaced = fs->allocatedReplaced = 0;
1012 rpmfs rpmfsFree(rpmfs fs) {
1013 fs->replaced =
_free(fs->replaced);
1014 fs->states =
_free(fs->states);
1015 fs->actions =
_free(fs->actions);
1021 rpm_count_t rpmfsFC(rpmfs fs) {
1025 void rpmfsAddReplaced(rpmfs fs,
int pkgFileNum,
int otherPkg,
int otherFileNum)
1027 if (!fs->replaced) {
1028 fs->replaced = (sharedFileInfo)
xcalloc(3,
sizeof(*fs->replaced));
1029 fs->allocatedReplaced = 3;
1031 if (fs->numReplaced>=fs->allocatedReplaced) {
1032 fs->allocatedReplaced += (fs->allocatedReplaced>>1) + 2;
1033 fs->replaced = (sharedFileInfo)
xrealloc(fs->replaced, fs->allocatedReplaced*
sizeof(*fs->replaced));
1035 fs->replaced[fs->numReplaced].pkgFileNum = pkgFileNum;
1036 fs->replaced[fs->numReplaced].otherPkg = otherPkg;
1037 fs->replaced[fs->numReplaced].otherFileNum = otherFileNum;
1042 sharedFileInfo rpmfsGetReplaced(rpmfs fs)
1044 if (fs && fs->numReplaced)
1045 return fs->replaced;
1050 sharedFileInfo rpmfsNextReplaced(rpmfs fs , sharedFileInfo replaced)
1052 if (fs && replaced) {
1054 if (replaced - fs->replaced < fs->numReplaced)
1060 void rpmfsSetState(rpmfs fs,
unsigned int ix,
rpmfileState state)
1062 assert(ix < fs->fc);
1063 fs->states[ix] = state;
1068 assert(ix < fs->fc);
1069 if (fs->states)
return fs->states[ix];
1073 rpm_fstate_t * rpmfsGetStates(rpmfs fs)
1078 rpmFileAction rpmfsGetAction(rpmfs fs,
unsigned int ix)
1080 rpmFileAction action;
1081 if (fs->actions != NULL && ix < fs->fc) {
1082 action = fs->actions[ix];
1089 void rpmfsSetAction(rpmfs fs,
unsigned int ix, rpmFileAction action)
1091 if (fs->actions != NULL && ix < fs->fc) {
1092 fs->actions[ix] = action;
int rpmteChain(rpmte p, rpmte q, Header oh, const char *msg)
Chain p <-> q forward/backward transaction element links.
int rpmteClose(rpmte te, rpmts ts, int reset_fi)
FD_t rpmteFd(rpmte te)
Retrieve file handle from transaction element.
rpmds rpmdsInit(rpmds ds)
Initialize dependency set iterator.
int rpmteSetDegree(rpmte te, int ndegree)
Set number of children of transaction element.
rpmuint32_t rpmteColor(rpmte te)
Retrieve color bits of transaction element.
rpmPRCO rpmdsFreePRCO(rpmPRCO PRCO)
Free dependency set(s) container.
static void delTE(rpmte p)
Destroy transaction element data.
int rpmteOpen(rpmte te, rpmts ts, int reload_fi)
int rpmteSetTree(rpmte te, int ntree)
Set tree index of transaction element.
Header rpmteFDHeader(rpmts ts, rpmte te)
void * rpmtsNotify(rpmts ts, rpmte te, rpmCallbackType what, rpmuint64_t amount, rpmuint64_t total)
Perform transaction progress notify callback.
Header rpmteDBHeader(rpmts ts, uint32_t rec)
void rpmteFreeTSI(rpmte te)
Destroy tsort info of transaction element.
rpmte rpmtsElement(rpmts ts, int ix)
Return (ordered) transaction set element.
const char * rpmteSourcerpm(rpmte te)
Retrieve sourcerpm string from transaction element.
rpmuint32_t rpmfiFDepends(rpmfi fi, const rpmuint32_t **fddictp)
Return current file depends dictionary from file info set.
int rpmteSetBreadth(rpmte te, int nbreadth)
Set dependency tree breadth of transaction element.
Structures used for an "rpmte" transaction element.
char * xstrdup(const char *str)
Structure(s) used for file info tag sets.
rpmioItem rpmioLinkPoolItem(rpmioItem item, const char *msg, const char *fn, unsigned ln)
Increment a pool item refcount.
void rpmteColorDS(rpmte te, rpmTag tag)
Calculate transaction element dependency colors/refs from file info.
const char * rpmteN(rpmte te)
Retrieve name string of transaction element.
int rpmteDegree(rpmte te)
Retrieve number of children of transaction element.
int rpmteNpreds(rpmte te)
Retrieve tsort no.
rpmuint32_t rpmdsSetColor(const rpmds ds, rpmuint32_t color)
Set current dependency color.
rpmfi rpmfiFree(rpmfi fi)
Destroy a file info set.
rpmtsi rpmtsiFree(rpmtsi tsi)
Destroy transaction element iterator.
struct rpmtsi_s * rpmtsi
Transaction element iterator.
struct rpmps_s * rpmps
Transaction problems found while processing a transaction set/.
rpmElementType rpmteType(rpmte te)
Retrieve type of transaction element.
const char * rpmteA(rpmte te)
Retrieve arch string of transaction element.
rpmfi rpmfiNew(const void *_ts, Header h, rpmTag tagN, int flags)
Create and load a file info set.
rpmts rpmtsLink(rpmts ts, const char *msg)
Reference a transaction set instance.
struct rpmds_s * rpmds
Dependency tag sets from a header, so that a header can be discarded early.
rpmuint32_t rpmfiFColor(rpmfi fi)
Return current file color bits from file info set.
int rpmteHaveTransScript(rpmte te, rpmTag tag)
rpmds rpmteDS(rpmte te, rpmTag tag)
Retrieve dependency tag set from transaction element.
int rpmfiFC(rpmfi fi)
Return file count from file info set.
struct rpmte_s * rpmte
An element of a transaction set, i.e.
struct tsortInfo_s * tsortInfo
Transaction element ordering chain linkage.
const char * rpmteE(rpmte te)
Retrieve epoch string of transaction element.
#define RPMFILE_STATE_MISSING
alKey rpmteSetAddedKey(rpmte te, alKey npkgKey)
rpmPRCO rpmdsNewPRCO(Header h)
Create dependency set(s) container.
enum rpmElementType_e rpmElementType
Transaction element type.
int rpmteBreadth(rpmte te)
Retrieve dependency tree breadth of transaction element.
const char * rpmteV(rpmte te)
Retrieve version string of transaction element.
const char * rpmteNEVR(rpmte te)
Retrieve name-version-release string from transaction element.
void * xcalloc(size_t nmemb, size_t size)
rpmte rpmteParent(rpmte te)
Retrieve parent transaction element.
int rpmteDepth(rpmte te)
Retrieve dependency tree depth of transaction element.
alKey rpmteAddedKey(rpmte te)
rpmioItem rpmioGetPool(rpmioPool pool, size_t size)
Get unused item from pool, or alloc a new item.
rpmfi rpmteFI(rpmte te, rpmTag tag)
Retrieve file info tag set from transaction element.
FD_t fdFree(FD_t fd, const char *msg)
struct rpmfi_s * rpmfi
File info tag sets from a header, so that a header can be discarded early.
ARGV_t argvFree(ARGV_t argv)
Destroy an argv array.
static void rpmtsiFini(void *_tsi)
int rpmtsNElements(rpmts ts)
Return number of (ordered) transaction set elements.
static rpmtsi rpmtsiGetPool(rpmioPool pool)
rpmRC rpmReadPackageFile(rpmts ts, FD_t fd, const char *fn, Header *hdrp)
Return package header from file handle, verifying digests/signatures.
int rpmdsNext(rpmds ds)
Return next dependency set iterator index.
Structure(s) used for dependency tag sets.
void rpmteCleanDS(rpmte te)
Destroy dependency set info of transaction element.
rpmtsi XrpmtsiInit(rpmts ts, const char *fn, unsigned int ln)
Create transaction element iterator.
The FD_t File Handle data structure.
rpmmi rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)
Return transaction database iterator.
const char * rpmteD(rpmte te)
Retrieve distepoch string of transaction element.
const char * rpmteNEVRA(rpmte te)
Retrieve name-version-release.arch string from transaction element.
int argvAdd(ARGV_t *argvp, ARGstr_t val)
Add a string to an argv array.
rpmuint32_t rpmdsSetRefs(const rpmds ds, rpmuint32_t refs)
Set current dependency file refs.
pgpVSFlags rpmVSFlags
Bit(s) to control digest and signature verification.
Header headerFree(Header h)
Dereference a header instance.
int rpmdsCount(const rpmds ds)
Return dependency set count.
void * alKey
An added/available package retrieval key.
void rpmteNewTSI(rpmte te)
Initialize tsort info of transaction element.
rpmRelocation rpmfiFreeRelocations(rpmRelocation relocs)
Free relocation array.
const char * rpmteO(rpmte te)
Retrieve os string of transaction element.
const char * rpmteHdrid(rpmte te)
Retrieve hdrid string from transaction element.
Header rpmteSetHeader(rpmte te, Header h)
Save header into transaction element.
rpmmi rpmmiFree(rpmmi mi)
Destroy rpm database iterator.
rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type)
Return next transaction element of type.
Header rpmteHeader(rpmte te)
Retrieve header from transaction element.
rpmuint32_t * rpmteOriginTid(rpmte te)
Retrieve transaction start time that package was first installed.
int rpmfiNext(rpmfi fi)
Return next file iterator index.
Header headerLink(Header h)
Reference a header instance.
rpmuint32_t * rpmteOriginTime(rpmte te)
Retrieve time that package was first installed.
int rpmtsiOc(rpmtsi tsi)
Return transaction element index.
int rpmteSetDepth(rpmte te, int ndepth)
Set dependency tree depth of transaction element.
fnpyKey rpmteKey(rpmte te)
Retrieve key from transaction element.
enum rpmRC_e rpmRC
RPM return codes.
uint32_t rpmteDBInstance(rpmte te)
Retrieve last instance installed to the database.
rpmfi rpmfiInit(rpmfi fi, int fx)
Initialize file iterator index.
enum rpmfileState_e rpmfileState
File States (when installed).
rpmfi rpmfiLink(rpmfi fi, const char *msg)
Reference a file info set instance.
static rpmte rpmteGetPool(rpmioPool pool)
rpmts rpmtsFree(rpmts ts)
Destroy transaction set, closing the database as well.
static rpmte rpmtsiNextElement(rpmtsi tsi)
Return next transaction element.
Methods to handle package elements.
rpmte rpmtsSetRelocateElement(rpmts ts, rpmte relocateElement)
Set current relocate transaction element.
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.
rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
Set verify signatures flag(s).
struct rpmts_s * rpmts
The RPM Transaction Set.
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
static void rpmteFini(void *_te)
int rpmteDBOffset(rpmte te)
Retrieve rpmdb instance of TR_REMOVED transaction element.
rpmuint32_t rpmtePkgFileSize(rpmte te)
Retrieve size in bytes of package file.
Structures and prototypes used for an "rpmts" transaction set.
Header rpmmiNext(rpmmi mi)
Return next package header from iteration.
rpmVSFlags rpmtsVSFlags(rpmts ts)
Get verify signatures flag(s).
int rpmteSetNpreds(rpmte te, int npreds)
Set tsort no.
rpmfi rpmteSetFI(rpmte te, rpmfi fi)
tsortInfo rpmteTSI(rpmte te)
Retrieve tsort info for transaction element.
rpmte rpmteSetParent(rpmte te, rpmte pte)
Set parent transaction element.
rpmRelocation rpmfiDupeRelocations(rpmRelocation relocs, int *nrelocsp)
Duplicate a relocation array.
static void addTE(rpmts ts, rpmte p, Header h, fnpyKey key, rpmRelocation relocs)
Initialize transaction element data from header.
int rpmteFailed(rpmte te)
void rpmteSetDBInstance(rpmte te, unsigned int instance)
Set last instance installed to the database.
rpmuint32_t rpmteSetColor(rpmte te, rpmuint32_t color)
Set color bits of transaction element.
rpmtsi rpmtsiInit(rpmts ts)
Create transaction element iterator.
Access RPM indices using Berkeley DB interface(s).
const char * rpmtePkgid(rpmte te)
Retrieve pkgid string from transaction element.
rpmte rpmteNew(const rpmts ts, Header h, rpmElementType type, fnpyKey key, rpmRelocation relocs, uint32_t dboffset, alKey pkgKey)
Create a transaction element.
int rpmteTree(rpmte te)
Retrieve tree index of transaction element.
const char * rpmteR(rpmte te)
Retrieve release string of transaction element.
#define RPMDBI_PACKAGES
Pseudo-tags used by the rpmdb and rpmgi iterator API's.
int rpmteIsSource(rpmte te)
Retrieve isSource attribute of transaction element.
rpmds rpmdsFromPRCO(rpmPRCO PRCO, rpmTag tagN)
Retrieve a dependency set from container.