Commit 93936cac50e393cefd8733351f8036d93059a034

Authored by Silvan Calarco
1 parent fac5730549
Exists in master

handleObsoletedPackages(): fix: prevent upper repositories packages to obsolete …

…packages in current repository; code formatting fixes

Showing 3 changed files with 135 additions and 137 deletions Side-by-side Diff

1   -1.5.0
  1 +1.5.0.1
src/backend-sqlite3.c
... ... @@ -235,13 +235,14 @@
235 235 provided->flags,
236 236 provided->numproviders);
237 237 if (sqlite3_prepare_v3(db, sqlite3_query, -1, 0, &stmt, NULL)) {
238   - fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query);
  238 + fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n",
  239 + sqlite3_errmsg(db), sqlite3_query);
239 240 return 1;
240 241 }
241 242 sqlite3_bind_text(stmt, 1, provided->name, -1, SQLITE_STATIC);
242 243 if (sqlite3_step(stmt) != SQLITE_DONE) {
243   - fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
244   - return 3;
  244 + fprintf(stderr, "ERROR: SQLite: (%s %s) %s; ignoring\n", sqlite3_query,
  245 + provided->name, sqlite3_errmsg(db));
245 246 }
246 247 sqlite3_finalize(stmt);
247 248 }
... ... @@ -255,26 +255,26 @@
255 255 }
256 256  
257 257 if (prov->numproviders > 1) {
258   - for (i = 0; i < prov->numproviders; i++) obs[i]=-1;
259   - for (i = 0; i < prov->numproviders; i++)
260   - for (j = 0; j < prov->provider[i]->obsoletecount; j++)
261   - for (k = 0; k < prov->numproviders; k++)
262   - if (!strcmp(prov->provider[i]->obsoletename[j],prov->provider[k]->name)
263   - && strcmp(prov->provider[i]->name,prov->provider[k]->name)) {
264   - if (prov->provider[i]->obsoleteflags[j] & (RPMSENSE_EQUAL|RPMSENSE_GREATER|RPMSENSE_LESS)) {
  258 + for (i = 0; i < prov->numproviders; i++) obs[i]=-1;
  259 + for (i = 0; i < prov->numproviders; i++)
  260 + for (j = 0; j < prov->provider[i]->obsoletecount; j++)
  261 + for (k = 0; k < prov->numproviders; k++)
  262 + if (!strcmp(prov->provider[i]->obsoletename[j],prov->provider[k]->name)
  263 + && strcmp(prov->provider[i]->name,prov->provider[k]->name)) {
  264 + if (prov->provider[i]->obsoleteflags[j] & (RPMSENSE_EQUAL|RPMSENSE_GREATER|RPMSENSE_LESS)) {
265 265 snprintf(buf, PATH_MAX, "%s-%s",prov->provider[k]->version,prov->provider[k]->release);
266 266 if (!checkVersionWithFlags(
267 267 prov->provider[i]->obsoleteversion[j],
268 268 prov->provider[i]->obsoleteflags[j],
269 269 buf)) continue;
270   - }
271   - /* print 'obsoletes' warning for binary packages belonging to target repository,
272   - and 'obsoleted by' for all obsoletions in upper level repositories */
273   - if (prov->provider[k]->altrepository != ct->repository_level) {
274   - currheader = prov->provider[k]->sourceheader->firstchild[archidx];
275   - while (currheader) {
276   - if (!strcmp(currheader->name, prov->provider[k]->name)) {
277   - prov->provider[k]->obsoleted = 1;
  270 + }
  271 + /* print 'obsoletes' warning for binary packages belonging to target repository,
  272 + and 'obsoleted by' for all obsoletions in upper level repositories */
  273 + if (prov->provider[k]->altrepository != ct->repository_level) {
  274 + currheader = prov->provider[k]->sourceheader->firstchild[archidx];
  275 + while (currheader) {
  276 + if (!strcmp(currheader->name, prov->provider[k]->name)) {
  277 + prov->provider[k]->obsoleted = 1;
278 278 snprintf(buf, PATH_MAX, "%s(%s,%s) obsoleted by %s(%s,%s)",
279 279 prov->provider[k]->name,
280 280 prov->provider[k]->arch,
... ... @@ -283,25 +283,27 @@
283 283 prov->provider[i]->arch,
284 284 ct->repository[prov->provider[i]->altrepository]->tag);
285 285 addWarning(prov->provider[k]->sourceheader, buf);
286   - logmsg(LOG_WARNING,"%s", buf);
287   - break;
288   - }
289   - currheader = currheader -> nextbrother;
290   - }
291   - } else {
292   - prov->provider[k]->obsoleted = 1;
293   - snprintf(buf, PATH_MAX, "%s(%s,%s) obsoletes %s(%s,%s)",
294   - prov->provider[i]->name,
295   - prov->provider[i]->arch,
296   - ct->repository[prov->provider[i]->altrepository]->tag,
297   - prov->provider[k]->name,
298   - prov->provider[k]->arch,
299   - ct->repository[prov->provider[k]->altrepository]->tag);
300   - addWarning(prov->provider[i]->sourceheader, buf);
301   - logmsg(LOG_WARNING,"%s", buf);
302   - }
303   - obs[k]=i;
304   - }
  286 + logmsg(LOG_WARNING,"%s", buf);
  287 + break;
  288 + }
  289 + currheader = currheader -> nextbrother;
  290 + }
  291 + obs[k]=i;
  292 + } else if (prov->provider[i]->altrepository == ct->repository_level) {
  293 + // NOTE: don't obsolete if it comes from an upper level repository
  294 + prov->provider[k]->obsoleted = 1;
  295 + snprintf(buf, PATH_MAX, "%s(%s,%s) obsoletes %s(%s,%s)",
  296 + prov->provider[i]->name,
  297 + prov->provider[i]->arch,
  298 + ct->repository[prov->provider[i]->altrepository]->tag,
  299 + prov->provider[k]->name,
  300 + prov->provider[k]->arch,
  301 + ct->repository[prov->provider[k]->altrepository]->tag);
  302 + addWarning(prov->provider[i]->sourceheader, buf);
  303 + logmsg(LOG_WARNING,"%s", buf);
  304 + obs[k]=i;
  305 + }
  306 + }
305 307  
306 308 // now delete found obsoleted providers
307 309 j = prov->numproviders;
... ... @@ -325,7 +327,6 @@
325 327 prov->numproviders = j;
326 328 }
327 329 }
328   -
329 330 prov=prov->next;
330 331 }
331 332  
332 333  
333 334  
334 335  
335 336  
... ... @@ -584,111 +585,107 @@
584 585 provided->version=newversion;
585 586 }
586 587 }
587   - }
  588 + }
