packages.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. /*
  2. * dpkg - main program for package management
  3. * packages.c - common to actions that process packages
  4. *
  5. * Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk>
  6. * Copyright © 2011 Linaro Limited
  7. * Copyright © 2011 Raphaël Hertzog <hertzog@debian.org>
  8. *
  9. * This is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. #include <config.h>
  23. #include <compat.h>
  24. #include <sys/types.h>
  25. #include <sys/stat.h>
  26. #include <assert.h>
  27. #include <ctype.h>
  28. #include <string.h>
  29. #include <fcntl.h>
  30. #include <dirent.h>
  31. #include <unistd.h>
  32. #include <stdlib.h>
  33. #include <stdio.h>
  34. #include <dpkg/i18n.h>
  35. #include <dpkg/dpkg.h>
  36. #include <dpkg/dpkg-db.h>
  37. #include <dpkg/pkg-list.h>
  38. #include <dpkg/pkg-queue.h>
  39. #include <dpkg/pkg-spec.h>
  40. #include <dpkg/options.h>
  41. #include "filesdb.h"
  42. #include "infodb.h"
  43. #include "main.h"
  44. static struct pkginfo *progress_bytrigproc;
  45. static struct pkg_queue queue = PKG_QUEUE_INIT;
  46. int sincenothing = 0, dependtry = 0;
  47. void
  48. add_to_queue(struct pkginfo *pkg)
  49. {
  50. pkg_queue_push(&queue, pkg);
  51. }
  52. static void
  53. enqueue_pending(void)
  54. {
  55. struct pkgiterator *it;
  56. struct pkginfo *pkg;
  57. it = pkg_db_iter_new();
  58. while ((pkg = pkg_db_iter_next_pkg(it)) != NULL) {
  59. switch (cipaction->arg_int) {
  60. case act_configure:
  61. if (!(pkg->status == stat_unpacked ||
  62. pkg->status == stat_halfconfigured ||
  63. pkg->trigpend_head))
  64. continue;
  65. if (pkg->want != want_install)
  66. continue;
  67. break;
  68. case act_triggers:
  69. if (!pkg->trigpend_head)
  70. continue;
  71. if (pkg->want != want_install)
  72. continue;
  73. break;
  74. case act_remove:
  75. case act_purge:
  76. if (pkg->want != want_purge) {
  77. if (pkg->want != want_deinstall)
  78. continue;
  79. if (pkg->status == stat_configfiles)
  80. continue;
  81. }
  82. if (pkg->status == stat_notinstalled)
  83. continue;
  84. break;
  85. default:
  86. internerr("unknown action '%d'", cipaction->arg_int);
  87. }
  88. add_to_queue(pkg);
  89. }
  90. pkg_db_iter_free(it);
  91. }
  92. static void
  93. enqueue_specified(const char *const *argv)
  94. {
  95. const char *thisarg;
  96. while ((thisarg = *argv++) != NULL) {
  97. struct dpkg_error err;
  98. struct pkginfo *pkg;
  99. pkg = pkg_spec_parse_pkg(thisarg, &err);
  100. if (pkg == NULL)
  101. badusage(_("--%s needs a valid package name but '%.250s' is not: %s"),
  102. cipaction->olong, thisarg, err.str);
  103. if (pkg->status == stat_notinstalled) {
  104. size_t l = strlen(pkg->set->name);
  105. const char *extension = pkg->set->name + l - sizeof(DEBEXT) + 1;
  106. if (l >= sizeof(DEBEXT) && strcmp(extension, DEBEXT) == 0)
  107. badusage(_("you must specify packages by their own names,"
  108. " not by quoting the names of the files they come in"));
  109. }
  110. add_to_queue(pkg);
  111. }
  112. }
  113. int
  114. packages(const char *const *argv)
  115. {
  116. trigproc_install_hooks();
  117. modstatdb_open(f_noact ? msdbrw_readonly :
  118. fc_nonroot ? msdbrw_write :
  119. msdbrw_needsuperuser);
  120. checkpath();
  121. pkg_infodb_upgrade();
  122. log_message("startup packages %s", cipaction->olong);
  123. if (f_pending) {
  124. if (*argv)
  125. badusage(_("--%s --pending does not take any non-option arguments"),cipaction->olong);
  126. enqueue_pending();
  127. } else {
  128. if (!*argv)
  129. badusage(_("--%s needs at least one package name argument"), cipaction->olong);
  130. enqueue_specified(argv);
  131. }
  132. ensure_diversions();
  133. process_queue();
  134. trigproc_run_deferred();
  135. modstatdb_shutdown();
  136. return 0;
  137. }
  138. void process_queue(void) {
  139. struct pkg_list *rundown;
  140. struct pkginfo *volatile pkg;
  141. volatile enum action action_todo;
  142. jmp_buf ejbuf;
  143. enum istobes istobe= itb_normal;
  144. if (abort_processing)
  145. return;
  146. clear_istobes();
  147. switch (cipaction->arg_int) {
  148. case act_triggers:
  149. case act_configure: case act_install: istobe= itb_installnew; break;
  150. case act_remove: case act_purge: istobe= itb_remove; break;
  151. default:
  152. internerr("unknown action '%d'", cipaction->arg_int);
  153. }
  154. for (rundown = queue.head; rundown; rundown = rundown->next) {
  155. ensure_package_clientdata(rundown->pkg);
  156. if (rundown->pkg->clientdata->istobe == istobe) {
  157. /* Erase the queue entry - this is a second copy! */
  158. switch (cipaction->arg_int) {
  159. case act_triggers:
  160. case act_configure: case act_remove: case act_purge:
  161. printf(_("Package %s listed more than once, only processing once.\n"),
  162. pkg_name(rundown->pkg, pnaw_nonambig));
  163. break;
  164. case act_install:
  165. printf(_("More than one copy of package %s has been unpacked\n"
  166. " in this run ! Only configuring it once.\n"),
  167. pkg_name(rundown->pkg, pnaw_nonambig));
  168. break;
  169. default:
  170. internerr("unknown action '%d'", cipaction->arg_int);
  171. }
  172. rundown->pkg = NULL;
  173. } else {
  174. rundown->pkg->clientdata->istobe= istobe;
  175. }
  176. }
  177. while (!pkg_queue_is_empty(&queue)) {
  178. pkg = pkg_queue_pop(&queue);
  179. if (!pkg)
  180. continue; /* Duplicate, which we removed earlier. */
  181. action_todo = cipaction->arg_int;
  182. if (sincenothing++ > queue.length * 2 + 2) {
  183. if (progress_bytrigproc && progress_bytrigproc->trigpend_head) {
  184. add_to_queue(pkg);
  185. pkg = progress_bytrigproc;
  186. action_todo = act_configure;
  187. } else {
  188. dependtry++;
  189. sincenothing = 0;
  190. assert(dependtry <= 4);
  191. }
  192. }
  193. assert(pkg->status <= stat_installed);
  194. if (setjmp(ejbuf)) {
  195. /* Give up on it from the point of view of other packages, i.e. reset
  196. * istobe. */
  197. pkg->clientdata->istobe= itb_normal;
  198. pop_error_context(ehflag_bombout);
  199. if (abort_processing)
  200. return;
  201. continue;
  202. }
  203. push_error_context_jump(&ejbuf, print_error_perpackage,
  204. pkg_name(pkg, pnaw_nonambig));
  205. switch (action_todo) {
  206. case act_triggers:
  207. if (!pkg->trigpend_head)
  208. ohshit(_("package %.250s is not ready for trigger processing\n"
  209. " (current status `%.250s' with no pending triggers)"),
  210. pkg_name(pkg, pnaw_nonambig), statusinfos[pkg->status].name);
  211. /* Fall through. */
  212. case act_install:
  213. /* Don't try to configure pkgs that we've just disappeared. */
  214. if (pkg->status == stat_notinstalled)
  215. break;
  216. /* Fall through. */
  217. case act_configure:
  218. /* Do whatever is most needed. */
  219. if (pkg->trigpend_head)
  220. trigproc(pkg);
  221. else
  222. deferred_configure(pkg);
  223. break;
  224. case act_remove: case act_purge:
  225. deferred_remove(pkg);
  226. break;
  227. default:
  228. internerr("unknown action '%d'", cipaction->arg_int);
  229. }
  230. m_output(stdout, _("<standard output>"));
  231. m_output(stderr, _("<standard error>"));
  232. pop_error_context(ehflag_normaltidy);
  233. }
  234. assert(!queue.length);
  235. }
  236. /*** Dependency processing - common to --configure and --remove. ***/
  237. /*
  238. * The algorithm for deciding what to configure or remove first is as
  239. * follows:
  240. *
  241. * Loop through all packages doing a ‘try 1’ until we've been round and
  242. * nothing has been done, then do ‘try 2’ and ‘try 3’ likewise.
  243. *
  244. * When configuring, in each try we check to see whether all
  245. * dependencies of this package are done. If so we do it. If some of
  246. * the dependencies aren't done yet but will be later we defer the
  247. * package, otherwise it is an error.
  248. *
  249. * When removing, in each try we check to see whether there are any
  250. * packages that would have dependencies missing if we removed this
  251. * one. If not we remove it now. If some of these packages are
  252. * themselves scheduled for removal we defer the package until they
  253. * have been done.
  254. *
  255. * The criteria for satisfying a dependency vary with the various
  256. * tries. In try 1 we treat the dependencies as absolute. In try 2 we
  257. * check break any cycles in the dependency graph involving the package
  258. * we are trying to process before trying to process the package
  259. * normally. In try 3 (which should only be reached if
  260. * --force-depends-version is set) we ignore version number clauses in
  261. * Depends lines. In try 4 (only reached if --force-depends is set) we
  262. * say "ok" regardless.
  263. *
  264. * If we are configuring and one of the packages we depend on is
  265. * awaiting configuration but wasn't specified in the argument list we
  266. * will add it to the argument list if --configure-any is specified.
  267. * In this case we note this as having "done something" so that we
  268. * don't needlessly escalate to higher levels of dependency checking
  269. * and breaking.
  270. */
  271. enum found_status {
  272. found_none = 0,
  273. found_defer = 1,
  274. found_forced = 2,
  275. found_ok = 3,
  276. };
  277. /*
  278. * Return values:
  279. * 0: cannot be satisfied.
  280. * 1: defer: may be satisfied later, when other packages are better or
  281. * at higher dependtry due to --force
  282. * will set *fixbytrig to package whose trigger processing would help
  283. * if applicable (and leave it alone otherwise).
  284. * 2: not satisfied but forcing
  285. * (*interestingwarnings >= 0 on exit? caller is to print oemsgs).
  286. * 3: satisfied now.
  287. */
  288. static enum found_status
  289. deppossi_ok_found(struct pkginfo *possdependee, struct pkginfo *requiredby,
  290. struct pkginfo *removing, struct pkgset *providing,
  291. struct pkginfo **fixbytrig,
  292. bool *matched, struct deppossi *checkversion,
  293. int *interestingwarnings, struct varbuf *oemsgs)
  294. {
  295. enum found_status thisf;
  296. if (ignore_depends(possdependee)) {
  297. debug(dbg_depcondetail," ignoring depended package so ok and found");
  298. return found_ok;
  299. }
  300. thisf = found_none;
  301. if (possdependee == removing) {
  302. if (providing) {
  303. varbuf_printf(oemsgs,
  304. _(" Package %s which provides %s is to be removed.\n"),
  305. pkg_name(possdependee, pnaw_nonambig), providing->name);
  306. } else {
  307. varbuf_printf(oemsgs, _(" Package %s is to be removed.\n"),
  308. pkg_name(possdependee, pnaw_nonambig));
  309. }
  310. *matched = true;
  311. debug(dbg_depcondetail," removing possdependee, returning %d",thisf);
  312. return thisf;
  313. }
  314. switch (possdependee->status) {
  315. case stat_unpacked:
  316. case stat_halfconfigured:
  317. case stat_triggersawaited:
  318. case stat_triggerspending:
  319. case stat_installed:
  320. if (checkversion && !versionsatisfied(&possdependee->installed,checkversion)) {
  321. varbuf_printf(oemsgs, _(" Version of %s on system is %s.\n"),
  322. pkg_name(possdependee, pnaw_nonambig),
  323. versiondescribe(&possdependee->installed.version,
  324. vdew_nonambig));
  325. assert(checkversion->verrel != dpkg_relation_none);
  326. if (fc_dependsversion)
  327. thisf = (dependtry >= 3) ? found_forced : found_defer;
  328. debug(dbg_depcondetail," bad version, returning %d",thisf);
  329. (*interestingwarnings)++;
  330. return thisf;
  331. }
  332. if (possdependee->status == stat_installed ||
  333. possdependee->status == stat_triggerspending) {
  334. debug(dbg_depcondetail," is installed, ok and found");
  335. return found_ok;
  336. }
  337. if (possdependee->status == stat_triggersawaited) {
  338. assert(possdependee->trigaw.head);
  339. if (removing || !(f_triggers ||
  340. possdependee->clientdata->istobe == itb_installnew)) {
  341. if (providing) {
  342. varbuf_printf(oemsgs,
  343. _(" Package %s which provides %s awaits trigger processing.\n"),
  344. pkg_name(possdependee, pnaw_nonambig), providing->name);
  345. } else {
  346. varbuf_printf(oemsgs,
  347. _(" Package %s awaits trigger processing.\n"),
  348. pkg_name(possdependee, pnaw_nonambig));
  349. }
  350. debug(dbg_depcondetail, " triggers-awaited, no fixbytrig");
  351. goto unsuitable;
  352. }
  353. /* We don't check the status of trigaw.head->pend here, just in case
  354. * we get into the pathological situation where Triggers-Awaited but
  355. * the named package doesn't actually have any pending triggers. In
  356. * that case we queue the non-pending package for trigger processing
  357. * anyway, and that trigger processing will be a noop except for
  358. * sorting out all of the packages which name it in Triggers-Awaited.
  359. *
  360. * (This situation can only arise if modstatdb_note success in
  361. * clearing the triggers-pending status of the pending package
  362. * but then fails to go on to update the awaiters.) */
  363. *fixbytrig = possdependee->trigaw.head->pend;
  364. debug(dbg_depcondetail,
  365. " triggers-awaited, fixbytrig '%s', defer",
  366. pkg_name(*fixbytrig, pnaw_always));
  367. return found_defer;
  368. }
  369. if (possdependee->clientdata &&
  370. possdependee->clientdata->istobe == itb_installnew) {
  371. debug(dbg_depcondetail," unpacked/halfconfigured, defer");
  372. return found_defer;
  373. } else if (!removing && fc_configureany &&
  374. !skip_due_to_hold(possdependee) &&
  375. !(possdependee->status == stat_halfconfigured)) {
  376. notice(_("also configuring '%s' (required by '%s')"),
  377. pkg_name(possdependee, pnaw_nonambig),
  378. pkg_name(requiredby, pnaw_nonambig));
  379. add_to_queue(possdependee);
  380. sincenothing = 0;
  381. return found_defer;
  382. } else {
  383. if (providing) {
  384. varbuf_printf(oemsgs,
  385. _(" Package %s which provides %s is not configured yet.\n"),
  386. pkg_name(possdependee, pnaw_nonambig), providing->name);
  387. } else {
  388. varbuf_printf(oemsgs, _(" Package %s is not configured yet.\n"),
  389. pkg_name(possdependee, pnaw_nonambig));
  390. }
  391. debug(dbg_depcondetail, " not configured/able");
  392. goto unsuitable;
  393. }
  394. default:
  395. if (providing) {
  396. varbuf_printf(oemsgs,
  397. _(" Package %s which provides %s is not installed.\n"),
  398. pkg_name(possdependee, pnaw_nonambig), providing->name);
  399. } else {
  400. varbuf_printf(oemsgs, _(" Package %s is not installed.\n"),
  401. pkg_name(possdependee, pnaw_nonambig));
  402. }
  403. debug(dbg_depcondetail, " not installed");
  404. goto unsuitable;
  405. }
  406. unsuitable:
  407. debug(dbg_depcondetail, " returning %d", thisf);
  408. (*interestingwarnings)++;
  409. return thisf;
  410. }
  411. static void
  412. breaks_check_one(struct varbuf *aemsgs, enum dep_check *ok,
  413. struct deppossi *breaks, struct pkginfo *broken,
  414. struct pkginfo *breaker, struct pkgset *virtbroken)
  415. {
  416. struct varbuf depmsg = VARBUF_INIT;
  417. debug(dbg_depcondetail, " checking breaker %s virtbroken %s",
  418. pkg_name(breaker, pnaw_always),
  419. virtbroken ? virtbroken->name : "<none>");
  420. if (breaker->status == stat_notinstalled ||
  421. breaker->status == stat_configfiles) return;
  422. if (broken == breaker) return;
  423. if (!versionsatisfied(&broken->installed, breaks)) return;
  424. /* The test below can only trigger if dep_breaks start having
  425. * arch qualifiers different from “any”. */
  426. if (!archsatisfied(&broken->installed, breaks))
  427. return;
  428. if (ignore_depends(breaker)) return;
  429. if (virtbroken && ignore_depends(&virtbroken->pkg))
  430. return;
  431. varbufdependency(&depmsg, breaks->up);
  432. varbuf_end_str(&depmsg);
  433. varbuf_printf(aemsgs, _(" %s (%s) breaks %s and is %s.\n"),
  434. pkg_name(breaker, pnaw_nonambig),
  435. versiondescribe(&breaker->installed.version, vdew_nonambig),
  436. depmsg.buf, gettext(statusstrings[breaker->status]));
  437. varbuf_destroy(&depmsg);
  438. if (virtbroken) {
  439. varbuf_printf(aemsgs, _(" %s (%s) provides %s.\n"),
  440. pkg_name(broken, pnaw_nonambig),
  441. versiondescribe(&broken->installed.version, vdew_nonambig),
  442. virtbroken->name);
  443. } else if (breaks->verrel != dpkg_relation_none) {
  444. varbuf_printf(aemsgs, _(" Version of %s to be configured is %s.\n"),
  445. pkg_name(broken, pnaw_nonambig),
  446. versiondescribe(&broken->installed.version, vdew_nonambig));
  447. if (fc_dependsversion) return;
  448. }
  449. if (force_breaks(breaks)) return;
  450. *ok = dep_check_halt;
  451. }
  452. static void
  453. breaks_check_target(struct varbuf *aemsgs, enum dep_check *ok,
  454. struct pkginfo *broken, struct pkgset *target,
  455. struct pkgset *virtbroken)
  456. {
  457. struct deppossi *possi;
  458. for (possi = target->depended.installed; possi; possi = possi->rev_next) {
  459. if (possi->up->type != dep_breaks) continue;
  460. if (virtbroken && possi->verrel != dpkg_relation_none)
  461. continue;
  462. breaks_check_one(aemsgs, ok, possi, broken, possi->up->up, virtbroken);
  463. }
  464. }
  465. enum dep_check
  466. breakses_ok(struct pkginfo *pkg, struct varbuf *aemsgs)
  467. {
  468. struct dependency *dep;
  469. struct pkgset *virtbroken;
  470. enum dep_check ok = dep_check_ok;
  471. debug(dbg_depcon, " checking Breaks");
  472. breaks_check_target(aemsgs, &ok, pkg, pkg->set, NULL);
  473. for (dep= pkg->installed.depends; dep; dep= dep->next) {
  474. if (dep->type != dep_provides) continue;
  475. virtbroken = dep->list->ed;
  476. debug(dbg_depcondetail, " checking virtbroken %s", virtbroken->name);
  477. breaks_check_target(aemsgs, &ok, pkg, virtbroken, virtbroken);
  478. }
  479. return ok;
  480. }
  481. /*
  482. * Checks [Pre]-Depends only.
  483. */
  484. enum dep_check
  485. dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
  486. struct varbuf *aemsgs)
  487. {
  488. /* Valid values: 2 = ok, 1 = defer, 0 = halt. */
  489. enum dep_check ok;
  490. /* Valid values: 0 = none, 1 = defer, 2 = withwarning, 3 = ok. */
  491. enum found_status found, thisf;
  492. int interestingwarnings;
  493. bool matched, anycannotfixbytrig;
  494. struct varbuf oemsgs = VARBUF_INIT;
  495. struct dependency *dep;
  496. struct deppossi *possi, *provider;
  497. struct pkginfo *possfixbytrig, *canfixbytrig;
  498. interestingwarnings= 0;
  499. ok = dep_check_ok;
  500. debug(dbg_depcon,"checking dependencies of %s (- %s)",
  501. pkg_name(pkg, pnaw_always),
  502. removing ? pkg_name(removing, pnaw_always) : "<none>");
  503. anycannotfixbytrig = false;
  504. canfixbytrig = NULL;
  505. for (dep= pkg->installed.depends; dep; dep= dep->next) {
  506. if (dep->type != dep_depends && dep->type != dep_predepends) continue;
  507. debug(dbg_depcondetail," checking group ...");
  508. matched = false;
  509. varbuf_reset(&oemsgs);
  510. found = found_none;
  511. possfixbytrig = NULL;
  512. for (possi = dep->list; found != found_ok && possi; possi = possi->next) {
  513. struct deppossi_pkg_iterator *possi_iter;
  514. struct pkginfo *pkg_pos;
  515. debug(dbg_depcondetail," checking possibility -> %s",possi->ed->name);
  516. if (possi->cyclebreak) {
  517. debug(dbg_depcondetail," break cycle so ok and found");
  518. found = found_ok;
  519. break;
  520. }
  521. thisf = found_none;
  522. possi_iter = deppossi_pkg_iter_new(possi, wpb_installed);
  523. while ((pkg_pos = deppossi_pkg_iter_next(possi_iter))) {
  524. thisf = deppossi_ok_found(pkg_pos, pkg, removing, NULL,
  525. &possfixbytrig, &matched, possi,
  526. &interestingwarnings, &oemsgs);
  527. if (thisf > found)
  528. found = thisf;
  529. if (found == found_ok)
  530. break;
  531. }
  532. deppossi_pkg_iter_free(possi_iter);
  533. if (found != found_ok && possi->verrel == dpkg_relation_none) {
  534. for (provider = possi->ed->depended.installed;
  535. found != found_ok && provider;
  536. provider = provider->rev_next) {
  537. if (provider->up->type != dep_provides)
  538. continue;
  539. debug(dbg_depcondetail, " checking provider %s",
  540. pkg_name(provider->up->up, pnaw_always));
  541. if (!deparchsatisfied(&provider->up->up->installed, provider->arch,
  542. possi)) {
  543. debug(dbg_depcondetail, " provider does not satisfy arch");
  544. continue;
  545. }
  546. thisf = deppossi_ok_found(provider->up->up, pkg, removing,
  547. possi->ed,
  548. &possfixbytrig, &matched, NULL,
  549. &interestingwarnings, &oemsgs);
  550. if (thisf > found)
  551. found = thisf;
  552. }
  553. }
  554. debug(dbg_depcondetail," found %d",found);
  555. if (thisf > found) found= thisf;
  556. }
  557. if (fc_depends) {
  558. thisf = (dependtry >= 4) ? found_forced : found_defer;
  559. if (thisf > found) {
  560. found = thisf;
  561. debug(dbg_depcondetail, " rescued by force-depends, found %d", found);
  562. }
  563. }
  564. debug(dbg_depcondetail, " found %d matched %d possfixbytrig %s",
  565. found, matched,
  566. possfixbytrig ? pkg_name(possfixbytrig, pnaw_always) : "-");
  567. if (removing && !matched) continue;
  568. switch (found) {
  569. case found_none:
  570. anycannotfixbytrig = true;
  571. ok = dep_check_halt;
  572. case found_forced:
  573. varbuf_add_str(aemsgs, " ");
  574. varbuf_add_pkgbin_name(aemsgs, pkg, &pkg->installed, pnaw_nonambig);
  575. varbuf_add_str(aemsgs, _(" depends on "));
  576. varbufdependency(aemsgs, dep);
  577. if (interestingwarnings) {
  578. /* Don't print the line about the package to be removed if
  579. * that's the only line. */
  580. varbuf_end_str(&oemsgs);
  581. varbuf_add_str(aemsgs, _("; however:\n"));
  582. varbuf_add_str(aemsgs, oemsgs.buf);
  583. } else {
  584. varbuf_add_str(aemsgs, ".\n");
  585. }
  586. break;
  587. case found_defer:
  588. if (possfixbytrig)
  589. canfixbytrig = possfixbytrig;
  590. else
  591. anycannotfixbytrig = true;
  592. if (ok > dep_check_defer)
  593. ok = dep_check_defer;
  594. break;
  595. case found_ok:
  596. break;
  597. default:
  598. internerr("unknown value for found '%d'", found);
  599. }
  600. }
  601. if (ok == dep_check_halt &&
  602. (pkg->clientdata && pkg->clientdata->istobe == itb_remove))
  603. ok = dep_check_defer;
  604. if (!anycannotfixbytrig && canfixbytrig)
  605. progress_bytrigproc = canfixbytrig;
  606. varbuf_destroy(&oemsgs);
  607. debug(dbg_depcon,"ok %d msgs >>%.*s<<", ok, (int)aemsgs->used, aemsgs->buf);
  608. return ok;
  609. }