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);
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?"));
135 static const char hex[] =
"0123456789abcdef";
139 p->pkgid = t = (
char *)
xmalloc((2*he->
c) + 1);
140 for (i = 0 ; i < he->
c; i++) {
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?"));
174 p->epoch = (
char *)
xmalloc(20);
180 #ifdef RPM_VENDOR_MANDRIVA
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);
263 p->pkgFileSize = 96 + 256;
267 p->pkgFileSize += *he->
p.
ui32p;
272 p->u.removed.dboffset = dboffset;
281 return (te !=
NULL ? te->db_instance : 0);
288 te->db_instance = instance;
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;
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);
685 const char * blinkNEVRA =
NULL;
686 const char * blinkPkgid =
NULL;
687 const char * blinkHdrid =
NULL;
695 blinkNEVRA = he->
p.
str;
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;
821 if (tsi->oc >= 0) oc = tsi->oc--;
836 if (type == 0 || (te->type & type) != 0)
860 if (te->fd !=
NULL) {
903 te->fi = getFI(te, ts, h);
907 static int scareMem = 0;
929 if (te->fd !=
NULL) {
947 return (te !=
NULL) ? te->linkFailed : -1;
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));
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)
1063 fs->states[
ix] = state;
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;
const char * rpmteV(rpmte te)
Retrieve version string of transaction element.
rpmuint32_t rpmdsSetRefs(const rpmds ds, rpmuint32_t refs)
Set current dependency file refs.
int rpmdsNext(rpmds ds)
Return next dependency set iterator index.
int rpmteBreadth(rpmte te)
Retrieve dependency tree breadth of transaction element.
const char * rpmteNEVRA(rpmte te)
Retrieve name-version-release.arch string from transaction element.
int rpmteClose(rpmte te, rpmts ts, int reset_fi)
rpmuint32_t * rpmteOriginTime(rpmte te)
Retrieve time that package was first installed.
rpmte rpmtsSetRelocateElement(rpmts ts, rpmte relocateElement)
Set current relocate transaction element.
const char * rpmtePkgid(rpmte te)
Retrieve pkgid string from transaction element.
int rpmteTree(rpmte te)
Retrieve tree index of transaction element.
static void delTE(rpmte p)
Destroy transaction element data.
int rpmteOpen(rpmte te, rpmts ts, int reload_fi)
void rpmteFreeTSI(rpmte te)
Destroy tsort info of transaction element.
rpmuint32_t rpmteColor(rpmte te)
Retrieve color bits of transaction element.
Header rpmteFDHeader(rpmts ts, rpmte te)
struct rpmte_s * rpmte
An element of a transaction set, i.e.
Header rpmteDBHeader(rpmts ts, uint32_t rec)
rpmte rpmteSetParent(rpmte te, rpmte pte)
Set parent transaction element.
static PyObject *int type
rpmuint32_t rpmfiFDepends(rpmfi fi, const rpmuint32_t **fddictp)
Return current file depends dictionary from file info set.
void * alKey
An added/available package retrieval key.
Structures used for an "rpmte" transaction element.
char * xstrdup(const char *str)
int rpmteSetNpreds(rpmte te, int npreds)
Set tsort no.
Structure(s) used for file info tag sets.
rpmfi rpmteFI(rpmte te, rpmTag tag)
Retrieve file info tag set from transaction element.
static char *size_t nb
fgets(3) analogue that reads \ continuations.
rpmioItem rpmioLinkPoolItem(rpmioItem item, const char *msg, const char *fn, unsigned ln)
Increment a pool item refcount.
rpmuint32_t * rpmteOriginTid(rpmte te)
Retrieve transaction start time that package was first installed.
struct rpmts_s * rpmts
The RPM Transaction Set.
int rpmteDepth(rpmte te)
Retrieve dependency tree depth of transaction element.
int rpmteNpreds(rpmte te)
Retrieve tsort no.
rpmts rpmtsFree(rpmts ts)
Destroy transaction set, closing the database as well.
int rpmteSetBreadth(rpmte te, int nbreadth)
Set dependency tree breadth of transaction element.
rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type)
Return next transaction element of type.
rpmfi rpmfiFree(rpmfi fi)
Destroy a file info set.
FD_t rpmteFd(rpmte te)
Retrieve file handle from transaction element.
rpmPRCO rpmdsNewPRCO(Header h)
Create dependency set(s) container.
struct rpmps_s * rpmps
Transaction problems found while processing a transaction set/.
const char * rpmteN(rpmte te)
Retrieve name string of transaction element.
rpmfi rpmfiNew(const void *_ts, Header h, rpmTag tagN, int flags)
Create and load a file info set.
rpmuint32_t rpmfiFColor(rpmfi fi)
Return current file color bits from file info set.
int rpmteHaveTransScript(rpmte te, rpmTag tag)
int rpmfiFC(rpmfi fi)
Return file count from file info set.
const char * rpmteA(rpmte te)
Retrieve arch string of transaction element.
sprintf(t," (%u)",(unsigned) dig->nbytes)
rpmPRCO rpmdsFreePRCO(rpmPRCO PRCO)
Free dependency set(s) container.
#define RPMFILE_STATE_MISSING
int rpmteSetDegree(rpmte te, int ndegree)
Set number of children of transaction element.
int rpmtsiOc(rpmtsi tsi)
Return transaction element index.
rpmds rpmteDS(rpmte te, rpmTag tag)
Retrieve dependency tag set from transaction element.
alKey rpmteSetAddedKey(rpmte te, alKey npkgKey)
enum rpmRC_e rpmRC
RPM return codes.
memset(_r, 0, sizeof(*_r))
int rpmteChain(rpmte p, rpmte q, Header oh, const char *msg)
Chain p <-> q forward/backward transaction element links.
enum rpmElementType_e rpmElementType
Transaction element type.
rpmuint32_t rpmteSetColor(rpmte te, rpmuint32_t color)
Set color bits of transaction element.
rpmts rpmtsLink(rpmts ts, const char *msg)
Reference a transaction set instance.
int rpmteSetTree(rpmte te, int ntree)
Set tree index of transaction element.
void * xcalloc(size_t nmemb, size_t size)
assert(key->size==sizeof(hdrNum))
void rpmteColorDS(rpmte te, rpmTag tag)
Calculate transaction element dependency colors/refs from file info.
rpmmi rpmmiFree(rpmmi mi)
Destroy rpm database iterator.
alKey rpmteAddedKey(rpmte te)
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)
FD_t fdFree(FD_t fd, const char *msg)
rpmds rpmdsFromPRCO(rpmPRCO PRCO, rpmTag tagN)
Retrieve a dependency set from container.
ARGV_t argvFree(ARGV_t argv)
Destroy an argv array.
static void rpmtsiFini(void *_tsi)
void rpmteNewTSI(rpmte te)
Initialize tsort info of transaction element.
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.
Header rpmmiNext(rpmmi mi)
Return next package header from iteration.
struct tsortInfo_s * tsortInfo
Transaction element ordering chain linkage.
Structure(s) used for dependency tag sets.
void * rpmtsNotify(rpmts ts, rpmte te, rpmCallbackType what, rpmuint64_t amount, rpmuint64_t total)
Perform transaction progress notify callback.
The FD_t File Handle data structure.
rpmtsi XrpmtsiInit(rpmts ts, const char *fn, unsigned int ln)
Create transaction element iterator.
int rpmdsCount(const rpmds ds)
Return dependency set count.
int rpmteSetDepth(rpmte te, int ndepth)
Set dependency tree depth of transaction element.
int argvAdd(ARGV_t *argvp, ARGstr_t val)
Add a string to an argv array.
const char * rpmteSourcerpm(rpmte te)
Retrieve sourcerpm string from transaction element.
rpmtsi rpmtsiFree(rpmtsi tsi)
Destroy transaction element iterator.
rpmte rpmtsElement(rpmts ts, int ix)
Return (ordered) transaction set element.
rpmRelocation rpmfiFreeRelocations(rpmRelocation relocs)
Free relocation array.
rpmuint32_t rpmdsSetColor(const rpmds ds, rpmuint32_t color)
Set current dependency color.
pgpVSFlags rpmVSFlags
Bit(s) to control digest and signature verification.
rpmte rpmteNew(const rpmts ts, Header h, rpmElementType type, fnpyKey key, rpmRelocation relocs, uint32_t dboffset, alKey pkgKey)
Create a transaction element.
struct rpmds_s * rpmds
Dependency tag sets from a header, so that a header can be discarded early.
Header rpmteSetHeader(rpmte te, Header h)
Save header into transaction element.
int rpmteDegree(rpmte te)
Retrieve number of children of transaction element.
int rpmfiNext(rpmfi fi)
Return next file iterator index.
int rpmteIsSource(rpmte te)
Retrieve isSource attribute of transaction element.
const char * rpmteD(rpmte te)
Retrieve distepoch string of transaction element.
rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
Set verify signatures flag(s).
void rpmteCleanDS(rpmte te)
Destroy dependency set info of transaction element.
rpmfi rpmfiInit(rpmfi fi, int fx)
Initialize file iterator index.
enum rpmfileState_e rpmfileState
File States (when installed).
struct rpmtsi_s * rpmtsi
Transaction element iterator.
void rpmteSetDBInstance(rpmte te, unsigned int instance)
Set last instance installed to the database.
rpmte rpmteParent(rpmte te)
Retrieve parent transaction element.
const char * rpmteO(rpmte te)
Retrieve os string of transaction element.
rpmfi rpmfiLink(rpmfi fi, const char *msg)
Reference a file info set instance.
static rpmte rpmteGetPool(rpmioPool pool)
static rpmte rpmtsiNextElement(rpmtsi tsi)
Return next transaction element.
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.
const char * rpmteE(rpmte te)
Retrieve epoch string of transaction element.
int rpmtsNElements(rpmts ts)
Return number of (ordered) transaction set elements.
rpmds rpmdsInit(rpmds ds)
Initialize dependency set iterator.
static void rpmteFini(void *_te)
Structures and prototypes used for an "rpmts" transaction set.
rpmfi rpmteSetFI(rpmte te, rpmfi fi)
rpmVSFlags rpmtsVSFlags(rpmts ts)
Get verify signatures flag(s).
rpmElementType rpmteType(rpmte te)
Retrieve type of transaction element.
rpmRelocation rpmfiDupeRelocations(rpmRelocation relocs, int *nrelocsp)
Duplicate a relocation array.
Header rpmteHeader(rpmte te)
Retrieve header from transaction element.
tsortInfo rpmteTSI(rpmte te)
Retrieve tsort info for transaction element.
static void
Print copy of spec file, filling in Group/Description/Summary from specspo.
static void addTE(rpmts ts, rpmte p, Header h, fnpyKey key, rpmRelocation relocs)
Initialize transaction element data from header.
const char * rpmteNEVR(rpmte te)
Retrieve name-version-release string from transaction element.
int rpmteFailed(rpmte te)
struct rpmfi_s * rpmfi
File info tag sets from a header, so that a header can be discarded early.
const char * rpmteR(rpmte te)
Retrieve release string of transaction element.
fnpyKey rpmteKey(rpmte te)
Retrieve key from transaction element.
Access RPM indices using Berkeley DB interface(s).
int rpmteDBOffset(rpmte te)
Retrieve rpmdb instance of TR_REMOVED transaction element.
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.
#define RPMDBI_PACKAGES
Pseudo-tags used by the rpmdb and rpmgi iterator API's.
uint32_t rpmteDBInstance(rpmte te)
Retrieve last instance installed to the database.
rpmuint32_t rpmtePkgFileSize(rpmte te)
Retrieve size in bytes of package file.
rpmtsi rpmtsiInit(rpmts ts)
Create transaction element iterator.
const char * rpmteHdrid(rpmte te)
Retrieve hdrid string from transaction element.
static PyObject *rpmds ds