Your message dated Sun, 05 Dec 2021 18:18:47 +0000
with message-id <[email protected]>
and subject line Bug#996959: fixed in dpkg 1.21.0
has caused the Debian Bug report #996959,
regarding Revert (or document) 9d3ec0f5 (prerm fallback version test)
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
996959: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=996959
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: dpkg
Version: 1.16.1
Control: found -1 1.20.9

Recently, #996949 came to my attention.  In summary, due to a
combination of other bugs, bad .debs can be produced.  These .debs
have broken maintainer scripts - notably, broken prerms.

The submitter there writes:
| The only way to fix the installation and allow any other apt/dpkg
| installations to complete, is to delete the broken maintainer scripts
| from /var/lib/dpkg/info/ or edit them to remove the :amd64 addition.
| This is the only way to allow a fixed package to install.

I was surprised, because I thought dpkg's prerm fallback behaviour
would enable a non-broken package's prerm to be tried instead.
I asked for repro details:

12:49 <Diziet> codehelp: Can you easily give me links to the .debs ?  I would 
               like to experiment.  You're *meant* to be able to make .debs 
               which can fix this without messing in /var.

12:52 <codehelp> Diziet:
 
https://salsa.debian.org/python-team/packages/python-envparse/-/jobs/2100822/artifacts/file/debian/output/python3-envparse_0.2.0-3+salsaci_all.deb
               - check the postinst and prerm for the py3clean and
               py3compile commands. The breakage is the :amd64 part of
               the -p argument. Fixed package is -2 from
               https://packages.debian.org/source/unstable/python-envparse

And sure enough, installing -2 over -3+salsa doesn't work.

I looked at Policy to double-check my recollection:
 
https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html#details-of-unpack-phase-of-installation-or-upgrade

|  1. Notify the currently installed package:
|
|   a. If a version of the package is already “Installed”, call
|        old-prerm upgrade new-version
|
|   b. If the script runs but exits with a non-zero exit status, dpkg will 
attempt:
|       new-prerm failed-upgrade old-version
|      If this works, the upgrade continues. If this does not work, [...]

This seemed to be a bug so I UTSL.  I found

  commit 9d3ec0f5a727d439c3cbc8885bcbc78f7a34dd0b
  Author: Raphaël Hertzog <[email protected]>
  Date:   Sat Jun 18 21:36:40 2011 +0200

      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.

and

   dpkg (1.16.1) unstable; urgency=low
   ...

     * 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.

I do not agree with this change.

The claim that "it can't work around" is false.  It will often be the
case that simply running a prerm without the bug is sufficient and
correct.

Empirically, this is true in this particular case.  I constructed a
stunt copy of python3-envparse_0.2.0-2_all.deb with the Version field
changed to 0.2.0-10:

(build)root@zealot:/home/ian/d# ed x/DEBIAN/control 
762
/Version
Version: 0.2.0-2
s/2$/10
Version: 0.2.0-10
w
763
q
(build)root@zealot:/home/ian/d# dpkg-deb -b x
dpkg-deb: building package 'python3-envparse' in 'x.deb'.
(build)root@zealot:/home/ian/d# dpkg -i x.deb 
(Reading database ... 23640 files and directories currently installed.)
Preparing to unpack x.deb ...
dpkg-query: package 'python3-envparse' is not installed
Use dpkg --contents (= dpkg-deb --contents) to list archive files contents.
Traceback (most recent call last):
  File "/usr/bin/py3clean", line 210, in <module>
    main()
  File "/usr/bin/py3clean", line 196, in main
    pfiles = set(dpf.from_package(options.package))
  File "/usr/share/python3/debpython/files.py", line 53, in from_package
    raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of python3-envparse:amd64
dpkg: warning: old python3-envparse package pre-removal script subprocess 
returned error exit status 1
dpkg: trying script from the new package instead ...
dpkg: ... it looks like that went OK
Unpacking python3-envparse (0.2.0-10) over (0.2.0-3+salsaci) ...
Setting up python3-envparse (0.2.0-10) ...
(build)root@zealot:/home/ian/d#


Analysis:

Downgrades are not usual.  Higher-level package managers like apt will
not do it by default.  And indeed downgrades are not fully supported
by Debian; rather they are available on a best-effort basis.

