From patchwork Sun Mar 6 04:39:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Steve Langasek X-Patchwork-Id: 393 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:42:14 -0000 Delivered-To: patches@linaro.org Received: by 10.224.60.68 with SMTP id o4cs63969qah; Sat, 5 Mar 2011 20:39:16 -0800 (PST) Received: by 10.42.146.70 with SMTP id i6mr2360945icv.361.1299386355836; Sat, 05 Mar 2011 20:39:15 -0800 (PST) Received: from becquer.dodds.net (becquer.dodds.net [207.224.24.209]) by mx.google.com with ESMTP id 11si3233352ibb.68.2011.03.05.20.39.15; Sat, 05 Mar 2011 20:39:15 -0800 (PST) Received-SPF: pass (google.com: domain of vorlon@dodds.net designates 207.224.24.209 as permitted sender) client-ip=207.224.24.209; Authentication-Results: mx.google.com; spf=pass (google.com: domain of vorlon@dodds.net designates 207.224.24.209 as permitted sender) smtp.mail=vorlon@dodds.net Received: from virgil.dodds.net (unknown [192.168.15.11]) by becquer.dodds.net (Postfix) with ESMTPA id 92D14251D9 for ; Sat, 5 Mar 2011 20:39:14 -0800 (PST) Received: by virgil.dodds.net (Postfix, from userid 1000) id 66466400DE; Sat, 5 Mar 2011 20:39:11 -0800 (PST) Resent-From: Steve Langasek Resent-Date: Sat, 5 Mar 2011 20:39:11 -0800 Resent-Message-ID: <20110306043911.GC14374@virgil.dodds.net> Resent-To: patches@linaro.org Date: Sat, 5 Mar 2011 20:39:01 -0800 From: Steve Langasek To: 614298@bugs.debian.org Subject: Re: Bug#614298: multiarch: apt-get remove of foreign-arch package removes wrong one Message-ID: <20110306043901.GB14374@virgil.dodds.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) tags 614298 patch thanks Hi David, Please find attached a tentative patch for this issue. It's not exactly the most elegant, but it seemed to be the best we can do without changing the libapt ABI. If you prefer a different solution, please let me know and I can give it a try. === modified file 'apt-pkg/deb/dpkgpm.cc' --- apt-pkg/deb/dpkgpm.cc 2011-02-03 13:22:32 +0000 +++ apt-pkg/deb/dpkgpm.cc 2011-03-06 04:30:47 +0000 @@ -881,7 +881,10 @@ // 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 @@ } 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 @@ 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; === modified file 'debian/changelog' --- debian/changelog 2011-02-24 18:39:12 +0000 +++ debian/changelog 2011-03-06 04:30:47 +0000 @@ -1,10 +1,16 @@ apt (0.8.11.6) UNRELEASED; urgency=low + [ Christian Perrier ] * Fix error in French translation of manpages (apt_preferences(5)). Merci, RĂ©mi Vanicat. Closes: #613689 * Complete French manpage translation * Italian translation update (Milo Casagrande). Closes: #614395 + [ Steve Langasek ] + * apt-pkg/deb/dpkgpm.cc: make sure that for multiarch packages, we're + passing the full qualified package name to dpkg for removals. + Closes: #614298 + -- Christian Perrier Fri, 18 Feb 2011 05:53:49 +0100 apt (0.8.11.5) unstable; urgency=low