Add bindings for rpmte and FD_t.
CVS patchset: 5451 CVS date: 2002/05/27 21:40:08
This commit is contained in:
parent
259bb824cc
commit
23bbe266cc
4
build.c
4
build.c
|
@ -31,11 +31,11 @@ static int checkSpec(rpmts ts, Header h)
|
|||
&& !headerIsEntry(h, RPMTAG_CONFLICTNAME))
|
||||
return 0;
|
||||
|
||||
rc = rpmtsAddPackage(ts, h, NULL, 0, NULL);
|
||||
rc = rpmtsAddInstallElement(ts, h, NULL, 0, NULL);
|
||||
|
||||
rc = rpmtsCheck(ts);
|
||||
|
||||
ps = rpmtsGetProblems(ts);
|
||||
ps = rpmtsProblems(ts);
|
||||
if (rc == 0 && ps) {
|
||||
rpmMessage(RPMMESS_ERROR, _("Failed build dependencies:\n"));
|
||||
printDepProblems(stderr, ps);
|
||||
|
|
118
lib/depends.c
118
lib/depends.c
|
@ -121,13 +121,13 @@ static int removePackage(rpmts ts, Header h, int dboffset,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int rpmtsAddPackage(rpmts ts, Header h,
|
||||
int rpmtsAddInstallElement(rpmts ts, Header h,
|
||||
fnpyKey key, int upgrade, rpmRelocation * relocs)
|
||||
{
|
||||
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
|
||||
int isSource;
|
||||
int duplicate = 0;
|
||||
rpmtei pi; rpmte p;
|
||||
rpmtsi pi; rpmte p;
|
||||
rpmds add;
|
||||
rpmds obsoletes;
|
||||
alKey pkgKey; /* addedPackages key */
|
||||
|
@ -142,7 +142,7 @@ int rpmtsAddPackage(rpmts ts, Header h,
|
|||
*/
|
||||
add = rpmdsThis(h, RPMTAG_REQUIRENAME, (RPMSENSE_EQUAL|RPMSENSE_LESS));
|
||||
pkgKey = RPMAL_NOMATCH;
|
||||
for (pi = rpmteiInit(ts), oc = 0; (p = rpmteiNext(pi, 0)) != NULL; oc++) {
|
||||
for (pi = rpmtsiInit(ts), oc = 0; (p = rpmtsiNext(pi, 0)) != NULL; oc++) {
|
||||
rpmds this;
|
||||
|
||||
/* XXX Only added packages need be checked for dupes. */
|
||||
|
@ -165,7 +165,7 @@ int rpmtsAddPackage(rpmts ts, Header h,
|
|||
break;
|
||||
}
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
add = rpmdsFree(add);
|
||||
|
||||
isSource = headerIsEntry(h, RPMTAG_SOURCEPACKAGE);
|
||||
|
@ -302,10 +302,11 @@ int rpmtsAddPackage(rpmts ts, Header h,
|
|||
ec = 0;
|
||||
|
||||
exit:
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
return ec;
|
||||
}
|
||||
|
||||
#ifdef DYING
|
||||
void rpmtsAvailablePackage(rpmts ts, Header h, fnpyKey key)
|
||||
{
|
||||
int scareMem = 0;
|
||||
|
@ -318,8 +319,9 @@ void rpmtsAvailablePackage(rpmts ts, Header h, fnpyKey key)
|
|||
fi = rpmfiFree(fi, 1);
|
||||
provides = rpmdsFree(provides);
|
||||
}
|
||||
#endif
|
||||
|
||||
int rpmtsRemovePackage(rpmts ts, Header h, int dboffset)
|
||||
int rpmtsAddEraseElement(rpmts ts, Header h, int dboffset)
|
||||
{
|
||||
return removePackage(ts, h, dboffset, RPMAL_NOMATCH);
|
||||
}
|
||||
|
@ -980,7 +982,7 @@ static inline int addRelation(rpmts ts,
|
|||
/*@globals fileSystem @*/
|
||||
/*@modifies ts, p, *selected, fileSystem @*/
|
||||
{
|
||||
rpmtei qi; rpmte q;
|
||||
rpmtsi qi; rpmte q;
|
||||
tsortInfo tsi;
|
||||
const char * Name;
|
||||
fnpyKey key;
|
||||
|
@ -1006,7 +1008,7 @@ fprintf(stderr, "addRelation: pkgKey %ld\n", (long)pkgKey);
|
|||
|
||||
/* XXX Set q to the added package that has pkgKey == q->u.addedKey */
|
||||
/* XXX FIXME: bsearch is possible/needed here */
|
||||
for (qi = rpmteiInit(ts), i = 0; (q = rpmteiNext(qi, 0)) != NULL; i++) {
|
||||
for (qi = rpmtsiInit(ts), i = 0; (q = rpmtsiNext(qi, 0)) != NULL; i++) {
|
||||
|
||||
/* XXX Only added packages need be checked for matches. */
|
||||
if (rpmteType(q) == TR_REMOVED)
|
||||
|
@ -1015,7 +1017,7 @@ fprintf(stderr, "addRelation: pkgKey %ld\n", (long)pkgKey);
|
|||
if (pkgKey == rpmteAddedKey(q))
|
||||
break;
|
||||
}
|
||||
qi = rpmteiFree(qi);
|
||||
qi = rpmtsiFree(qi);
|
||||
if (q == NULL || i == ts->orderCount)
|
||||
return 0;
|
||||
|
||||
|
@ -1150,9 +1152,9 @@ int rpmtsOrder(rpmts ts)
|
|||
#else
|
||||
int chainsaw = 1;
|
||||
#endif
|
||||
rpmtei pi; rpmte p;
|
||||
rpmtei qi; rpmte q;
|
||||
rpmtei ri; rpmte r;
|
||||
rpmtsi pi; rpmte p;
|
||||
rpmtsi qi; rpmte q;
|
||||
rpmtsi ri; rpmte r;
|
||||
tsortInfo tsi;
|
||||
tsortInfo tsi_next;
|
||||
alKey * ordering;
|
||||
|
@ -1196,16 +1198,16 @@ fprintf(stderr, "*** rpmtsOrder(%p) order %p[%d]\n", ts, ts->order, ts->orderCou
|
|||
ordering = alloca(sizeof(*ordering) * (numOrderList + 1));
|
||||
loopcheck = numOrderList;
|
||||
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, oType)) != NULL)
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, oType)) != NULL)
|
||||
rpmteNewTSI(p);
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
|
||||
/* Record all relations. */
|
||||
rpmMessage(RPMMESS_DEBUG, _("========== recording tsort relations\n"));
|
||||
pi = rpmteiInit(ts);
|
||||
pi = rpmtsiInit(ts);
|
||||
/* XXX Only added packages are ordered (for now). */
|
||||
while ((p = rpmteiNext(pi, oType)) != NULL) {
|
||||
while ((p = rpmtsiNext(pi, oType)) != NULL) {
|
||||
|
||||
if ((requires = rpmteDS(p, RPMTAG_REQUIRENAME)) == NULL)
|
||||
continue;
|
||||
|
@ -1213,7 +1215,7 @@ fprintf(stderr, "*** rpmtsOrder(%p) order %p[%d]\n", ts, ts->order, ts->orderCou
|
|||
memset(selected, 0, sizeof(*selected) * ts->orderCount);
|
||||
|
||||
/* Avoid narcisstic relations. */
|
||||
selected[rpmteiGetOc(pi)] = 1;
|
||||
selected[rpmtsiOc(pi)] = 1;
|
||||
|
||||
/* T2. Next "q <- p" relation. */
|
||||
|
||||
|
@ -1279,12 +1281,12 @@ fprintf(stderr, "*** rpmtsOrder(%p) order %p[%d]\n", ts, ts->order, ts->orderCou
|
|||
|
||||
}
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
|
||||
/* Save predecessor count and mark tree roots. */
|
||||
treex = 0;
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, oType)) != NULL) {
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, oType)) != NULL) {
|
||||
int npreds;
|
||||
|
||||
npreds = rpmteTSI(p)->tsi_count;
|
||||
|
@ -1301,25 +1303,25 @@ fprintf(stderr, "*** rpmtsOrder(%p) order %p[%d]\n", ts, ts->order, ts->orderCou
|
|||
|
||||
/*@-modfilesystem -nullpass @*/
|
||||
if (_tso_debug)
|
||||
/*@i@*/ fprintf(stderr, "\t+++ %p[%d] %s npreds %d\n", p, rpmteiGetOc(pi), rpmteNEVR(p), rpmteNpreds(p));
|
||||
/*@i@*/ fprintf(stderr, "\t+++ %p[%d] %s npreds %d\n", p, rpmtsiOc(pi), rpmteNEVR(p), rpmteNpreds(p));
|
||||
/*@=modfilesystem =nullpass @*/
|
||||
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
|
||||
/* T4. Scan for zeroes. */
|
||||
rpmMessage(RPMMESS_DEBUG, _("========== tsorting packages (order, #predecessors, #succesors, tree, depth)\n"));
|
||||
|
||||
rescan:
|
||||
if (pi != NULL) pi = rpmteiFree(pi);
|
||||
if (pi != NULL) pi = rpmtsiFree(pi);
|
||||
q = r = NULL;
|
||||
qlen = 0;
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, oType)) != NULL) {
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, oType)) != NULL) {
|
||||
|
||||
/* Prefer packages in chainsaw or presentation order. */
|
||||
if (!chainsaw)
|
||||
rpmteTSI(p)->tsi_qcnt = (ts->orderCount - rpmteiGetOc(pi));
|
||||
rpmteTSI(p)->tsi_qcnt = (ts->orderCount - rpmtsiOc(pi));
|
||||
|
||||
if (rpmteTSI(p)->tsi_count != 0)
|
||||
continue;
|
||||
|
@ -1332,7 +1334,7 @@ if (_tso_debug)
|
|||
prtTSI(" p", rpmteTSI(p));
|
||||
/*@=modfilesystem =nullpass @*/
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
|
||||
/* T5. Output front of queue (T7. Remove from queue.) */
|
||||
for (; q != NULL; q = rpmteTSI(q)->tsi_suc) {
|
||||
|
@ -1405,15 +1407,15 @@ prtTSI(" p", rpmteTSI(p));
|
|||
|
||||
/* Relink the queue in presentation order. */
|
||||
tsi = rpmteTSI(q);
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, oType)) != NULL) {
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, oType)) != NULL) {
|
||||
/* Is this element in the queue? */
|
||||
if (rpmteTSI(p)->tsi_reqx == 0)
|
||||
/*@innercontinue@*/ continue;
|
||||
tsi->tsi_suc = p;
|
||||
tsi = rpmteTSI(p);
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
tsi->tsi_suc = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1424,30 +1426,30 @@ prtTSI(" p", rpmteTSI(p));
|
|||
|
||||
/* T9. Initialize predecessor chain. */
|
||||
nzaps = 0;
|
||||
qi = rpmteiInit(ts);
|
||||
while ((q = rpmteiNext(qi, oType)) != NULL) {
|
||||
qi = rpmtsiInit(ts);
|
||||
while ((q = rpmtsiNext(qi, oType)) != NULL) {
|
||||
rpmteTSI(q)->tsi_chain = NULL;
|
||||
rpmteTSI(q)->tsi_reqx = 0;
|
||||
/* Mark packages already sorted. */
|
||||
if (rpmteTSI(q)->tsi_count == 0)
|
||||
rpmteTSI(q)->tsi_count = -1;
|
||||
}
|
||||
qi = rpmteiFree(qi);
|
||||
qi = rpmtsiFree(qi);
|
||||
|
||||
/* T10. Mark all packages with their predecessors. */
|
||||
qi = rpmteiInit(ts);
|
||||
while ((q = rpmteiNext(qi, oType)) != NULL) {
|
||||
qi = rpmtsiInit(ts);
|
||||
while ((q = rpmtsiNext(qi, oType)) != NULL) {
|
||||
if ((tsi = rpmteTSI(q)->tsi_next) == NULL)
|
||||
continue;
|
||||
rpmteTSI(q)->tsi_next = NULL;
|
||||
markLoop(tsi, q);
|
||||
rpmteTSI(q)->tsi_next = tsi;
|
||||
}
|
||||
qi = rpmteiFree(qi);
|
||||
qi = rpmtsiFree(qi);
|
||||
|
||||
/* T11. Print all dependency loops. */
|
||||
ri = rpmteiInit(ts);
|
||||
while ((r = rpmteiNext(ri, oType)) != NULL)
|
||||
ri = rpmtsiInit(ts);
|
||||
while ((r = rpmtsiNext(ri, oType)) != NULL)
|
||||
{
|
||||
int printed;
|
||||
|
||||
|
@ -1501,7 +1503,7 @@ prtTSI(" p", rpmteTSI(p));
|
|||
rpmteTSI(p)->tsi_reqx = 0;
|
||||
}
|
||||
}
|
||||
ri = rpmteiFree(ri);
|
||||
ri = rpmtsiFree(ri);
|
||||
|
||||
/* If a relation was eliminated, then continue sorting. */
|
||||
/* XXX TODO: add control bit. */
|
||||
|
@ -1517,10 +1519,10 @@ prtTSI(" p", rpmteTSI(p));
|
|||
}
|
||||
|
||||
/* Clean up tsort remnants (if any). */
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, 0)) != NULL)
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, 0)) != NULL)
|
||||
rpmteFreeTSI(p);
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
|
||||
/*
|
||||
* The order ends up as installed packages followed by removed packages,
|
||||
|
@ -1530,8 +1532,8 @@ prtTSI(" p", rpmteTSI(p));
|
|||
*/
|
||||
orderList = xcalloc(numOrderList, sizeof(*orderList));
|
||||
j = 0;
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, oType)) != NULL) {
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, oType)) != NULL) {
|
||||
/* Prepare added package ordering permutation. */
|
||||
switch (rpmteType(p)) {
|
||||
case TR_ADDED:
|
||||
|
@ -1541,10 +1543,10 @@ prtTSI(" p", rpmteTSI(p));
|
|||
orderList[j].pkgKey = RPMAL_NOMATCH;
|
||||
/*@switchbreak@*/ break;
|
||||
}
|
||||
orderList[j].orIndex = rpmteiGetOc(pi);
|
||||
orderList[j].orIndex = rpmtsiOc(pi);
|
||||
j++;
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
|
||||
qsort(orderList, numOrderList, sizeof(*orderList), orderListIndexCmp);
|
||||
|
||||
|
@ -1602,11 +1604,11 @@ assert(newOrderCount == ts->orderCount);
|
|||
|
||||
#ifdef DYING
|
||||
/* Clean up after dependency checks */
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, 0)) != NULL) {
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
||||
rpmteCleanDS(p);
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
|
||||
ts->addedPackages = rpmalFree(ts->addedPackages);
|
||||
ts->numAddedPackages = 0;
|
||||
|
@ -1655,7 +1657,7 @@ static int rpmdbCloseDBI(/*@null@*/ rpmdb db, int rpmtag)
|
|||
int rpmtsCheck(rpmts ts)
|
||||
{
|
||||
rpmdbMatchIterator mi = NULL;
|
||||
rpmtei pi = NULL; rpmte p;
|
||||
rpmtsi pi = NULL; rpmte p;
|
||||
int closeatexit = 0;
|
||||
int xx;
|
||||
int rc;
|
||||
|
@ -1677,8 +1679,8 @@ int rpmtsCheck(rpmts ts)
|
|||
* Look at all of the added packages and make sure their dependencies
|
||||
* are satisfied.
|
||||
*/
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, TR_ADDED)) != NULL) {
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, TR_ADDED)) != NULL) {
|
||||
rpmds provides;
|
||||
|
||||
rpmMessage(RPMMESS_DEBUG, "========== +++ %s\n" , rpmteNEVR(p));
|
||||
|
@ -1718,13 +1720,13 @@ int rpmtsCheck(rpmts ts)
|
|||
if (rc)
|
||||
goto exit;
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
|
||||
/*
|
||||
* Look at the removed packages and make sure they aren't critical.
|
||||
*/
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, TR_REMOVED)) != NULL) {
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, TR_REMOVED)) != NULL) {
|
||||
rpmds provides;
|
||||
rpmfi fi;
|
||||
|
||||
|
@ -1772,13 +1774,13 @@ int rpmtsCheck(rpmts ts)
|
|||
if (rc)
|
||||
goto exit;
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
|
||||
rc = 0;
|
||||
|
||||
exit:
|
||||
mi = rpmdbFreeIterator(mi);
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
/*@-branchstate@*/
|
||||
if (closeatexit)
|
||||
xx = rpmtsCloseDB(ts);
|
||||
|
|
|
@ -494,7 +494,7 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
|
|||
goto exit;
|
||||
}
|
||||
|
||||
(void) rpmtsAddPackage(ts, h, NULL, 0, NULL);
|
||||
(void) rpmtsAddInstallElement(ts, h, NULL, 0, NULL);
|
||||
|
||||
fi = rpmfiNew(ts, fi, h, RPMTAG_BASENAMES, scareMem);
|
||||
h = headerFree(h, "InstallSourcePackage");
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* Structure(s) used for dependency tag sets.
|
||||
*/
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@unchecked@*/
|
||||
extern int _rpmds_debug;
|
||||
|
||||
|
|
|
@ -485,7 +485,7 @@ Header relocateFileList(const rpmts ts, rpmfi fi,
|
|||
|
||||
/* XXX actions check prevents problem from being appended twice. */
|
||||
if (j == numValid && !allowBadRelocate && actions) {
|
||||
rpmps ps = rpmtsGetProblems(ts);
|
||||
rpmps ps = rpmtsProblems(ts);
|
||||
rpmpsAppend(ps, RPMPROB_BADRELOCATE,
|
||||
rpmteNEVR(p), rpmteKey(p),
|
||||
relocations[i].oldPath, NULL, NULL, 0);
|
||||
|
|
|
@ -454,7 +454,7 @@ restart:
|
|||
}
|
||||
|
||||
/*@-abstract@*/
|
||||
rc = rpmtsAddPackage(ts, eiu->h, (fnpyKey)fileName,
|
||||
rc = rpmtsAddInstallElement(ts, eiu->h, (fnpyKey)fileName,
|
||||
(ia->installInterfaceFlags & INSTALL_UPGRADE) != 0,
|
||||
relocations);
|
||||
/*@=abstract@*/
|
||||
|
@ -537,7 +537,7 @@ restart:
|
|||
stopInstall = 1;
|
||||
}
|
||||
|
||||
ps = rpmtsGetProblems(ts);
|
||||
ps = rpmtsProblems(ts);
|
||||
if (!stopInstall && ps) {
|
||||
rpmMessage(RPMMESS_ERROR, _("Failed dependencies:\n"));
|
||||
printDepProblems(stderr, ps);
|
||||
|
@ -579,7 +579,7 @@ restart:
|
|||
rpmMessage(RPMMESS_DEBUG, _("installing binary packages\n"));
|
||||
|
||||
rc = rpmtsRun(ts, NULL, probFilter);
|
||||
ps = rpmtsGetProblems(ts);
|
||||
ps = rpmtsProblems(ts);
|
||||
|
||||
if (rc < 0) {
|
||||
eiu->numFailed += eiu->numRPMS;
|
||||
|
@ -679,7 +679,7 @@ int rpmErase(rpmts ts,
|
|||
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
||||
unsigned int recOffset = rpmdbGetIteratorOffset(mi);
|
||||
if (recOffset) {
|
||||
(void) rpmtsRemovePackage(ts, h, recOffset);
|
||||
(void) rpmtsAddEraseElement(ts, h, recOffset);
|
||||
numPackages++;
|
||||
}
|
||||
}
|
||||
|
@ -694,7 +694,7 @@ int rpmErase(rpmts ts,
|
|||
stopUninstall = 1;
|
||||
}
|
||||
|
||||
ps = rpmtsGetProblems(ts);
|
||||
ps = rpmtsProblems(ts);
|
||||
if (!stopUninstall && ps) {
|
||||
rpmMessage(RPMMESS_ERROR, _("removing these packages would break "
|
||||
"dependencies:\n"));
|
||||
|
@ -708,7 +708,7 @@ int rpmErase(rpmts ts,
|
|||
if (!stopUninstall) {
|
||||
(void) rpmtsSetFlags(ts, (rpmtsFlags(ts) | RPMTRANS_FLAG_REVERSE));
|
||||
numFailed += rpmtsRun(ts, NULL, 0);
|
||||
ps = rpmtsGetProblems(ts);
|
||||
ps = rpmtsProblems(ts);
|
||||
ps = rpmpsFree(ps);
|
||||
}
|
||||
|
||||
|
@ -1013,7 +1013,7 @@ int rpmRollback(rpmts ts,
|
|||
|
||||
rpmMessage(RPMMESS_DEBUG, "\t+++ %s\n", rp->key);
|
||||
|
||||
rc = rpmtsAddPackage(ts, rp->h, (fnpyKey)rp->key,
|
||||
rc = rpmtsAddInstallElement(ts, rp->h, (fnpyKey)rp->key,
|
||||
0, ia->relocations);
|
||||
if (rc != 0)
|
||||
goto exit;
|
||||
|
@ -1038,7 +1038,7 @@ int rpmRollback(rpmts ts,
|
|||
rpmMessage(RPMMESS_DEBUG,
|
||||
"\t--- rpmdb instance #%u\n", ip->instance);
|
||||
|
||||
rc = rpmtsRemovePackage(ts, ip->instance);
|
||||
rc = rpmtsAddEraseElement(ts, ip->instance);
|
||||
if (rc != 0)
|
||||
goto exit;
|
||||
|
||||
|
@ -1065,7 +1065,7 @@ int rpmRollback(rpmts ts,
|
|||
packagesTotal, ctime(&tid));
|
||||
|
||||
rc = rpmtsCheck(ts);
|
||||
ps = rpmtsGetProblems(ts);
|
||||
ps = rpmtsProblems(ts);
|
||||
if (rc != 0 && ps) {
|
||||
rpmMessage(RPMMESS_ERROR, _("Failed dependencies:\n"));
|
||||
printDepProblems(stderr, ps);
|
||||
|
@ -1079,7 +1079,7 @@ int rpmRollback(rpmts ts,
|
|||
goto exit;
|
||||
|
||||
rc = rpmtsRun(ts, NULL, (ia->probFilter|RPMPROB_FILTER_OLDPACKAGE));
|
||||
ps = rpmtsGetProblems(ts);
|
||||
ps = rpmtsProblems(ts);
|
||||
if (rc > 0)
|
||||
rpmpsPrint(stderr, ps);
|
||||
ps = rpmpsFree(ps);
|
||||
|
|
62
lib/rpmte.c
62
lib/rpmte.c
|
@ -19,11 +19,11 @@
|
|||
#include "debug.h"
|
||||
|
||||
/*@unchecked@*/
|
||||
int _te_debug = 0;
|
||||
int _rpmte_debug = 0;
|
||||
|
||||
/*@access alKey @*/
|
||||
/*@access rpmtei @*/
|
||||
/*@access rpmte @*/
|
||||
/*@access rpmtsi @*/
|
||||
/*@access rpmts @*/
|
||||
|
||||
void rpmteCleanDS(rpmte te)
|
||||
|
@ -419,72 +419,72 @@ rpmfi rpmteFI(rpmte te, rpmTag tag)
|
|||
/*@=compdef =refcounttrans =retalias =retexpose =usereleased @*/
|
||||
}
|
||||
|
||||
int rpmteiGetOc(rpmtei tei)
|
||||
int rpmtsiOc(rpmtsi tsi)
|
||||
{
|
||||
return tei->ocsave;
|
||||
return tsi->ocsave;
|
||||
}
|
||||
|
||||
rpmtei XrpmteiFree(/*@only@*//*@null@*/ rpmtei tei,
|
||||
rpmtsi XrpmtsiFree(/*@only@*//*@null@*/ rpmtsi tsi,
|
||||
const char * fn, unsigned int ln)
|
||||
{
|
||||
if (tei)
|
||||
tei->ts = rpmtsUnlink(tei->ts, "tsIterator");
|
||||
if (tsi)
|
||||
tsi->ts = rpmtsUnlink(tsi->ts, "rpmtsiInit");
|
||||
/*@-modfilesys@*/
|
||||
if (_te_debug)
|
||||
fprintf(stderr, "*** tei %p -- %s:%d\n", tei, fn, ln);
|
||||
if (_rpmte_debug)
|
||||
fprintf(stderr, "*** tsi %p -- %s:%d\n", tsi, fn, ln);
|
||||
/*@=modfilesys@*/
|
||||
return _free(tei);
|
||||
return _free(tsi);
|
||||
}
|
||||
|
||||
rpmtei XrpmteiInit(rpmts ts, const char * fn, unsigned int ln)
|
||||
rpmtsi XrpmtsiInit(rpmts ts, const char * fn, unsigned int ln)
|
||||
{
|
||||
rpmtei tei = NULL;
|
||||
rpmtsi tsi = NULL;
|
||||
|
||||
tei = xcalloc(1, sizeof(*tei));
|
||||
tei->ts = rpmtsLink(ts, "rpmtei");
|
||||
tei->reverse = ((rpmtsFlags(ts) & RPMTRANS_FLAG_REVERSE) ? 1 : 0);
|
||||
tei->oc = (tei->reverse ? (rpmtsNElements(ts) - 1) : 0);
|
||||
tei->ocsave = tei->oc;
|
||||
tsi = xcalloc(1, sizeof(*tsi));
|
||||
tsi->ts = rpmtsLink(ts, "rpmtsi");
|
||||
tsi->reverse = ((rpmtsFlags(ts) & RPMTRANS_FLAG_REVERSE) ? 1 : 0);
|
||||
tsi->oc = (tsi->reverse ? (rpmtsNElements(ts) - 1) : 0);
|
||||
tsi->ocsave = tsi->oc;
|
||||
/*@-modfilesys@*/
|
||||
if (_te_debug)
|
||||
fprintf(stderr, "*** tei %p ++ %s:%d\n", tei, fn, ln);
|
||||
if (_rpmte_debug)
|
||||
fprintf(stderr, "*** tsi %p ++ %s:%d\n", tsi, fn, ln);
|
||||
/*@=modfilesys@*/
|
||||
return tei;
|
||||
return tsi;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return next transaction element.
|
||||
* @param tei transaction element iterator
|
||||
* @param tsi transaction element iterator
|
||||
* @return transaction element, NULL on termination
|
||||
*/
|
||||
static /*@dependent@*/ /*@null@*/
|
||||
rpmte rpmteiNextIterator(rpmtei tei)
|
||||
/*@modifies tei @*/
|
||||
rpmte rpmtsiNextElement(rpmtsi tsi)
|
||||
/*@modifies tsi @*/
|
||||
{
|
||||
rpmte te = NULL;
|
||||
int oc = -1;
|
||||
|
||||
if (tei == NULL || tei->ts == NULL || rpmtsNElements(tei->ts) <= 0)
|
||||
if (tsi == NULL || tsi->ts == NULL || rpmtsNElements(tsi->ts) <= 0)
|
||||
return te;
|
||||
|
||||
if (tei->reverse) {
|
||||
if (tei->oc >= 0) oc = tei->oc--;
|
||||
if (tsi->reverse) {
|
||||
if (tsi->oc >= 0) oc = tsi->oc--;
|
||||
} else {
|
||||
if (tei->oc < rpmtsNElements(tei->ts)) oc = tei->oc++;
|
||||
if (tsi->oc < rpmtsNElements(tsi->ts)) oc = tsi->oc++;
|
||||
}
|
||||
tei->ocsave = oc;
|
||||
tsi->ocsave = oc;
|
||||
/*@-branchstate@*/
|
||||
if (oc != -1)
|
||||
te = rpmtsElement(tei->ts, oc);
|
||||
te = rpmtsElement(tsi->ts, oc);
|
||||
/*@=branchstate@*/
|
||||
return te;
|
||||
}
|
||||
|
||||
rpmte rpmteiNext(rpmtei tei, rpmElementType type)
|
||||
rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type)
|
||||
{
|
||||
rpmte te;
|
||||
|
||||
while ((te = rpmteiNextIterator(tei)) != NULL) {
|
||||
while ((te = rpmtsiNextElement(tsi)) != NULL) {
|
||||
if (type == 0 || (te->type & type) != 0)
|
||||
break;
|
||||
}
|
||||
|
|
35
lib/rpmte.h
35
lib/rpmte.h
|
@ -6,6 +6,11 @@
|
|||
* Structures used for an "rpmte" transaction element.
|
||||
*/
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@unchecked@*/
|
||||
extern int _rpmte_debug;
|
||||
|
||||
/**
|
||||
* Transaction element ordering chain linkage.
|
||||
*/
|
||||
|
@ -14,7 +19,7 @@ typedef /*@abstract@*/ struct tsortInfo_s * tsortInfo;
|
|||
/**
|
||||
* Transaction element iterator.
|
||||
*/
|
||||
typedef /*@abstract@*/ struct rpmtei_s * rpmtei;
|
||||
typedef /*@abstract@*/ struct rpmtsi_s * rpmtsi;
|
||||
|
||||
/** \ingroup rpmte
|
||||
* Transaction element type.
|
||||
|
@ -121,7 +126,7 @@ struct rpmte_s {
|
|||
/**
|
||||
* Iterator across transaction elements, forward on install, backward on erase.
|
||||
*/
|
||||
struct rpmtei_s {
|
||||
struct rpmtsi_s {
|
||||
/*@refcounted@*/
|
||||
rpmts ts; /*!< transaction set. */
|
||||
int reverse; /*!< reversed traversal? */
|
||||
|
@ -441,33 +446,33 @@ rpmfi rpmteFI(rpmte te, rpmTag tag)
|
|||
|
||||
/**
|
||||
* Return transaction element index.
|
||||
* @param tei transaction element iterator
|
||||
* @param tsi transaction element iterator
|
||||
* @return transaction element index
|
||||
*/
|
||||
int rpmteiGetOc(rpmtei tei)
|
||||
int rpmtsiOc(rpmtsi tsi)
|
||||
/*@*/;
|
||||
|
||||
/**
|
||||
* Destroy transaction element iterator.
|
||||
* @param tei transaction element iterator
|
||||
* @param tsi transaction element iterator
|
||||
* @return NULL always
|
||||
*/
|
||||
/*@unused@*/ /*@null@*/
|
||||
rpmtei rpmteiFree(/*@only@*//*@null@*/ rpmtei tei)
|
||||
rpmtsi rpmtsiFree(/*@only@*//*@null@*/ rpmtsi tsi)
|
||||
/*@*/;
|
||||
|
||||
/**
|
||||
* Destroy transaction element iterator.
|
||||
* @param tei transaction element iterator
|
||||
* @param tsi transaction element iterator
|
||||
* @param fn
|
||||
* @param ln
|
||||
* @return NULL always
|
||||
*/
|
||||
/*@null@*/
|
||||
rpmtei XrpmteiFree(/*@only@*//*@null@*/ rpmtei tei,
|
||||
rpmtsi XrpmtsiFree(/*@only@*//*@null@*/ rpmtsi tsi,
|
||||
const char * fn, unsigned int ln)
|
||||
/*@*/;
|
||||
#define rpmteiFree(_tei) XrpmteiFree(_tei, __FILE__, __LINE__)
|
||||
#define rpmtsiFree(_tsi) XrpmtsiFree(_tsi, __FILE__, __LINE__)
|
||||
|
||||
/**
|
||||
* Create transaction element iterator.
|
||||
|
@ -475,7 +480,7 @@ rpmtei XrpmteiFree(/*@only@*//*@null@*/ rpmtei tei,
|
|||
* @return transaction element iterator
|
||||
*/
|
||||
/*@unused@*/ /*@only@*/
|
||||
rpmtei rpmteiInit(rpmts ts)
|
||||
rpmtsi rpmtsiInit(rpmts ts)
|
||||
/*@modifies ts @*/;
|
||||
|
||||
/**
|
||||
|
@ -486,20 +491,20 @@ rpmtei rpmteiInit(rpmts ts)
|
|||
* @return transaction element iterator
|
||||
*/
|
||||
/*@unused@*/ /*@only@*/
|
||||
rpmtei XrpmteiInit(rpmts ts,
|
||||
rpmtsi XrpmtsiInit(rpmts ts,
|
||||
const char * fn, unsigned int ln)
|
||||
/*@modifies ts @*/;
|
||||
#define rpmteiInit(_ts) XrpmteiInit(_ts, __FILE__, __LINE__)
|
||||
#define rpmtsiInit(_ts) XrpmtsiInit(_ts, __FILE__, __LINE__)
|
||||
|
||||
/**
|
||||
* Return next transaction element of type.
|
||||
* @param tei transaction element iterator
|
||||
* @param tsi transaction element iterator
|
||||
* @param type transaction element type selector (0 for any)
|
||||
* @return next transaction element of type, NULL on termination
|
||||
*/
|
||||
/*@dependent@*/ /*@null@*/
|
||||
rpmte rpmteiNext(rpmtei tei, rpmElementType type)
|
||||
/*@modifies tei @*/;
|
||||
rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type)
|
||||
/*@modifies tsi @*/;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
26
lib/rpmts.c
26
lib/rpmts.c
|
@ -311,7 +311,7 @@ int rpmtsAvailable(rpmts ts, const rpmds ds)
|
|||
/*@=nullstate@*/
|
||||
}
|
||||
|
||||
rpmps rpmtsGetProblems(rpmts ts)
|
||||
rpmps rpmtsProblems(rpmts ts)
|
||||
{
|
||||
rpmps ps = NULL;
|
||||
if (ts) {
|
||||
|
@ -326,13 +326,13 @@ rpmps rpmtsGetProblems(rpmts ts)
|
|||
void rpmtsClean(rpmts ts)
|
||||
{
|
||||
if (ts) {
|
||||
rpmtei pi; rpmte p;
|
||||
rpmtsi pi; rpmte p;
|
||||
|
||||
/* Clean up after dependency checks. */
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, 0)) != NULL)
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, 0)) != NULL)
|
||||
rpmteCleanDS(p);
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
|
||||
ts->addedPackages = rpmalFree(ts->addedPackages);
|
||||
ts->numAddedPackages = 0;
|
||||
|
@ -353,7 +353,7 @@ void rpmtsClean(rpmts ts)
|
|||
rpmts rpmtsFree(rpmts ts)
|
||||
{
|
||||
if (ts) {
|
||||
rpmtei pi; rpmte p;
|
||||
rpmtsi pi; rpmte p;
|
||||
int oc;
|
||||
|
||||
(void) rpmtsUnlink(ts, "tsCreate");
|
||||
|
@ -379,12 +379,12 @@ rpmts rpmtsFree(rpmts ts)
|
|||
ts->rootDir = _free(ts->rootDir);
|
||||
ts->currDir = _free(ts->currDir);
|
||||
|
||||
for (pi = rpmteiInit(ts), oc = 0; (p = rpmteiNext(pi, 0)) != NULL; oc++) {
|
||||
for (pi = rpmtsiInit(ts), oc = 0; (p = rpmtsiNext(pi, 0)) != NULL; oc++) {
|
||||
/*@-type -unqualifiedtrans @*/
|
||||
ts->order[oc] = rpmteFree(ts->order[oc]);
|
||||
/*@=type =unqualifiedtrans @*/
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
/*@-type +voidabstract @*/ /* FIX: double indirection */
|
||||
ts->order = _free(ts->order);
|
||||
/*@=type =voidabstract @*/
|
||||
|
@ -678,7 +678,7 @@ void rpmtsCheckDSIProblems(const rpmts ts, const rpmte te)
|
|||
if (fc <= 0)
|
||||
return;
|
||||
|
||||
ps = rpmtsGetProblems(ts);
|
||||
ps = rpmtsProblems(ts);
|
||||
for (i = 0; i < ts->filesystemCount; i++, dsi++) {
|
||||
|
||||
/* XXX Avoid FAT and other file systems that have not inodes. */
|
||||
|
@ -775,12 +775,12 @@ int rpmtsGetKeys(const rpmts ts, fnpyKey ** ep, int * nep)
|
|||
|
||||
if (nep) *nep = ts->orderCount;
|
||||
if (ep) {
|
||||
rpmtei pi; rpmte p;
|
||||
rpmtsi pi; rpmte p;
|
||||
fnpyKey * e;
|
||||
|
||||
*ep = e = xmalloc(ts->orderCount * sizeof(*e));
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, 0)) != NULL) {
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
||||
switch (rpmteType(p)) {
|
||||
case TR_ADDED:
|
||||
/*@-dependenttrans@*/
|
||||
|
@ -794,7 +794,7 @@ int rpmtsGetKeys(const rpmts ts, fnpyKey ** ep, int * nep)
|
|||
}
|
||||
e++;
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
|
12
lib/rpmts.h
12
lib/rpmts.h
|
@ -104,9 +104,11 @@ struct rpmts_s {
|
|||
rpmal addedPackages; /*!< Set of packages being installed. */
|
||||
int numAddedPackages; /*!< No. added package instances. */
|
||||
|
||||
#ifndef DYING
|
||||
/*@only@*/
|
||||
rpmal availablePackages; /*!< Universe of available packages. */
|
||||
int numAvailablePackages; /*!< No. available package instances. */
|
||||
#endif
|
||||
|
||||
/*@owned@*/
|
||||
rpmte * order; /*!< Packages sorted by dependencies. */
|
||||
|
@ -288,12 +290,12 @@ int rpmtsAvailable(rpmts ts, const rpmds ds)
|
|||
/*@modifies ts, fileSystem @*/;
|
||||
|
||||
/**
|
||||
* Return (and clear) current transaction set problems.
|
||||
* Return current transaction set problems.
|
||||
* @param ts transaction set
|
||||
* @return current problem set (or NULL)
|
||||
*/
|
||||
/*@null@*/
|
||||
rpmps rpmtsGetProblems(rpmts ts)
|
||||
rpmps rpmtsProblems(rpmts ts)
|
||||
/*@modifies ts @*/;
|
||||
|
||||
/** \ingroup rpmts
|
||||
|
@ -544,12 +546,13 @@ rpmts rpmtsCreate(void)
|
|||
* @param relocs package file relocations
|
||||
* @return 0 on success, 1 on I/O error, 2 needs capabilities
|
||||
*/
|
||||
int rpmtsAddPackage(rpmts ts, Header h,
|
||||
int rpmtsAddInstallElement(rpmts ts, Header h,
|
||||
/*@exposed@*/ /*@null@*/ const fnpyKey key, int upgrade,
|
||||
/*@null@*/ rpmRelocation * relocs)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies ts, h, fileSystem, internalState @*/;
|
||||
|
||||
#ifdef DYING
|
||||
/** \ingroup rpmts
|
||||
* Add package to universe of possible packages to install in transaction set.
|
||||
* @warning The key parameter is non-functional.
|
||||
|
@ -561,6 +564,7 @@ int rpmtsAddPackage(rpmts ts, Header h,
|
|||
void rpmtsAvailablePackage(rpmts ts, Header h,
|
||||
/*@exposed@*/ /*@null@*/ fnpyKey key)
|
||||
/*@modifies h, ts @*/;
|
||||
#endif
|
||||
|
||||
/** \ingroup rpmts
|
||||
* Add package to be erased to transaction set.
|
||||
|
@ -569,7 +573,7 @@ void rpmtsAvailablePackage(rpmts ts, Header h,
|
|||
* @param dboffset rpm database instance
|
||||
* @return 0 on success
|
||||
*/
|
||||
int rpmtsRemovePackage(rpmts ts, Header h, int dboffset)
|
||||
int rpmtsAddEraseElement(rpmts ts, Header h, int dboffset)
|
||||
/*@modifies ts, h @*/;
|
||||
|
||||
/** \ingroup rpmts
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
/*@access rpmfi @*/
|
||||
|
||||
/*@access rpmtei @*/
|
||||
/*@access rpmtsi @*/
|
||||
/*@access rpmts @*/
|
||||
|
||||
/**
|
||||
|
@ -244,7 +244,7 @@ static int handleInstInstalledFiles(const rpmts ts,
|
|||
|
||||
fi->replaced = xcalloc(sharedCount, sizeof(*fi->replaced));
|
||||
|
||||
ps = rpmtsGetProblems(ts);
|
||||
ps = rpmtsProblems(ts);
|
||||
for (i = 0; i < sharedCount; i++, shared++) {
|
||||
int otherFileNum, fileNum;
|
||||
|
||||
|
@ -497,7 +497,7 @@ static void handleOverlappedFiles(const rpmts ts,
|
|||
const char * fn;
|
||||
int i, j;
|
||||
|
||||
ps = rpmtsGetProblems(ts);
|
||||
ps = rpmtsProblems(ts);
|
||||
fi = rpmfiInit(fi, 0);
|
||||
if (fi != NULL)
|
||||
while ((i = rpmfiNext(fi)) >= 0) {
|
||||
|
@ -692,7 +692,7 @@ static int ensureOlder(rpmts ts,
|
|||
req = rpmdsFree(req);
|
||||
|
||||
if (rc == 0) {
|
||||
rpmps ps = rpmtsGetProblems(ts);
|
||||
rpmps ps = rpmtsProblems(ts);
|
||||
const char * altNEVR = hGetNEVR(h, NULL);
|
||||
rpmpsAppend(ps, RPMPROB_OLDPACKAGE,
|
||||
rpmteNEVR(p), rpmteKey(p),
|
||||
|
@ -907,18 +907,18 @@ static void skipFiles(const rpmts ts, rpmfi fi)
|
|||
/**
|
||||
* Return transaction element's file info.
|
||||
* @todo Take a rpmfi refcount here.
|
||||
* @param tei transaction element iterator
|
||||
* @param tsi transaction element iterator
|
||||
* @return transaction element file info
|
||||
*/
|
||||
static /*@null@*/
|
||||
rpmfi rpmteiGetFi(const rpmtei tei)
|
||||
rpmfi rpmtsiFi(const rpmtsi tsi)
|
||||
/*@*/
|
||||
{
|
||||
rpmfi fi = NULL;
|
||||
|
||||
if (tei != NULL && tei->ocsave != -1) {
|
||||
if (tsi != NULL && tsi->ocsave != -1) {
|
||||
/*@-type -abstract@*/ /* FIX: rpmte not opaque */
|
||||
rpmte te = rpmtsElement(tei->ts, tei->ocsave);
|
||||
rpmte te = rpmtsElement(tsi->ts, tsi->ocsave);
|
||||
/*@-assignexpose@*/
|
||||
if (te != NULL && (fi = te->fi) != NULL)
|
||||
fi->te = te;
|
||||
|
@ -945,8 +945,8 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
|||
fingerPrintCache fpc;
|
||||
rpmps ps;
|
||||
PSM_t psm = memset(alloca(sizeof(*psm)), 0, sizeof(*psm));
|
||||
rpmtei pi; rpmte p;
|
||||
rpmtei qi; rpmte q;
|
||||
rpmtsi pi; rpmte p;
|
||||
rpmtsi qi; rpmte q;
|
||||
int xx;
|
||||
|
||||
/* FIXME: what if the same package is included in ts twice? */
|
||||
|
@ -989,14 +989,14 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
|||
* For packages being removed:
|
||||
* - count files.
|
||||
*/
|
||||
ps = rpmtsGetProblems(ts);
|
||||
ps = rpmtsProblems(ts);
|
||||
/* The ordering doesn't matter here */
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, TR_ADDED)) != NULL) {
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, TR_ADDED)) != NULL) {
|
||||
rpmdbMatchIterator mi;
|
||||
int fc;
|
||||
|
||||
if ((fi = rpmteiGetFi(pi)) == NULL)
|
||||
if ((fi = rpmtsiFi(pi)) == NULL)
|
||||
continue; /* XXX can't happen */
|
||||
fc = rpmfiFC(fi);
|
||||
|
||||
|
@ -1044,21 +1044,21 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
|||
totalFileCount += fc;
|
||||
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
ps = rpmpsFree(ps);
|
||||
|
||||
/* The ordering doesn't matter here */
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, TR_REMOVED)) != NULL) {
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, TR_REMOVED)) != NULL) {
|
||||
int fc;
|
||||
|
||||
if ((fi = rpmteiGetFi(pi)) == NULL)
|
||||
if ((fi = rpmtsiFi(pi)) == NULL)
|
||||
continue; /* XXX can't happen */
|
||||
fc = rpmfiFC(fi);
|
||||
|
||||
totalFileCount += fc;
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
|
||||
/* ===============================================
|
||||
* Initialize transaction element file info for package:
|
||||
|
@ -1069,15 +1069,15 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
|||
* calling fpLookupList only once. I'm not sure that the speedup is
|
||||
* worth the trouble though.
|
||||
*/
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, 0)) != NULL) {
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
||||
int fc;
|
||||
|
||||
if ((fi = rpmteiGetFi(pi)) == NULL)
|
||||
if ((fi = rpmtsiFi(pi)) == NULL)
|
||||
continue; /* XXX can't happen */
|
||||
fc = rpmfiFC(fi);
|
||||
|
||||
#ifdef DYING /* XXX W2DO? this is now done in rpmteiGetFi, okay ??? */
|
||||
#ifdef DYING /* XXX W2DO? this is now done in rpmtsiFi, okay ??? */
|
||||
fi->magic = RPMFIMAGIC;
|
||||
fi->te = p;
|
||||
#endif
|
||||
|
@ -1098,7 +1098,7 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
|||
|
||||
fi->fps = (fc > 0 ? xmalloc(fc * sizeof(*fi->fps)) : NULL);
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
|
||||
if (!rpmtsChrootDone(ts)) {
|
||||
const char * rootDir = rpmtsRootDir(ts);
|
||||
|
@ -1116,11 +1116,11 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
|||
/* ===============================================
|
||||
* Add fingerprint for each file not skipped.
|
||||
*/
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, 0)) != NULL) {
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
||||
int fc;
|
||||
|
||||
if ((fi = rpmteiGetFi(pi)) == NULL)
|
||||
if ((fi = rpmtsiFi(pi)) == NULL)
|
||||
continue; /* XXX can't happen */
|
||||
fc = rpmfiFC(fi);
|
||||
|
||||
|
@ -1137,7 +1137,7 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
|||
}
|
||||
/*@=branchstate@*/
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
|
||||
NOTIFY(ts, (NULL, RPMCALLBACK_TRANS_START, 6, ts->orderCount,
|
||||
NULL, ts->notifyData));
|
||||
|
@ -1145,18 +1145,18 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
|||
/* ===============================================
|
||||
* Compute file disposition for each package in transaction set.
|
||||
*/
|
||||
ps = rpmtsGetProblems(ts);
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, 0)) != NULL) {
|
||||
ps = rpmtsProblems(ts);
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
||||
dbiIndexSet * matches;
|
||||
int knownBad;
|
||||
int fc;
|
||||
|
||||
if ((fi = rpmteiGetFi(pi)) == NULL)
|
||||
if ((fi = rpmtsiFi(pi)) == NULL)
|
||||
continue; /* XXX can't happen */
|
||||
fc = rpmfiFC(fi);
|
||||
|
||||
NOTIFY(ts, (NULL, RPMCALLBACK_TRANS_PROGRESS, rpmteiGetOc(pi),
|
||||
NOTIFY(ts, (NULL, RPMCALLBACK_TRANS_PROGRESS, rpmtsiOc(pi),
|
||||
ts->orderCount, NULL, ts->notifyData));
|
||||
|
||||
if (fc == 0) continue;
|
||||
|
@ -1187,14 +1187,14 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
|||
int ro;
|
||||
ro = dbiIndexRecordOffset(matches[i], j);
|
||||
knownBad = 0;
|
||||
qi = rpmteiInit(ts);
|
||||
while ((q = rpmteiNext(qi, TR_REMOVED)) != NULL) {
|
||||
qi = rpmtsiInit(ts);
|
||||
while ((q = rpmtsiNext(qi, TR_REMOVED)) != NULL) {
|
||||
if (ro == knownBad)
|
||||
/*@innerbreak@*/ break;
|
||||
if (rpmteDBOffset(q) == ro)
|
||||
knownBad = ro;
|
||||
}
|
||||
qi = rpmteiFree(qi);
|
||||
qi = rpmtsiFree(qi);
|
||||
|
||||
shared->pkgFileNum = i;
|
||||
shared->otherPkg = dbiIndexRecordOffset(matches[i], j);
|
||||
|
@ -1262,7 +1262,7 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
|||
/*@switchbreak@*/ break;
|
||||
}
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
ps = rpmpsFree(ps);
|
||||
|
||||
if (rpmtsChrootDone(ts)) {
|
||||
|
@ -1281,15 +1281,15 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
|||
/* ===============================================
|
||||
* Free unused memory as soon as possible.
|
||||
*/
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, 0)) != NULL) {
|
||||
if ((fi = rpmteiGetFi(pi)) == NULL)
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
||||
if ((fi = rpmtsiFi(pi)) == NULL)
|
||||
continue; /* XXX can't happen */
|
||||
if (rpmfiFC(fi) == 0)
|
||||
continue;
|
||||
fi->fps = _free(fi->fps);
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
|
||||
fpc = fpCacheFree(fpc);
|
||||
ts->ht = htFree(ts->ht);
|
||||
|
@ -1311,9 +1311,9 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
|||
* Save removed files before erasing.
|
||||
*/
|
||||
if (rpmtsFlags(ts) & (RPMTRANS_FLAG_DIRSTASH | RPMTRANS_FLAG_REPACKAGE)) {
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, 0)) != NULL) {
|
||||
fi = rpmteiGetFi(pi);
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
||||
fi = rpmtsiFi(pi);
|
||||
switch (rpmteType(p)) {
|
||||
case TR_ADDED:
|
||||
/*@switchbreak@*/ break;
|
||||
|
@ -1329,21 +1329,21 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
|||
/*@switchbreak@*/ break;
|
||||
}
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
}
|
||||
|
||||
/* ===============================================
|
||||
* Install and remove packages.
|
||||
*/
|
||||
lastKey = (alKey)-2; /* erased packages have -1 */
|
||||
pi = rpmteiInit(ts);
|
||||
pi = rpmtsiInit(ts);
|
||||
/*@-branchstate@*/ /* FIX: fi reload needs work */
|
||||
while ((p = rpmteiNext(pi, 0)) != NULL) {
|
||||
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
||||
alKey pkgKey;
|
||||
int gotfd;
|
||||
|
||||
gotfd = 0;
|
||||
if ((fi = rpmteiGetFi(pi)) == NULL)
|
||||
if ((fi = rpmtsiFi(pi)) == NULL)
|
||||
continue; /* XXX can't happen */
|
||||
|
||||
psm->te = p;
|
||||
|
@ -1448,7 +1448,7 @@ fi->actions = actions;
|
|||
/*@=type@*/
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
|
||||
psm->ts = rpmtsUnlink(psm->ts, "tsRun");
|
||||
|
||||
|
|
4
lib/ts.c
4
lib/ts.c
|
@ -185,7 +185,7 @@ static int ftsPrint(FTS * ftsp, FTSENT * fts, rpmts ts)
|
|||
indent * (fts->fts_level < 0 ? 0 : fts->fts_level), "",
|
||||
n, v, r);
|
||||
#ifdef NOTYET
|
||||
xx = rpmtsAddPackage(ts, h, fts->fts_path, 1, NULL);
|
||||
xx = rpmtsAddInstallElement(ts, h, fts->fts_path, 1, NULL);
|
||||
#endif
|
||||
|
||||
break;
|
||||
|
@ -374,7 +374,7 @@ if (!_debug) {
|
|||
|
||||
xx = rpmtsCheck(ts);
|
||||
|
||||
ps = rpmtsGetProblems(ts);
|
||||
ps = rpmtsProblems(ts);
|
||||
if (ps) {
|
||||
rpmMessage(RPMMESS_ERROR, _("Failed dependencies:\n"));
|
||||
printDepProblems(stderr, ps);
|
||||
|
|
|
@ -357,10 +357,10 @@ static int verifyDependencies(/*@unused@*/ QVA_t qva, rpmts ts,
|
|||
int i;
|
||||
|
||||
rpmtsClean(ts);
|
||||
(void) rpmtsAddPackage(ts, h, NULL, 0, NULL);
|
||||
(void) rpmtsAddInstallElement(ts, h, NULL, 0, NULL);
|
||||
|
||||
xx = rpmtsCheck(ts);
|
||||
ps = rpmtsGetProblems(ts);
|
||||
ps = rpmtsProblems(ts);
|
||||
|
||||
/*@-branchstate@*/
|
||||
if (ps) {
|
||||
|
|
|
@ -14,7 +14,8 @@ INCLUDES = -I. \
|
|||
@INCPATH@
|
||||
|
||||
noinst_HEADERS = db-py.h hash.h header-py.h \
|
||||
rpmal-py.h rpmds-py.h rpmfi-py.h rpmts-py.h upgrade.h
|
||||
rpmal-py.h rpmds-py.h rpmfd-py.h rpmfi-py.h rpmte-py.h rpmts-py.h \
|
||||
upgrade.h
|
||||
|
||||
mylibs= \
|
||||
$(top_builddir)/lib/.libs/librpm.so \
|
||||
|
@ -35,7 +36,8 @@ poptmodule_so_LDFLAGS = $(mylibs) $(LIBS) -shared -Wl,-soname,poptmodule.so
|
|||
|
||||
noinst_LTLIBRARIES = librpmmodule.la
|
||||
librpmmodule_la_SOURCES = rpmmodule.c hash.c upgrade.c \
|
||||
db-py.c header-py.c rpmal-py.c rpmds-py.c rpmfi-py.c rpmts-py.c
|
||||
db-py.c header-py.c rpmal-py.c rpmds-py.c rpmfd-py.c rpmfi-py.c \
|
||||
rpmte-py.c rpmts-py.c
|
||||
|
||||
rpmmodule.so$(EXEEXT): $(librpmmodule_la_OBJECTS)
|
||||
$(CC) -o $@ $(librpmmodule_la_OBJECTS) $(rpmmodule_so_LDFLAGS)
|
||||
|
|
|
@ -209,7 +209,8 @@ INCLUDES = -I. \
|
|||
|
||||
|
||||
noinst_HEADERS = db-py.h hash.h header-py.h \
|
||||
rpmal-py.h rpmds-py.h rpmfi-py.h rpmts-py.h upgrade.h
|
||||
rpmal-py.h rpmds-py.h rpmfd-py.h rpmfi-py.h rpmte-py.h rpmts-py.h \
|
||||
upgrade.h
|
||||
|
||||
|
||||
mylibs = \
|
||||
|
@ -232,7 +233,8 @@ poptmodule_so_LDFLAGS = $(mylibs) $(LIBS) -shared -Wl,-soname,poptmodule.so
|
|||
|
||||
noinst_LTLIBRARIES = librpmmodule.la
|
||||
librpmmodule_la_SOURCES = rpmmodule.c hash.c upgrade.c \
|
||||
db-py.c header-py.c rpmal-py.c rpmds-py.c rpmfi-py.c rpmts-py.c
|
||||
db-py.c header-py.c rpmal-py.c rpmds-py.c rpmfd-py.c rpmfi-py.c \
|
||||
rpmte-py.c rpmts-py.c
|
||||
|
||||
subdir = python
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
|
@ -243,7 +245,8 @@ LTLIBRARIES = $(noinst_LTLIBRARIES)
|
|||
librpmmodule_la_LDFLAGS =
|
||||
librpmmodule_la_LIBADD =
|
||||
am_librpmmodule_la_OBJECTS = rpmmodule.lo hash.lo upgrade.lo db-py.lo \
|
||||
header-py.lo rpmal-py.lo rpmds-py.lo rpmfi-py.lo rpmts-py.lo
|
||||
header-py.lo rpmal-py.lo rpmds-py.lo rpmfd-py.lo rpmfi-py.lo \
|
||||
rpmte-py.lo rpmts-py.lo
|
||||
librpmmodule_la_OBJECTS = $(am_librpmmodule_la_OBJECTS)
|
||||
python_PROGRAMS = rpmmodule.so$(EXEEXT) poptmodule.so$(EXEEXT)
|
||||
PROGRAMS = $(python_PROGRAMS)
|
||||
|
@ -267,7 +270,8 @@ am__depfiles_maybe = depfiles
|
|||
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/db-py.Plo ./$(DEPDIR)/hash.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/header-py.Plo ./$(DEPDIR)/poptmodule.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/rpmal-py.Plo ./$(DEPDIR)/rpmds-py.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/rpmfi-py.Plo ./$(DEPDIR)/rpmmodule.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/rpmfd-py.Plo ./$(DEPDIR)/rpmfi-py.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/rpmmodule.Plo ./$(DEPDIR)/rpmte-py.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/rpmts-py.Plo ./$(DEPDIR)/upgrade.Plo
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
|
@ -338,8 +342,10 @@ distclean-compile:
|
|||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poptmodule.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmal-py.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmds-py.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmfd-py.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmfi-py.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmmodule.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmte-py.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmts-py.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upgrade.Plo@am__quote@
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ rpmmi_Pattern(rpmmiObject * s, PyObject * args) {
|
|||
PyObject *TagN = NULL;
|
||||
int type;
|
||||
char * pattern;
|
||||
int tag;
|
||||
rpmTag tag;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "Ois:Pattern", &TagN, &type, &pattern))
|
||||
return NULL;
|
||||
|
|
|
@ -0,0 +1,215 @@
|
|||
/** \ingroup python
|
||||
* \file python/rpmfd-py.c
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#include <glob.h> /* XXX rpmio.h */
|
||||
#include <dirent.h> /* XXX rpmio.h */
|
||||
#include <rpmio_internal.h>
|
||||
#include <rpmlib.h> /* XXX _free */
|
||||
|
||||
#include "header-py.h" /* XXX pyrpmError */
|
||||
#include "rpmfd-py.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
extern int _rpmio_debug;
|
||||
|
||||
/** \ingroup python
|
||||
* \name Class: rpm.fd
|
||||
* \class rpm.fd
|
||||
* \brief An python rpm.fd object represents an rpm I/O handle.
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
rpmfd_Debug(rpmfdObject * s, PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "i", &_rpmio_debug)) return NULL;
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef struct FDlist_t FDlist;
|
||||
|
||||
/**
|
||||
*/
|
||||
struct FDlist_t {
|
||||
FILE * f;
|
||||
FD_t fd;
|
||||
const char * note;
|
||||
FDlist * next;
|
||||
} ;
|
||||
|
||||
/**
|
||||
*/
|
||||
static FDlist *fdhead = NULL;
|
||||
|
||||
/**
|
||||
*/
|
||||
static FDlist *fdtail = NULL;
|
||||
|
||||
/**
|
||||
*/
|
||||
static int closeCallback(FILE * f)
|
||||
{
|
||||
FDlist *node, *last;
|
||||
|
||||
node = fdhead;
|
||||
last = NULL;
|
||||
while (node) {
|
||||
if (node->f == f)
|
||||
break;
|
||||
last = node;
|
||||
node = node->next;
|
||||
}
|
||||
if (node) {
|
||||
if (last)
|
||||
last->next = node->next;
|
||||
else
|
||||
fdhead = node->next;
|
||||
node->note = _free (node->note);
|
||||
node->fd = fdLink(node->fd, "closeCallback");
|
||||
Fclose (node->fd);
|
||||
while (node->fd)
|
||||
node->fd = fdFree(node->fd, "closeCallback");
|
||||
node = _free (node);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
static PyObject *
|
||||
rpmfd_Fopen(PyObject * self, PyObject * args)
|
||||
{
|
||||
char * path, * mode;
|
||||
FDlist *node;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ss", &path, &mode))
|
||||
return NULL;
|
||||
|
||||
node = xmalloc (sizeof(FDlist));
|
||||
|
||||
node->fd = Fopen(path, mode);
|
||||
node->fd = fdLink(node->fd, "doFopen");
|
||||
node->note = xstrdup (path);
|
||||
|
||||
if (!node->fd) {
|
||||
PyErr_SetFromErrno(pyrpmError);
|
||||
node = _free (node);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (Ferror(node->fd)) {
|
||||
const char *err = Fstrerror(node->fd);
|
||||
node = _free(node);
|
||||
if (err) {
|
||||
PyErr_SetString(pyrpmError, err);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
node->f = fdGetFp(node->fd);
|
||||
if (!node->f) {
|
||||
PyErr_SetString(pyrpmError, "FD_t has no FILE*");
|
||||
free(node);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
node->next = NULL;
|
||||
if (!fdhead) {
|
||||
fdhead = fdtail = node;
|
||||
} else if (fdtail) {
|
||||
fdtail->next = node;
|
||||
} else {
|
||||
fdhead = node;
|
||||
}
|
||||
fdtail = node;
|
||||
|
||||
return PyFile_FromFile (node->f, path, mode, closeCallback);
|
||||
}
|
||||
|
||||
/** \ingroup python
|
||||
*/
|
||||
static struct PyMethodDef rpmfd_methods[] = {
|
||||
{"Debug", (PyCFunction)rpmfd_Debug, METH_VARARGS,
|
||||
NULL},
|
||||
{"Fopen", (PyCFunction)rpmfd_Fopen, METH_VARARGS,
|
||||
NULL},
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
/* ---------- */
|
||||
|
||||
/** \ingroup python
|
||||
*/
|
||||
static PyObject * rpmfd_getattr(rpmfdObject * o, char * name)
|
||||
{
|
||||
return Py_FindMethod(rpmfd_methods, (PyObject *) o, name);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
static char rpmfd_doc[] =
|
||||
"";
|
||||
|
||||
/** \ingroup python
|
||||
*/
|
||||
PyTypeObject rpmfd_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
"rpm.io", /* tp_name */
|
||||
sizeof(rpmfdObject), /* tp_size */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)0, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
(getattrfunc) rpmfd_getattr, /* tp_getattr */
|
||||
(setattrfunc)0, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
0, /* tp_getattro */
|
||||
0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT, /* tp_flags */
|
||||
rpmfd_doc, /* tp_doc */
|
||||
#if Py_TPFLAGS_HAVE_ITER
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
rpmfd_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
0, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
0, /* tp_new */
|
||||
0, /* tp_free */
|
||||
0, /* tp_is_gc */
|
||||
#endif
|
||||
};
|
||||
|
||||
rpmfdObject * rpmfd_Wrap(FD_t fd)
|
||||
{
|
||||
rpmfdObject *s = PyObject_NEW(rpmfdObject, &rpmfd_Type);
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
s->fd = fd;
|
||||
return s;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef H_RPMFD_PY
|
||||
#define H_RPMFD_PY
|
||||
|
||||
/** \ingroup python
|
||||
* \file python/rpmfd-py.h
|
||||
*/
|
||||
|
||||
typedef struct rpmfdObject_s {
|
||||
PyObject_HEAD
|
||||
FD_t fd;
|
||||
} rpmfdObject;
|
||||
|
||||
extern PyTypeObject rpmfd_Type;
|
||||
|
||||
rpmfdObject * rpmfd_Wrap(FD_t fd);
|
||||
|
||||
#endif
|
|
@ -4,25 +4,13 @@
|
|||
|
||||
#include "system.h"
|
||||
|
||||
#include <alloca.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <glob.h> /* XXX rpmio.h */
|
||||
#include <dirent.h> /* XXX rpmio.h */
|
||||
#include <locale.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "Python.h"
|
||||
#include "rpmio_internal.h"
|
||||
#include "rpmcli.h" /* XXX for rpmCheckSig */
|
||||
|
||||
#include "rpmdb.h"
|
||||
#include "rpmps.h"
|
||||
|
||||
#include "rpmte.h"
|
||||
#define _RPMTS_INTERNAL /* XXX for ts->rdb */
|
||||
#include "rpmts.h"
|
||||
|
||||
|
@ -35,13 +23,13 @@
|
|||
#include "header-py.h"
|
||||
#include "rpmal-py.h"
|
||||
#include "rpmds-py.h"
|
||||
#include "rpmfd-py.h"
|
||||
#include "rpmfi-py.h"
|
||||
#include "rpmte-py.h"
|
||||
#include "rpmts-py.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
extern int _rpmio_debug;
|
||||
|
||||
#ifdef __LCLINT__
|
||||
#undef PyObject_HEAD
|
||||
#define PyObject_HEAD int _PyObjectHead
|
||||
|
@ -358,110 +346,6 @@ static PyObject * setVerbosity (PyObject * self, PyObject * args)
|
|||
return (PyObject *) Py_None;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef struct FDlist_t FDlist;
|
||||
|
||||
/**
|
||||
*/
|
||||
struct FDlist_t {
|
||||
FILE *f;
|
||||
FD_t fd;
|
||||
char *note;
|
||||
FDlist *next;
|
||||
} ;
|
||||
|
||||
/**
|
||||
*/
|
||||
static FDlist *fdhead = NULL;
|
||||
|
||||
/**
|
||||
*/
|
||||
static FDlist *fdtail = NULL;
|
||||
|
||||
/**
|
||||
*/
|
||||
static int closeCallback(FILE * f)
|
||||
{
|
||||
FDlist *node, *last;
|
||||
|
||||
printf ("close callback on %p\n", f);
|
||||
|
||||
node = fdhead;
|
||||
last = NULL;
|
||||
while (node) {
|
||||
if (node->f == f)
|
||||
break;
|
||||
last = node;
|
||||
node = node->next;
|
||||
}
|
||||
if (node) {
|
||||
if (last)
|
||||
last->next = node->next;
|
||||
else
|
||||
fdhead = node->next;
|
||||
printf ("closing %s %p\n", node->note, node->fd);
|
||||
free (node->note);
|
||||
node->fd = fdLink(node->fd, "closeCallback");
|
||||
Fclose (node->fd);
|
||||
while (node->fd)
|
||||
node->fd = fdFree(node->fd, "closeCallback");
|
||||
free (node);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
static PyObject * doFopen(PyObject * self, PyObject * args)
|
||||
{
|
||||
char * path, * mode;
|
||||
FDlist *node;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ss", &path, &mode))
|
||||
return NULL;
|
||||
|
||||
node = malloc (sizeof(FDlist));
|
||||
|
||||
node->fd = Fopen(path, mode);
|
||||
node->fd = fdLink(node->fd, "doFopen");
|
||||
node->note = strdup (path);
|
||||
|
||||
if (!node->fd) {
|
||||
PyErr_SetFromErrno(pyrpmError);
|
||||
free (node);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (Ferror(node->fd)) {
|
||||
const char *err = Fstrerror(node->fd);
|
||||
free(node);
|
||||
if (err) {
|
||||
PyErr_SetString(pyrpmError, err);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
node->f = fdGetFp(node->fd);
|
||||
printf ("opening %s fd = %p f = %p\n", node->note, node->fd, node->f);
|
||||
if (!node->f) {
|
||||
PyErr_SetString(pyrpmError, "FD_t has no FILE*");
|
||||
free(node);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
node->next = NULL;
|
||||
if (!fdhead) {
|
||||
fdhead = fdtail = node;
|
||||
} else if (fdtail) {
|
||||
fdtail->next = node;
|
||||
} else {
|
||||
fdhead = node;
|
||||
}
|
||||
fdtail = node;
|
||||
|
||||
return PyFile_FromFile (node->f, path, mode, closeCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
static PyMethodDef rpmModuleMethods[] = {
|
||||
|
@ -504,8 +388,6 @@ static PyMethodDef rpmModuleMethods[] = {
|
|||
NULL },
|
||||
{ "checksig", (PyCFunction) checkSig, METH_VARARGS,
|
||||
NULL },
|
||||
{ "Fopen", (PyCFunction) doFopen, METH_VARARGS,
|
||||
NULL },
|
||||
{ "setVerbosity", (PyCFunction) setVerbosity, METH_VARARGS,
|
||||
NULL },
|
||||
{ "dsSingle", (PyCFunction) rpmds_Single, METH_VARARGS,
|
||||
|
@ -555,6 +437,10 @@ void initrpm(void)
|
|||
Py_INCREF(&rpmds_Type);
|
||||
PyModule_AddObject(m, "ds", (PyObject *) &rpmds_Type);
|
||||
|
||||
rpmfd_Type.ob_type = &PyType_Type;
|
||||
Py_INCREF(&rpmfd_Type);
|
||||
PyModule_AddObject(m, "fd", (PyObject *) &rpmfd_Type);
|
||||
|
||||
rpmfi_Type.ob_type = &PyType_Type;
|
||||
Py_INCREF(&rpmfi_Type);
|
||||
PyModule_AddObject(m, "fi", (PyObject *) &rpmfi_Type);
|
||||
|
@ -567,6 +453,10 @@ void initrpm(void)
|
|||
Py_INCREF(&rpmmi_Type);
|
||||
PyModule_AddObject(m, "mi", (PyObject *) &rpmmi_Type);
|
||||
|
||||
rpmte_Type.ob_type = &PyType_Type;
|
||||
Py_INCREF(&rpmte_Type);
|
||||
PyModule_AddObject(m, "te", (PyObject *) &rpmte_Type);
|
||||
|
||||
rpmts_Type.ob_type = &PyType_Type;
|
||||
Py_INCREF(&rpmts_Type);
|
||||
PyModule_AddObject(m, "ts", (PyObject *) &rpmts_Type);
|
||||
|
@ -686,14 +576,8 @@ void initrpm(void)
|
|||
REGISTER_ENUM(RPMPROB_DISKNODES);
|
||||
REGISTER_ENUM(RPMPROB_BADPRETRANS);
|
||||
|
||||
#ifdef DEAD
|
||||
REGISTER_ENUM(CHECKSIG_PGP); /* XXX use VERIFY_SIGNATURE */
|
||||
REGISTER_ENUM(CHECKSIG_GPG); /* XXX use VERIFY_SIGNATURE */
|
||||
REGISTER_ENUM(CHECKSIG_MD5); /* XXX use VERIFY_DIGEST */
|
||||
#else
|
||||
REGISTER_ENUM(VERIFY_DIGEST);
|
||||
REGISTER_ENUM(VERIFY_SIGNATURE);
|
||||
#endif
|
||||
|
||||
REGISTER_ENUM(RPMLOG_EMERG);
|
||||
REGISTER_ENUM(RPMLOG_ALERT);
|
||||
|
@ -709,6 +593,8 @@ void initrpm(void)
|
|||
REGISTER_ENUM(RPMMIRE_REGEX);
|
||||
REGISTER_ENUM(RPMMIRE_GLOB);
|
||||
|
||||
PyDict_SetItemString(d, "RPMAL_NOMATCH", o=PyInt_FromLong( (long)RPMAL_NOMATCH ));
|
||||
Py_DECREF(o);
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
|
|
@ -0,0 +1,272 @@
|
|||
/** \ingroup python
|
||||
* \file python/rpmte-py.c
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#include <rpmlib.h>
|
||||
#include "rpmps.h"
|
||||
|
||||
#include "rpmds.h"
|
||||
#include "rpmfi.h"
|
||||
#include "rpmte.h"
|
||||
|
||||
#include "header-py.h" /* XXX tagNumFromPyObject */
|
||||
#include "rpmds-py.h"
|
||||
#include "rpmfi-py.h"
|
||||
#include "rpmte-py.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
/** \ingroup python
|
||||
* \name Class: rpm.te
|
||||
* \class rpm.te
|
||||
* \brief An python rpm.te object represents an element of a RPM transaction set.
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
rpmte_Debug(rpmteObject * s, PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "i", &_rpmte_debug)) return NULL;
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
rpmte_N(rpmteObject * s, PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ":N")) return NULL;
|
||||
return Py_BuildValue("s", rpmteN(s->te));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
rpmte_E(rpmteObject * s, PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ":E")) return NULL;
|
||||
return Py_BuildValue("s", rpmteE(s->te));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
rpmte_V(rpmteObject * s, PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ":V")) return NULL;
|
||||
return Py_BuildValue("s", rpmteV(s->te));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
rpmte_R(rpmteObject * s, PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ":R")) return NULL;
|
||||
return Py_BuildValue("s", rpmteR(s->te));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
rpmte_A(rpmteObject * s, PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ":A")) return NULL;
|
||||
return Py_BuildValue("s", rpmteA(s->te));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
rpmte_O(rpmteObject * s, PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ":O")) return NULL;
|
||||
return Py_BuildValue("s", rpmteO(s->te));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
rpmte_NEVR(rpmteObject * s, PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ":NEVR")) return NULL;
|
||||
return Py_BuildValue("s", rpmteNEVR(s->te));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
rpmte_MultiLib(rpmteObject * s, PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ":MultiLib")) return NULL;
|
||||
return Py_BuildValue("i", rpmteMultiLib(s->te));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
rpmte_Depth(rpmteObject * s, PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ":Depth")) return NULL;
|
||||
return Py_BuildValue("i", rpmteDepth(s->te));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
rpmte_Npreds(rpmteObject * s, PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ":Npreds")) return NULL;
|
||||
return Py_BuildValue("i", rpmteNpreds(s->te));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
rpmte_Degree(rpmteObject * s, PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ":Degree")) return NULL;
|
||||
return Py_BuildValue("i", rpmteDegree(s->te));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
rpmte_AddedKey(rpmteObject * s, PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ":Degree")) return NULL;
|
||||
return Py_BuildValue("i", rpmteDegree(s->te));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
rpmte_DS(rpmteObject * s, PyObject * args)
|
||||
{
|
||||
PyObject * TagN = NULL;
|
||||
rpmds ds;
|
||||
rpmTag tag;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O:DS", &TagN)) return NULL;
|
||||
|
||||
tag = tagNumFromPyObject(TagN);
|
||||
if (tag == -1) {
|
||||
PyErr_SetString(PyExc_TypeError, "unknown tag type");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ds = rpmteDS(s->te, tag);
|
||||
if (ds == NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "invalid ds tag");
|
||||
return NULL;
|
||||
}
|
||||
return (PyObject *) rpmds_Wrap(ds);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
rpmte_FI(rpmteObject * s, PyObject * args)
|
||||
{
|
||||
PyObject * TagN = NULL;
|
||||
rpmfi fi;
|
||||
rpmTag tag;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O:FI", &TagN)) return NULL;
|
||||
|
||||
tag = tagNumFromPyObject(TagN);
|
||||
if (tag == -1) {
|
||||
PyErr_SetString(PyExc_TypeError, "unknown tag type");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fi = rpmteFI(s->te, tag);
|
||||
if (fi == NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "invalid fi tag");
|
||||
return NULL;
|
||||
}
|
||||
return (PyObject *) rpmfi_Wrap(fi);
|
||||
}
|
||||
|
||||
/** \ingroup python
|
||||
*/
|
||||
static struct PyMethodDef rpmte_methods[] = {
|
||||
{"Debug", (PyCFunction)rpmte_Debug, METH_VARARGS,
|
||||
NULL},
|
||||
{"N", (PyCFunction)rpmte_N, METH_VARARGS,
|
||||
NULL},
|
||||
{"E", (PyCFunction)rpmte_E, METH_VARARGS,
|
||||
NULL},
|
||||
{"V", (PyCFunction)rpmte_V, METH_VARARGS,
|
||||
NULL},
|
||||
{"R", (PyCFunction)rpmte_R, METH_VARARGS,
|
||||
NULL},
|
||||
{"A", (PyCFunction)rpmte_A, METH_VARARGS,
|
||||
NULL},
|
||||
{"O", (PyCFunction)rpmte_O, METH_VARARGS,
|
||||
NULL},
|
||||
{"NEVR", (PyCFunction)rpmte_NEVR, METH_VARARGS,
|
||||
NULL},
|
||||
{"MultiLib",(PyCFunction)rpmte_MultiLib, METH_VARARGS,
|
||||
NULL},
|
||||
{"Depth", (PyCFunction)rpmte_Depth, METH_VARARGS,
|
||||
NULL},
|
||||
{"Npreds", (PyCFunction)rpmte_Npreds, METH_VARARGS,
|
||||
NULL},
|
||||
{"Degree", (PyCFunction)rpmte_Degree, METH_VARARGS,
|
||||
NULL},
|
||||
{"AddedKey",(PyCFunction)rpmte_AddedKey, METH_VARARGS,
|
||||
NULL},
|
||||
{"DS", (PyCFunction)rpmte_DS, METH_VARARGS,
|
||||
NULL},
|
||||
{"FI", (PyCFunction)rpmte_FI, METH_VARARGS,
|
||||
NULL},
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
/* ---------- */
|
||||
|
||||
/** \ingroup python
|
||||
*/
|
||||
static PyObject * rpmte_getattr(rpmteObject * o, char * name)
|
||||
{
|
||||
return Py_FindMethod(rpmte_methods, (PyObject *) o, name);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
static char rpmte_doc[] =
|
||||
"";
|
||||
|
||||
/** \ingroup python
|
||||
*/
|
||||
PyTypeObject rpmte_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
"rpm.te", /* tp_name */
|
||||
sizeof(rpmteObject), /* tp_size */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)0, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
(getattrfunc) rpmte_getattr, /* tp_getattr */
|
||||
(setattrfunc)0, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
0, /* tp_getattro */
|
||||
0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT, /* tp_flags */
|
||||
rpmte_doc, /* tp_doc */
|
||||
#if Py_TPFLAGS_HAVE_ITER
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
rpmte_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
0, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
0, /* tp_new */
|
||||
0, /* tp_free */
|
||||
0, /* tp_is_gc */
|
||||
#endif
|
||||
};
|
||||
|
||||
rpmteObject * rpmte_Wrap(rpmte te)
|
||||
{
|
||||
rpmteObject *s = PyObject_NEW(rpmteObject, &rpmte_Type);
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
s->te = te;
|
||||
return s;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef H_RPMTE_PY
|
||||
#define H_RPMTE_PY
|
||||
|
||||
/** \ingroup python
|
||||
* \file python/rpmte-py.h
|
||||
*/
|
||||
|
||||
typedef struct rpmteObject_s {
|
||||
PyObject_HEAD
|
||||
rpmte te;
|
||||
} rpmteObject;
|
||||
|
||||
extern PyTypeObject rpmte_Type;
|
||||
|
||||
rpmteObject * rpmte_Wrap(rpmte te);
|
||||
|
||||
#endif
|
|
@ -1,19 +1,26 @@
|
|||
/** \ingroup python
|
||||
* \file python/rpmmodule.c
|
||||
* \file python/rpmts-py.c
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#include <rpmlib.h>
|
||||
#include "rpmdb.h"
|
||||
#include "rpmps.h"
|
||||
|
||||
#define _RPMTS_INTERNAL /* XXX for ts->rdb */
|
||||
#include "rpmal.h"
|
||||
#include "rpmds.h"
|
||||
#include "rpmfi.h"
|
||||
#include "rpmte.h"
|
||||
|
||||
#define _RPMTS_INTERNAL /* XXX for ts->rdb, ts->availablePackage */
|
||||
#include "rpmts.h"
|
||||
|
||||
#include "db-py.h"
|
||||
#include "header-py.h"
|
||||
#include "rpmte-py.h"
|
||||
#include "rpmts-py.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
@ -33,8 +40,8 @@
|
|||
*
|
||||
* A rpm.ts object has the following methods:
|
||||
*
|
||||
* - add(header,data,mode) Add a binary package to a transaction set.
|
||||
* @param header the header to be added
|
||||
* - addInstall(hdr,data,mode) Add an install element to a transaction set.
|
||||
* @param hdr the header to be added
|
||||
* @param data user data that will be passed to the transaction callback
|
||||
* during transaction execution
|
||||
* @param mode optional argument that specifies if this package should
|
||||
|
@ -43,13 +50,13 @@
|
|||
* dependencies but no action should be performed with it
|
||||
* ('a').
|
||||
*
|
||||
* - remove
|
||||
* - addErase(name) Add an erase element to a transaction set.
|
||||
* @param name the package name to be erased
|
||||
*
|
||||
* - depcheck() Perform a dependency and conflict check on the
|
||||
* transaction set. After headers have been added to a
|
||||
* transaction set, a dependency check can be performed
|
||||
* to make sure that all package dependencies are
|
||||
* satisfied.
|
||||
* - check() Perform a dependency check on the transaction set. After
|
||||
* headers have been added to a transaction set, a dependency
|
||||
* check can be performed to make sure that all package
|
||||
* dependencies are satisfied.
|
||||
* @return None If there are no unresolved dependencies
|
||||
* Otherwise a list of complex tuples is returned, one tuple per
|
||||
* unresolved dependency, with
|
||||
|
@ -82,6 +89,9 @@
|
|||
* rpm.RPMDEP_SENSE_REQUIRES are set to show a dependency as a
|
||||
* requirement or a conflict.
|
||||
*
|
||||
* - order() Do a topological sort of added element relations.
|
||||
* @return None
|
||||
*
|
||||
* - run(flags,problemSetFilter,callback,data) Attempt to execute a
|
||||
* transaction set. After the transaction set has been populated
|
||||
* with install and upgrade actions, it can be executed by invoking
|
||||
|
@ -116,10 +126,31 @@
|
|||
* - rpm.RPMPROB_FILTER_DISKSPACE -
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add package to universe of possible packages to install in transaction set.
|
||||
* @param ts transaction set
|
||||
* @param h header
|
||||
* @param key package private data
|
||||
*/
|
||||
static void rpmtsAddAvailableElement(rpmts ts, Header h,
|
||||
/*@exposed@*/ /*@null@*/ fnpyKey key)
|
||||
/*@modifies h, ts @*/
|
||||
{
|
||||
int scareMem = 0;
|
||||
rpmds provides = rpmdsNew(h, RPMTAG_PROVIDENAME, scareMem);
|
||||
rpmfi fi = rpmfiNew(ts, NULL, h, RPMTAG_BASENAMES, scareMem);
|
||||
|
||||
/* XXX FIXME: return code RPMAL_NOMATCH is error */
|
||||
(void) rpmalAdd(&ts->availablePackages, RPMAL_NOMATCH, key,
|
||||
provides, fi);
|
||||
fi = rpmfiFree(fi, 1);
|
||||
provides = rpmdsFree(provides);
|
||||
}
|
||||
|
||||
/** \ingroup python
|
||||
*/
|
||||
static PyObject *
|
||||
rpmts_Add(rpmtsObject * s, PyObject * args)
|
||||
rpmts_AddInstall(rpmtsObject * s, PyObject * args)
|
||||
{
|
||||
hdrObject * h;
|
||||
PyObject * key;
|
||||
|
@ -145,9 +176,9 @@ rpmts_Add(rpmtsObject * s, PyObject * args)
|
|||
isUpgrade = 1;
|
||||
|
||||
if (how && !strcmp(how, "a"))
|
||||
rpmtsAvailablePackage(s->ts, hdrGetHeader(h), key);
|
||||
rpmtsAddAvailableElement(s->ts, hdrGetHeader(h), key);
|
||||
else
|
||||
rpmtsAddPackage(s->ts, hdrGetHeader(h), key, isUpgrade, NULL);
|
||||
rpmtsAddInstallElement(s->ts, hdrGetHeader(h), key, isUpgrade, NULL);
|
||||
|
||||
/* This should increment the usage count for me */
|
||||
if (key) {
|
||||
|
@ -161,7 +192,7 @@ rpmts_Add(rpmtsObject * s, PyObject * args)
|
|||
/** \ingroup python
|
||||
*/
|
||||
static PyObject *
|
||||
rpmts_Remove(rpmtsObject * s, PyObject * args)
|
||||
rpmts_AddErase(rpmtsObject * s, PyObject * args)
|
||||
{
|
||||
char * name;
|
||||
int count;
|
||||
|
@ -181,7 +212,7 @@ rpmts_Remove(rpmtsObject * s, PyObject * args)
|
|||
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
||||
unsigned int recOffset = rpmdbGetIteratorOffset(mi);
|
||||
if (recOffset) {
|
||||
rpmtsRemovePackage(s->ts, h, recOffset);
|
||||
rpmtsAddEraseElement(s->ts, h, recOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +237,7 @@ rpmts_Check(rpmtsObject * s, PyObject * args)
|
|||
if (!PyArg_ParseTuple(args, "|i:Check", &allSuggestions)) return NULL;
|
||||
|
||||
xx = rpmtsCheck(s->ts);
|
||||
ps = rpmtsGetProblems(s->ts);
|
||||
ps = rpmtsProblems(s->ts);
|
||||
if (ps) {
|
||||
list = PyList_New(0);
|
||||
|
||||
|
@ -395,7 +426,7 @@ static PyObject * rpmts_Run(rpmtsObject * s, PyObject * args)
|
|||
(void) rpmtsSetFlags(s->ts, flags);
|
||||
|
||||
rc = rpmtsRun(s->ts, NULL, ignoreSet);
|
||||
ps = rpmtsGetProblems(s->ts);
|
||||
ps = rpmtsProblems(s->ts);
|
||||
|
||||
if (cbInfo.pythonError) {
|
||||
ps = rpmpsFree(ps);
|
||||
|
@ -426,14 +457,44 @@ static PyObject * rpmts_Run(rpmtsObject * s, PyObject * args)
|
|||
return list;
|
||||
}
|
||||
|
||||
#if Py_TPFLAGS_HAVE_ITER
|
||||
static PyObject *
|
||||
rpmts_Next(rpmtsObject * s)
|
||||
{
|
||||
rpmte te;
|
||||
|
||||
if (s == NULL || s->tsi == NULL)
|
||||
return NULL;
|
||||
|
||||
te = rpmtsiNext(s->tsi, s->tsiFilter);
|
||||
if (te == NULL) {
|
||||
s->tsi = rpmtsiFree(s->tsi);
|
||||
s->tsiFilter = 0;
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
return (PyObject *) rpmte_Wrap(te);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
rpmts_Iter(rpmtsObject * s)
|
||||
{
|
||||
s->tsi = rpmtsiInit(s->ts);
|
||||
s->tsiFilter = 0;
|
||||
Py_INCREF(s);
|
||||
return (PyObject *) s;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** \ingroup python
|
||||
*/
|
||||
static struct PyMethodDef rpmts_methods[] = {
|
||||
{"add", (PyCFunction) rpmts_Add, METH_VARARGS,
|
||||
{"addInstall", (PyCFunction) rpmts_AddInstall, METH_VARARGS,
|
||||
NULL },
|
||||
{"remove", (PyCFunction) rpmts_Remove, METH_VARARGS,
|
||||
{"addErase", (PyCFunction) rpmts_AddErase, METH_VARARGS,
|
||||
NULL },
|
||||
{"depcheck", (PyCFunction) rpmts_Check, METH_VARARGS,
|
||||
{"check", (PyCFunction) rpmts_Check, METH_VARARGS,
|
||||
NULL },
|
||||
{"order", (PyCFunction) rpmts_Order, METH_VARARGS,
|
||||
NULL },
|
||||
|
@ -441,7 +502,13 @@ static struct PyMethodDef rpmts_methods[] = {
|
|||
NULL },
|
||||
{"run", (PyCFunction) rpmts_Run, METH_VARARGS,
|
||||
NULL },
|
||||
{NULL, NULL} /* sentinel */
|
||||
#if Py_TPFLAGS_HAVE_ITER
|
||||
{"next", (PyCFunction)rpmts_Next, METH_VARARGS,
|
||||
NULL},
|
||||
{"iter", (PyCFunction)rpmts_Iter, METH_VARARGS,
|
||||
NULL},
|
||||
#endif
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
/** \ingroup python
|
||||
|
@ -527,8 +594,8 @@ PyTypeObject rpmts_Type = {
|
|||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
(getiterfunc)rpmts_Iter, /* tp_iter */
|
||||
(iternextfunc)rpmts_Next, /* tp_iternext */
|
||||
rpmts_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0, /* tp_getset */
|
||||
|
|
|
@ -11,6 +11,8 @@ typedef struct rpmtsObject_s {
|
|||
rpmdbObject * dbo;
|
||||
PyObject * keyList; /* keeps reference counts correct */
|
||||
FD_t scriptFd;
|
||||
rpmtsi tsi;
|
||||
rpmElementType tsiFilter;
|
||||
} rpmtsObject;
|
||||
|
||||
extern PyTypeObject rpmts_Type;
|
||||
|
|
|
@ -45,7 +45,6 @@ static inline /*@observer@*/ const char * const identifyDepend(int_32 f)
|
|||
static int
|
||||
do_tsort(const char *fileArgv[])
|
||||
{
|
||||
const char * rootdir = "/";
|
||||
rpmts ts = NULL;
|
||||
const char ** pkgURL = NULL;
|
||||
char * pkgState = NULL;
|
||||
|
@ -77,10 +76,12 @@ do_tsort(const char *fileArgv[])
|
|||
goto exit;
|
||||
}
|
||||
|
||||
#ifdef DYING
|
||||
/* Load all the available packages. */
|
||||
if (!(noDeps || noAvailable)) {
|
||||
rpmdbMatchIterator mi = NULL;
|
||||
struct rpmdb_s * avdb = NULL;
|
||||
const char * rootdir = "/";
|
||||
|
||||
addMacro(NULL, "_dbpath", NULL, avdbpath, RMIL_CMDLINE);
|
||||
rc = rpmdbOpen(rootdir, &avdb, O_RDONLY, 0644);
|
||||
|
@ -98,6 +99,7 @@ endavail:
|
|||
if (mi) rpmdbFreeIterator(mi);
|
||||
if (avdb) rpmdbClose(avdb);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Build fully globbed list of arguments in argv[argc]. */
|
||||
for (fnp = fileArgv; *fnp; fnp++) {
|
||||
|
@ -170,7 +172,7 @@ restart:
|
|||
}
|
||||
|
||||
if (rc == 0) {
|
||||
rc = rpmtsAddPackage(ts, h, (fnpyKey)fileName, 0, NULL);
|
||||
rc = rpmtsAddInstallElement(ts, h, (fnpyKey)fileName, 0, NULL);
|
||||
headerFree(h, "do_tsort");
|
||||
continue;
|
||||
}
|
||||
|
@ -215,7 +217,7 @@ restart:
|
|||
|
||||
rc = rpmtsCheck(ts);
|
||||
|
||||
ps = rpmtsGetProblems(ts);
|
||||
ps = rpmtsProblems(ts);
|
||||
if (ps) {
|
||||
rpmMessage(RPMMESS_ERROR, _("Failed dependencies:\n"));
|
||||
printDepProblems(stderr, ps);
|
||||
|
@ -230,7 +232,7 @@ restart:
|
|||
if (rc)
|
||||
goto exit;
|
||||
|
||||
{ rpmtei pi;
|
||||
{ rpmtsi pi;
|
||||
rpmte p;
|
||||
rpmte q;
|
||||
unsigned char * selected =
|
||||
|
@ -242,8 +244,8 @@ fprintf(stdout, "digraph XXX {\n");
|
|||
fprintf(stdout, " rankdir=LR\n");
|
||||
|
||||
fprintf(stdout, "//===== Packages:\n");
|
||||
pi = rpmteiInit(ts);
|
||||
while ((p = rpmteiNext(pi, oType)) != NULL) {
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, oType)) != NULL) {
|
||||
fprintf(stdout, "//%5d%5d %s\n", rpmteTree(p), rpmteDepth(p), rpmteN(p));
|
||||
q = rpmteParent(p);
|
||||
if (q != NULL)
|
||||
|
@ -253,7 +255,7 @@ fprintf(stdout, " \"%s\"\n", rpmteN(p));
|
|||
fprintf(stdout, " { rank=max ; \"%s\" }\n", rpmteN(p));
|
||||
}
|
||||
}
|
||||
pi = rpmteiFree(pi);
|
||||
pi = rpmtsiFree(pi);
|
||||
|
||||
fprintf(stdout, "}\n");
|
||||
|
||||
|
|
Loading…
Reference in New Issue