Furthermore, this version-number dependent behaviour in maintscript
processing in dpkg is (i) anomalous and (ii) confusing.  I don't think
there are other cases where dpkg behaviour so subtly depends on
whether something is thought to be an upgrade or downgrade.

It seems to me that it is better to enable the fallback in all cases.
That would have helped the users in this case.  When it's a downgrade,
things are already going wrong and the user is already knowingly
taking some risks.  Most likely, they are a developer trying out
local, experimental or untested packages, or a user who likes to live
on the bleeding edge.

Having the fallback available even for downgrades will often make it
possible to recover from a broken package simply by reinstalling the
non-broken one (as in this case).


If you disagree and think the behavioural change should be kept, then
policy ought to be changed.  And probably, a message about skipping
the fallback would be helpful - both for un-confusing someone
debugging dpkg, and for the user/developer who is afflicted by a
broken pre-rm: it would tell them what they need to do (a bodge like I
just did).

Thanks,
Ian.


-- 
Ian Jackson <[email protected]>   These opinions are my own.  

Pronouns: they/he.  If I emailed you from @fyvzl.net or @evade.org.uk,
that is a private address which bypasses my fierce spamfilter.

--- End Message ---
--- Begin Message ---
Source: dpkg
Source-Version: 1.21.0
Done: Guillem Jover <[email protected]>

