Преглед изворни кода

dpkg: depisok() can now suggest to process awaited triggers for a package

Package in triggers-awaited state do not satisfy dependencies but they
could easily if their awaited triggers were processed. So we enhance the
function to return such a hint when possible.

All the callers pass NULL to the new parameter so that this commit
should not change the current behaviour.
Raphaël Hertzog пре 15 година
родитељ
комит
2b8cfa5070
5 измењених фајлова са 27 додато и 12 уклоњено
  1. 4 4
      src/archives.c
  2. 16 2
      src/depcon.c
  3. 2 2
      src/enquiry.c
  4. 2 1
      src/main.h
  5. 3 3
      src/processarc.c

+ 4 - 4
src/archives.c

@@ -1029,7 +1029,7 @@ void check_breaks(struct dependency *dep, struct pkginfo *pkg,
   int ok;
 
   fixbydeconf = NULL;
-  if (depisok(dep, &why, &fixbydeconf, false)) {
+  if (depisok(dep, &why, &fixbydeconf, NULL, false)) {
     varbuf_destroy(&why);
     return;
   }
@@ -1084,7 +1084,7 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
   struct dependency *providecheck;
 
   fixbyrm = NULL;
-  if (depisok(dep, &conflictwhy, &fixbyrm, false)) {
+  if (depisok(dep, &conflictwhy, &fixbyrm, NULL, false)) {
     varbuf_destroy(&conflictwhy);
     varbuf_destroy(&removalwhy);
     return;
@@ -1116,7 +1116,7 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
              pdep = pdep->rev_next) {
           if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends)
             continue;
-          if (depisok(pdep->up, &removalwhy, NULL, false))
+          if (depisok(pdep->up, &removalwhy, NULL, NULL, false))
             continue;
           varbuf_end_str(&removalwhy);
           if (!try_remove_can(pdep,fixbyrm,removalwhy.buf))
@@ -1133,7 +1133,7 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
                  pdep = pdep->rev_next) {
               if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends)
                 continue;
-              if (depisok(pdep->up, &removalwhy, NULL, false))
+              if (depisok(pdep->up, &removalwhy, NULL, NULL, false))
                 continue;
               varbuf_end_str(&removalwhy);
               fprintf(stderr, _("dpkg"

+ 16 - 2
src/depcon.c

@@ -218,10 +218,16 @@ void describedepcon(struct varbuf *addto, struct dependency *dep) {
  * if removed (dep_conflicts) or deconfigured (dep_breaks) will fix
  * the problem. Caller may pass NULL for canfixbyremove and need not
  * initialize *canfixbyremove.
+ *
+ * On false return (‘not OK’), *canfixbytrigaw refers to a package which
+ * can fix the problem if all the packages listed in Triggers-Awaited have
+ * their triggers processed. Caller may pass NULL for canfixbytrigaw and
+ * need not initialize *canfixbytrigaw.
  */
 bool
 depisok(struct dependency *dep, struct varbuf *whynot,
-        struct pkginfo **canfixbyremove, bool allowunconfigd)
+        struct pkginfo **canfixbyremove, struct pkginfo **canfixbytrigaw,
+        bool allowunconfigd)
 {
   struct deppossi *possi;
   struct deppossi *provider;
@@ -240,6 +246,8 @@ depisok(struct dependency *dep, struct varbuf *whynot,
 
   if (canfixbyremove)
     *canfixbyremove = NULL;
+  if (canfixbytrigaw)
+    *canfixbytrigaw = NULL;
 
   /* The dependency is always OK if we're trying to remove the depend*ing*
    * package. */
@@ -311,9 +319,13 @@ depisok(struct dependency *dep, struct varbuf *whynot,
            * isn't and issue a diagnostic then. */
           *linebuf = '\0';
           break;
+        case stat_triggersawaited:
+            if (canfixbytrigaw && versionsatisfied(&possi->ed->installed, possi))
+              *canfixbytrigaw = possi->ed;
+            /* Fall through to have a chance to return OK due to
+             * allowunconfigd and to fill the explanation */
         case stat_unpacked:
         case stat_halfconfigured:
-        case stat_triggersawaited:
           if (allowunconfigd) {
             if (!informativeversion(&possi->ed->configversion)) {
               sprintf(linebuf, _("  %.250s is unpacked, but has never been configured.\n"),
@@ -382,6 +394,8 @@ depisok(struct dependency *dep, struct varbuf *whynot,
             if (provider->up->up->status == stat_installed ||
                 provider->up->up->status == stat_triggerspending)
               return true;
+            if (provider->up->up->status == stat_triggersawaited)
+              *canfixbytrigaw = provider->up->up;
             sprintf(linebuf, _("  %.250s provides %.250s but is %s.\n"),
                     provider->up->up->name, possi->ed->name,
                     gettext(statusstrings[provider->up->up->status]));

+ 2 - 2
src/enquiry.c

@@ -388,7 +388,7 @@ predeppackage(const char *const *argv)
     pkg->clientdata->istobe= itb_preinstall;
     for (dep= pkg->available.depends; dep; dep= dep->next) {
       if (dep->type != dep_predepends) continue;
-      if (depisok(dep, &vb, NULL, true))
+      if (depisok(dep, &vb, NULL, NULL, true))
         continue;
       /* This will leave dep non-NULL, and so exit the loop. */
       break;
@@ -438,7 +438,7 @@ predeppackage(const char *const *argv)
     pkg->clientdata->istobe= itb_preinstall;
     for (dep= pkg->available.depends; dep; dep= dep->next) {
       if (dep->type != dep_predepends) continue;
-      if (depisok(dep, &vb, NULL, true))
+      if (depisok(dep, &vb, NULL, NULL, true))
         continue;
       /* This will leave dep non-NULL, and so exit the loop. */
       break;

+ 2 - 1
src/main.h

@@ -266,7 +266,8 @@ void trig_activate_packageprocessing(struct pkginfo *pkg);
 /* from depcon.c */
 
 bool depisok(struct dependency *dep, struct varbuf *whynot,
-             struct pkginfo **fixbyrm, bool allowunconfigd);
+             struct pkginfo **fixbyrm, struct pkginfo **fixbytrigaw,
+             bool allowunconfigd);
 struct cyclesofarlink;
 bool findbreakcycle(struct pkginfo *pkg);
 void describedepcon(struct varbuf *addto, struct dependency *dep);

+ 3 - 3
src/processarc.c

@@ -503,7 +503,7 @@ void process_archive(const char *filename) {
       /* Ignore these here. */
       break;
     case dep_predepends:
-      if (!depisok(dsearch, &depprobwhy, NULL, true)) {
+      if (!depisok(dsearch, &depprobwhy, NULL, NULL, true)) {
         varbuf_end_str(&depprobwhy);
         fprintf(stderr, _("dpkg: regarding %s containing %s, pre-dependency problem:\n%s"),
                 pfilename, pkg->name, depprobwhy.buf);
@@ -1150,7 +1150,7 @@ void process_archive(const char *filename) {
          pdep = pdep->rev_next) {
       if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends &&
           pdep->up->type != dep_recommends) continue;
-      if (depisok(pdep->up, &depprobwhy, NULL, false))
+      if (depisok(pdep->up, &depprobwhy, NULL, NULL, false))
         continue;
       varbuf_end_str(&depprobwhy);
       debug(dbg_veryverbose,"process_archive cannot disappear: %s",depprobwhy.buf);
@@ -1168,7 +1168,7 @@ void process_archive(const char *filename) {
           if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends &&
               pdep->up->type != dep_recommends)
             continue;
-          if (depisok(pdep->up, &depprobwhy, NULL, false))
+          if (depisok(pdep->up, &depprobwhy, NULL, NULL, false))
             continue;
           varbuf_end_str(&depprobwhy);
           debug(dbg_veryverbose,"process_archive cannot disappear (provides %s): %s",