From ab59c1ca30640b90bb657d08b2c219bbaeb65783 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 9 Jun 2012 22:15:51 +0200 Subject: * apt-pkg/cdrom.cc: - fix regression from 0.9.3 which dumped the main configuration _config instead of the cdrom settings (Cnf) as identified and tested by Milan Kupcevic, thanks! (Closes: #674100) --- apt-pkg/cdrom.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index c10ca6bd1..8462e8286 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -409,7 +409,7 @@ bool pkgCdrom::WriteDatabase(Configuration &Cnf) /* Write out all of the configuration directives by walking the configuration tree */ - _config->Dump(Out, NULL, "%f \"%v\";\n", false); + Cnf.Dump(Out, NULL, "%f \"%v\";\n", false); Out.close(); -- cgit v1.2.3 From ae2be086c6996e6ed02b7d828fdcac38248a964d Mon Sep 17 00:00:00 2001 From: Daniel Hartwig Date: Sat, 9 Jun 2012 22:49:37 +0200 Subject: * apt-pkg/contrib/cmdline.cc: - apply patch from Daniel Hartwig to fix a segfault in case the LongOpt is empty (Closes: #676331) --- apt-pkg/contrib/cmndline.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc index 159f330a1..b8c7f7984 100644 --- a/apt-pkg/contrib/cmndline.cc +++ b/apt-pkg/contrib/cmndline.cc @@ -92,8 +92,9 @@ bool CommandLine::Parse(int argc,const char **argv) // Match up to a = against the list Args *A; const char *OptEnd = strchrnul(Opt, '='); - for (A = ArgList; A->end() == false && - stringcasecmp(Opt,OptEnd,A->LongOpt) != 0; A++); + for (A = ArgList; A->end() == false && + (A->LongOpt == 0 || stringcasecmp(Opt,OptEnd,A->LongOpt) != 0); + ++A); // Failed, look for a word after the first - (no-foo) bool PreceedMatch = false; -- cgit v1.2.3 From 7a6d9076595b2acc164d6f057f609c96c359ea08 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 9 Jun 2012 22:55:51 +0200 Subject: fix segfault with empty LongOpt in --no-* branch --- apt-pkg/contrib/cmndline.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc index b8c7f7984..75d02cad4 100644 --- a/apt-pkg/contrib/cmndline.cc +++ b/apt-pkg/contrib/cmndline.cc @@ -106,7 +106,8 @@ bool CommandLine::Parse(int argc,const char **argv) Opt++; for (A = ArgList; A->end() == false && - stringcasecmp(Opt,OptEnd,A->LongOpt) != 0; A++); + (A->LongOpt == 0 || stringcasecmp(Opt,OptEnd,A->LongOpt) != 0); + ++A); // Failed again.. if (A->end() == true && OptEnd - Opt != 1) -- cgit v1.2.3 From e5a91f7e42a72c97e12e66569f3b8fc777652c26 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 10 Jun 2012 00:08:28 +0200 Subject: * apt-pkg/deb/deblistparser.cc: - set pkgCacheGen::Essential to "all" again (Closes: #675449) * apt-pkg/algorithms.cc: - force install only for one essential package out of a group --- apt-pkg/algorithms.cc | 35 ++++++++++++++++++++++++++++++----- apt-pkg/deb/deblistparser.cc | 11 +++++------ 2 files changed, 35 insertions(+), 11 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 2d710097a..2f5fcc7ab 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -362,11 +362,36 @@ bool pkgDistUpgrade(pkgDepCache &Cache) if (I->CurrentVer != 0) Cache.MarkInstall(I, true, 0, false); - /* Now, auto upgrade all essential packages - this ensures that - the essential packages are present and working */ - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) - if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential) - Cache.MarkInstall(I, true, 0, false); + /* Now, install each essential package which is not installed + (and not provided by another package in the same name group) */ + std::string essential = _config->Find("pkgCacheGen::Essential", "all"); + if (essential == "all") + { + for (pkgCache::GrpIterator G = Cache.GrpBegin(); G.end() == false; ++G) + { + bool isEssential = false; + bool instEssential = false; + for (pkgCache::PkgIterator P = G.PackageList(); P.end() == false; P = G.NextPkg(P)) + { + if ((P->Flags & pkgCache::Flag::Essential) != pkgCache::Flag::Essential) + continue; + isEssential = true; + if (Cache[P].Install() == true) + { + instEssential = true; + break; + } + } + if (isEssential == false || instEssential == true) + continue; + pkgCache::PkgIterator P = G.FindPreferredPkg(); + Cache.MarkInstall(P, true, 0, false); + } + } + else if (essential != "none") + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) + if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential) + Cache.MarkInstall(I, true, 0, false); /* We do it again over all previously installed packages to force conflict resolution on them all. */ diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 7bef6772c..0a7e41538 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -243,13 +243,12 @@ bool debListParser::UsePackage(pkgCache::PkgIterator &Pkg, if (Pkg->Section == 0) Pkg->Section = UniqFindTagWrite("Section"); - // 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"); - string const static essential = _config->Find("pkgCacheGen::Essential", "native"); - if ((essential == "native" && Pkg->Arch != 0 && myArch == Pkg.Arch()) || - essential == "all") + // Possible values are: "all", "native", "installed" and "none" + // The "installed" mode is handled by ParseStatus(), See #544481 and friends. + string const static essential = _config->Find("pkgCacheGen::Essential", "all"); + if (essential == "all" || + (essential == "native" && 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) -- cgit v1.2.3 From f87fab03bade8a049b318df68dfa4c361fab944c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 10 Jun 2012 00:40:55 +0200 Subject: * apt-pkg/aptconfiguration.cc: - if APT::Languages=none save "none" in allCodes so that the detected configuration is cached as intended (Closes: #674690, LP: #1004947) --- apt-pkg/aptconfiguration.cc | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index d763546f8..d31ccb642 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -234,17 +234,21 @@ std::vector const Configuration::getLanguages(bool const &All, // override the configuration settings vector of languages. string const forceLang = _config->Find("Acquire::Languages",""); if (forceLang.empty() == false) { - if (forceLang == "environment") { - codes = environment; - } else if (forceLang != "none") - codes.push_back(forceLang); - else //if (forceLang == "none") - builtin.clear(); - allCodes = codes; - for (std::vector::const_iterator b = builtin.begin(); - b != builtin.end(); ++b) - if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end()) - allCodes.push_back(*b); + if (forceLang == "none") { + codes.clear(); + allCodes.clear(); + allCodes.push_back("none"); + } else { + if (forceLang == "environment") + codes = environment; + else + codes.push_back(forceLang); + allCodes = codes; + for (std::vector::const_iterator b = builtin.begin(); + b != builtin.end(); ++b) + if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end()) + allCodes.push_back(*b); + } if (All == true) return allCodes; else -- cgit v1.2.3 From d5648746d4d4ea3f71aae5578a42050385e7b61d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 11 Jun 2012 01:31:27 +0200 Subject: * apt-pkg/cacheiterators.h: - add an IsMultiArchImplicit() method for Dep- and PrvIterator --- apt-pkg/cacheiterators.h | 4 +++- apt-pkg/edsp.cc | 12 ++++-------- apt-pkg/pkgcache.cc | 26 ++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 9 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index d5e018be9..dcd353119 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -285,6 +285,7 @@ class pkgCache::DepIterator : public Iterator { bool IsNegative() const; bool IsIgnorable(PrvIterator const &Prv) const; bool IsIgnorable(PkgIterator const &Pkg) const; + bool IsMultiArchImplicit() const; void GlobOr(DepIterator &Start,DepIterator &End); Version **AllTargets() const; bool SmartTargetPkg(PkgIterator &Result) const; @@ -329,8 +330,9 @@ class pkgCache::PrvIterator : public Iterator { inline VerIterator OwnerVer() const {return VerIterator(*Owner,Owner->VerP + S->Version);}; inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->Version].ParentPkg);}; - inline PrvIterator() : Iterator(), Type(PrvVer) {}; + bool IsMultiArchImplicit() const; + inline PrvIterator() : Iterator(), Type(PrvVer) {}; inline PrvIterator(pkgCache &Owner, Provides *Trg, Version*) : Iterator(Owner, Trg), Type(PrvVer) { if (S == 0) diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index 791aac72f..adb8788b3 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -118,8 +118,7 @@ void EDSP::WriteScenarioDependency(pkgDepCache &Cache, FILE* output, pkgCache::P bool orGroup = false; for (pkgCache::DepIterator Dep = Ver.DependsList(); Dep.end() == false; ++Dep) { - // Ignore implicit dependencies for multiarch here - if (strcmp(Pkg.Arch(), Dep.TargetPkg().Arch()) != 0) + if (Dep.IsMultiArchImplicit() == true) continue; if (orGroup == false) dependencies[Dep->Type].append(", "); @@ -140,8 +139,7 @@ void EDSP::WriteScenarioDependency(pkgDepCache &Cache, FILE* output, pkgCache::P string provides; for (pkgCache::PrvIterator Prv = Ver.ProvidesList(); Prv.end() == false; ++Prv) { - // Ignore implicit provides for multiarch here - if (strcmp(Pkg.Arch(), Prv.ParentPkg().Arch()) != 0 || strcmp(Pkg.Name(),Prv.Name()) == 0) + if (Prv.IsMultiArchImplicit() == true) continue; provides.append(", ").append(Prv.Name()); } @@ -159,8 +157,7 @@ void EDSP::WriteScenarioLimitedDependency(pkgDepCache &Cache, FILE* output, bool orGroup = false; for (pkgCache::DepIterator Dep = Ver.DependsList(); Dep.end() == false; ++Dep) { - // Ignore implicit dependencies for multiarch here - if (strcmp(Pkg.Arch(), Dep.TargetPkg().Arch()) != 0) + if (Dep.IsMultiArchImplicit() == true) continue; if (orGroup == false) { @@ -193,8 +190,7 @@ void EDSP::WriteScenarioLimitedDependency(pkgDepCache &Cache, FILE* output, string provides; for (pkgCache::PrvIterator Prv = Ver.ProvidesList(); Prv.end() == false; ++Prv) { - // Ignore implicit provides for multiarch here - if (strcmp(Pkg.Arch(), Prv.ParentPkg().Arch()) != 0 || strcmp(Pkg.Name(),Prv.Name()) == 0) + if (Prv.IsMultiArchImplicit() == true) continue; if (pkgset.find(Prv.ParentPkg()) == pkgset.end()) continue; diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 997c70768..e06e74579 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -708,6 +708,18 @@ bool pkgCache::DepIterator::IsIgnorable(PrvIterator const &Prv) const return false; } /*}}}*/ +// DepIterator::IsMultiArchImplicit - added by the cache generation /*{{{*/ +// --------------------------------------------------------------------- +/* MultiArch can be translated to SingleArch for an resolver and we did so, + by adding dependencies to help the resolver understand the problem, but + sometimes it is needed to identify these to ignore them… */ +bool pkgCache::DepIterator::IsMultiArchImplicit() const +{ + if (ParentPkg()->Arch != TargetPkg()->Arch) + return true; + return false; +} + /*}}}*/ // ostream operator to handle string representation of a dependecy /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -946,3 +958,17 @@ pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const }; /*}}}*/ +// PrvIterator::IsMultiArchImplicit - added by the cache generation /*{{{*/ +// --------------------------------------------------------------------- +/* MultiArch can be translated to SingleArch for an resolver and we did so, + by adding provides to help the resolver understand the problem, but + sometimes it is needed to identify these to ignore them… */ +bool pkgCache::PrvIterator::IsMultiArchImplicit() const +{ + pkgCache::PkgIterator const Owner = OwnerPkg(); + pkgCache::PkgIterator const Parent = ParentPkg(); + if (Owner->Arch != Parent->Arch || Owner->Name == Parent->Name) + return true; + return false; +} + /*}}}*/ -- cgit v1.2.3 From 0f485ee50e9bcd75a93f24b632280b5bcc078141 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Mon, 11 Jun 2012 02:06:40 +0200 Subject: * apt-pkg/deb/deblistparser.cc: - add support for arch-specific qualifiers in dependencies --- apt-pkg/deb/deblistparser.cc | 20 +++++++++++++++++--- apt-pkg/pkgcache.cc | 5 ++++- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 0a7e41538..4948c9be4 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -637,16 +637,18 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver, if (Section.Find(Tag,Start,Stop) == false) return true; - string Package; string const pkgArch = Ver.Arch(); - string Version; - unsigned int Op; while (1) { + string Package; + string Version; + unsigned int Op; + Start = ParseDepends(Start,Stop,Package,Version,Op,false,!MultiArchEnabled); if (Start == 0) return _error->Error("Problem parsing dependency %s",Tag); + size_t const found = Package.rfind(':'); if (MultiArchEnabled == true && (Type == pkgCache::Dep::Conflicts || @@ -658,6 +660,18 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver, if (NewDepends(Ver,Package,*a,Version,Op,Type) == false) return false; } + else if (MultiArchEnabled == true && found != string::npos && + strcmp(Package.c_str() + found, ":any") != 0) + { + string Arch = Package.substr(found+1, string::npos); + Package = Package.substr(0, found); + // Such dependencies are not supposed to be accepted … + // … but this is probably the best thing to do. + if (Arch == "native") + Arch = _config->Find("APT::Architecture"); + if (NewDepends(Ver,Package,Arch,Version,Op,Type) == false) + return false; + } else if (NewDepends(Ver,Package,pkgArch,Version,Op,Type) == false) return false; if (Start == Stop) diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index e06e74579..f694a237e 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -715,7 +715,10 @@ bool pkgCache::DepIterator::IsIgnorable(PrvIterator const &Prv) const sometimes it is needed to identify these to ignore them… */ bool pkgCache::DepIterator::IsMultiArchImplicit() const { - if (ParentPkg()->Arch != TargetPkg()->Arch) + if (ParentPkg()->Arch != TargetPkg()->Arch && + (S->Type == pkgCache::Dep::Replaces || + S->Type == pkgCache::Dep::DpkgBreaks || + S->Type == pkgCache::Dep::Conflicts)) return true; return false; } -- cgit v1.2.3