Package: apt Version: 0.9.7.4 Severity: normal Tags: patch Moving the discussion about pinning by architecture to a new report. Original context is <http://bugs.debian.org/670322>
On 11 September 2012 09:18, Daniel Hartwig <mand...@gmail.com> wrote: >> Arch-qualification will work for specific-packages stanzas only, > > A bit of a hack but it worked when I tested it. apt-cache policy > listed every armel package as pinned, which is not very nice output > ;-) Looks like I misread and thought you were saying that doesn't work. Sorry for that :-) > >> but you can do this: >> Package: * >> Pin: release n=squeeze,b=armel >> Pin-Priority: 991 > > A better format, though it is not documented or working (?) in 0.9.7.4: I see where the support for this is in versionmatch.cc and the above seems to not work because PackageFile::Architecture is never populated. Actually, python-apt docs say this is normal: > class apt_pkg.PackageFile > … > architecture > The architecture of the package file. This attribute normally > contains an empty string and is thus not very useful. Is there a reason for that (maybe to do with arch: all)? Looks like it could be done in debListParser::LoadReleaseInfo (or debPackagesIndex::Merge). I have attached a first attempt at a patch, which partially works (obviously needs more testing). Note that the candidate for aptitude /seems/ wrong, but technically the first stanza (“Package: *”) does not apply since the second is more specific. Changing the second to “Package: aptitude:amd64” gives better output but defeats the purpose of using “b=amd64”, at least on specific-package stanzas. Note also in the reportbug info that my apt policy has /two/ entries for experimental. -- with patch applied: $ cat /etc/apt/preferences Package: * Pin: release a=experimental,b=i386 Pin-Priority: 991 Package: aptitude Pin: release a=experimental,b=amd64 Pin-Priority: 992 $ apt-cache policy Package files: 100 /var/lib/dpkg/status release a=now 500 http://ftp.iinet.net.au/debian/debian/ experimental/main Translation-en 991 http://ftp.iinet.net.au/debian/debian/ experimental/main i386 Packages release o=Debian,a=experimental,n=experimental,l=Debian,c=main,b=i386 origin ftp.iinet.net.au 1 http://ftp.iinet.net.au/debian/debian/ experimental/main amd64 Packages release o=Debian,a=experimental,n=experimental,l=Debian,c=main,b=amd64 origin ftp.iinet.net.au 500 http://ftp.iinet.net.au/debian/debian/ sid/main Translation-en 500 http://ftp.iinet.net.au/debian/debian/ sid/main i386 Packages release o=Debian,a=unstable,n=sid,l=Debian,c=main,b=i386 origin ftp.iinet.net.au 500 http://ftp.iinet.net.au/debian/debian/ sid/main amd64 Packages release o=Debian,a=unstable,n=sid,l=Debian,c=main,b=amd64 origin ftp.iinet.net.au Pinned packages: aptitude:amd64 -> 0.6.9.1-1 aptitude -> (not found) $ apt-cache policy aptitude aptitude:amd64 aptitude: Installed: 0.6.8.1-1 Candidate: 0.6.8.1-1 Package pin: (not found) Version table: 0.6.9.1-1 992 991 http://ftp.iinet.net.au/debian/debian/ experimental/main i386 Packages 0.6.8.1-1 992 500 http://ftp.iinet.net.au/debian/debian/ sid/main i386 Packages *** 0.6.8.1-1 992 100 /var/lib/dpkg/status aptitude:amd64: Installed: (none) Candidate: 0.6.9.1-1 Package pin: 0.6.9.1-1 Version table: 0.6.9.1-1 992 1 http://ftp.iinet.net.au/debian/debian/ experimental/main amd64 Packages 0.6.8.1-1 992 500 http://ftp.iinet.net.au/debian/debian/ sid/main amd64 Packages -- System Information: Debian Release: wheezy/sid APT prefers unstable APT policy: (991, 'experimental'), (500, 'unstable'), (1, 'experimental') Architecture: i386 (i686) Foreign Architectures: amd64 Kernel: Linux 2.6.32-5-686-bigmem (SMP w/1 CPU core) Locale: LANG=en_AU.utf8, LC_CTYPE=en_AU.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages apt depends on: ii debian-archive-keyring 2010.08.28 ii gnupg 1.4.11-3 ii libapt-pkg4.12 0.9.7.4 ii libc6 2.13-35 ii libgcc1 1:4.7.1-7 ii libstdc++6 4.7.1-7 apt recommends no packages. Versions of packages apt suggests: pn apt-doc <none> ii aptitude 0.6.8.1-1 ii dpkg-dev 1.16.8 ii python-apt 0.8.7 ii synaptic 0.75.13 ii xz-utils 5.1.1alpha+20110809-3 -- no debconf information
=== modified file 'apt-pkg/deb/debindexfile.cc' --- apt-pkg/deb/debindexfile.cc 2012-06-16 17:55:43 +0000 +++ apt-pkg/deb/debindexfile.cc 2012-09-11 07:21:28 +0000 @@ -340,7 +340,7 @@ FileFd Rel(ReleaseFile,FileFd::ReadOnly); if (_error->PendingError() == true) return false; - Parser.LoadReleaseInfo(File,Rel,Section); + Parser.LoadReleaseInfo(File,Rel,Section,Architecture); } return true; === modified file 'apt-pkg/deb/deblistparser.cc' --- apt-pkg/deb/deblistparser.cc 2012-07-09 15:42:25 +0000 +++ apt-pkg/deb/deblistparser.cc 2012-09-11 08:03:10 +0000 @@ -779,13 +779,16 @@ // --------------------------------------------------------------------- /* */ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI, - FileFd &File, string component) + FileFd &File, string component, string architecture) { // apt-secure does no longer download individual (per-section) Release // file. to provide Component pinning we use the section name now map_ptrloc const storage = WriteUniqString(component); FileI->Component = storage; + map_ptrloc const storage_arch = WriteUniqString(architecture); + FileI->Architecture = storage_arch; + // FIXME: Code depends on the fact that Release files aren't compressed FILE* release = fdopen(dup(File.Fd()), "r"); if (release == NULL) @@ -830,7 +833,7 @@ ++lineEnd; // which datastorage need to be updated - enum { Suite, Component, Version, Origin, Codename, Label, None } writeTo = None; + enum { Suite, Component, Version, Origin, Codename, Label, Architecture, None } writeTo = None; if (buffer[0] == ' ') ; #define APT_PARSER_WRITETO(X) else if (strncmp(#X, buffer, len) == 0) writeTo = X; @@ -840,6 +843,7 @@ APT_PARSER_WRITETO(Origin) APT_PARSER_WRITETO(Codename) APT_PARSER_WRITETO(Label) + APT_PARSER_WRITETO(Architecture) #undef APT_PARSER_WRITETO #define APT_PARSER_FLAGIT(X) else if (strncmp(#X, buffer, len) == 0) \ pkgTagSection::FindFlag(FileI->Flags, pkgCache::Flag:: X, dataStart, lineEnd); @@ -879,6 +883,7 @@ case Origin: FileI->Origin = storage; break; case Codename: FileI->Codename = storage; break; case Label: FileI->Label = storage; break; + case Architecture: FileI->Architecture = storage; break; case None: break; } } === modified file 'apt-pkg/deb/deblistparser.h' --- apt-pkg/deb/deblistparser.h 2011-12-13 00:22:38 +0000 +++ apt-pkg/deb/deblistparser.h 2012-09-11 07:20:30 +0000 @@ -71,7 +71,7 @@ virtual bool Step(); bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File, - std::string section); + std::string section, std::string architecture); static const char *ParseDepends(const char *Start,const char *Stop, std::string &Package,std::string &Ver,unsigned int &Op,