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;
124 const char * pkgNEVR,
fnpyKey key,
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;