Просмотр исходного кода

dpkg: do not fallback to "new-prerm failed-upgrade" for downgrades

If "installed-prerm upgrade" fails, dpkg tries to run "new-prerm
failed-upgrade" so that newer versions of packages can work-around
a bug in the prerm of the installed package.

In the case of downgrade this logic doesn't make any sense since
the oldest version can't be aware of the bug in the newest version
(that did not exist when the prerm of the oldest version was
written).

Thus we're disabling the fallback in case of a downgrade or a
reinstallation of the same version.
Raphaël Hertzog лет назад: 15
Родитель
Сommit
9d3ec0f5a7
2 измененных файлов с 11 добавлено и 2 удалено
  1. 3 0
      debian/changelog
  2. 8 2
      src/processarc.c

+ 3 - 0
debian/changelog

@@ -47,6 +47,9 @@ dpkg (1.16.1) UNRELEASED; urgency=low
   * dpkg-gensymbols(1): document syntax of comments. Closes: #630996
   * Allow empty lines in symbols files to better delimit multiple libraries.
     Thanks to Cyril Brulebois <kibi@debian.org> for the patch.
+  * dpkg: if "prerm upgrade" fails when downgrading, do not try to run
+    "prerm failed-upgrade" with the prerm of the oldest prerm, it can't work
+    around a bug of a newer prerm anyway.
 
   [ Guillem Jover ]
   * Install deb-src-control(5) man pages in dpkg-dev. Closes: #620520

+ 8 - 2
src/processarc.c

@@ -648,8 +648,14 @@ void process_archive(const char *filename) {
     pkg->status= stat_halfconfigured;
     modstatdb_note(pkg);
     push_cleanup(cu_prermupgrade, ~ehflag_normaltidy, NULL, 0, 1, (void *)pkg);
-    maintainer_script_alternative(pkg, PRERMFILE, "pre-removal", cidir, cidirrest,
-                                  "upgrade", "failed-upgrade");
+    if (versioncompare(&pkg->available.version,
+                       &pkg->installed.version) >= 0) /* Upgrade or reinstall */
+      maintainer_script_alternative(pkg, PRERMFILE, "pre-removal", cidir, cidirrest,
+                                    "upgrade", "failed-upgrade");
+    else /* Downgrade => no fallback */
+      maintainer_script_installed(pkg, PRERMFILE, "pre-removal", "upgrade",
+                                  versiondescribe(&pkg->available.version,
+                                                  vdew_nonambig), NULL);
     pkg->status= stat_unpacked;
     oldversionstatus= stat_unpacked;
     modstatdb_note(pkg);