588 589 }
589 590  
590   - if (provided->numproviders > 0) {
591   - if (strcmp(currheader->require[i]->version,"") &&
592   - (currheader->require[i]->flags & (RPMSENSE_LESS|RPMSENSE_GREATER|RPMSENSE_EQUAL))) {
  591 + if (provided->numproviders > 0) {
  592 + if (strcmp(currheader->require[i]->version,"") &&
  593 + (currheader->require[i]->flags & (RPMSENSE_LESS|RPMSENSE_GREATER|RPMSENSE_EQUAL))) {
593 594  
594   - found = 0;
595   - foundprovider = -1;
596   - foundupstreamprovider = 0;
597   - for (j = 0; j < provided->numproviders; j++) {
598   - /* updated packages: ignore check with upstream package */
599   - if ((foundprovider >= 0) &&
600   - !strcmp(provided->provider[foundprovider]->name,provided->provider[j]->name) &&
601   - provided->provider[foundprovider]->altrepository < provided->provider[j]->altrepository) {
602   - found -= 1;
603   - foundupstreamprovider = foundprovider;
604   - foundprovider = -1;
605   - }
606   - if (!strcmp(provided->version[j],"")) {
607   - /* provider with no version; assume ok */
608   - found += 1;
609   - foundupstreamprovider = foundprovider;
610   - foundprovider = j;
611   - } else {
612   - if (checkVersionWithFlags(
613   - currheader->require[i]->version,
614   - currheader->require[i]->flags,
615   - provided->version[j])) {
616   - found += 1;
617   - foundupstreamprovider = foundprovider;
618   - foundprovider = j;
619   - }
620   - }
621   -/*if (!strcmp(provided->name,"pkgconfig(gio-2.0)"))
622   - printf("provided->name=pkgconfig(gio-2.0) found=%d foundprovider=%d foundupstreamprovider=%d provided->version[j]=%s\n",
623   - found, foundprovider, foundupstreamprovider, provided->version[j]);*/
624   - } /* for */
625   - if ((found >= 1) && (!foundupstreamprovider) &&
626   - (currheader->altrepository != 0) &&
627   - (currheader->altrepository = ct->repository_level) &&
628   - (provided->provider[foundprovider]->sourceheader != currheader->sourceheader) &&
629   - (provided->provider[foundprovider]->altrepository == currheader->altrepository)) {
630   - snprintf(warning, PATH_MAX, "%s(%s,%s) requires %s(%s,%s) because it needs %s=%s",
631   - currheader->name,
632   - currheader->arch,
633   - ct->repository[currheader->altrepository]->tag,
634   - provided->provider[foundprovider]->name,
635   - provided->provider[foundprovider]->arch,
636   - ct->repository[provided->provider[foundprovider]->altrepository]->tag,
637   - provided->name,
638   - provided->version[foundprovider]);
639   - logmsg(LOG_WARNING,"%s", warning);
640   - addWarning(currheader->sourceheader, warning);
641   - } else if (!found) {
642   - for (j = 0; j < provided->numproviders; j++) {
643   - if (!checkVersionWithFlags(
644   - currheader->require[i]->version,
645   - currheader->require[i]->flags,
646   - provided->version[j])) {
647   - snprintf(warning, PATH_MAX, "%s=%s from %s(%s,%s) fails to provide %s",
648   - provided->name,
649   - provided->version[j],
650   - provided->provider[j]->name,
651   - provided->provider[j]->arch,
652   - ct->repository[provided->provider[j]->altrepository]->tag,
653   - provided->name);
654   - if (currheader->require[i]->flags & RPMSENSE_LESS) snprintf(&warning[strlen(warning)], PATH_MAX,"<");
655   - if (currheader->require[i]->flags & RPMSENSE_GREATER) snprintf(&warning[strlen(warning)], PATH_MAX, ">");
656   - if (currheader->require[i]->flags & RPMSENSE_EQUAL) snprintf(&warning[strlen(warning)], PATH_MAX, "=");
657   - snprintf(&warning[strlen(warning)], PATH_MAX, "%s to %s(%s,%s)",
  595 + found = 0;
  596 + foundprovider = -1;
  597 + foundupstreamprovider = 0;
  598 + for (j = 0; j < provided->numproviders; j++) {
  599 + /* updated packages: ignore check with upstream package */
  600 + if ((foundprovider >= 0) &&
  601 + !strcmp(provided->provider[foundprovider]->name,provided->provider[j]->name) &&
  602 + provided->provider[foundprovider]->altrepository < provided->provider[j]->altrepository)
  603 + {
  604 + found -= 1;
  605 + foundupstreamprovider = foundprovider;
  606 + foundprovider = -1;
  607 + }
  608 + if (!strcmp(provided->version[j],"")) {
  609 + /* provider with no version; assume ok */
  610 + found += 1;
  611 + foundupstreamprovider = foundprovider;
  612 + foundprovider = j;
  613 + } else {
  614 + if (checkVersionWithFlags(
  615 + currheader->require[i]->version,
  616 + currheader->require[i]->flags,
  617 + provided->version[j])) {
  618 + found += 1;
  619 + foundupstreamprovider = foundprovider;
  620 + foundprovider = j;
  621 + }
  622 + }
  623 + } /* for */
  624 + if ((found >= 1) && (!foundupstreamprovider) &&
  625 + (currheader->altrepository != 0) &&
  626 + (currheader->altrepository = ct->repository_level) &&
  627 + (provided->provider[foundprovider]->sourceheader != currheader->sourceheader) &&
  628 + (provided->provider[foundprovider]->altrepository == currheader->altrepository)) {
  629 + snprintf(warning, PATH_MAX, "%s(%s,%s) requires %s(%s,%s) because it needs %s=%s",
  630 + currheader->name, currheader->arch,
  631 + ct->repository[currheader->altrepository]->tag,
  632 + provided->provider[foundprovider]->name,
  633 + provided->provider[foundprovider]->arch,
  634 + ct->repository[provided->provider[foundprovider]->altrepository]->tag,
  635 + provided->name,
  636 + provided->version[foundprovider]);
  637 + logmsg(LOG_WARNING,"%s", warning);
  638 + addWarning(currheader->sourceheader, warning);
  639 + } else if (!found) {
  640 + for (j = 0; j < provided->numproviders; j++) {
  641 + if (!checkVersionWithFlags(
  642 + currheader->require[i]->version,
  643 + currheader->require[i]->flags,
  644 + provided->version[j])) {
  645 + snprintf(warning, PATH_MAX, "%s=%s from %s(%s,%s) fails to provide %s",
  646 + provided->name,
  647 + provided->version[j],
  648 + provided->provider[j]->name,
  649 + provided->provider[j]->arch,
  650 + ct->repository[provided->provider[j]->altrepository]->tag,
  651 + provided->name);
  652 + if (currheader->require[i]->flags & RPMSENSE_LESS) snprintf(&warning[strlen(warning)], PATH_MAX,"<");
  653 + if (currheader->require[i]->flags & RPMSENSE_GREATER) snprintf(&warning[strlen(warning)], PATH_MAX, ">");
  654 + if (currheader->require[i]->flags & RPMSENSE_EQUAL) snprintf(&warning[strlen(warning)], PATH_MAX, "=");
  655 + snprintf(&warning[strlen(warning)], PATH_MAX, "%s to %s(%s,%s)",
658 656 currheader->require[i]->version,
659 657 currheader->name,
660 658 currheader->arch,
661 659 ct->repository[currheader->altrepository]->tag);
662   - logmsg(LOG_WARNING,"%s", warning);
663   - for (k = 0; k < provided->numproviders; k++) {
664   - if (provided->provider[k]->sourceheader &&
665   - (provided->provider[k]->altrepository == ct->repository_level)) {
666   - addWarning(provided->provider[k]->sourceheader, warning);
667   - }
668   - if ((currheader->altrepository == ct->repository_level)) {
669   - addWarning(currheader->sourceheader, warning);
670   - }
671   - }
672   - }
673   - }
674   - }
675   -
676   - }
677   - }
678   - currheader->require[i]->resolved=provided;
679   - } else {
680   - currheader->require[i]->resolved=NULL;
681   - }
  660 + logmsg(LOG_WARNING,"%s", warning);
  661 + for (k = 0; k < provided->numproviders; k++) {
  662 + if (provided->provider[k]->sourceheader &&
  663 + (provided->provider[k]->altrepository == ct->repository_level)) {
  664 + addWarning(provided->provider[k]->sourceheader, warning);
  665 + }
  666 + if ((currheader->altrepository == ct->repository_level)) {
  667 + addWarning(currheader->sourceheader, warning);
  668 + }
  669 + }
  670 + }
  671 + } /* for */
  672 + }
  673 + }
682 674 }
683   - // sort required list by first provider's name
684   - qsort((void *) &currheader->require[0],
685   - currheader->requirecount,
686   - sizeof(struct Require *),
687   - compareRequiredList);
688   - currheader = currheader->next;
689   - }
690   - logmsg(LOG_DEBUG,"resolveFirstLevelDependencies - done");
691   - return 0;
  675 + currheader->require[i]->resolved=provided;
  676 + } else {
  677 + currheader->require[i]->resolved=NULL;
  678 + }
  679 + }
  680 + // sort required list by first provider's name
  681 + qsort((void *) &currheader->require[0],
  682 + currheader->requirecount,
  683 + sizeof(struct Require *),
  684 + compareRequiredList);
  685 + currheader = currheader->next;
  686 + }
  687 + logmsg(LOG_DEBUG,"resolveFirstLevelDependencies - done");
  688 + return 0;
692 689 }
693 690  
694 691 static int