tags 712116 + patch thanks Dear maintainers,
On Thu, 13 Jun 2013, Anders Kaseorg wrote:
The current input format for DPkg::Pre-Install-Pkgs hooks makes it impossible to tell which architecture of a multiarch package is being removed. For example, removing libbz2-1.0:amd64 and libbz2-1.0:i386 results in this input: libbz2-1.0 1.0.6-4 > - **REMOVE** libbz2-1.0 1.0.6-4 > - **REMOVE** Can we change the format to arch-qualify the package names as ${binary:Package} does?
Attached is a patch to add a new v3 mode for input to Pre-Install-Pkgs, and extend SendV2Pkgs to insert the architecture immediately after the name of the package. I've tested this locally and this seems to work fine for installing and removing native-arch, arch-all, and non-native-arch packages. (The native arch, not "all", seems to get displayed for arch-all packages, which seems acceptable but a little confusing.)
So now a line of output is something like libfuse2 i386 2.9.2-4 > - **REMOVE**I suppose what we're really interested in pkg.FullName(true), since we don't hugely care to see the architecture if it's the native one. So for our use case, v3 mode calling FullName(true) instead of Name() would also be fine. I'm not sure if this would make any existing scripts harder to implement, which is why I didn't include it. I suppose adding two new fields for Arch and FullName(true) would be the most useful, but it seems somewhat excessive.
Note that this issue applies to the configure step as well as to the remove step.
-- Geoffrey Thomas geo...@mit.edu
From 924125b8eae1dbe9e057dd620c2572ef5955d779 Mon Sep 17 00:00:00 2001 From: Geoffrey Thomas <geo...@ldpreload.com> Date: Mon, 17 Jun 2013 00:51:44 -0700 Subject: [PATCH] Add a v3 mode that includes the architecture for Pre-Install-Pkgs input. --- apt-pkg/deb/dpkgpm.cc | 8 +++++--- apt-pkg/deb/dpkgpm.h | 2 +- doc/apt.conf.5.xml | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 3bc31dc..732c58a 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -242,9 +242,9 @@ bool pkgDPkgPM::Remove(PkgIterator Pkg,bool Purge) // --------------------------------------------------------------------- /* This is part of the helper script communication interface, it sends very complete information down to the other end of the pipe.*/ -bool pkgDPkgPM::SendV2Pkgs(FILE *F) +bool pkgDPkgPM::SendV2Pkgs(FILE *F, unsigned int Version) { - fprintf(F,"VERSION 2\n"); + fprintf(F,"VERSION %u\n", Version); /* Write out all of the configuration directives by walking the configuration tree */ @@ -280,6 +280,8 @@ bool pkgDPkgPM::SendV2Pkgs(FILE *F) pkgDepCache::StateCache &S = Cache[I->Pkg]; fprintf(F,"%s ",I->Pkg.Name()); + if (Version >= 3) + fprintf(F,"%s ",I->Pkg.Arch()); // Current version if (I->Pkg->CurrentVer == 0) fprintf(F,"- "); @@ -404,7 +406,7 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf) } } else - SendV2Pkgs(F); + SendV2Pkgs(F, Version); fclose(F); diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index aab39f6..2aa0556 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -79,7 +79,7 @@ class pkgDPkgPM : public pkgPackageManager // Helpers bool RunScriptsWithPkgs(const char *Cnf); - bool SendV2Pkgs(FILE *F); + bool SendV2Pkgs(FILE *F, unsigned int Version); void WriteHistoryTag(std::string const &tag, std::string value); // apport integration diff --git a/doc/apt.conf.5.xml b/doc/apt.conf.5.xml index be1d7ad..39f47ec 100644 --- a/doc/apt.conf.5.xml +++ b/doc/apt.conf.5.xml @@ -691,8 +691,9 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";}; <para>Version 2 of this protocol dumps more information, including the protocol version, the APT configuration space and the packages, files - and versions being changed. Version 2 is enabled by setting - <literal>DPkg::Tools::options::cmd::Version</literal> to 2. <literal>cmd</literal> is a + and versions being changed. Version 3 also adds the architecture of the + package to the output. These versions can be enabled by setting + <literal>DPkg::Tools::options::cmd::Version</literal> to 2 or 3. <literal>cmd</literal> is a command given to <literal>Pre-Install-Pkgs</literal>.</para></listitem> </varlistentry> -- 1.7.10.4