diff options
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire-item.cc | 24 | ||||
-rw-r--r-- | apt-pkg/algorithms.h | 2 | ||||
-rw-r--r-- | apt-pkg/aptconfiguration.cc | 33 | ||||
-rw-r--r-- | apt-pkg/cacheiterators.h | 4 | ||||
-rw-r--r-- | apt-pkg/contrib/strutl.cc | 8 | ||||
-rw-r--r-- | apt-pkg/deb/deblistparser.cc | 35 | ||||
-rw-r--r-- | apt-pkg/deb/deblistparser.h | 3 | ||||
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 8 | ||||
-rw-r--r-- | apt-pkg/depcache.cc | 153 | ||||
-rw-r--r-- | apt-pkg/depcache.h | 7 | ||||
-rw-r--r-- | apt-pkg/pkgcache.cc | 12 | ||||
-rw-r--r-- | apt-pkg/pkgcache.h | 4 | ||||
-rw-r--r-- | apt-pkg/pkgcachegen.cc | 14 | ||||
-rw-r--r-- | apt-pkg/vendor.h | 3 | ||||
-rw-r--r-- | apt-pkg/vendorlist.cc | 11 | ||||
-rw-r--r-- | apt-pkg/vendorlist.h | 3 |
16 files changed, 191 insertions, 133 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 184802ca3..39b9feff2 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -17,7 +17,6 @@ #include <apt-pkg/configuration.h> #include <apt-pkg/aptconfiguration.h> #include <apt-pkg/sourcelist.h> -#include <apt-pkg/vendorlist.h> #include <apt-pkg/error.h> #include <apt-pkg/strutl.h> #include <apt-pkg/fileutl.h> @@ -1390,29 +1389,6 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/ /*}}}*/ bool pkgAcqMetaIndex::VerifyVendor(string Message) /*{{{*/ { -// // Maybe this should be made available from above so we don't have -// // to read and parse it every time? -// pkgVendorList List; -// List.ReadMainList(); - -// const Vendor* Vndr = NULL; -// for (std::vector<string>::const_iterator I = GPGVOutput.begin(); I != GPGVOutput.end(); I++) -// { -// string::size_type pos = (*I).find("VALIDSIG "); -// if (_config->FindB("Debug::Vendor", false)) -// std::cerr << "Looking for VALIDSIG in \"" << (*I) << "\": pos " << pos -// << std::endl; -// if (pos != std::string::npos) -// { -// string Fingerprint = (*I).substr(pos+sizeof("VALIDSIG")); -// if (_config->FindB("Debug::Vendor", false)) -// std::cerr << "Looking for \"" << Fingerprint << "\" in vendor..." << -// std::endl; -// Vndr = List.FindVendor(Fingerprint) != ""; -// if (Vndr != NULL); -// break; -// } -// } string::size_type pos; // check for missing sigs (that where not fatal because otherwise we had diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h index cf4a98c4f..ebe31cc10 100644 --- a/apt-pkg/algorithms.h +++ b/apt-pkg/algorithms.h @@ -108,7 +108,7 @@ class pkgProblemResolver /*{{{*/ public: - inline void Protect(pkgCache::PkgIterator Pkg) {Flags[Pkg->ID] |= Protected;}; + inline void Protect(pkgCache::PkgIterator Pkg) {Flags[Pkg->ID] |= Protected; Cache.MarkProtected(Pkg);}; inline void Remove(pkgCache::PkgIterator Pkg) {Flags[Pkg->ID] |= ToRemove;}; inline void Clear(pkgCache::PkgIterator Pkg) {Flags[Pkg->ID] &= ~(Protected | ToRemove);}; diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index b23e12acb..14ee09e0d 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -17,6 +17,7 @@ #include <sys/types.h> #include <dirent.h> +#include <stdio.h> #include <algorithm> #include <string> @@ -314,11 +315,41 @@ std::vector<std::string> const Configuration::getArchitectures(bool const &Cache if (likely(Cached == true) && archs.empty() == false) return archs; - archs = _config->FindVector("APT::Architectures"); string const arch = _config->Find("APT::Architecture"); + archs = _config->FindVector("APT::Architectures"); + if (unlikely(arch.empty() == true)) return archs; + // FIXME: It is a bit unclean to have debian specific code here… + if (archs.empty() == true) { + archs.push_back(arch); + string dpkgcall = _config->Find("Dir::Bin::dpkg", "dpkg"); + std::vector<string> const dpkgoptions = _config->FindVector("DPkg::options"); + for (std::vector<string>::const_iterator o = dpkgoptions.begin(); + o != dpkgoptions.end(); ++o) + dpkgcall.append(" ").append(*o); + dpkgcall.append(" --print-foreign-architectures 2> /dev/null"); + FILE *dpkg = popen(dpkgcall.c_str(), "r"); + char buf[1024]; + if(dpkg != NULL) { + if (fgets(buf, sizeof(buf), dpkg) != NULL) { + char* arch = strtok(buf, " "); + while (arch != NULL) { + for (; isspace(*arch) != 0; ++arch); + if (arch != '\0') { + char const* archend = arch; + for (; isspace(*archend) == 0 && *archend != '\0'; ++archend); + archs.push_back(string(arch, (archend - arch))); + } + arch = strtok(NULL, " "); + } + } + pclose(dpkg); + } + return archs; + } + if (archs.empty() == true || std::find(archs.begin(), archs.end(), arch) == archs.end()) archs.push_back(arch); diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 31b3aced3..8f9f811da 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -206,6 +206,10 @@ class pkgCache::VerIterator : public Iterator<Version, VerIterator> { inline const char *VerStr() const {return S->VerStr == 0?0:Owner->StrP + S->VerStr;}; inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;}; inline const char *Arch() const { + if (S->MultiArch == pkgCache::Version::All || + S->MultiArch == pkgCache::Version::AllForeign || + S->MultiArch == pkgCache::Version::AllAllowed) + return "all"; return S->ParentPkg == 0?0:Owner->StrP + ParentPkg()->Arch; }; __deprecated inline const char *Arch(bool const pseudo) const { diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 2e2bb5ebc..072dda3ac 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -692,14 +692,16 @@ int StringToBool(const string &Text,int Default) year 2000 complient and timezone neutral */ string TimeRFC1123(time_t Date) { - struct tm Conv = *gmtime(&Date); - char Buf[300]; + struct tm Conv; + if (gmtime_r(&Date, &Conv) == NULL) + return ""; + char Buf[300]; const char *Day[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"}; const char *Month[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul", "Aug","Sep","Oct","Nov","Dec"}; - sprintf(Buf,"%s, %02i %s %i %02i:%02i:%02i GMT",Day[Conv.tm_wday], + snprintf(Buf, sizeof(Buf), "%s, %02i %s %i %02i:%02i:%02i GMT",Day[Conv.tm_wday], Conv.tm_mday,Month[Conv.tm_mon],Conv.tm_year+1900,Conv.tm_hour, Conv.tm_min,Conv.tm_sec); return Buf; diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index edc001abb..4be626741 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -106,7 +106,7 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver) Ver->MultiArch = pkgCache::Version::None; else if (MultiArch == "same") { // Parse multi-arch - if (Section.FindS("Architecture") == "all") + if (ArchitectureAll() == true) { /* Arch all packages can't be Multi-Arch: same */ _error->Warning("Architecture: all package '%s' can't be Multi-Arch: same", @@ -127,6 +127,14 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver) Ver->MultiArch = pkgCache::Version::None; } + if (ArchitectureAll() == true) + switch (Ver->MultiArch) + { + case pkgCache::Version::Foreign: Ver->MultiArch = pkgCache::Version::AllForeign; break; + case pkgCache::Version::Allowed: Ver->MultiArch = pkgCache::Version::AllAllowed; break; + default: Ver->MultiArch = pkgCache::Version::All; + } + // Archive Size Ver->Size = Section.FindULL("Size"); // Unpacked Size (in K) @@ -624,7 +632,7 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver, while (1) { - Start = ParseDepends(Start,Stop,Package,Version,Op); + Start = ParseDepends(Start,Stop,Package,Version,Op,false,!MultiArchEnabled); if (Start == 0) return _error->Error("Problem parsing dependency %s",Tag); @@ -677,27 +685,28 @@ bool debListParser::ParseProvides(pkgCache::VerIterator &Ver) } } - if (Ver->MultiArch == pkgCache::Version::Allowed) + if (MultiArchEnabled == false) + return true; + else if (Ver->MultiArch == pkgCache::Version::Allowed || Ver->MultiArch == pkgCache::Version::AllAllowed) { string const Package = string(Ver.ParentPkg().Name()).append(":").append("any"); - NewProvides(Ver, Package, "any", Ver.VerStr()); + return NewProvidesAllArch(Ver, Package, Ver.VerStr()); } + else if (Ver->MultiArch == pkgCache::Version::Foreign || Ver->MultiArch == pkgCache::Version::AllForeign) + return NewProvidesAllArch(Ver, Ver.ParentPkg().Name(), Ver.VerStr()); - if (Ver->MultiArch != pkgCache::Version::Foreign) - return true; - - if (MultiArchEnabled == false) - return true; - - string const Package = Ver.ParentPkg().Name(); - string const Version = Ver.VerStr(); + return true; +} + /*}}}*/ +// ListParser::NewProvides - add provides for all architectures /*{{{*/ +bool debListParser::NewProvidesAllArch(pkgCache::VerIterator &Ver, string const &Package, + string const &Version) { for (std::vector<string>::const_iterator a = Architectures.begin(); a != Architectures.end(); ++a) { if (NewProvides(Ver, Package, *a, Version) == false) return false; } - return true; } /*}}}*/ diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 4bc1bd93c..d62ce641c 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -40,6 +40,7 @@ class debListParser : public pkgCacheGenerator::ListParser bool ParseDepends(pkgCache::VerIterator &Ver,const char *Tag, unsigned int Type); bool ParseProvides(pkgCache::VerIterator &Ver); + bool NewProvidesAllArch(pkgCache::VerIterator &Ver, string const &Package, string const &Version); static bool GrabWord(string Word,WordList *List,unsigned char &Out); public: @@ -69,7 +70,7 @@ class debListParser : public pkgCacheGenerator::ListParser static const char *ParseDepends(const char *Start,const char *Stop, string &Package,string &Ver,unsigned int &Op, bool const &ParseArchFlags = false, - bool const &StripMultiArch = false); + bool const &StripMultiArch = true); static const char *ConvertRelation(const char *I,unsigned int &Op); debListParser(FileFd *File, string const &Arch = ""); diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 240574d2a..e957ce5fd 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1002,6 +1002,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) else { string const nativeArch = _config->Find("APT::Architecture"); + unsigned long const oldSize = I->Op == Item::Configure ? Size : 0; for (;I != J && Size < MaxArgBytes; I++) { if((*I).Pkg.end() == true) @@ -1016,8 +1017,11 @@ bool pkgDPkgPM::Go(int OutStatusFd) Args[n++] = Packages[pkgcount++]; } Size += strlen(Args[n-1]); - } - } + } + // skip configure action if all sheduled packages disappeared + if (oldSize == Size) + continue; + } Args[n] = 0; J = I; diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index a30bea3cc..8cf322464 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -819,8 +819,7 @@ void pkgDepCache::Update(PkgIterator const &Pkg) void pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser, unsigned long Depth) { - // Simplifies other routines. - if (Pkg.end() == true) + if (IsModeChangeOk(ModeKeep, Pkg, Depth, FromUser) == false) return; /* Reject an attempt to keep a non-source broken installed package, those @@ -828,25 +827,22 @@ void pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser, if (Pkg.State() == PkgIterator::NeedsUnpack && Pkg.CurrentVer().Downloadable() == false) return; - - /** \todo Can this be moved later in the method? */ - ActionGroup group(*this); /* We changed the soft state all the time so the UI is a bit nicer to use */ StateCache &P = PkgState[Pkg->ID]; + + // Check that it is not already kept + if (P.Mode == ModeKeep) + return; + if (Soft == true) P.iFlags |= AutoKept; else P.iFlags &= ~AutoKept; - - // Check that it is not already kept - if (P.Mode == ModeKeep) - return; - // We dont even try to keep virtual packages.. - if (Pkg->VersionList == 0) - return; + ActionGroup group(*this); + #if 0 // reseting the autoflag here means we lose the // auto-mark information if a user selects a package for removal // but changes his mind then and sets it for keep again @@ -883,30 +879,26 @@ void pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser, void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge, unsigned long Depth, bool FromUser) { - // Simplifies other routines. - if (Pkg.end() == true) + if (IsModeChangeOk(ModeDelete, Pkg, Depth, FromUser) == false) return; - ActionGroup group(*this); + StateCache &P = PkgState[Pkg->ID]; // Check that it is not already marked for delete - StateCache &P = PkgState[Pkg->ID]; - P.iFlags &= ~(AutoKept | Purge); - if (rPurge == true) - P.iFlags |= Purge; - if ((P.Mode == ModeDelete || P.InstallVer == 0) && (Pkg.Purge() == true || rPurge == false)) return; - - // We dont even try to delete virtual packages.. - if (Pkg->VersionList == 0) - return; - // check if we are allowed to install the package + // check if we are allowed to remove the package if (IsDeleteOk(Pkg,rPurge,Depth,FromUser) == false) return; + P.iFlags &= ~(AutoKept | Purge); + if (rPurge == true) + P.iFlags |= Purge; + + ActionGroup group(*this); + if (DebugMarker == true) std::clog << OutputInDepth(Depth) << (rPurge ? "MarkPurge " : "MarkDelete ") << Pkg << " FU=" << FromUser << std::endl; @@ -927,22 +919,12 @@ void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge, /*}}}*/ // DepCache::IsDeleteOk - check if it is ok to remove this package /*{{{*/ // --------------------------------------------------------------------- -/* The default implementation just honors dpkg hold - But an application using this library can override this method - to control the MarkDelete behaviour */ +/* The default implementation tries to prevent deletion of install requests. + dpkg holds are enforced by the private IsModeChangeOk */ bool pkgDepCache::IsDeleteOk(PkgIterator const &Pkg,bool rPurge, unsigned long Depth, bool FromUser) { - if (FromUser == false && Pkg->SelectedState == pkgCache::State::Hold && _config->FindB("APT::Ignore-Hold",false) == false) - { - if (DebugMarker == true) - std::clog << OutputInDepth(Depth) << "Hold prevents MarkDelete of " << Pkg << " FU=" << FromUser << std::endl; - return false; - } - // if the removal is not explictely requested by the user, protect - // explicit new-install package from accidental removal by the - // problemresolver - else if (FromUser == false && Pkg->CurrentVer == 0) + if (FromUser == false && Pkg->CurrentVer == 0) { StateCache &P = PkgState[Pkg->ID]; // Status == 2 means this applies for new installs only @@ -956,6 +938,61 @@ bool pkgDepCache::IsDeleteOk(PkgIterator const &Pkg,bool rPurge, return true; } /*}}}*/ +// DepCache::IsModeChangeOk - check if it is ok to change the mode /*{{{*/ +// --------------------------------------------------------------------- +/* this is used by all Mark methods on the very first line to check sanity + and prevents mode changes for packages on hold for example. + If you want to check Mode specific stuff you can use the virtual public + Is<Mode>Ok methods instead */ +char const* PrintMode(char const mode) +{ + switch (mode) + { + case pkgDepCache::ModeInstall: return "Install"; + case pkgDepCache::ModeKeep: return "Keep"; + case pkgDepCache::ModeDelete: return "Delete"; + default: return "UNKNOWN"; + } +} +bool pkgDepCache::IsModeChangeOk(ModeList const mode, PkgIterator const &Pkg, + unsigned long const Depth, bool const FromUser) +{ + // we are not trying to hard… + if (unlikely(Depth > 100)) + return false; + + // general sanity + if (unlikely(Pkg.end() == true || Pkg->VersionList == 0)) + return false; + + // the user is always right + if (FromUser == true) + return true; + + StateCache &P = PkgState[Pkg->ID]; + + // if previous state was set by user only user can reset it + if ((P.iFlags & Protected) == Protected) + { + if (unlikely(DebugMarker == true) && P.Mode != mode) + std::clog << OutputInDepth(Depth) << "Ignore Mark" << PrintMode(mode) + << " of " << Pkg << " as its mode (" << PrintMode(P.Mode) + << ") is protected" << std::endl; + return false; + } + // enforce dpkg holds + else if (mode != ModeKeep && Pkg->SelectedState == pkgCache::State::Hold && + _config->FindB("APT::Ignore-Hold",false) == false) + { + if (unlikely(DebugMarker == true) && P.Mode != mode) + std::clog << OutputInDepth(Depth) << "Hold prevents Mark" << PrintMode(mode) + << " of " << Pkg << std::endl; + return false; + } + + return true; +} + /*}}}*/ // DepCache::MarkInstall - Put the package in the install state /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -963,19 +1000,17 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, unsigned long Depth, bool FromUser, bool ForceImportantDeps) { - if (Depth > 100) + if (IsModeChangeOk(ModeInstall, Pkg, Depth, FromUser) == false) return; - - // Simplifies other routines. - if (Pkg.end() == true) + + StateCache &P = PkgState[Pkg->ID]; + + // See if there is even any possible instalation candidate + if (P.CandidateVer == 0) return; - - ActionGroup group(*this); /* Check that it is not already marked for install and that it can be installed */ - StateCache &P = PkgState[Pkg->ID]; - P.iFlags &= ~AutoKept; if ((P.InstPolicyBroken() == false && P.InstBroken() == false) && (P.Mode == ModeInstall || P.CandidateVer == (Version *)Pkg.CurrentVer())) @@ -985,17 +1020,13 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, return; } - // See if there is even any possible instalation candidate - if (P.CandidateVer == 0) - return; - // We dont even try to install virtual packages.. - if (Pkg->VersionList == 0) - return; - // check if we are allowed to install the package if (IsInstallOk(Pkg,AutoInst,Depth,FromUser) == false) return; + ActionGroup group(*this); + P.iFlags &= ~AutoKept; + /* Target the candidate version and remove the autoflag. We reset the autoflag below if this was called recursively. Otherwise the user should have the ability to de-auto a package by changing its state */ @@ -1208,18 +1239,11 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, /*}}}*/ // DepCache::IsInstallOk - check if it is ok to install this package /*{{{*/ // --------------------------------------------------------------------- -/* The default implementation just honors dpkg hold - But an application using this library can override this method - to control the MarkInstall behaviour */ +/* The default implementation does nothing. + dpkg holds are enforced by the private IsModeChangeOk */ bool pkgDepCache::IsInstallOk(PkgIterator const &Pkg,bool AutoInst, unsigned long Depth, bool FromUser) { - if (FromUser == false && Pkg->SelectedState == pkgCache::State::Hold && _config->FindB("APT::Ignore-Hold",false) == false) - { - if (DebugMarker == true) - std::clog << OutputInDepth(Depth) << "Hold prevents MarkInstall of " << Pkg << " FU=" << FromUser << std::endl; - return false; - } return true; } /*}}}*/ @@ -1244,11 +1268,6 @@ void pkgDepCache::SetReInstall(PkgIterator const &Pkg,bool To) AddStates(Pkg); AddSizes(Pkg); - - if (unlikely(Pkg.CurrentVer().end() == true)) - return; - - SetReInstall(Pkg.Group().FindPkg("all"), To); } /*}}}*/ // DepCache::SetCandidateVersion - Change the candidate version /*{{{*/ diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index b95681118..750da3d6f 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -119,7 +119,7 @@ class pkgDepCache : protected pkgCache::Namespace DepCandPolicy = (1 << 4), DepCandMin = (1 << 5)}; // These flags are used in StateCache::iFlags - enum InternalFlags {AutoKept = (1 << 0), Purge = (1 << 1), ReInstall = (1 << 2)}; + enum InternalFlags {AutoKept = (1 << 0), Purge = (1 << 1), ReInstall = (1 << 2), Protected = (1 << 3)}; enum VersionTypes {NowVersion, InstallVersion, CandidateVersion}; enum ModeList {ModeDelete = 0, ModeKeep = 1, ModeInstall = 2}; @@ -393,6 +393,7 @@ class pkgDepCache : protected pkgCache::Namespace void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true, unsigned long Depth = 0, bool FromUser = true, bool ForceImportantDeps = false); + void MarkProtected(PkgIterator const &Pkg) { PkgState[Pkg->ID].iFlags |= Protected; }; void SetReInstall(PkgIterator const &Pkg,bool To); // FIXME: Remove the unused boolean parameter on abi break @@ -486,6 +487,10 @@ class pkgDepCache : protected pkgCache::Namespace __deprecated bool RemovePseudoInstalledPkg(PkgIterator &Pkg, std::set<unsigned long> &recheck) { return true; }; __deprecated bool ReInstallPseudoForGroup(unsigned long const &Grp, std::set<unsigned long> &recheck) { return true; }; __deprecated bool ReInstallPseudoForGroup(pkgCache::PkgIterator const &P, std::set<unsigned long> &recheck) { return true; }; + + + bool IsModeChangeOk(ModeList const mode, PkgIterator const &Pkg, + unsigned long const Depth, bool const FromUser); }; #endif diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 7014aee22..c6326abf1 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -317,22 +317,22 @@ pkgCache::PkgIterator pkgCache::GrpIterator::FindPkg(string Arch) const { if (unlikely(IsGood() == false || S->FirstPackage == 0)) return PkgIterator(*Owner, 0); + /* If we accept any package we simply return the "first" + package in this group (the last one added). */ + if (Arch == "any") + return PkgIterator(*Owner, Owner->PkgP + S->FirstPackage); + static string const myArch = _config->Find("APT::Architecture"); /* Most of the time the package for our native architecture is the one we add at first to the cache, but this would be the last one we check, so we do it now. */ - if (Arch == "native" || Arch == myArch) { + if (Arch == "native" || Arch == myArch || Arch == "all") { Arch = myArch; pkgCache::Package *Pkg = Owner->PkgP + S->LastPackage; if (stringcasecmp(Arch, Owner->StrP + Pkg->Arch) == 0) return PkgIterator(*Owner, Pkg); } - /* If we accept any package we simply return the "first" - package in this group (the last one added). */ - if (Arch == "any") - return PkgIterator(*Owner, Owner->PkgP + S->FirstPackage); - /* Iterate over the list to find the matching arch unfortunately this list includes "package noise" (= different packages with same calculated hash), diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h index 89a296ce9..d654a2976 100644 --- a/apt-pkg/pkgcache.h +++ b/apt-pkg/pkgcache.h @@ -506,8 +506,8 @@ struct pkgCache::Version if it is built for another architecture as the requester. Same indicates that builds for different architectures can be co-installed on the system */ - // FIXME: remove All on abi break - enum {None, All, Foreign, Same, Allowed} MultiArch; + /* FIXME: A bitflag would be better with the next abibreak… */ + enum {None, All, Foreign, Same, Allowed, AllForeign, AllAllowed} MultiArch; /** \brief references all the PackageFile's that this version came from diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index d44dbf3a9..b0ee04554 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -178,12 +178,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List, if (PackageName.empty() == true) return false; - /* Treat Arch all packages as the same as the native arch. */ - string Arch; - if (List.ArchitectureAll() == true) - Arch = _config->Find("APT::Architecture"); - else - Arch = List.Architecture(); + string const Arch = List.Architecture(); // Get a pointer to the package structure pkgCache::PkgIterator Pkg; @@ -484,7 +479,7 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name // Set the name, arch and the ID Pkg->Name = Grp->Name; Pkg->Group = Grp.Index(); - map_ptrloc const idxArch = WriteUniqString(Arch.c_str()); + map_ptrloc const idxArch = WriteUniqString((Arch == "all") ? _config->Find("APT::Architecture") : Arch.c_str()); if (unlikely(idxArch == 0)) return false; Pkg->Arch = idxArch; @@ -643,7 +638,7 @@ bool pkgCacheGenerator::FinishCache(OpProgress *Progress) - MultiArch: same → Co-Installable if they have the same version - Architecture: all → Need to be Co-Installable for internal reasons - All others conflict with all other group members */ - bool const coInstall = (V->MultiArch == pkgCache::Version::Same); + bool const coInstall = ((V->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same); for (vector<string>::const_iterator A = archs.begin(); A != archs.end(); ++A) { if (*A == Arch) @@ -787,7 +782,8 @@ bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator &Ver, pkgCache &Cache = Owner->Cache; // We do not add self referencing provides - if (Ver.ParentPkg().Name() == PkgName && PkgArch == Ver.Arch()) + if (Ver.ParentPkg().Name() == PkgName && (PkgArch == Ver.ParentPkg().Arch() || + (PkgArch == "all" && _config->Find("APT::Architecture") == Ver.ParentPkg().Arch()))) return true; // Get a structure diff --git a/apt-pkg/vendor.h b/apt-pkg/vendor.h index 2d39fd15f..df229737a 100644 --- a/apt-pkg/vendor.h +++ b/apt-pkg/vendor.h @@ -4,11 +4,12 @@ #include <vector> #include <map> +#include <apt-pkg/macros.h> using std::string; // A class representing a particular software provider. -class Vendor +class __deprecated Vendor { public: struct Fingerprint diff --git a/apt-pkg/vendorlist.cc b/apt-pkg/vendorlist.cc index 92ff38894..48ac12cee 100644 --- a/apt-pkg/vendorlist.cc +++ b/apt-pkg/vendorlist.cc @@ -1,8 +1,13 @@ -#include <apt-pkg/vendorlist.h> #include <apt-pkg/fileutl.h> #include <apt-pkg/error.h> #include <apti18n.h> +#if __GNUC__ >= 4 + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + +#include <apt-pkg/vendorlist.h> + pkgVendorList::~pkgVendorList() { for (vector<const Vendor *>::const_iterator I = VendorList.begin(); @@ -143,3 +148,7 @@ const Vendor* pkgVendorList::FindVendor(const std::vector<string> GPGVOutput) /* return NULL; } /*}}}*/ + +#if __GNUC__ >= 4 + #pragma GCC diagnostic warning "-Wdeprecated-declarations" +#endif diff --git a/apt-pkg/vendorlist.h b/apt-pkg/vendorlist.h index ff2f4ed5d..eaeecb173 100644 --- a/apt-pkg/vendorlist.h +++ b/apt-pkg/vendorlist.h @@ -17,12 +17,13 @@ #include <vector> #include <apt-pkg/vendor.h> #include <apt-pkg/configuration.h> +#include <apt-pkg/macros.h> using std::string; using std::vector; -class pkgVendorList +class __deprecated pkgVendorList { protected: vector<Vendor const *> VendorList; |