packages.c 22 KB

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