21 #define _RPMTE_INTERNAL
22 #define _RPMTS_INTERNAL
27 #define _RPMROLLBACK_INTERNAL
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)
119 qsort(idtx->idt, idtx->nidt, idtx->size,
IDTintcmp);
139 if (!xx || he->
p.
ui32p == NULL)
144 if (tid == 0 || tid == 0xffffffff)
152 if (idtx == NULL || idtx->idt == NULL)
157 idt = idtx->idt + idtx->nidt;
179 const char ** av = NULL;
192 for (i = 0; i < ac; i++) {
195 fd =
Fopen(av[i],
"r.fdio");
196 if (fd == NULL ||
Ferror(fd)) {
199 if (fd != NULL) (void)
Fclose(fd);
221 assert(origin != NULL);
222 assert(!strcmp(av[i], origin));
226 if (!xx || he->
p.
ui32p == NULL)
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++) {
292 if (AV != NULL && B != NULL)
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;
345 if (pn == 1 && flinkPkgid[0] != NULL && !strcmp(flinkPkgid[0],
RPMTE_CHAIN_END)) {
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);
397 rpmte q = ts->teErase;
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);
488 {
const char * globstr =
rpmExpand(
"%{_repackage_dir}/*/*.rpm", NULL);
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);
622 rc =
findErases(ts, NULL, 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 rpmteChain(rpmte p, rpmte q, Header oh, const char *msg)
Chain p <-> q forward/backward transaction element links.
const char bson_timestamp_t * ts
static int cmpArgvStr(rpmts ts, const char *lname, const char **AV, int AC, const char *B)
Search for string B in argv array AV.
enum rpmInstallInterfaceFlags_e rpmInstallInterfaceFlags
Bit(s) to control rpmcliInstall() and rpmErase() operation.
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.
uint32_t rpmmiInstance(rpmmi mi)
Return header instance for current position of rpmdb iterator.
FD_t Fopen(const char *path, const char *_fmode)
fopen(3) clone.
int rpmtsAddInstallElement(rpmts ts, Header h, fnpyKey key, int upgrade, rpmRelocation relocs)
Add package to be installed to transaction set.
enum rpmprobFilterFlags_e rpmprobFilterFlags
IDTX IDTXglob(rpmts ts, const char *globstr, rpmTag tag, rpmuint32_t rbtid)
Load tag (instance,value) pairs from packages, and return sorted id index.
static rpmVSFlags vsflags
int rpmtsSetNotifyCallback(rpmts ts, rpmCallbackFunction notify, rpmCallbackData notifyData)
Set transaction notify callback function and argument.
static void rpmlog(int code, const char *fmt,...)
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.
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.
struct rpmte_s * rpmte
An element of a transaction set, i.e.
rpmtransFlags rpmtsSetFlags(rpmts ts, rpmtransFlags transFlags)
Set transaction flags, i.e.
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)
int rpmcliInstallProblems(rpmts ts, const char *msg, int rc)
Report package problems (if any).
IDTX IDTXgrow(IDTX idtx, int need)
Insure that index has room for "need" elements.
enum rpmdepFlags_e rpmdepFlags
Bit(s) to control rpmtsCheck() and rpmtsOrder() operation.
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.
Structure(s) used for dependency tag sets.
#define QVA_ISSET(_qvaflags, _FLAG)
The FD_t File Handle data structure.
rpmmi rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)
Return transaction database iterator.
int rpmRollback(rpmts ts, QVA_t ia, const char **argv)
Rollback transactions, erasing new, reinstalling old, package(s).
pgpVSFlags rpmVSFlags
Bit(s) to control digest and signature verification.
Header headerFree(Header h)
Dereference a header instance.
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
rpmuint32_t * rbtidExcludes
void rpmtsSetType(rpmts ts, rpmTSType type)
Set transaction type.
IDTX IDTXfree(IDTX idtx)
Destroy id index.
rpmInstallInterfaceFlags installInterfaceFlags
rpmmi rpmmiFree(rpmmi mi)
Destroy rpm database iterator.
int Fclose(FD_t fd)
fclose(3) clone.
rpmprobFilterFlags probFilter
rpmps rpmpsFree(rpmps ps)
Destroy a problem set.
Header headerLink(Header h)
Reference a header instance.
IDTX IDTXload(rpmts ts, rpmTag tag, rpmuint32_t rbtid)
Load tag (instance,value) pairs from rpm databse, and return sorted id index.
IDTX IDTXsort(IDTX idtx)
Sort tag (instance,value) pairs.
enum rpmRC_e rpmRC
RPM return codes.
int Ferror(FD_t fd)
ferror(3) clone.
int rpmmiAddPattern(rpmmi mi, rpmTag tag, rpmMireMode mode, const char *pattern)
Add pattern to iterator selector.
rpmdepFlags rpmtsSetDFlags(rpmts ts, rpmdepFlags depFlags)
Set dependency flags, i.e.
Methods to handle package elements.
rpmps rpmtsProblems(rpmts ts)
Return current transaction set problems.
enum rpmtransFlags_e rpmtransFlags
Bit(s) to control rpmtsRun() operation.
static int IDTintcmp(const void *a, const void *b)
rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
Set verify signatures flag(s).
struct rpmts_s * rpmts
The RPM Transaction Set.
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
Header rpmmiNext(rpmmi mi)
Return next package header from iteration.
int rpmtsAddEraseElement(rpmts ts, Header h, uint32_t hdrNum)
Add package to be erased to transaction set.
#define VSF_SET(_vsflags, _FLAG)
Access RPM indices using Berkeley DB interface(s).
IDTX IDTXnew(void)
Create id index.
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
void rpmtsEmpty(rpmts ts)
Re-create an empty transaction set.
void rpmtsClean(rpmts ts)
Free memory needed only for dependency checks and ordering.
int(* rbRun)(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
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.