From 45df0ad2aab7d019cec855ba2cfe7ecdd0f8c7c8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 26 Nov 2009 22:23:08 +0100 Subject: [BREAK] add possibility to download and use multiply Translation files, configurable with Acquire::Languages accessable with APT::Configuration::getLanguages() and as always with documentation in apt.conf. The commit also includes a very very simple testapp. --- apt-pkg/deb/deblistparser.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 517b771a5..16e6ee332 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -129,10 +130,11 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver) only describe package properties */ string debListParser::Description() { - if (DescriptionLanguage().empty()) + string const lang = DescriptionLanguage(); + if (lang.empty()) return Section.FindS("Description"); else - return Section.FindS(("Description-" + pkgIndexFile::LanguageCode()).c_str()); + return Section.FindS(string("Description-").append(lang).c_str()); } /*}}}*/ // ListParser::DescriptionLanguage - Return the description lang string /*{{{*/ @@ -142,7 +144,16 @@ string debListParser::Description() assumed to describe original description. */ string debListParser::DescriptionLanguage() { - return Section.FindS("Description").empty() ? pkgIndexFile::LanguageCode() : ""; + if (Section.FindS("Description").empty() == false) + return ""; + + std::vector const lang = APT::Configuration::getLanguages(); + for (std::vector::const_iterator l = lang.begin(); + l != lang.end(); l++) + if (Section.FindS(string("Description-").append(*l).c_str()).empty() == false) + return *l; + + return ""; } /*}}}*/ // ListParser::Description - Return the description_md5 MD5SumValue /*{{{*/ -- cgit v1.2.3 From 41c81fd85d43ed747375d8f1ee7a9b71fb3c7016 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 29 Nov 2009 00:23:26 +0100 Subject: Ignore :qualifiers after package name in build dependencies for now as long we don't understand them (Closes: #558103) --- apt-pkg/deb/deblistparser.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 16e6ee332..25a1df3f9 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -395,7 +395,8 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op) bit by bit. */ const char *debListParser::ParseDepends(const char *Start,const char *Stop, string &Package,string &Ver, - unsigned int &Op, bool ParseArchFlags) + unsigned int &Op, bool const &ParseArchFlags, + bool const &StripMultiArch) { // Strip off leading space for (;Start != Stop && isspace(*Start) != 0; Start++); @@ -414,7 +415,14 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop, // Stash the package name Package.assign(Start,I - Start); - + + // We don't want to confuse library users which can't handle MultiArch + if (StripMultiArch == true) { + size_t const found = Package.rfind(':'); + if (found != string::npos) + Package = Package.substr(0,found); + } + // Skip white space to the '(' for (;I != Stop && isspace(*I) != 0 ; I++); -- cgit v1.2.3 From 5bf15716398fdb767ca6249a0155219b88d7ae60 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 19 Dec 2009 16:25:56 +0100 Subject: Implement the first step toward Multi-Arch by setting up a Group infrastructor for packages. APT is now aware of the fact that a package A in architecture X can't satisfy a dependency on package A in architecture Y - to handle these packages are now identified by name and architecture, so different architectures of the same package are handled internally as completly different packages. This is great for pinning, dependency checking and in many other situations, but sometimes we need to know which archs are available for a given package: Here Groups come to our rescue! --- apt-pkg/deb/deblistparser.cc | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 25a1df3f9..fe68aec0b 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -53,12 +53,25 @@ unsigned long debListParser::UniqFindTagWrite(const char *Tag) // ListParser::Package - Return the package name /*{{{*/ // --------------------------------------------------------------------- /* This is to return the name of the package this section describes */ -string debListParser::Package() -{ - string Result = Section.FindS("Package"); - if (Result.empty() == true) - _error->Error("Encountered a section with no Package: header"); - return Result; +string debListParser::Package() { + string const Result = Section.FindS("Package"); + if(unlikely(Result.empty() == true)) + _error->Error("Encountered a section with no Package: header"); + return Result; +} + /*}}}*/ +// ListParser::Architecture - Return the package arch /*{{{*/ +// --------------------------------------------------------------------- +/* This will return the Architecture of the package this section describes + Note that architecture "all" packages will get the architecture of the + Packages file parsed here */ +string debListParser::Architecture() { + string const Result = Section.FindS("Architecture"); + if (Result.empty() == true) + return Arch; + if (Result == "all") + return Arch; + return Result; } /*}}}*/ // ListParser::Version - Return the version string /*{{{*/ @@ -78,8 +91,10 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver) { // Parse the section Ver->Section = UniqFindTagWrite("Section"); - Ver->Arch = UniqFindTagWrite("Architecture"); - + + // Parse the architecture + Ver->Arch = WriteUniqString(Architecture()); + // Archive Size Ver->Size = (unsigned)Section.FindI("Size"); @@ -537,6 +552,7 @@ bool debListParser::ParseDepends(pkgCache::VerIterator Ver, return true; string Package; + string const pkgArch = Ver.Arch(); string Version; unsigned int Op; @@ -546,7 +562,7 @@ bool debListParser::ParseDepends(pkgCache::VerIterator Ver, if (Start == 0) return _error->Error("Problem parsing dependency %s",Tag); - if (NewDepends(Ver,Package,Version,Op,Type) == false) + if (NewDepends(Ver,Package,pkgArch,Version,Op,Type) == false) return false; if (Start == Stop) break; @@ -619,6 +635,7 @@ bool debListParser::Step() if (Section.Find("Architecture",Start,Stop) == false) return true; + //FIXME: Accept different Architectures here if (stringcmp(Arch,Start,Stop) == 0) return true; @@ -641,8 +658,9 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator FileI, if (Tags.Step(Section) == false) return false; - //mvo: I don't think we need to fill that in (it's unused since apt-0.6) - //FileI->Architecture = WriteUniqString(Arch); + // FIXME: Do we need it now for multi-arch? + // mvo: I don't think we need to fill that in (it's unused since apt-0.6) +// FileI->Architecture = WriteUniqString(Arch); // apt-secure does no longer download individual (per-section) Release // file. to provide Component pinning we use the section name now -- cgit v1.2.3 From 5dd4c8b811d9c7bc33e50254811f5bc0fc37f872 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 23 Dec 2009 12:38:19 +0100 Subject: merge Goswin Brederlow "support download of index files for different archs" patch which includes the following big changes: - Declare the unused [vendor] field in sources.list as option field, e.g. deb [arch=amd64,i386 lang=en_GB have=fun] http://example.org - When fetching index files download them for all APT::Architectures (overrideable with the options field above) - Allow all architectures of APT::Architectures to be in the Cache - Add the architecture to status and progress informations - Add b= (Binary architecture) to policy This commit doesn't incude the "pin-hack" as the Group structure will take care of this (and does it already to some extend). --- apt-pkg/deb/deblistparser.cc | 57 +++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 19 deletions(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index fe68aec0b..b57eca813 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -32,10 +32,13 @@ static debListParser::WordList PrioList[] = {{"important",pkgCache::State::Impor // ListParser::debListParser - Constructor /*{{{*/ // --------------------------------------------------------------------- -/* */ -debListParser::debListParser(FileFd *File) : Tags(File) -{ - Arch = _config->Find("APT::architecture"); +/* Provide an architecture and only this one and "all" will be accepted + in Step(), if no Architecture is given we will accept every arch + we would accept in general with checkArchitecture() */ +debListParser::debListParser(FileFd *File, string const &Arch) : Tags(File), + Arch(Arch) { + if (Arch == "native") + this->Arch = _config->Find("APT::Architecture"); } /*}}}*/ // ListParser::UniqFindTagWrite - Find the tag and write a unq string /*{{{*/ @@ -64,13 +67,19 @@ string debListParser::Package() { // --------------------------------------------------------------------- /* This will return the Architecture of the package this section describes Note that architecture "all" packages will get the architecture of the - Packages file parsed here */ + Packages file parsed here. */ string debListParser::Architecture() { string const Result = Section.FindS("Architecture"); - if (Result.empty() == true) - return Arch; - if (Result == "all") - return Arch; + if (Result.empty() == true || Result == "all") { + if (Arch.empty() == true) + /* FIXME: this is a problem for installed arch all + packages as we don't know from which arch this + package was installed - and therefore which + dependency this package resolves. */ + return _config->Find("APT::Architecture"); + else + return Arch; + } return Result; } /*}}}*/ @@ -199,8 +208,12 @@ bool debListParser::UsePackage(pkgCache::PkgIterator Pkg, { if (Pkg->Section == 0) Pkg->Section = UniqFindTagWrite("Section"); - if (Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false) - return false; + + // Packages which are not from "our" arch doesn't get the essential flag + string const static myArch = _config->Find("APT::Architecture"); + if (Pkg->Arch != 0 && myArch == Pkg.Arch()) + if (Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false) + return false; if (Section.FindFlag("Important",Pkg->Flags,pkgCache::Flag::Important) == false) return false; @@ -630,17 +643,23 @@ bool debListParser::Step() /* See if this is the correct Architecture, if it isn't then we drop the whole section. A missing arch tag only happens (in theory) inside the Status file, so that is a positive return */ - const char *Start; - const char *Stop; - if (Section.Find("Architecture",Start,Stop) == false) + string const Architecture = Section.FindS("Architecture"); + if (Architecture.empty() == true) return true; - //FIXME: Accept different Architectures here - if (stringcmp(Arch,Start,Stop) == 0) - return true; + if (Arch.empty() == true) + { + if (APT::Configuration::checkArchitecture(Architecture) == true) + return true; + } + else + { + if (Architecture == Arch) + return true; - if (stringcmp(Start,Stop,"all") == 0) - return true; + if (Architecture == "all") + return true; + } iOffset = Tags.Offset(); } -- cgit v1.2.3 From 25396fb06350344996a20d05423562f08a4165db Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 27 Dec 2009 19:39:47 +0100 Subject: Split ListParser::NewDepends into two methods to use these new method for creating the dependencies needed for our groups: For now for all groups only one package can be installed at the same time which conflicts with each other packages in the group. The exceptions are architecture all package. Also, the Multi-Arch field is now parsed, but not used for now. --- apt-pkg/deb/deblistparser.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index b57eca813..f683de423 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -104,6 +104,30 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver) // Parse the architecture Ver->Arch = WriteUniqString(Architecture()); + // Parse multi-arch + if (Section.FindS("Architecture") == "all") + /* Arch all packages can't have a Multi-Arch field, + but we need a special treatment for them nonetheless */ + Ver->MultiArch = pkgCache::Version::All; + else + { + string const MultiArch = Section.FindS("Multi-Arch"); + if (MultiArch.empty() == true) + Ver->MultiArch = pkgCache::Version::None; + else if (MultiArch == "same") + Ver->MultiArch = pkgCache::Version::Same; + else if (MultiArch == "foreign") + Ver->MultiArch = pkgCache::Version::Foreign; + else if (MultiArch == "allowed") + Ver->MultiArch = pkgCache::Version::Allowed; + else + { + _error->Warning("Unknown Multi-Arch type »%s« for package »%s«", + MultiArch.c_str(), Section.FindS("Package").c_str()); + Ver->MultiArch = pkgCache::Version::None; + } + } + // Archive Size Ver->Size = (unsigned)Section.FindI("Size"); -- cgit v1.2.3 From 5c0d3668dd2b6852812502f33d64b1644c2b137a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 30 Jan 2010 22:19:57 +0100 Subject: * apt-pkg/contrib/macros.h: - move the header system.h with a new name to the public domain, to be able to use it in other headers (Closes: #567662) --- apt-pkg/deb/deblistparser.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 25a1df3f9..66108d822 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -17,10 +17,9 @@ #include #include #include +#include #include - -#include /*}}}*/ static debListParser::WordList PrioList[] = {{"important",pkgCache::State::Important}, -- cgit v1.2.3 From 857e9c13d8d9808fcd1ac8ff3469f6c0b90b7fea Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 7 Feb 2010 12:38:13 +0100 Subject: Drop the Arch information from the Version structure as we can get the information from the parent package now --- apt-pkg/deb/deblistparser.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index f683de423..26841d3d2 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -83,6 +83,13 @@ string debListParser::Architecture() { return Result; } /*}}}*/ +// ListParser::ArchitectureAll /*{{{*/ +// --------------------------------------------------------------------- +/* */ +bool debListParser::ArchitectureAll() { + return Section.FindS("Architecture") == "all"; +} + /*}}}*/ // ListParser::Version - Return the version string /*{{{*/ // --------------------------------------------------------------------- /* This is to return the string describing the version in debian form, @@ -101,9 +108,6 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver) // Parse the section Ver->Section = UniqFindTagWrite("Section"); - // Parse the architecture - Ver->Arch = WriteUniqString(Architecture()); - // Parse multi-arch if (Section.FindS("Architecture") == "all") /* Arch all packages can't have a Multi-Arch field, -- cgit v1.2.3 From 67e0766f0eab85ce1aeacee75fc6b200f36996c9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 10 Feb 2010 22:45:58 +0100 Subject: Foreign Versions add an implicit Provides to the other packages in the group --- apt-pkg/deb/deblistparser.cc | 55 +++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 19 deletions(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 26841d3d2..b6082cdd5 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -618,29 +618,46 @@ bool debListParser::ParseProvides(pkgCache::VerIterator Ver) { const char *Start; const char *Stop; - if (Section.Find("Provides",Start,Stop) == false) - return true; - - string Package; - string Version; - unsigned int Op; - - while (1) + if (Section.Find("Provides",Start,Stop) == true) { - Start = ParseDepends(Start,Stop,Package,Version,Op); - if (Start == 0) - return _error->Error("Problem parsing Provides line"); - if (Op != pkgCache::Dep::NoOp) { - _error->Warning("Ignoring Provides line with DepCompareOp for package %s", Package.c_str()); - } else { - if (NewProvides(Ver,Package,Version) == false) - return false; + string Package; + string Version; + string const Arch = Ver.Arch(); + unsigned int Op; + + while (1) + { + Start = ParseDepends(Start,Stop,Package,Version,Op); + if (Start == 0) + return _error->Error("Problem parsing Provides line"); + if (Op != pkgCache::Dep::NoOp) { + _error->Warning("Ignoring Provides line with DepCompareOp for package %s", Package.c_str()); + } else { + if (NewProvides(Ver, Package, Arch, Version) == false) + return false; + } + + if (Start == Stop) + break; } + } - if (Start == Stop) - break; + if (Ver->MultiArch != pkgCache::Version::Foreign) + return true; + + std::vector const archs = APT::Configuration::getArchitectures(); + if (archs.size() <= 1) + return true; + + string const Package = Ver.ParentPkg().Name(); + string const Version = Ver.VerStr(); + for (std::vector::const_iterator a = archs.begin(); + a != archs.end(); ++a) + { + if (NewProvides(Ver, Package, *a, Version) == false) + return false; } - + return true; } /*}}}*/ -- cgit v1.2.3 From 4d174dc84ea184b5afa81abb3b94e2ef3380ece8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Feb 2010 12:19:48 +0100 Subject: Add Multi-Arch: allowed support by creating an implicit provide of name:any for such packages, so dependencies in this style can be easily resolved. --- apt-pkg/deb/deblistparser.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index b6082cdd5..3726a6a04 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -642,6 +642,12 @@ bool debListParser::ParseProvides(pkgCache::VerIterator Ver) } } + if (Ver->MultiArch == pkgCache::Version::Allowed) + { + string const Package = string(Ver.ParentPkg().Name()).append(":").append("any"); + NewProvides(Ver, Package, "any", Ver.VerStr()); + } + if (Ver->MultiArch != pkgCache::Version::Foreign) return true; -- cgit v1.2.3 From 803ea2a87f81252b2c0d541b8502ed206ce57c84 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 12 Feb 2010 00:04:31 +0100 Subject: Add yet another pseudo package which isn't as pseudo as the others: Arch all packages are now represented by arch depending packages which all depend on a package with the same name and the special arch "all". This packages has NO dependencies, but beside this the same information. It is the only package which has a size, the arch depending ones all have a zero size. While the arch depending pseudo packages are used for dependency resolution the arch "all" package is used for downloading and ordering of the package. --- apt-pkg/deb/deblistparser.cc | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 3726a6a04..b3d95164a 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -148,6 +148,24 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver) Ver->Priority = pkgCache::State::Extra; } + if (Ver->MultiArch == pkgCache::Version::All) + { + /* We maintain a "pseudo" arch=all package for architecture all versions + on which these versions can depend on. This pseudo package is many used + for downloading/installing: The other pseudo-packages will degenerate + to a NOP in the download/install step - this package will ensure that + it is downloaded only one time and installed only one time -- even if + the architecture bound versions coming in and out on regular basis. */ + if (strcmp(Ver.Arch(true),"all") == 0) + return true; + else + { + // our pseudo packages have no size to not confuse the fetcher + Ver->Size = 0; + Ver->InstalledSize = 0; + } + } + if (ParseDepends(Ver,"Depends",pkgCache::Dep::Depends) == false) return false; if (ParseDepends(Ver,"Pre-Depends",pkgCache::Dep::PreDepends) == false) @@ -593,7 +611,7 @@ bool debListParser::ParseDepends(pkgCache::VerIterator Ver, return true; string Package; - string const pkgArch = Ver.Arch(); + string const pkgArch = Ver.Arch(true); string Version; unsigned int Op; @@ -622,7 +640,7 @@ bool debListParser::ParseProvides(pkgCache::VerIterator Ver) { string Package; string Version; - string const Arch = Ver.Arch(); + string const Arch = Ver.Arch(true); unsigned int Op; while (1) -- cgit v1.2.3 From 42d71ab5fe58953a680bd300a99d173e23430d7c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 12 Feb 2010 17:17:16 +0100 Subject: In SingleArch environments we don't need the arch "all" pseudo package for handling arch:all packages, so we create only one package and stop calling it a pseudo package. --- apt-pkg/deb/deblistparser.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index b3d95164a..1948aedf3 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -158,7 +158,7 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver) the architecture bound versions coming in and out on regular basis. */ if (strcmp(Ver.Arch(true),"all") == 0) return true; - else + else if (Ver.Pseudo() == true) { // our pseudo packages have no size to not confuse the fetcher Ver->Size = 0; -- cgit v1.2.3 From ee60a63480f7d1a963d7ef2a8e399d0f9b651d71 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 14 Feb 2010 22:24:55 +0100 Subject: Pseudo() doesn't work in the Cache generation step as the check if only one package is in the group will generate false positives - as the others will (maybe) added a little time later in the process. --- apt-pkg/deb/deblistparser.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index bfc0e762e..84eab44a7 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -155,9 +155,10 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver) to a NOP in the download/install step - this package will ensure that it is downloaded only one time and installed only one time -- even if the architecture bound versions coming in and out on regular basis. */ + bool const static multiArch = APT::Configuration::getArchitectures().size() > 1; if (strcmp(Ver.Arch(true),"all") == 0) return true; - else if (Ver.Pseudo() == true) + else if (multiArch == true) { // our pseudo packages have no size to not confuse the fetcher Ver->Size = 0; -- cgit v1.2.3 From 306eacf617b8ea8c87b31258c55a5373be4ad946 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 18 Mar 2010 18:07:51 +0100 Subject: generate "negative" dependencies against all architectures of a package Negative means here Conflicts, Replaces and Breaks - this adds again a whole lot of dependencies. --- apt-pkg/deb/deblistparser.cc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 84eab44a7..5c9cf6d4b 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -609,7 +609,10 @@ bool debListParser::ParseDepends(pkgCache::VerIterator Ver, const char *Stop; if (Section.Find(Tag,Start,Stop) == false) return true; - + + static std::vector const archs = APT::Configuration::getArchitectures(); + static bool const multiArch = archs.size() <= 1; + string Package; string const pkgArch = Ver.Arch(true); string Version; @@ -620,8 +623,18 @@ bool debListParser::ParseDepends(pkgCache::VerIterator Ver, Start = ParseDepends(Start,Stop,Package,Version,Op); if (Start == 0) return _error->Error("Problem parsing dependency %s",Tag); - - if (NewDepends(Ver,Package,pkgArch,Version,Op,Type) == false) + + if (multiArch == true && + (Type == pkgCache::Dep::Conflicts || + Type == pkgCache::Dep::DpkgBreaks || + Type == pkgCache::Dep::Replaces)) + { + for (std::vector::const_iterator a = archs.begin(); + a != archs.end(); ++a) + if (NewDepends(Ver,Package,*a,Version,Op,Type) == false) + return false; + } + else if (NewDepends(Ver,Package,pkgArch,Version,Op,Type) == false) return false; if (Start == Stop) break; -- cgit v1.2.3 From 6bc703c22970055d9e1a1b4e3e0efe74f4cefda5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 21 Mar 2010 21:48:09 +0100 Subject: =?UTF-8?q?Add=20with=20pkgCacheGen::Essential=20a=20way=20to=20co?= =?UTF-8?q?ntrol=20which=20packages=20get=20the=20essential=20flag:=20*=20?= =?UTF-8?q?native=20is=20the=20default=20and=20will=20only=20mark=20packag?= =?UTF-8?q?es=20of=20the=20main=20arch=20*=20all=20will=20mark=20all=20pac?= =?UTF-8?q?kages=20which=20have=20these=20flag=20in=20Packages=20*=20none?= =?UTF-8?q?=20will=20obviously=20do=20the=20opposite=20*=20installed=20wil?= =?UTF-8?q?l=20only=20mark=20packages=20which=20are=20installed=20as=20ess?= =?UTF-8?q?ential,=20=20=20so=20it=20will=20behave=20in=20the=20same=20way?= =?UTF-8?q?=20as=20dpkg=20does=20it.=20It=20is=20mostly=20needed=20sometim?= =?UTF-8?q?es=20for=20debugging=20but=20some=20users=20with=20special=20ne?= =?UTF-8?q?eds=20might=20like=20to=20switch=20the=20mode=20as=20well=20und?= =?UTF-8?q?er=20the=20expense=20to=20be=20on=20their=20own=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apt-pkg/deb/deblistparser.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 5c9cf6d4b..947e060e3 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -255,9 +255,13 @@ bool debListParser::UsePackage(pkgCache::PkgIterator Pkg, if (Pkg->Section == 0) Pkg->Section = UniqFindTagWrite("Section"); - // Packages which are not from "our" arch doesn't get the essential flag + // Packages which are not from the "native" arch doesn't get the essential flag + // in the default "native" mode - it is also possible to mark "all" or "none". + // The "installed" mode is handled by ParseStatus(), See #544481 and friends. string const static myArch = _config->Find("APT::Architecture"); - if (Pkg->Arch != 0 && myArch == Pkg.Arch()) + string const static essential = _config->Find("pkgCacheGen::Essential", "native"); + if ((essential == "native" && Pkg->Arch != 0 && myArch == Pkg.Arch()) || + essential == "all") if (Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false) return false; if (Section.FindFlag("Important",Pkg->Flags,pkgCache::Flag::Important) == false) @@ -333,7 +337,13 @@ bool debListParser::ParseStatus(pkgCache::PkgIterator Pkg, const char *Stop; if (Section.Find("Status",Start,Stop) == false) return true; - + + // UsePackage() is responsible for setting the flag in the default case + bool const static essential = _config->Find("pkgCacheGen::Essential", "") == "installed"; + if (essential == true && + Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false) + return false; + // Isolate the first word const char *I = Start; for(; I < Stop && *I != ' '; I++); -- cgit v1.2.3 From 33dd02e3a95141d4e16677048614c3171c4c4ffc Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 30 Mar 2010 14:45:38 +0200 Subject: convert some tabs to spaces to respect the style guide --- apt-pkg/deb/deblistparser.cc | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 947e060e3..0551a5f7c 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -36,8 +36,8 @@ static debListParser::WordList PrioList[] = {{"important",pkgCache::State::Impor we would accept in general with checkArchitecture() */ debListParser::debListParser(FileFd *File, string const &Arch) : Tags(File), Arch(Arch) { - if (Arch == "native") - this->Arch = _config->Find("APT::Architecture"); + if (Arch == "native") + this->Arch = _config->Find("APT::Architecture"); } /*}}}*/ // ListParser::UniqFindTagWrite - Find the tag and write a unq string /*{{{*/ @@ -56,10 +56,10 @@ unsigned long debListParser::UniqFindTagWrite(const char *Tag) // --------------------------------------------------------------------- /* This is to return the name of the package this section describes */ string debListParser::Package() { - string const Result = Section.FindS("Package"); - if(unlikely(Result.empty() == true)) - _error->Error("Encountered a section with no Package: header"); - return Result; + string const Result = Section.FindS("Package"); + if(unlikely(Result.empty() == true)) + _error->Error("Encountered a section with no Package: header"); + return Result; } /*}}}*/ // ListParser::Architecture - Return the package arch /*{{{*/ @@ -68,25 +68,26 @@ string debListParser::Package() { Note that architecture "all" packages will get the architecture of the Packages file parsed here. */ string debListParser::Architecture() { - string const Result = Section.FindS("Architecture"); - if (Result.empty() == true || Result == "all") { - if (Arch.empty() == true) - /* FIXME: this is a problem for installed arch all - packages as we don't know from which arch this - package was installed - and therefore which - dependency this package resolves. */ - return _config->Find("APT::Architecture"); - else - return Arch; - } - return Result; + string const Result = Section.FindS("Architecture"); + if (Result.empty() == true || Result == "all") + { + if (Arch.empty() == true) + /* FIXME: this is a problem for installed arch all + packages as we don't know from which arch this + package was installed - and therefore which + dependency this package resolves. */ + return _config->Find("APT::Architecture"); + else + return Arch; + } + return Result; } /*}}}*/ // ListParser::ArchitectureAll /*{{{*/ // --------------------------------------------------------------------- /* */ bool debListParser::ArchitectureAll() { - return Section.FindS("Architecture") == "all"; + return Section.FindS("Architecture") == "all"; } /*}}}*/ // ListParser::Version - Return the version string /*{{{*/ -- cgit v1.2.3 From e2c66de5c5e63d8400efb0522c31fbe1ec225f93 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 3 Jun 2010 09:22:00 +0200 Subject: * apt-pkg/pkgcache.h: - switch {,Install-}Size to unsigned long long * apt-pkg/depcache.cc: - deal with long long, not with int to remove 2GB Limit (LP: #250909) --- apt-pkg/deb/deblistparser.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 0551a5f7c..83c5b8d2e 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -133,10 +133,9 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver) } // Archive Size - Ver->Size = (unsigned)Section.FindI("Size"); - + Ver->Size = Section.FindULL("Size"); // Unpacked Size (in K) - Ver->InstalledSize = (unsigned)Section.FindI("Installed-Size"); + Ver->InstalledSize = Section.FindULL("Installed-Size"); Ver->InstalledSize *= 1024; // Priority -- cgit v1.2.3 From d4af23c2d81116b8f7557ee795059bca126ae9f4 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 26 Jun 2010 20:56:44 +0200 Subject: * apt-pkg/deb/deblistparser.cc: - Handle architecture wildcards (Closes: #547724). --- apt-pkg/deb/deblistparser.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 83c5b8d2e..ddbd0d31a 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -19,6 +19,7 @@ #include #include +#include #include /*}}}*/ @@ -572,8 +573,15 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop, I++; } - if (stringcmp(arch,I,End) == 0) + if (stringcmp(arch,I,End) == 0) { Found = true; + } else { + std::string wildcard = SubstVar(string(I, End), "any", "*"); + if (fnmatch(wildcard.c_str(), arch.c_str(), 0) == 0) + Found = true; + else if (fnmatch(wildcard.c_str(), ("linux-" + arch).c_str(), 0) == 0) + Found = true; + } if (*End++ == ']') { I = End; -- cgit v1.2.3 From 3b20aef1a2b5fd2fcd6f62a819edbdb19631fb98 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 26 Jun 2010 23:01:49 +0200 Subject: apt-pkg/deb/deblistparser.cc: Fix bug in architecture wildcard support. Previously, linux-any was always matched, because the code simply appended linux- to the APT::Architecture value. Now, it does this only if the APT::Architecture value does not contain "-". --- apt-pkg/deb/deblistparser.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index ddbd0d31a..00016679a 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -473,6 +473,14 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op) return I; } +/* + * CompleteArch: + * + * The complete architecture, consisting of -. + */ +static string CompleteArch(std::string& arch) { + return (arch.find("-") != string::npos) ? arch : "linux-" + arch; +} /*}}}*/ // ListParser::ParseDepends - Parse a dependency element /*{{{*/ // --------------------------------------------------------------------- @@ -546,6 +554,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop, if (ParseArchFlags == true) { string arch = _config->Find("APT::Architecture"); + string completeArch = CompleteArch(arch); // Parse an architecture if (I != Stop && *I == '[') @@ -577,9 +586,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop, Found = true; } else { std::string wildcard = SubstVar(string(I, End), "any", "*"); - if (fnmatch(wildcard.c_str(), arch.c_str(), 0) == 0) - Found = true; - else if (fnmatch(wildcard.c_str(), ("linux-" + arch).c_str(), 0) == 0) + if (fnmatch(wildcard.c_str(), completeArch.c_str(), 0) == 0) Found = true; } -- cgit v1.2.3 From 5143f361005775e3674f4f5871ad574cbe8ef705 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 27 Jun 2010 21:04:53 +0200 Subject: deblistparser: Special-case *-armel, lpia and powerpcspe architectures. --- apt-pkg/deb/deblistparser.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 00016679a..6ede14c4d 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -479,6 +479,12 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op) * The complete architecture, consisting of -. */ static string CompleteArch(std::string& arch) { + if (arch == "armel") return "linux-arm"; + if (arch == "lpia") return "linux-i386"; + if (arch == "powerpcspe") return "linux-powerpc"; + if (arch == "uclibc-linux-armel") return "linux-arm"; + if (arch == "uclinux-armel") return "uclinux-arm"; + return (arch.find("-") != string::npos) ? arch : "linux-" + arch; } /*}}}*/ -- cgit v1.2.3 From dcfa253fa4b3c563b3ed085c40d3336933840d55 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 4 Jul 2010 17:04:07 +0200 Subject: clean deblistparser a bit by get the Architectures at one place instead of distributed in a few methods --- apt-pkg/deb/deblistparser.cc | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 83c5b8d2e..d1931f909 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -38,6 +38,8 @@ debListParser::debListParser(FileFd *File, string const &Arch) : Tags(File), Arch(Arch) { if (Arch == "native") this->Arch = _config->Find("APT::Architecture"); + Architectures = APT::Configuration::getArchitectures(); + MultiArchEnabled = Architectures.size() > 1; } /*}}}*/ // ListParser::UniqFindTagWrite - Find the tag and write a unq string /*{{{*/ @@ -155,10 +157,9 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver) to a NOP in the download/install step - this package will ensure that it is downloaded only one time and installed only one time -- even if the architecture bound versions coming in and out on regular basis. */ - bool const static multiArch = APT::Configuration::getArchitectures().size() > 1; if (strcmp(Ver.Arch(true),"all") == 0) return true; - else if (multiArch == true) + else if (MultiArchEnabled == true) { // our pseudo packages have no size to not confuse the fetcher Ver->Size = 0; @@ -620,9 +621,6 @@ bool debListParser::ParseDepends(pkgCache::VerIterator Ver, if (Section.Find(Tag,Start,Stop) == false) return true; - static std::vector const archs = APT::Configuration::getArchitectures(); - static bool const multiArch = archs.size() <= 1; - string Package; string const pkgArch = Ver.Arch(true); string Version; @@ -634,13 +632,13 @@ bool debListParser::ParseDepends(pkgCache::VerIterator Ver, if (Start == 0) return _error->Error("Problem parsing dependency %s",Tag); - if (multiArch == true && + if (MultiArchEnabled == true && (Type == pkgCache::Dep::Conflicts || Type == pkgCache::Dep::DpkgBreaks || Type == pkgCache::Dep::Replaces)) { - for (std::vector::const_iterator a = archs.begin(); - a != archs.end(); ++a) + for (std::vector::const_iterator a = Architectures.begin(); + a != Architectures.end(); ++a) if (NewDepends(Ver,Package,*a,Version,Op,Type) == false) return false; } @@ -692,14 +690,13 @@ bool debListParser::ParseProvides(pkgCache::VerIterator Ver) if (Ver->MultiArch != pkgCache::Version::Foreign) return true; - std::vector const archs = APT::Configuration::getArchitectures(); - if (archs.size() <= 1) + if (MultiArchEnabled == false) return true; string const Package = Ver.ParentPkg().Name(); string const Version = Ver.VerStr(); - for (std::vector::const_iterator a = archs.begin(); - a != archs.end(); ++a) + for (std::vector::const_iterator a = Architectures.begin(); + a != Architectures.end(); ++a) { if (NewProvides(Ver, Package, *a, Version) == false) return false; @@ -739,7 +736,7 @@ bool debListParser::Step() if (Architecture.empty() == true) return true; - if (Arch.empty() == true) + if (Arch.empty() == true || MultiArchEnabled == false) { if (APT::Configuration::checkArchitecture(Architecture) == true) return true; -- cgit v1.2.3 From 32b9a14cb4c6bdcddfe84c4451c225ced1a34bb7 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 8 Jul 2010 11:10:46 +0200 Subject: use references instead of copies in the Cache generation methods --- apt-pkg/deb/deblistparser.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 24df57a5c..2cfeb23e9 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -106,7 +106,7 @@ string debListParser::Version() // ListParser::NewVersion - Fill in the version structure /*{{{*/ // --------------------------------------------------------------------- /* */ -bool debListParser::NewVersion(pkgCache::VerIterator Ver) +bool debListParser::NewVersion(pkgCache::VerIterator &Ver) { // Parse the section Ver->Section = UniqFindTagWrite("Section"); @@ -251,8 +251,8 @@ MD5SumValue debListParser::Description_md5() // --------------------------------------------------------------------- /* This is called to update the package with any new information that might be found in the section */ -bool debListParser::UsePackage(pkgCache::PkgIterator Pkg, - pkgCache::VerIterator Ver) +bool debListParser::UsePackage(pkgCache::PkgIterator &Pkg, + pkgCache::VerIterator &Ver) { if (Pkg->Section == 0) Pkg->Section = UniqFindTagWrite("Section"); @@ -332,8 +332,8 @@ unsigned short debListParser::VersionHash() Some of the above are obsolete (I think?) flag = hold-* and status = post-inst-failed, removal-failed at least. */ -bool debListParser::ParseStatus(pkgCache::PkgIterator Pkg, - pkgCache::VerIterator Ver) +bool debListParser::ParseStatus(pkgCache::PkgIterator &Pkg, + pkgCache::VerIterator &Ver) { const char *Start; const char *Stop; @@ -634,7 +634,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop, // --------------------------------------------------------------------- /* This is the higher level depends parser. It takes a tag and generates a complete depends tree for the given version. */ -bool debListParser::ParseDepends(pkgCache::VerIterator Ver, +bool debListParser::ParseDepends(pkgCache::VerIterator &Ver, const char *Tag,unsigned int Type) { const char *Start; @@ -674,7 +674,7 @@ bool debListParser::ParseDepends(pkgCache::VerIterator Ver, // ListParser::ParseProvides - Parse the provides list /*{{{*/ // --------------------------------------------------------------------- /* */ -bool debListParser::ParseProvides(pkgCache::VerIterator Ver) +bool debListParser::ParseProvides(pkgCache::VerIterator &Ver) { const char *Start; const char *Stop; @@ -779,7 +779,7 @@ bool debListParser::Step() // ListParser::LoadReleaseInfo - Load the release information /*{{{*/ // --------------------------------------------------------------------- /* */ -bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator FileI, +bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI, FileFd &File, string component) { pkgTagFile Tags(&File, File.Size() + 256); // XXX -- cgit v1.2.3 From dd13742ef11a6a601a2e85afd9d80be92ed7513a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 11 Jul 2010 18:50:41 +0200 Subject: * apt-pkg/deb/debmetaindex.cc: - do not query each architecture for flat file archives --- apt-pkg/deb/deblistparser.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/deb/deblistparser.cc') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 2cfeb23e9..5fb737970 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -757,7 +757,7 @@ bool debListParser::Step() if (Architecture.empty() == true) return true; - if (Arch.empty() == true || MultiArchEnabled == false) + if (Arch.empty() == true || Arch == "any" || MultiArchEnabled == false) { if (APT::Configuration::checkArchitecture(Architecture) == true) return true; -- cgit v1.2.3