* apt-pkg/deb/dpkgpm.cc:
authorSteve Langasek <steve.langasek@linaro.org>
Mon, 7 Mar 2011 21:57:52 +0000 (22:57 +0100)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Mon, 7 Mar 2011 21:57:52 +0000 (22:57 +0100)
  - make sure that for multiarch packages, we are passing the full
    qualified package name to dpkg for removals. (Closes: #614298)

apt-pkg/deb/dpkgpm.cc
debian/changelog

index 7d0d34a..8444344 100644 (file)
@@ -881,7 +881,10 @@ bool pkgDPkgPM::Go(int OutStatusFd)
 
       // Generate the argument list
       const char *Args[MaxArgs + 50];
-      
+      // keep track of allocated strings for multiarch package names
+      char *Packages[MaxArgs + 50];
+      unsigned int pkgcount = 0;
+
       // Now check if we are within the MaxArgs limit
       //
       // this code below is problematic, because it may happen that
@@ -989,13 +992,22 @@ bool pkgDPkgPM::Go(int OutStatusFd)
       }      
       else
       {
+        string const nativeArch = _config->Find("APT::Architecture");
         for (;I != J && Size < MaxArgBytes; I++)
         {
            if((*I).Pkg.end() == true)
               continue;
            if (I->Op == Item::Configure && disappearedPkgs.find(I->Pkg.Name()) != disappearedPkgs.end())
               continue;
-           Args[n++] = I->Pkg.Name();
+           if (I->Pkg.Arch() == nativeArch || !strcmp(I->Pkg.Arch(), "all"))
+              Args[n++] = I->Pkg.Name();
+           else
+           {
+              string const PkgDesc = I->Pkg.Name() + string(":") + string(I->Pkg.Arch());
+              Packages[pkgcount] = new char[PkgDesc.size()+1];
+              strncpy(Packages[pkgcount++],PkgDesc.c_str(),PkgDesc.size()+1);
+              Args[n++] = Packages[pkgcount-1];
+           }
            Size += strlen(Args[n-1]);
         }       
       }      
@@ -1145,6 +1157,11 @@ bool pkgDPkgPM::Go(int OutStatusFd)
       sigemptyset(&sigmask);
       sigprocmask(SIG_BLOCK,&sigmask,&original_sigmask);
 
+      /* clean up the temporary allocation for multiarch package names in
+         the parent, so we don't leak memory when we return. */
+      for (unsigned int i = 0; i < pkgcount; i++)
+        delete [] Packages[i];
+
       // the result of the waitpid call
       int res;
       int select_ret;
index 971e967..bcafbd7 100644 (file)
@@ -28,7 +28,12 @@ apt (0.8.11.6) UNRELEASED; urgency=low
   * cmdline/apt-get.cc:
     - reinstall dependencies of reinstalled "garbage" (Closes: #617257)
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Mon, 07 Mar 2011 22:43:15 +0100
+  [ Steve Langasek ]
+  * apt-pkg/deb/dpkgpm.cc:
+    - make sure that for multiarch packages, we are passing the full
+      qualified package name to dpkg for removals. (Closes: #614298)
+
+ -- David Kalnischkies <kalnischkies@gmail.com>  Mon, 07 Mar 2011 22:46:24 +0100
 
 apt (0.8.11.5) unstable; urgency=low