9 #define _RPMPS_INTERNAL
22 const char * fn,
unsigned ln)
26 fprintf(stderr,
"--> ps %p -- %d %s at %s:%u\n", ps, ps->nrefs, msg, fn, ln);
35 const char * fn,
unsigned ln)
40 fprintf(stderr,
"--> ps %p ++ %d %s at %s:%u\n", ps, ps->nrefs, msg, fn, ln);
51 numProblems = ps->numProblems;
63 if (ps == NULL)
return NULL;
70 for (i = 0; i < ps->numProblems; i++) {
72 p->pkgNEVR =
_free(p->pkgNEVR);
73 p->altNEVR =
_free(p->altNEVR);
74 p->str1 =
_free(p->str1);
76 ps->probs =
_free(ps->probs);
83 const char * pkgNEVR,
fnpyKey key,
84 const char * dn,
const char * bn,
85 const char * altNEVR,
unsigned long long ulong1)
90 if (ps == NULL)
return;
92 if (ps->numProblems == ps->numProblemsAlloced) {
93 if (ps->numProblemsAlloced)
94 ps->numProblemsAlloced *= 2;
96 ps->numProblemsAlloced = 2;
98 ps->numProblemsAlloced *
sizeof(*ps->probs));
101 p = ps->probs + ps->numProblems;
104 memset(p, 0,
sizeof(*p));
110 p->ignoreProblem = 0;
112 p->pkgNEVR = (pkgNEVR ?
xstrdup(pkgNEVR) : NULL);
113 p->altNEVR = (altNEVR ?
xstrdup(altNEVR) : NULL);
116 if (dn != NULL || bn != NULL) {
118 t =
xcalloc(1, (dn != NULL ? strlen(dn) : 0) +
119 (bn != NULL ? strlen(bn) : 0) + 1);
121 if (dn != NULL) t =
stpcpy(t, dn);
122 if (bn != NULL) t =
stpcpy(t, bn);
127 #define XSTRCMP(a, b) ((!(a) && !(b)) || ((a) && (b) && !strcmp((a), (b))))
135 if (ps == NULL || ps->numProblems == 0)
139 return (ps->numProblems == 0 ? 0 : 1);
144 while ((f - filter->probs) < filter->numProblems) {
145 if (!f->ignoreProblem) {
149 while ((t - ps->probs) < ps->numProblems) {
151 if (f->type == t->type && t->key == f->key &&
160 if ((t - ps->probs) == ps->numProblems)
163 t->ignoreProblem = f->ignoreProblem;
167 if ((t - ps->probs) < ps->numProblems)
173 #if !defined(HAVE_VSNPRINTF)
176 const char * fmt, va_list ap)
178 return vsprintf(buf, fmt, ap);
182 #if !defined(HAVE_SNPRINTF)
183 static inline int snprintf(
char * buf,
int nb,
const char * fmt, ...)
197 const char * pkgNEVR = (prob->pkgNEVR ? prob->pkgNEVR :
"?pkgNEVR?");
199 const char * altNEVR = (prob->altNEVR ? prob->altNEVR :
"? ?altNEVR?");
201 const char * str1 = (prob->str1 ? prob->str1 :
N_(
"different"));
202 int nb = strlen(pkgNEVR) + strlen(str1) + strlen(altNEVR) + 100;
206 switch (prob->type) {
209 _(
"package %s is intended for a %s platform"),
214 _(
"package %s is already installed"),
219 _(
"re-packaged package with %s: %s is missing"),
224 _(
"path %s in package %s is not relocatable"),
229 _(
"file %s conflicts between attempted installs of %s and %s"),
230 str1, pkgNEVR, altNEVR);
234 _(
"file %s from install of %s conflicts with file from package %s"),
235 str1, pkgNEVR, altNEVR);
239 _(
"package %s (which is newer than %s) is already installed"),
244 _(
"installing package %s needs %lu%cB on the %s filesystem"),
246 (
unsigned long) (prob->ulong1 > (1024*1024)
247 ? (prob->ulong1 + 1024 * 1024 - 1) / (1024 * 1024)
248 : (prob->ulong1 + 1023) / 1024),
249 prob->ulong1 > (1024*1024) ?
'M' :
'K',
254 _(
"installing package %s needs %lu inodes on the %s filesystem"),
255 pkgNEVR, (
unsigned long)prob->ulong1, str1);
259 _(
"package %s pre-transaction syscall(s): %s failed: %s"),
260 pkgNEVR, str1, strerror((
int)(prob->ulong1)));
263 rc =
snprintf(buf, nb,
_(
"%s is needed by %s%s"),
265 (prob->ulong1 ?
"" :
_(
"(installed) ")), pkgNEVR);
268 rc =
snprintf(buf, nb,
_(
"%s conflicts with %s%s"),
270 (prob->ulong1 ?
"" :
_(
"(installed) ")), pkgNEVR);
274 _(
"installing package %s on %s rdonly filesystem"),
279 _(
"unknown error %d encountered while manipulating package %s"),
280 prob->type, pkgNEVR);
291 if (ap->type != bp->type)
294 if (bp->pkgNEVR && strcmp(ap->pkgNEVR, bp->pkgNEVR))
297 if (bp->altNEVR && strcmp(ap->altNEVR, bp->altNEVR))
300 if (bp->str1 && strcmp(ap->str1, bp->str1))
303 if (ap->ulong1 != bp->ulong1)
314 if (ps == NULL || ps->probs == NULL || ps->numProblems <= 0)
320 for (i = 0; i < ps->numProblems; i++) {
326 if (p->ignoreProblem)
330 for (j = 0; j < i; j++) {
338 fprintf(fp,
"\t%s\n", msg);
346 if (num > ps->numProblems)
349 return(ps->probs + num);
354 return(prob->pkgNEVR);
359 return(prob->altNEVR);
369 return(prob->ulong1);