11 #define _RPMPS_INTERNAL
33 if (ps == NULL)
return;
35 for (i = 0; i < ps->numProblems; i++) {
37 p->pkgNEVR =
_free(p->pkgNEVR);
38 p->altNEVR =
_free(p->altNEVR);
39 p->str1 =
_free(p->str1);
41 ps->probs =
_free(ps->probs);
53 if (_rpmpsPool == NULL) {
54 _rpmpsPool =
rpmioNewPool(
"ps",
sizeof(*ps), -1, _rpmps_debug,
65 ps->numProblemsAlloced = 0;
74 numProblems = ps->numProblems;
104 if (psi != NULL && ++psi->ix >= 0) {
118 p = psi->ps->probs + psi->ix;
125 const char * dn,
const char * bn,
131 if (ps == NULL)
return;
133 if (ps->numProblems == ps->numProblemsAlloced) {
134 if (ps->numProblemsAlloced)
135 ps->numProblemsAlloced *= 2;
137 ps->numProblemsAlloced = 2;
139 ps->numProblemsAlloced *
sizeof(*ps->probs));
142 p = ps->probs + ps->numProblems;
144 memset(p, 0,
sizeof(*p));
149 p->ignoreProblem = 0;
151 p->pkgNEVR = (pkgNEVR ?
xstrdup(pkgNEVR) : NULL);
152 p->altNEVR = (altNEVR ?
xstrdup(altNEVR) : NULL);
155 if (dn != NULL || bn != NULL) {
156 t = (
char *)
xcalloc(1, (dn != NULL ? strlen(dn) : 0) +
157 (bn != NULL ? strlen(bn) : 0) + 1);
159 if (dn != NULL) t =
stpcpy(t, dn);
160 if (bn != NULL) t =
stpcpy(t, bn);
164 #define XSTRCMP(a, b) ((!(a) && !(b)) || ((a) && (b) && !strcmp((a), (b))))
172 if (ps == NULL || ps->numProblems == 0)
176 return (ps->numProblems == 0 ? 0 : 1);
181 while ((f - filter->probs) < filter->numProblems) {
182 if (!f->ignoreProblem) {
186 while ((t - ps->probs) < ps->numProblems) {
188 if (f->type == t->type && t->key == f->key &&
197 if ((t - ps->probs) == ps->numProblems)
200 t->ignoreProblem = f->ignoreProblem;
204 if ((t - ps->probs) < ps->numProblems)
210 #if !defined(HAVE_VSNPRINTF)
213 const char * fmt, va_list ap)
215 return vsprintf(buf, fmt, ap);
219 #if !defined(HAVE_SNPRINTF)
220 static inline int snprintf(
char * buf,
int nb,
const char * fmt, ...)
234 const char * pkgNEVR = (prob->pkgNEVR ? prob->pkgNEVR :
"?pkgNEVR?");
236 const char * altNEVR = (prob->altNEVR ? prob->altNEVR :
"? ?altNEVR?");
238 const char * str1 = (prob->str1 ? prob->str1 :
N_(
"different"));
239 size_t nb = strlen(pkgNEVR) + strlen(str1) + strlen(altNEVR) + 1024;
240 char * buf = (
char *)
xmalloc(nb+1);
243 switch (prob->type) {
246 _(
"package %s is intended for a %s platform"),
251 _(
"package %s is already installed"),
256 _(
"re-packaged package with %s: %s is missing"),
261 _(
"path %s in package %s is not relocatable"),
266 _(
"file %s conflicts between attempted installs of %s and %s"),
267 str1, pkgNEVR, altNEVR);
271 _(
"file %s from install of %s conflicts with file from package %s"),
272 str1, pkgNEVR, altNEVR);
276 _(
"package %s (which is newer than %s) is already installed"),
281 _(
"installing package %s needs %lu%cB on the %s filesystem"),
283 (
unsigned long) (prob->ulong1 > (1024*1024)
284 ? (prob->ulong1 + 1024 * 1024 - 1) / (1024 * 1024)
285 : (prob->ulong1 + 1023) / 1024),
286 prob->ulong1 > (1024*1024) ?
'M' :
'K',
291 _(
"installing package %s needs %lu inodes on the %s filesystem"),
292 pkgNEVR, (
unsigned long)prob->ulong1, str1);
296 _(
"package %s pre-transaction syscall(s): %s failed: %s"),
297 pkgNEVR, str1, strerror((
int)(prob->ulong1)));
300 rc =
snprintf(buf, nb,
_(
"%s is needed by %s%s"),
302 (prob->ulong1 ?
"" :
_(
"(installed) ")), pkgNEVR);
305 rc =
snprintf(buf, nb,
_(
"%s conflicts with %s%s"),
307 (prob->ulong1 ?
"" :
_(
"(installed) ")), pkgNEVR);
311 _(
"installing package %s on %s rdonly filesystem"),
316 _(
"unknown error %d encountered while manipulating package %s"),
317 prob->type, pkgNEVR);
328 if (ap->type != bp->type)
331 if (bp->pkgNEVR && strcmp(ap->pkgNEVR, bp->pkgNEVR))
334 if (bp->altNEVR && strcmp(ap->altNEVR, bp->altNEVR))
337 if (bp->str1 && strcmp(ap->str1, bp->str1))
340 if (ap->ulong1 != bp->ulong1)
352 if (ps == NULL || ps->probs == NULL || ps->numProblems <= 0)
364 if (p->ignoreProblem)
379 fprintf(fp,
"\t%s\n", msg);
392 num = ps->numProblems - 1;
393 if (num >= ps->numProblems)
395 return (ps->probs + num);
400 return prob->pkgNEVR;
405 return prob->altNEVR;
const char * rpmProblemString(const rpmProblem prob)
Return formatted string representation of a problem.
rpmProblem rpmpsGetProblem(rpmps ps, int num)
Return a problem from problem set.
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.
char * xstrdup(const char *str)
rpmpsi rpmpsFreeIterator(rpmpsi psi)
Destroy problem set iterator.
void rpmpsPrint(FILE *fp, rpmps ps)
Print problems to file handle.
enum rpmProblemType_e rpmProblemType
Enumerate transaction set problem types.
char * rpmProblemGetPkgNEVR(rpmProblem prob)
Return the package NEVR causing the problem.
static int sameProblem(const rpmProblem ap, const rpmProblem bp)
struct rpmps_s * rpmps
Transaction problems found while processing a transaction set/.
int rpmpsTrim(rpmps ps, rpmps filter)
Filter a problem set.
int rpmpsNumProblems(rpmps ps)
Return number of problems in set.
static rpmps rpmpsGetPool(rpmioPool pool)
char * rpmProblemGetStr(rpmProblem prob)
Return a generic data string from a problem.
void * xcalloc(size_t nmemb, size_t size)
rpmps rpmpsCreate(void)
Create a problem set.
Structures and prototypes used for an "rpmps" problem set.
rpmioItem rpmioGetPool(rpmioPool pool, size_t size)
Get unused item from pool, or alloc a new item.
static void rpmpsFini(void *_ps)
int rpmpsNextIterator(rpmpsi psi)
Return next problem set iterator index.
char * rpmProblemGetAltNEVR(rpmProblem prob)
Return the second package NEVR causing the problem.
unsigned long long rpmuint64_t
rpmpsi rpmpsInitIterator(rpmps ps)
Initialize problem set iterator.
rpmuint64_t rpmProblemGetDiskNeed(rpmProblem prob)
Return generic pointer/long attribute from a problem.
static int snprintf(char *buf, int nb, const char *fmt,...)
const char const bson * key
static int vsnprintf(char *buf, int nb, const char *fmt, va_list ap)
rpmProblem rpmpsProblem(rpmpsi psi)
Return current problem from problem set.
rpmioPool rpmioNewPool(const char *name, size_t size, int limit, int flags, char *(*dbg)(void *item), void(*init)(void *item), void(*fini)(void *item))
Create a memory pool.
char * stpcpy(char *dest, const char *src)
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
struct rpmProblem_s * rpmProblem
Raw data for an element of a problem set.
rpmProblemType rpmProblemGetType(rpmProblem prob)
Return the problem type.
rpmps rpmpsUnlink(rpmps ps, const char *msg)
Unreference a problem set instance.
fnpyKey rpmProblemKey(rpmProblem prob)
Return the transaction key causing the problem.
rpmps rpmpsLink(rpmps ps, const char *msg)
Reference a problem set instance.
const char const bson int num