21 #define _RPMTE_INTERNAL
22 #define _RPMTS_INTERNAL
27 #define _RPMROLLBACK_INTERNAL
28 #include <rpmrollback.h>
40 #define QVA_ISSET(_qvaflags, _FLAG) ((_qvaflags) & (VERIFY_##_FLAG))
42 #define VSF_ISSET(_vsflags, _FLAG) ((_vsflags) & (RPMVSF_##_FLAG))
43 #define VSF_SET(_vsflags, _FLAG) \
44 (*((unsigned *)&(_vsflags)) |= (RPMVSF_##_FLAG))
45 #define VSF_CLR(_vsflags, _FLAG) \
46 (*((unsigned *)&(_vsflags)) &= ~(RPMVSF_##_FLAG))
53 #define QVA_ISSET(_qvaflags, _FLAG) ((_qvaflags) & (VERIFY_##_FLAG))
55 #define VSF_ISSET(_vsflags, _FLAG) ((_vsflags) & (RPMVSF_##_FLAG))
56 #define VSF_SET(_vsflags, _FLAG) (_vsflags) |= (RPMVSF_##_FLAG)
57 #define VSF_CLR(_vsflags, _FLAG) (_vsflags) &= ~(RPMVSF_##_FLAG)
70 return ( reverse * (((IDT)a)->
val.u32 - ((IDT)b)->val.u32) );
79 for (i = 0; i < idtx->nidt; i++) {
80 IDT
idt = idtx->idt +
i;
83 idt->key =
_free(idt->key);
85 idtx->idt =
_free(idtx->idt);
95 idtx->size = (
int)
sizeof(*((IDT)0));
101 if (need < 0)
return NULL;
104 if (need == 0)
return idtx;
106 if ((idtx->nidt + need) > idtx->alloced) {
108 idtx->alloced += idtx->delta;
111 idtx->idt = (IDT)
xrealloc(idtx->idt, (idtx->alloced * idtx->size));
118 if (idtx !=
NULL && idtx->idt !=
NULL && idtx->nidt > 0)
144 if (tid == 0 || tid == 0xffffffff)
152 if (idtx ==
NULL || idtx->idt ==
NULL)
157 idt = idtx->idt + idtx->nidt;
192 for (i = 0; i <
ac; i++) {
195 fd =
Fopen(av[i],
"r.fdio");
236 if (idtx ==
NULL || idtx->idt ==
NULL)
240 idt = idtx->idt + idtx->nidt;
254 for (i = 0; i <
ac; i++)
255 av[i] =
_free(av[i]);
256 av =
_free(av); ac = 0;
277 if (AV !=
NULL && AC > 0 && B ==
NULL) {
278 if (!
strcmp(lname,
"NEVRA")) {
280 for (i = 0; i < AC && (A = AV[
i]) !=
NULL; i++) {
293 for (i = 0; i < AC && (A = AV[
i]) !=
NULL; i++) {
294 if (*A && *B && !
strcmp(A, B))
327 while (ip !=
NULL && ip->val.u32 == thistid) {
333 const char ** flinkPkgid =
NULL;
334 const char ** flinkHdrid =
NULL;
335 const char ** flinkNEVRA =
NULL;
341 flinkPkgid = he->
p.
argv;
346 flinkPkgid =
_free(flinkPkgid);
352 flinkHdrid = he->
p.
argv;
356 flinkNEVRA = he->
p.
argv;
368 bingo =
cmpArgvStr(ts,
"NEVRA", flinkNEVRA, nn, (p ? p->NEVRA :
NULL));
370 bingo =
cmpArgvStr(ts,
"Hdrid", flinkHdrid, hn, (p ? p->hdrid : NULL));
373 bingo =
cmpArgvStr(ts,
"Pkgid", flinkPkgid, pn, (p ? p->pkgid : NULL));
375 flinkPkgid =
_free(flinkPkgid);
376 flinkHdrid =
_free(flinkHdrid);
377 flinkNEVRA =
_free(flinkNEVRA);
424 unsigned thistid = 0xffffffff;
437 unsigned int _unsafe_rollbacks = 0;
442 if (argv !=
NULL && *argv !=
NULL) {
451 #if defined(SUPPORT_NOSIGNATURES)
453 VSF_SET(vsflags, NOSHA1HEADER);
489 if (globstr ==
NULL || *globstr ==
'%') {
490 globstr =
_free(globstr);
503 globstr =
_free(globstr);
524 if (ip !=
NULL && ip->val.u32 > thistid)
525 thistid = ip->val.u32;
526 if (rp !=
NULL && rp->val.u32 > thistid)
527 thistid = rp->val.u32;
530 if (thistid == 0 || thistid < ia->
rbtid)
534 if (_unsafe_rollbacks && thistid <= _unsafe_rollbacks)
545 if (thistid == *excludedTID) {
546 time_t ttid = (time_t)thistid;
548 _(
"Excluding TID from rollback: %-24.24s (0x%08x)\n"),
549 ctime(&ttid), thistid);
556 while (rp !=
NULL && rp->val.u32 == thistid) {
565 while (ip !=
NULL && ip->val.u32 == thistid) {
584 while (rp !=
NULL && rp->val.u32 == thistid) {
587 (rp->key ? rp->key :
"???"));
603 rc =
findErases(ts, ts->teInstall, thistid, ip, niids);
627 while (ip !=
NULL && ip->val.u32 == thistid) {
635 if (_unsafe_rollbacks != 0)
658 tid = (time_t)thistid;
660 _(
"Rollback packages (+%d/-%d) to %-24.24s (0x%08x):\n"),
661 numAdded, numRemoved, ctime(&tid), thistid);
675 xx = rpmtsPrint(ts, stdout);
688 for (i = 0; i < rtids->nidt; i++) {
689 IDT rrp = rtids->idt +
i;
690 if (rrp->val.u32 != thistid)
694 (
void) unlink(rrp->key);
711 while (ip !=
NULL && ip->val.u32 == thistid) {
rpmRelocation relocations
int rpmtsSetNotifyCallback(rpmts ts, rpmCallbackFunction notify, rpmCallbackData notifyData)
Set transaction notify callback function and argument.
qsort(mc->macroTable, mc->firstFree, sizeof(mc->macroTable[0]), compareMacroName)
rpmlog(RPMLOG_ERR,"%s\n", buf)
struct rpmte_s * rpmte
An element of a transaction set, i.e.
static int cmpArgvStr(rpmts ts, const char *lname, const char **AV, int AC, const char *B)
Search for string B in argv array AV.
void rpmpsAppend(rpmps ps, rpmProblemType type, const char *pkgNEVR, fnpyKey key, const char *dn, const char *bn, const char *altNEVR, rpmuint64_t ulong1)
Append a problem to current set of problems.
FD_t Fopen(const char *path, const char *_fmode)
fopen(3) clone.
uint32_t rpmmiInstance(rpmmi mi)
Return header instance for current position of rpmdb iterator.
enum rpmprobFilterFlags_e rpmprobFilterFlags
rpmtransFlags rpmtsSetFlags(rpmts ts, rpmtransFlags transFlags)
Set transaction flags, i.e.
struct rpmts_s * rpmts
The RPM Transaction Set.
IDTX IDTXglob(rpmts ts, const char *globstr, rpmTag tag, rpmuint32_t rbtid)
static PyObject *const char * globstr
#define reverse(bot, top)
void rpmtsEmpty(rpmts ts)
Re-create an empty transaction set.
struct rpmps_s * rpmps
Transaction problems found while processing a transaction set/.
const char * rpmgiEscapeSpaces(const char *s)
Escape isspace(3) characters in string.
Command line option information.
rpmdepFlags rpmtsSetDFlags(rpmts ts, rpmdepFlags depFlags)
Set dependency flags, i.e.
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.
int rpmGlob(const char *patterns, int *argcPtr, const char ***argvPtr)
Return URL path(s) from a (URL prefixed) pattern glob.
const char * Fstrerror(FD_t fd)
strerror(3) clone.
void * xcalloc(size_t nmemb, size_t size)
assert(key->size==sizeof(hdrNum))
int rpmtsAddEraseElement(rpmts ts, Header h, uint32_t hdrNum)
Add package to be erased to transaction set.
rpmmi rpmmiFree(rpmmi mi)
Destroy rpm database iterator.
IDTX IDTXgrow(IDTX idtx, int need)
Routines to expand a manifest containing glob expressions into an argv list.
rpmRC rpmReadPackageFile(rpmts ts, FD_t fd, const char *fn, Header *hdrp)
Return package header from file handle, verifying digests/signatures.
Header rpmmiNext(rpmmi mi)
Return next package header from iteration.
Structure(s) used for dependency tag sets.
#define QVA_ISSET(_qvaflags, _FLAG)
int rpmmiAddPattern(rpmmi mi, rpmTag tag, rpmMireMode mode, const char *pattern)
Add pattern to iterator selector.
int rpmtsAddInstallElement(rpmts ts, Header h, fnpyKey key, int upgrade, rpmRelocation relocs)
Add package to be installed to transaction set.
The FD_t File Handle data structure.
int rpmRollback(rpmts ts, QVA_t ia, const char **argv)
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
rpmuint32_t * rbtidExcludes
pgpVSFlags rpmVSFlags
Bit(s) to control digest and signature verification.
rpmInstallInterfaceFlags installInterfaceFlags
int Fclose(FD_t fd)
fclose(3) clone.
rpmprobFilterFlags probFilter
rpmps rpmpsFree(rpmps ps)
Destroy a problem set.
IDTX IDTXload(rpmts ts, rpmTag tag, rpmuint32_t rbtid)
rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
Set verify signatures flag(s).
int Ferror(FD_t fd)
ferror(3) clone.
void rpmtsClean(rpmts ts)
Free memory needed only for dependency checks and ordering.
return strcmp(ame->name, bme->name)
static PyObject *rpmtransFlags transFlags
enum rpmInstallInterfaceFlags_e rpmInstallInterfaceFlags
Bit(s) to control rpmcliInstall() and rpmErase() operation.
enum rpmtransFlags_e rpmtransFlags
Bit(s) to control rpmtsRun() operation.
Methods to handle package elements.
static int IDTintcmp(const void *a, const void *b)
int rpmcliInstallProblems(rpmts ts, const char *msg, int rc)
Report package problems (if any).
static void
Print copy of spec file, filling in Group/Description/Summary from specspo.
int
Save source and expand field into target.
#define VSF_SET(_vsflags, _FLAG)
void rpmtsSetType(rpmts ts, rpmTSType type)
Set transaction type.
void * rpmShowProgress(const void *arg, const rpmCallbackType what, const rpmuint64_t amount, const rpmuint64_t total, fnpyKey key, void *data)
The rpm CLI generic transaction callback handler.
Access RPM indices using Berkeley DB interface(s).
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.
enum rpmdepFlags_e rpmdepFlags
Bit(s) to control rpmtsCheck() and rpmtsOrder() operation.
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
int(* rbRun)(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
rpmps rpmtsProblems(rpmts ts)
Return current transaction set problems.
static int findErases(rpmts ts, rpmte p, unsigned thistid, IDT ip, int niids)
Find (and add to transaction set) all erase elements with matching blink.