libdpkg: Deindent an else clause
[dpkg.git] / src / main / packages.c
blobaba9ba700f297a784a9490181233233aa0e64258
1 /*
2 * dpkg - main program for package management
3 * packages.c - common to actions that process packages
5 * Copyright © 1994,1995 Ian Jackson <ijackson@chiark.greenend.org.uk>
6 * Copyright © 2006-2014 Guillem Jover <guillem@debian.org>
7 * Copyright © 2011 Linaro Limited
8 * Copyright © 2011 Raphaël Hertzog <hertzog@debian.org>
10 * This is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 #include <config.h>
25 #include <compat.h>
27 #include <sys/types.h>
28 #include <sys/stat.h>
30 #include <string.h>
31 #include <fcntl.h>
32 #include <dirent.h>
33 #include <unistd.h>
34 #include <stdlib.h>
35 #include <stdio.h>
37 #include <dpkg/i18n.h>
38 #include <dpkg/dpkg.h>
39 #include <dpkg/dpkg-db.h>
40 #include <dpkg/pkg-list.h>
41 #include <dpkg/pkg-queue.h>
42 #include <dpkg/string.h>
43 #include <dpkg/options.h>
44 #include <dpkg/db-ctrl.h>
45 #include <dpkg/db-fsys.h>
47 #include "main.h"
49 static struct pkginfo *progress_bytrigproc;
50 static struct pkg_queue queue = PKG_QUEUE_INIT;
52 enum dependtry dependtry = DEPEND_TRY_NORMAL;
53 int sincenothing = 0;
55 void
56 enqueue_package(struct pkginfo *pkg)
58 ensure_package_clientdata(pkg);
59 if (pkg->clientdata->enqueued)
60 return;
61 pkg->clientdata->enqueued = true;
62 pkg_queue_push(&queue, pkg);
65 void
66 enqueue_package_mark_seen(struct pkginfo *pkg)
68 enqueue_package(pkg);
69 pkg->clientdata->cmdline_seen++;
72 static void
73 enqueue_pending(void)
75 struct pkg_hash_iter *iter;
76 struct pkginfo *pkg;
78 iter = pkg_hash_iter_new();
79 while ((pkg = pkg_hash_iter_next_pkg(iter)) != NULL) {
80 switch (cipaction->arg_int) {
81 case act_configure:
82 if (!(pkg->status == PKG_STAT_UNPACKED ||
83 pkg->status == PKG_STAT_HALFCONFIGURED ||
84 pkg->trigpend_head))
85 continue;
86 if (pkg->want != PKG_WANT_INSTALL &&
87 pkg->want != PKG_WANT_HOLD)
88 continue;
89 break;
90 case act_triggers:
91 if (!pkg->trigpend_head)
92 continue;
93 if (pkg->want != PKG_WANT_INSTALL &&
94 pkg->want != PKG_WANT_HOLD)
95 continue;
96 break;
97 case act_remove:
98 case act_purge:
99 if (pkg->want != PKG_WANT_PURGE) {
100 if (pkg->want != PKG_WANT_DEINSTALL)
101 continue;
102 if (pkg->status == PKG_STAT_CONFIGFILES)
103 continue;
105 if (pkg->status == PKG_STAT_NOTINSTALLED)
106 continue;
107 break;
108 default:
109 internerr("unknown action '%d'", cipaction->arg_int);
111 enqueue_package(pkg);
113 pkg_hash_iter_free(iter);
116 static void
117 enqueue_specified(const char *const *argv)
119 const char *thisarg;
121 while ((thisarg = *argv++) != NULL) {
122 struct pkginfo *pkg;
124 pkg = dpkg_options_parse_pkgname(cipaction, thisarg);
125 if (pkg->status == PKG_STAT_NOTINSTALLED &&
126 str_match_end(pkg->set->name, DEBEXT)) {
127 badusage(_("you must specify packages by their own names, "
128 "not by quoting the names of the files they come in"));
130 enqueue_package_mark_seen(pkg);
133 if (cipaction->arg_int == act_configure)
134 trigproc_populate_deferred();
138 packages(const char *const *argv)
140 trigproc_install_hooks();
142 modstatdb_open(f_noact ? msdbrw_readonly :
143 in_force(FORCE_NON_ROOT) ? msdbrw_write :
144 msdbrw_needsuperuser);
145 checkpath();
146 pkg_infodb_upgrade();
148 log_message("startup packages %s", cipaction->olong);
150 if (f_pending) {
151 if (*argv)
152 badusage(_("--%s --pending does not take any non-option arguments"),cipaction->olong);
154 enqueue_pending();
155 } else {
156 if (!*argv)
157 badusage(_("--%s (without --pending) needs at least one package name argument"),
158 cipaction->olong);
160 enqueue_specified(argv);
163 ensure_diversions();
165 process_queue();
166 trigproc_run_deferred();
168 modstatdb_shutdown();
170 return 0;
173 void process_queue(void) {
174 struct pkg_list *rundown;
175 volatile enum action action_todo;
176 jmp_buf ejbuf;
177 enum pkg_istobe istobe = PKG_ISTOBE_NORMAL;
179 if (abort_processing)
180 return;
182 clear_istobes();
184 switch (cipaction->arg_int) {
185 case act_triggers:
186 case act_configure:
187 case act_install:
188 istobe = PKG_ISTOBE_INSTALLNEW;
189 break;
190 case act_remove:
191 case act_purge:
192 istobe = PKG_ISTOBE_REMOVE;
193 break;
194 default:
195 internerr("unknown action '%d'", cipaction->arg_int);
197 for (rundown = queue.head; rundown; rundown = rundown->next) {
198 ensure_package_clientdata(rundown->pkg);
200 /* We have processed this package more than once. There are no duplicates
201 * as we make sure of that when enqueuing them. */
202 if (rundown->pkg->clientdata->cmdline_seen > 1) {
203 switch (cipaction->arg_int) {
204 case act_triggers:
205 case act_configure: case act_remove: case act_purge:
206 printf(_("Package %s listed more than once, only processing once.\n"),
207 pkg_name(rundown->pkg, pnaw_nonambig));
208 break;
209 case act_install:
210 printf(_("More than one copy of package %s has been unpacked\n"
211 " in this run ! Only configuring it once.\n"),
212 pkg_name(rundown->pkg, pnaw_nonambig));
213 break;
214 default:
215 internerr("unknown action '%d'", cipaction->arg_int);
218 rundown->pkg->clientdata->istobe = istobe;
221 while (!pkg_queue_is_empty(&queue)) {
222 struct pkginfo *volatile pkg;
224 pkg = pkg_queue_pop(&queue);
225 if (!pkg)
226 continue; /* Duplicate, which we removed earlier. */
228 ensure_package_clientdata(pkg);
229 pkg->clientdata->enqueued = false;
231 action_todo = cipaction->arg_int;
233 if (sincenothing++ > queue.length * 3 + 2) {
234 /* Make sure that even if we have exceeded the queue since not having
235 * made any progress, we are not getting stuck trying to progress by
236 * trigger processing, w/o jumping into the next dependtry. */
237 dependtry++;
238 sincenothing = 0;
239 if (dependtry >= DEPEND_TRY_LAST)
240 internerr("exceeded dependtry %d (sincenothing=%d; queue.length=%d)",
241 dependtry, sincenothing, queue.length);
242 } else if (sincenothing > queue.length * 2 + 2) {
243 if (dependtry >= DEPEND_TRY_TRIGGERS &&
244 progress_bytrigproc && progress_bytrigproc->trigpend_head) {
245 enqueue_package(pkg);
246 pkg = progress_bytrigproc;
247 progress_bytrigproc = NULL;
248 action_todo = act_configure;
249 } else {
250 dependtry++;
251 sincenothing = 0;
252 if (dependtry >= DEPEND_TRY_LAST)
253 internerr("exceeded dependtry %d (sincenothing=%d, queue.length=%d)",
254 dependtry, sincenothing, queue.length);
258 debug(dbg_general, "process queue pkg %s queue.len %d progress %d, try %d",
259 pkg_name(pkg, pnaw_always), queue.length, sincenothing, dependtry);
261 if (pkg->status > PKG_STAT_INSTALLED)
262 internerr("package %s status %d is out-of-bounds",
263 pkg_name(pkg, pnaw_always), pkg->status);
265 if (setjmp(ejbuf)) {
266 /* Give up on it from the point of view of other packages, i.e. reset
267 * istobe. */
268 pkg->clientdata->istobe = PKG_ISTOBE_NORMAL;
270 pop_error_context(ehflag_bombout);
271 if (abort_processing)
272 return;
273 continue;
275 push_error_context_jump(&ejbuf, print_error_perpackage,
276 pkg_name(pkg, pnaw_nonambig));
278 switch (action_todo) {
279 case act_triggers:
280 if (!pkg->trigpend_head)
281 ohshit(_("package %.250s is not ready for trigger processing\n"
282 " (current status '%.250s' with no pending triggers)"),
283 pkg_name(pkg, pnaw_nonambig), pkg_status_name(pkg));
284 /* Fall through. */
285 case act_install:
286 /* Don't try to configure pkgs that we've just disappeared. */
287 if (pkg->status == PKG_STAT_NOTINSTALLED)
288 break;
289 /* Fall through. */
290 case act_configure:
291 /* Do whatever is most needed. */
292 if (pkg->trigpend_head)
293 trigproc(pkg, TRIGPROC_TRY_QUEUED);
294 else
295 deferred_configure(pkg);
296 break;
297 case act_remove: case act_purge:
298 deferred_remove(pkg);
299 break;
300 default:
301 internerr("unknown action '%d'", cipaction->arg_int);
303 m_output(stdout, _("<standard output>"));
304 m_output(stderr, _("<standard error>"));
306 pop_error_context(ehflag_normaltidy);
309 if (queue.length)
310 internerr("finished package processing with non-empty queue length %d",
311 queue.length);
314 /*** Dependency processing - common to --configure and --remove. ***/
317 * The algorithm for deciding what to configure or remove first is as
318 * follows:
320 * Loop through all packages doing a ‘try 1’ until we've been round and
321 * nothing has been done, then do ‘try 2’ and ‘try 3’ likewise.
323 * When configuring, in each try we check to see whether all
324 * dependencies of this package are done. If so we do it. If some of
325 * the dependencies aren't done yet but will be later we defer the
326 * package, otherwise it is an error.
328 * When removing, in each try we check to see whether there are any
329 * packages that would have dependencies missing if we removed this
330 * one. If not we remove it now. If some of these packages are
331 * themselves scheduled for removal we defer the package until they
332 * have been done.
334 * The criteria for satisfying a dependency vary with the various
335 * tries. In try 1 we treat the dependencies as absolute. In try 2 we
336 * check break any cycles in the dependency graph involving the package
337 * we are trying to process before trying to process the package
338 * normally. In try 3 (which should only be reached if
339 * --force-depends-version is set) we ignore version number clauses in
340 * Depends lines. In try 4 (only reached if --force-depends is set) we
341 * say "ok" regardless.
343 * If we are configuring and one of the packages we depend on is
344 * awaiting configuration but wasn't specified in the argument list we
345 * will add it to the argument list if --configure-any is specified.
346 * In this case we note this as having "done something" so that we
347 * don't needlessly escalate to higher levels of dependency checking
348 * and breaking.
351 enum found_status {
352 FOUND_NONE = 0,
353 FOUND_DEFER = 1,
354 FOUND_FORCED = 2,
355 FOUND_OK = 3,
358 static enum found_status
359 found_forced_on(enum dependtry dependtry_forced)
361 if (dependtry >= dependtry_forced)
362 return FOUND_FORCED;
363 else
364 return FOUND_DEFER;
368 * Return values:
369 * 0: cannot be satisfied.
370 * 1: defer: may be satisfied later, when other packages are better or
371 * at higher dependtry due to --force
372 * will set *fixbytrig to package whose trigger processing would help
373 * if applicable (and leave it alone otherwise).
374 * 2: not satisfied but forcing
375 * (*interestingwarnings >= 0 on exit? caller is to print oemsgs).
376 * 3: satisfied now.
378 static enum found_status
379 deppossi_ok_found(struct pkginfo *possdependee, struct pkginfo *requiredby,
380 struct pkginfo *removing, struct deppossi *provider,
381 struct pkginfo **fixbytrig,
382 bool *matched, struct deppossi *checkversion,
383 int *interestingwarnings, struct varbuf *oemsgs)
385 enum found_status thisf;
387 if (ignore_depends(possdependee)) {
388 debug(dbg_depcondetail," ignoring depended package so ok and found");
389 return FOUND_OK;
391 thisf = FOUND_NONE;
392 if (possdependee == removing) {
393 if (provider) {
394 varbuf_printf(oemsgs,
395 _(" Package %s which provides %s is to be removed.\n"),
396 pkg_name(possdependee, pnaw_nonambig),
397 provider->ed->name);
398 } else {
399 varbuf_printf(oemsgs, _(" Package %s is to be removed.\n"),
400 pkg_name(possdependee, pnaw_nonambig));
403 *matched = true;
404 debug(dbg_depcondetail," removing possdependee, returning %d",thisf);
405 return thisf;
407 switch (possdependee->status) {
408 case PKG_STAT_UNPACKED:
409 case PKG_STAT_HALFCONFIGURED:
410 case PKG_STAT_TRIGGERSAWAITED:
411 case PKG_STAT_TRIGGERSPENDING:
412 case PKG_STAT_INSTALLED:
413 if (checkversion) {
414 if (provider) {
415 debug(dbg_depcondetail, " checking package %s provided by pkg %s",
416 checkversion->ed->name, pkg_name(possdependee, pnaw_always));
417 if (!pkg_virtual_deppossi_satisfied(checkversion, provider)) {
418 varbuf_printf(oemsgs,
419 _(" Version of %s on system, provided by %s, is %s.\n"),
420 checkversion->ed->name,
421 pkg_name(possdependee, pnaw_always),
422 versiondescribe(&provider->version, vdew_nonambig));
423 if (in_force(FORCE_DEPENDS_VERSION))
424 thisf = found_forced_on(DEPEND_TRY_FORCE_DEPENDS_VERSION);
425 debug(dbg_depcondetail, " bad version");
426 goto unsuitable;
428 } else {
429 debug(dbg_depcondetail, " checking non-provided pkg %s",
430 pkg_name(possdependee, pnaw_always));
431 if (!versionsatisfied(&possdependee->installed, checkversion)) {
432 varbuf_printf(oemsgs, _(" Version of %s on system is %s.\n"),
433 pkg_name(possdependee, pnaw_nonambig),
434 versiondescribe(&possdependee->installed.version,
435 vdew_nonambig));
436 if (in_force(FORCE_DEPENDS_VERSION))
437 thisf = found_forced_on(DEPEND_TRY_FORCE_DEPENDS_VERSION);
438 debug(dbg_depcondetail, " bad version");
439 goto unsuitable;
443 if (possdependee->status == PKG_STAT_INSTALLED ||
444 possdependee->status == PKG_STAT_TRIGGERSPENDING) {
445 debug(dbg_depcondetail," is installed, ok and found");
446 return FOUND_OK;
448 if (possdependee->status == PKG_STAT_TRIGGERSAWAITED) {
449 if (possdependee->trigaw.head == NULL)
450 internerr("package %s in state %s, has no awaited triggers",
451 pkg_name(possdependee, pnaw_always),
452 pkg_status_name(possdependee));
454 if (removing ||
455 !(f_triggers ||
456 (possdependee->clientdata &&
457 possdependee->clientdata->istobe == PKG_ISTOBE_INSTALLNEW))) {
458 if (provider) {
459 varbuf_printf(oemsgs,
460 _(" Package %s which provides %s awaits trigger processing.\n"),
461 pkg_name(possdependee, pnaw_nonambig),
462 provider->ed->name);
463 } else {
464 varbuf_printf(oemsgs,
465 _(" Package %s awaits trigger processing.\n"),
466 pkg_name(possdependee, pnaw_nonambig));
468 debug(dbg_depcondetail, " triggers-awaited, no fixbytrig");
469 goto unsuitable;
471 /* We don't check the status of trigaw.head->pend here, just in case
472 * we get into the pathological situation where Triggers-Awaited but
473 * the named package doesn't actually have any pending triggers. In
474 * that case we queue the non-pending package for trigger processing
475 * anyway, and that trigger processing will be a noop except for
476 * sorting out all of the packages which name it in Triggers-Awaited.
478 * (This situation can only arise if modstatdb_note success in
479 * clearing the triggers-pending status of the pending package
480 * but then fails to go on to update the awaiters.) */
481 *fixbytrig = possdependee->trigaw.head->pend;
482 debug(dbg_depcondetail,
483 " triggers-awaited, fixbytrig '%s', defer",
484 pkg_name(*fixbytrig, pnaw_always));
485 return FOUND_DEFER;
487 if (possdependee->clientdata &&
488 possdependee->clientdata->istobe == PKG_ISTOBE_INSTALLNEW) {
489 debug(dbg_depcondetail," unpacked/halfconfigured, defer");
490 return FOUND_DEFER;
491 } else if (!removing && in_force(FORCE_CONFIGURE_ANY) &&
492 !skip_due_to_hold(possdependee) &&
493 !(possdependee->status == PKG_STAT_HALFCONFIGURED)) {
494 notice(_("also configuring '%s' (required by '%s')"),
495 pkg_name(possdependee, pnaw_nonambig),
496 pkg_name(requiredby, pnaw_nonambig));
497 enqueue_package(possdependee);
498 sincenothing = 0;
499 return FOUND_DEFER;
500 } else {
501 if (provider) {
502 varbuf_printf(oemsgs,
503 _(" Package %s which provides %s is not configured yet.\n"),
504 pkg_name(possdependee, pnaw_nonambig),
505 provider->ed->name);
506 } else {
507 varbuf_printf(oemsgs, _(" Package %s is not configured yet.\n"),
508 pkg_name(possdependee, pnaw_nonambig));
511 debug(dbg_depcondetail, " not configured/able");
512 goto unsuitable;
515 default:
516 if (provider) {
517 varbuf_printf(oemsgs,
518 _(" Package %s which provides %s is not installed.\n"),
519 pkg_name(possdependee, pnaw_nonambig),
520 provider->ed->name);
521 } else {
522 varbuf_printf(oemsgs, _(" Package %s is not installed.\n"),
523 pkg_name(possdependee, pnaw_nonambig));
526 debug(dbg_depcondetail, " not installed");
527 goto unsuitable;
530 unsuitable:
531 debug(dbg_depcondetail, " returning %d", thisf);
532 (*interestingwarnings)++;
534 return thisf;
537 static void
538 breaks_check_one(struct varbuf *aemsgs, enum dep_check *ok,
539 struct deppossi *breaks, struct pkginfo *broken,
540 struct pkginfo *breaker, struct deppossi *virtbroken)
542 struct varbuf depmsg = VARBUF_INIT;
544 debug(dbg_depcondetail, " checking breaker %s virtbroken %s",
545 pkg_name(breaker, pnaw_always),
546 virtbroken ? virtbroken->ed->name : "<none>");
548 if (breaker->status == PKG_STAT_NOTINSTALLED ||
549 breaker->status == PKG_STAT_CONFIGFILES)
550 return;
551 if (broken == breaker) return;
552 if (!versionsatisfied(&broken->installed, breaks)) return;
553 /* The test below can only trigger if dep_breaks start having
554 * arch qualifiers different from “any”. */
555 if (!archsatisfied(&broken->installed, breaks))
556 return;
557 if (ignore_depends(breaker)) return;
558 if (virtbroken && ignore_depends(&virtbroken->ed->pkg))
559 return;
560 if (virtbroken && !pkg_virtual_deppossi_satisfied(breaks, virtbroken))
561 return;
563 varbufdependency(&depmsg, breaks->up);
564 varbuf_end_str(&depmsg);
565 varbuf_printf(aemsgs, _(" %s (%s) breaks %s and is %s.\n"),
566 pkg_name(breaker, pnaw_nonambig),
567 versiondescribe(&breaker->installed.version, vdew_nonambig),
568 depmsg.buf, gettext(statusstrings[breaker->status]));
569 varbuf_destroy(&depmsg);
571 if (virtbroken) {
572 varbuf_printf(aemsgs, _(" %s (%s) provides %s.\n"),
573 pkg_name(broken, pnaw_nonambig),
574 versiondescribe(&broken->installed.version, vdew_nonambig),
575 virtbroken->ed->name);
576 } else if (breaks->verrel != DPKG_RELATION_NONE) {
577 varbuf_printf(aemsgs, _(" Version of %s to be configured is %s.\n"),
578 pkg_name(broken, pnaw_nonambig),
579 versiondescribe(&broken->installed.version, vdew_nonambig));
580 if (in_force(FORCE_DEPENDS_VERSION))
581 return;
583 if (force_breaks(breaks)) return;
584 *ok = DEP_CHECK_HALT;
587 static void
588 breaks_check_target(struct varbuf *aemsgs, enum dep_check *ok,
589 struct pkginfo *broken, struct pkgset *target,
590 struct deppossi *virtbroken)
592 struct deppossi *possi;
594 for (possi = target->depended.installed; possi; possi = possi->rev_next) {
595 if (possi->up->type != dep_breaks) continue;
596 breaks_check_one(aemsgs, ok, possi, broken, possi->up->up, virtbroken);
600 enum dep_check
601 breakses_ok(struct pkginfo *pkg, struct varbuf *aemsgs)
603 struct dependency *dep;
604 struct deppossi *virtbroken;
605 enum dep_check ok = DEP_CHECK_OK;
607 debug(dbg_depcon, " checking Breaks");
609 breaks_check_target(aemsgs, &ok, pkg, pkg->set, NULL);
611 for (dep= pkg->installed.depends; dep; dep= dep->next) {
612 if (dep->type != dep_provides) continue;
613 virtbroken = dep->list;
614 debug(dbg_depcondetail, " checking virtbroken %s", virtbroken->ed->name);
615 breaks_check_target(aemsgs, &ok, pkg, virtbroken->ed, virtbroken);
617 return ok;
621 * Checks [Pre]-Depends only.
623 enum dep_check
624 dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
625 struct varbuf *aemsgs)
627 /* Valid values: 2 = ok, 1 = defer, 0 = halt. */
628 enum dep_check ok;
629 /* Valid values: 0 = none, 1 = defer, 2 = withwarning, 3 = ok. */
630 enum found_status found, thisf;
631 int interestingwarnings;
632 bool matched, anycannotfixbytrig;
633 struct varbuf oemsgs = VARBUF_INIT;
634 struct dependency *dep;
635 struct deppossi *possi, *provider;
636 struct pkginfo *possfixbytrig, *canfixbytrig;
638 ok = DEP_CHECK_OK;
639 debug(dbg_depcon,"checking dependencies of %s (- %s)",
640 pkg_name(pkg, pnaw_always),
641 removing ? pkg_name(removing, pnaw_always) : "<none>");
643 anycannotfixbytrig = false;
644 canfixbytrig = NULL;
645 for (dep= pkg->installed.depends; dep; dep= dep->next) {
646 if (dep->type != dep_depends && dep->type != dep_predepends) continue;
647 debug(dbg_depcondetail," checking group ...");
648 matched = false;
649 interestingwarnings = 0;
650 varbuf_reset(&oemsgs);
651 found = FOUND_NONE;
652 possfixbytrig = NULL;
653 for (possi = dep->list; found != FOUND_OK && possi; possi = possi->next) {
654 struct deppossi_pkg_iterator *possi_iter;
655 struct pkginfo *pkg_pos;
657 debug(dbg_depcondetail," checking possibility -> %s",possi->ed->name);
658 if (possi->cyclebreak) {
659 debug(dbg_depcondetail," break cycle so ok and found");
660 found = FOUND_OK;
661 break;
664 thisf = FOUND_NONE;
665 possi_iter = deppossi_pkg_iter_new(possi, wpb_installed);
666 while ((pkg_pos = deppossi_pkg_iter_next(possi_iter))) {
667 thisf = deppossi_ok_found(pkg_pos, pkg, removing, NULL,
668 &possfixbytrig, &matched, possi,
669 &interestingwarnings, &oemsgs);
670 if (thisf > found)
671 found = thisf;
672 if (found == FOUND_OK)
673 break;
675 deppossi_pkg_iter_free(possi_iter);
677 if (found != FOUND_OK) {
678 for (provider = possi->ed->depended.installed;
679 found != FOUND_OK && provider;
680 provider = provider->rev_next) {
681 if (provider->up->type != dep_provides)
682 continue;
683 debug(dbg_depcondetail, " checking provider %s",
684 pkg_name(provider->up->up, pnaw_always));
685 if (!deparchsatisfied(&provider->up->up->installed, provider->arch,
686 possi)) {
687 debug(dbg_depcondetail, " provider does not satisfy arch");
688 continue;
690 thisf = deppossi_ok_found(provider->up->up, pkg, removing, provider,
691 &possfixbytrig, &matched, possi,
692 &interestingwarnings, &oemsgs);
693 if (thisf == FOUND_DEFER && provider->up->up == pkg && !removing) {
694 /* IOW, if the pkg satisfies its own dep (via a provide), then
695 * we let it pass, even if it isn't configured yet (as we're
696 * installing it). */
697 thisf = FOUND_OK;
699 if (thisf > found)
700 found = thisf;
703 debug(dbg_depcondetail," found %d",found);
704 if (thisf > found) found= thisf;
706 if (in_force(FORCE_DEPENDS)) {
707 thisf = found_forced_on(DEPEND_TRY_FORCE_DEPENDS);
708 if (thisf > found) {
709 found = thisf;
710 debug(dbg_depcondetail, " rescued by force-depends, found %d", found);
713 debug(dbg_depcondetail, " found %d matched %d possfixbytrig %s",
714 found, matched,
715 possfixbytrig ? pkg_name(possfixbytrig, pnaw_always) : "-");
716 if (removing && !matched) continue;
717 switch (found) {
718 case FOUND_NONE:
719 anycannotfixbytrig = true;
720 ok = DEP_CHECK_HALT;
721 /* Fall through. */
722 case FOUND_FORCED:
723 varbuf_add_str(aemsgs, " ");
724 varbuf_add_pkgbin_name(aemsgs, pkg, &pkg->installed, pnaw_nonambig);
725 varbuf_add_str(aemsgs, _(" depends on "));
726 varbufdependency(aemsgs, dep);
727 if (interestingwarnings) {
728 /* Don't print the line about the package to be removed if
729 * that's the only line. */
730 varbuf_end_str(&oemsgs);
731 varbuf_add_str(aemsgs, _("; however:\n"));
732 varbuf_add_varbuf(aemsgs, &oemsgs);
733 } else {
734 varbuf_add_str(aemsgs, ".\n");
736 break;
737 case FOUND_DEFER:
738 if (possfixbytrig)
739 canfixbytrig = possfixbytrig;
740 else
741 anycannotfixbytrig = true;
742 if (ok > DEP_CHECK_DEFER)
743 ok = DEP_CHECK_DEFER;
744 break;
745 case FOUND_OK:
746 break;
747 default:
748 internerr("unknown value for found '%d'", found);
751 if (ok == DEP_CHECK_HALT &&
752 (pkg->clientdata && pkg->clientdata->istobe == PKG_ISTOBE_REMOVE))
753 ok = DEP_CHECK_DEFER;
754 if (!anycannotfixbytrig && canfixbytrig)
755 progress_bytrigproc = canfixbytrig;
757 varbuf_destroy(&oemsgs);
758 debug(dbg_depcon,"ok %d msgs >>%.*s<<", ok, (int)aemsgs->used, aemsgs->buf);
759 return ok;