We believe that the bug you reported is fixed in the latest version of
dpkg, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Guillem Jover <[email protected]> (supplier of updated dpkg package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Sun, 05 Dec 2021 16:32:45 +0100
Source: dpkg
Architecture: source
Version: 1.21.0
Distribution: unstable
Urgency: medium
Maintainer: Dpkg Developers <[email protected]>
Changed-By: Guillem Jover <[email protected]>
Closes: 582921 871420 940571 963087 980066 980527 980963 985401 985444 986103 
989824 991190 993991 995387 996044 996959 999600 1000421 1000557
Changes:
 dpkg (1.21.0) unstable; urgency=medium
 .
   [ Guillem Jover ]
   * dpkg-genchanges: Include orig tarball on source package renames.
     Closes: #980066
   * scripts: Consider SHA-1 and RIPEMD-160 weak algorithms in OpenPGP
     signatures.
   * dpkg: During unpack print a removal message due to Conflicts.
     Closes: #985401
   * scripts: Add zsh completions for dpkg-parsechangelog.
     Thanks to Daniel Shahaf <[email protected]>. Closes: #986103
   * dpkg-buildpackage: When printing build type match the extension exactly.
     Closes: #989824
   * dpkg-maintscript-helper: Use xargs -I argument instead of deprecated -i.
   * dpkg-maintscript-helper: Quote variable inside ${} to avoid pattern match.
   * libdpkg: Fix dpkg_fsys_get_path() to always strip leading / and ./.
   * libdpkg: Set the default database directory relative to the system root.
   * dpkg-divert, dpkg-statoverride: Set admindir after instdir.
   * update-alternatives: Fix admindir setting.
     Prompted by Johannes Schauer Marin Rodrigues <[email protected]>.
   * dselect: Honor DPKG_ADMINDIR environment variable.
   * dpkg-query, dpkg-trigger, dselect: Add support for setting the root
     directory.
   * dpkg-fsys-usrunmess: Move forced reconfiguration to the last step.
     See #991190.
   * dpkg-fsys-usrunmess: Install a local policy-rc.d to ignore service
     restarts. Closes: #991190
   * dpkg-fsys-usrunmess: Do not fail when removing lingering directories.
   * dpkg-fsys-usrunmess: Generate a regression prevention package.
   * dpkg-fsys-usrunmess: Fix typo in debug message.
   * dpkg: Distinguish deconfiguration message for installation and multi-arch
     syncs.
   * dpkg-buildpackage: Add new --changes-file option.
     Prompted by Niels Thykier <[email protected]>.
   * dpkg-buildpackage: Add new --buildinfo-file option.
   * dpkg: Rework --assert-<feature> logic to be more robust.
     Prompted by Helmut Grohne <[email protected]>.
     Prompted by David Kalnischkies <[email protected]>.
   * dpkg: Improve --assert-<feature> descriptions.
   * dpkg: Add a new --assert-help option.
   * scripts/mk: Pass DEB_BUILD_PATH to dpkg-buildflags. See #985553.
   * dpkg-db-backup: New program factored out from Debian-specific daily cron.
   * dpkg-db-backup: Accept an option to override the number of rotation cycles.
   * dpkg-db-backup: Honor the admindir set at configure time.
   * update-alternatives: Fix --auto and --set-selections output progress.
   * update-alternatives: Print defaults for configuration and database
     pathnames.
   * scripts: Replace shebang in dpkg-error shell library with shellcheck
     directive.
   * dpkg-buildpackage: Add support for terse DEB_BUILD_OPTIONS.
   * dpkg-mergechangelogs: Add new --merge-unreleased option. Closes: #582921
   * dpkg: Restore fallback to "new-prerm failed-upgrade" for downgrades.
     Analysis by Ian Jackson <[email protected]>. Closes: #996959
   * dselect: Use safe temporary file creation in methods setup.
   * dselect: Remove bashism from update script in multicd method.
   * dpkg: Fix --verify to handle missing or inaccessible pathnames.
     Closes: #963087
   * dpkg: Add partial --verify support for mode checks.
   * Use «digest» instead of «hash» in output messages.
     Reported by Sven Joachim <[email protected]>.
   * dselect: use `grep -E` instead of `egrep`.
     Thanks to Ville Skyttä <[email protected]>. Closes: #999600
   * libdpkg: Fix memory leak on End Of Tape condition in tar parser.
   * dpkg: Fix short lived memory leak with --recursive.
   * dpkg: Fix conffile removal-on-upgrade handling. Closes: #995387
   * dpkg-deb: Fix conffile name length tracking on remove-on-upgrade parsing.
     Reported by uau on IRC.
   * Architecture support:
     - Clarify that the regex columns need to be ordered to match first.
     - Add support for ARCv2 CPU. Closes: #980963
       Based on a patch by Alexey Brodkin <[email protected]>.
   * Portability:
     - start-stop-daemon: Define SOCK_NONBLOCK to 0 if not defined.
     - libdpkg: Add support for AIX to dpkg_get_progname().
   * Perl modules:
     - Dpkg::Source::Quilt: Add hint to check missing files on patch apply
       failures.
       Reported by Joseph Nahmias <[email protected]>.
     - Dpkg::Changelog::Parse: Require format plugins to inherit from
       Dpkg::Changelog.
     - Dpkg::OpenPGP: Refactor openpgp implementation execution into a new
       function.
     - Dpkg::Vendor::Debian: Refactor compiler flag names into an array.
     - Dpkg::Vendor::Debian: Add new lto feature in new optimize area.
       Closes: #940571
     - Test::Dpkg: Print actual error messages in test_neutralize_checksums().
     - Dpkg::Deps: Use current_sub feature for __SUB__.
     - Dpkg::BuildFlags: Add support for ASFLAGS.
       See https://salsa.debian.org/debian/debhelper/-/merge_requests/50.
     - Dpkg::Compression: Use gzip --rsyncable unconditionally.
     - Dpkg::Changelog::Entry::Debian: Fix full month misuse warning.
     - Dpkg::Shlibs::Symbol: Emit a warning on fully qualified symver patterns.
       Closes: #993991
     - Dpkg::Control::HashCore: Add new keep_duplicate option.
     - Dpkg::Control::FieldsCore: Add new field_parse_binary_source().
       Closes: #980527
     - Dpkg::Control::FieldsCore: Fix types allowed for
       field_parse_binary_source().
       Reported by Johannes Schauer Marin Rodrigues <[email protected]>.
     - Dpkg::Shlibs::Objdump: Fix apply_relocations to work with versioned
       symbols. Closes: #1000421
     - Dpkg::Vendor::Ubuntu: Update Maintainer field logic to include
       “canonical”. Based on a patch by
       William 'jawn-smith' Wilson <[email protected]>.
       Closes: #1000557
     - Dpkg::Source::Package::V2: Add hint about version matching source tree.
       Based on a patch by Samuel Henrique <[email protected]>.
       Closes: #996044
   * Documentation:
     - man: Itemize dpkg-gensymbols -c levels.
     - man: Add man page for deb-md5sums(5).
       Reported by Maxim Cournoyer (on IRC).
     - man: Switch the Architecture field in deb-control(5) to required.
       Reported by Maxim Cournoyer (on IRC).
     - man: Make clear that dpkg-query arguments accept multiple values.
       Prompted by Rémi Rampin <[email protected]>. See #913781.
     - man: Document dpkg-query --search and --listfiles output formats.
     - doc: Fix incorrect use of ‘an’ article.
     - doc: Update coding style to document POD instead of troff.
     - doc: Update THANKS file.
     - doc: Annotate current maintainer start year.
     - doc: Sort maintenance information chronologically.
     - man: Add versions since features where introduced.
     - man: Further clarify when re-inclusions of excluded pathnames happen.
       Closes: #871420
     - doc: Update Doxygen configuration from version 1.9.1.
     - doc: Improve description of dpkg suite.
       Prompted by Fabrice Bauzac-Stehly <[email protected]>.
     - man: Add a reference to where the Installed-Size algorithm is described.
     - man: Improve dpkg --verify-format rpm format documentation.
     - man: Document in deb-substvars(5) what ${} is good for.
       Prompted by Paul Wise <[email protected]>.
     - man: Document in dpkg-architecture(1) target being useful for emulators
       too. Prompted by Helmut Grohne <[email protected]>.
     - man: Document in dpkg-query(1) full --search and --listfiles output
       format. Prompted by Johannes Schauer Marin Rodrigues <[email protected]>.
   * Code internals:
     - Remove irrelevant or obsolete FIXME markers.
     - Turn FIXME markers denoting pending actions into TODO markers.
     - Turn FIXME markers giving historic information into simple Notes.
     - update-alternatives: Turn FIXME for explicit behavior choice into an XXX.
     - Use localtime_r() instead of localtime().
     - libdpkg: Remove MDEBUG support from m_malloc() implementation.
     - libdpkg: Mark dpkg_arch_unmark() arch_remove argument as const.
     - libdpkg: Mark treewalk_open() func argument as const.
     - dpkg: Mark ignore_depends() pkg argument as const.
     - dpkg: Mark deb_parse_conffiles() pkg argument as const.
     - libcompat: Remove local setexecfilecon() and require libselinux 2.3.
     - libdpkg: Add missing DPKG_{BEGIN,END}_DECLS in header files.
     - dpkg: Move SE Linux function declarations into its own header file.
     - dpkg: Move the command action enum to its own header file.
     - dpkg: Switch from including "main.h" to "force.h".
     - dselect: Rename dme() to display_menu_entry().
     - dpkg: Split function handling deconfiguration due to install and removal.
     - libdpkg: Add new ACTION_MUX macro for continued options.
     - dpkg: Refactor --assert-<feature> handling to be data driven.
     - dpkg-fsys-usrunmess: Do not use interpolated strings for literals.
     - dpkg-db-backup: Add a license header comment.
   * Build system:
     - Fallback to $^X and 'perl' if $Config{perlpath} is unset or empty.
     - Bump minimal Perl version to 5.28.1.
     - Remove redundant localedir and pkgconfdir initializations.
     - Check for libsocket.
     - Do not set have_libmd on the found branch in AC_SEARCH_LIBS.
     - Switch DPKG_FUNC_C99_SNPRINTF from AC_LANG_SOURCE to AC_LANG_PROGRAM.
     - Check whether fsync(3) works on directories.
     - Remove obsolete AC_HEADER_STDC.
     - Detect appropriate sed program at configure time.
     - Rename DPKG_DEB_PROG_TAR to DPKG_PROG_TAR.
     - Parametrize the backups directory with a configure option.
     - Add a check for symlinks in the git repository.
     - Rename shell scripts to .sh.
     - Switch from hardcoded /run to parametrized runstatedir.
     - Use new Dpkg::Control keep_duplicate option in gen-changelog.
     - Use title-case for field in gen-changelog.
     - Execute run-script via CONFIG_SHELL.
       Reported by Larkin Nickle <[email protected]>.
     - Quote variables containing pathnames in m4 macros.
     - Add support for commit message fix up machinery in gen-changelog.
   * Packaging:
     - Use absolute pathnames in .install debhelper fragments.
     - Remove unused dh_installcron call for arch-indep targets.
     - Add support for a native systemd timer. Closes: #985444
     - Create auotpkgtest installation directory.
     - Bump Standards-Version to 4.6.0 (no changes needed).
   * Test suite:
     - Pass --ignore-builtin-builddeps to dpkg-buildpackage.
     - Use can_run() instead of find_command().
     - Add descriptions to makefile test runners.
     - Add unit tests for architecture bijective mapping property.
     - Suppress cppcheck constParameter check.
     - Suppress bogus cppcheck for nullPointerRedundantCheck.
     - Mark external sourced shell files for checking.
     - Ignore new shellcheck checks.
     - Remove shipped dpkg database.
     - Add re-inclusion of symlink case to t-filtering. See #871420.
     - Generate symlink during test build time.
     - Remove superfluous long filename.
     - Refactor parse_ctrl() from parse_dsc().
     - Update codespell stopwords.
 .
   [ Helge Kreutzmann ]
   * deb-md5sums.pod: Fix typo.
 .
   [ Add programs translations ]
   * Occitan (Quentin PAGÈS).
 .
   [ Update dselect translations ]
   * German (Sven Joachim).
 .
   [ Update man pages translations ]
   * German (Helge Kreutzmann).
 .
   [ Update programs translations ]
   * German (Sven Joachim).
   * Polish (Marcin Owsiany, Łukasz Dulny).
 .
   [ Update scripts translations ]
   * German (Helge Kreutzmann).
Checksums-Sha1:
 0470585880a60d9f642e5e34663f0e3338875ef5 2120 dpkg_1.21.0.dsc
 27326e5edfc3d834c35b896cfff320cbae5ccfe5 4985476 dpkg_1.21.0.tar.xz
 012cb5e4cfcf1b87bc5a7e6b6acd6f0cff8e1d3b 7700 dpkg_1.21.0_amd64.buildinfo
Checksums-Sha256:
 09e3fdf4f343a3cef150da76f6de267502f6beea3b4edd3bc191bd6d9b1759cb 2120 
dpkg_1.21.0.dsc
 e98e3b8cc49ea5b35c4b62a2a363c56ad2fb46929cad0d35c6cdca9d64c8db93 4985476 
dpkg_1.21.0.tar.xz
 eed6d2231822f37edb624fbb9ecfbe46e701f276c1475286c8ba9b7826462f49 7700 
dpkg_1.21.0_amd64.buildinfo
Files:
 24c31ee2e751f1256ad5b219342e3bf6 2120 admin required dpkg_1.21.0.dsc
 511eac4cf058388ad14d54c38c441163 4985476 admin required dpkg_1.21.0.tar.xz
 9f9d15cab85c13655e9465ebb001dd81 7700 admin required 
dpkg_1.21.0_amd64.buildinfo

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEETz509DYFDBD1aWV0uXK/PqSuV6MFAmGs31MACgkQuXK/PqSu
V6MzwQ/7B/aQ35JxL1GOC0G2opkzIsu0Id1EAl6h7t19/mOltn4QgbOoLW4uSa8E
4fV2GuvnpCxlqowL+j8nN+x50FI/u/gZuObuKQ5p+aoahEhlLyxfDpVyHbl7oTzl
BY2dl31ybDEjrmvYMepDtH1wLx6sfbqyIeT1kTToKmh4k76uxXb3lToVJXuvSL2r
SrYiTAqq9ncikK7V7KKckY5o6aizlwF+DqLWGHE4B0w/Cau1CobscmtOq5bqHTHD
I3ouq3C1NA3KVddLky7dNLq+YFn+/fmEVki2UkS7a2Y9XSyByPf+NPrsWZ/1d5Zy
/p0eTWtw4gyj4zIlrpZucfZTvBYPCm3m+ZtyQ2Qs7Nrk/vFlKi3dNKjG6zWOeQoQ
PmGCHMiBH/DmiO9Ak8Y9ZcLXBpZ51bbCJ0Nsp4u79GEuQjFEXZwHG2c4QY/udwAH
CY9euvb7Gv/ztkhBc5ROB2W0p3MlEK++8fnSzvt1jxqDV7CMVBS99fs2sh6Z1ocm
sLM12UG+j/uSLmU1+XwlOP84HHQ2lgs/196jgWoT/LS0EmDAXZIzzYYpwo1yRCHH
cB1E3qYVF58PAs935ayvEj841Hod1Qb6w6tg61OVZou+aTlAFOmp0IvcMrHlqVqm
EjGxiL28hXBNyfLst3ChOu2fl1FSooggOFQP5n/4bTf1fjrQhCg=
=bxP/
-----END PGP SIGNATURE-----

--- End Message ---

Reply via email to