Browse Source

merged from lp:~donkult/apt/sid

debian/1.8.y
Michael Vogt 13 years ago
parent
commit
46361a17f0
  1. 21
      .bzrignore
  2. 113
      README.MultiArch
  3. 62
      apt-pkg/algorithms.cc
  4. 27
      apt-pkg/aptconfiguration.cc
  5. 16
      apt-pkg/aptconfiguration.h
  6. 723
      apt-pkg/cacheiterators.h
  7. 37
      apt-pkg/cdrom.cc
  8. 6
      apt-pkg/clean.cc
  9. 42
      apt-pkg/contrib/cmndline.cc
  10. 1
      apt-pkg/contrib/cmndline.h
  11. 8
      apt-pkg/contrib/error.h
  12. 34
      apt-pkg/contrib/macros.h
  13. 70
      apt-pkg/contrib/mmap.cc
  14. 5
      apt-pkg/contrib/mmap.h
  15. 76
      apt-pkg/contrib/strutl.cc
  16. 24
      apt-pkg/contrib/strutl.h
  17. 15
      apt-pkg/deb/debindexfile.cc
  18. 4
      apt-pkg/deb/debindexfile.h
  19. 219
      apt-pkg/deb/deblistparser.cc
  20. 4
      apt-pkg/deb/deblistparser.h
  21. 298
      apt-pkg/deb/debmetaindex.cc
  22. 28
      apt-pkg/deb/debmetaindex.h
  23. 18
      apt-pkg/deb/debversion.cc
  24. 18
      apt-pkg/deb/dpkgpm.cc
  25. 399
      apt-pkg/depcache.cc
  26. 20
      apt-pkg/depcache.h
  27. 4
      apt-pkg/metaindex.h
  28. 13
      apt-pkg/orderlist.cc
  29. 32
      apt-pkg/packagemanager.cc
  30. 240
      apt-pkg/pkgcache.cc
  31. 54
      apt-pkg/pkgcache.h
  32. 312
      apt-pkg/pkgcachegen.cc
  33. 17
      apt-pkg/pkgcachegen.h
  34. 41
      apt-pkg/policy.cc
  35. 81
      apt-pkg/sourcelist.cc
  36. 8
      apt-pkg/sourcelist.h
  37. 13
      apt-pkg/tagfile.cc
  38. 15
      apt-pkg/tagfile.h
  39. 8
      apt-pkg/versionmatch.cc
  40. 2
      apt-pkg/versionmatch.h
  41. 99
      cmdline/apt-cache.cc
  42. 136
      cmdline/apt-get.cc
  43. 4
      cmdline/apt-mark
  44. 3
      debian/apt-doc.docs
  45. 62
      debian/changelog
  46. 7
      debian/control
  47. 1
      debian/source/format
  48. 35
      doc/apt-ftparchive.1.xml
  49. 7
      doc/apt-get.8.xml
  50. 9
      doc/apt.ent
  51. 20
      doc/apt_preferences.5.xml
  52. 11
      doc/es/makefile
  53. 2
      doc/examples/configure-index
  54. 11
      doc/fr/makefile
  55. 11
      doc/it/makefile
  56. 11
      doc/ja/makefile
  57. 4
      doc/lang.makefile
  58. 16
      doc/makefile
  59. 11
      doc/pl/makefile
  60. 339
      doc/po/apt-doc.pot
  61. 423
      doc/po/de.po
  62. 361
      doc/po/es.po
  63. 348
      doc/po/fr.po
  64. 340
      doc/po/it.po
  65. 354
      doc/po/ja.po
  66. 360
      doc/po/pl.po
  67. 11096
      doc/po/pt.po
  68. 345
      doc/po/pt_BR.po
  69. 11
      doc/pt_BR/makefile
  70. 63
      ftparchive/apt-ftparchive.cc
  71. 55
      ftparchive/writer.cc
  72. 21
      ftparchive/writer.h
  73. 367
      po/apt-all.pot
  74. 39
      test/libapt/commandlineasstring_test.cc
  75. 123
      test/libapt/compareversion_test.cc
  76. 12
      test/libapt/makefile
  77. 7
      test/makefile
  78. 64
      test/versions.lst
  79. 233
      test/versiontest.cc

21
.bzrignore

@ -11,14 +11,17 @@ configure
buildlib/config.sub
buildlib/config.guess
# abichecker related files/dir
abicheck/apt_build.xml
abicheck/apt_installed.xml
abicheck/compat_reports/
abicheck/descriptors_storage/
abicheck/header_compile_errors/
abicheck/test_results/
abicheck/tests/
# generated files in the progress to build all
# apt man pages and other documentation
doc/*.1
doc/*.5
doc/*.8
doc/*/*.1
doc/*/*.5
doc/*/*.8
doc/*/apt.ent
doc/*/*.xml
doc/*/*.sgml
./doc/*/
!./doc/examples/
!./doc/po/

113
README.MultiArch

@ -0,0 +1,113 @@
Before we start with this topic: Note that MultiArch is not yet ready for
prime time and/or for the casual user. The implementation is so far widely
untested and only useful for developers of packagemanagment tools which
use APT and his friends and maintainers of (upcoming) MultiArch packages.
This README is especially NOT written for the casual user and is NOT a
usage guide - you have been warned. It is assumed that the reader has
at least a bit of knowledge about APT internals, dependency relations
and the MultiArch spec [0].
Note also that the toolchain isn't ready yet, e.g. while you can simulate
the installation of MultiArch packages they will more sooner than later
cause enormous problems if really installed as dpkg can't handle MultiArch
yet (no, --force-{overwrite,architecture} aren't good options here).
Other parts of the big picture are missing and/or untested too.
You have been warned!
The implementation is focused on NOT breaking existing singleArch-only
applications and/or systems as this is the current status-quo for all
systems. Also, many systems don't need (or can't make use of) MultiArch,
so APT will proceed in thinking SingleArch as long as it is not explicitly
told to handle MultiArch:
To activate MultiArch handling you need to specify architectures you
want to be considered by APT with the config list APT::Architectures
(Insert architectures in order of preference).
APT will download Packages files for all these architectures in the
update step. Exception: In the sourcelist is the optionfield used:
deb [ arch=amd64,i386 ] http://example.org/ experimental main
(This optionfield is a NOP in previous apt versions)
Internally in APT a package is represented as a PkgIterator -
before MultiArch this PkgIterator was architecture unaware,
only VerIterators include the architecture they came from.
This is/was a big problem as all versions in a package are
considered for dependency resolution, so pinning will not work in all cases.
The problem is solved by a conceptional change:
A PkgIterator is now architecture aware, so the packages
of foobar for amd64 and for i386 are now for apt internal totally
different packages. That is a good thing for e.g. pinning, but
sometimes you need the information that such packages are belonging together:
All these foobar packages therefore form a Group accessible with GrpIterators.
Note that the GrpIterator has the same name as all the packages in this group,
so e.g. apt-cache pkgnames iterates over GrpIterator to get the package names:
This is compatible to SingleArch as a Group consists only of a single package
and also to MultiArch as a Group consists of possible many packages which
all have the same name and are therefore out of interest for pkgnames.
Caused by the paragraph "Dependencies involving Architecture: all packages"
in the MultiArch spec we have a second major conceptional change
which could even break existing applications, but we hope for the best…
An Architecture: all package is internally split into pseudo packages
for all MultiArch Architectures and additional a package with the
architecture "all" with no dependencies which is a dependency of all
these architecture depending packages. While the architecture depending
packages are mainly used for dependency resolution (a package of arch A which
depends on an arch all package assumes that the dependencies of this package
are also from arch A. Packages also sometimes change from any to all or v.v.)
the arch "all" package is used for scheduling download/installation of the
underlying "real" package. Note that the architecture depending packages can
be detected with Pseudo() while the "all" package reports exactly this arch
as package architecture and as pseudo architecture of the versions of this pkg.
Beware: All versions of a "real" architecture all package will be report "all"
as their architecture if asked with Arch() regardless if they are the "all" or
the architecture depending packages. If you want to know the architecture this
pseudo package was created for call Arch(true). Also, while the spec say that
arch:all packages are not allowed to have a MultiArch flag APT assigns a
special value to them: MultiArch: all.
As you might guess this arch:all handling has a few problems (but we think so
far that the problems are minor compared to the problems we would have with
other implementations.)
APT doesn't know which pseudo packages of such an arch all package are
"installed" (to satisfy dependencies), so APT will generate a Cache in which
all these pseudo packages are installed (e.g. apt-cache policy will display
them all as installed). Later in the DepCache step it will "remove"
all pseudo packages whose dependencies are not satisfied.
The expense is that if the package state is broken APT could come to the
conclusion to "remove" too many pseudo packages, but in a stable environment
APT should never end up in a broken system state…
Given all these internal changes it is quite interesting that the actual
implementation of MultiArch is trivial: Some implicit dependencies and a few
more provides are all changes needed to get it working. Especially noteworthy
is that it wasn't needed to change the resolver in any way and other parts only
need to be told about ignoring pseudo packages or using GrpIterator instead of
PkgIterator, so chances are good that libapt-applications will proceed to work
without or at least only require minor changes, but your mileage may vary…
Known Issues and/or noteworthy stuff:
* The implementation is mostly untested, so it is very likely that APT will
eat your kids if you aren't as lucky as the author of these patches.
* the (install)size of a pseudo package is always NULL - if you want to know
the (install)size you need to get the info from the arch "all" package.
* It is maybe confusing, but the arch "all" package does have the same versions
and in general roughly the same information with one subtil difference:
It doesn't have any dependency, regardless of the type. The pseudo packages
depend on this package.
* apt-cache policy foobar on installed architecture all package foobar will
report all architecture depending packages as installed. Displaying here the
correct information would require to build the complete DepCache…
* [BUG] An installed package which changes the architecture from any to all
(and v.v.) shows up in the NEW packages section instead of UPGRADE.
* [TODO] Investigate the DepCache pseudo-package killer heuristic:
e.g. add more safety guards…
* [FIXME] a few corner cases/missing features marked as FIXME in the code
[0] https://wiki.ubuntu.com/MultiarchSpec

62
apt-pkg/algorithms.cc

@ -83,13 +83,28 @@ void pkgSimulate::Describe(PkgIterator Pkg,ostream &out,bool Current,bool Candid
bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/)
{
// Adapt the iterator
PkgIterator Pkg = Sim.FindPkg(iPkg.Name());
PkgIterator Pkg = Sim.FindPkg(iPkg.Name(), iPkg.Arch());
Flags[Pkg->ID] = 1;
cout << "Inst ";
Describe(Pkg,cout,true,true);
Sim.MarkInstall(Pkg,false);
if (strcmp(Pkg.Arch(),"all") == 0)
{
pkgCache::GrpIterator G = Pkg.Group();
pkgCache::GrpIterator iG = iPkg.Group();
for (pkgCache::PkgIterator P = G.FindPkg("any"); P.end() != true; P = G.NextPkg(P))
{
if (strcmp(P.Arch(), "all") == 0)
continue;
if (iG.FindPkg(P.Arch())->CurrentVer == 0)
continue;
Flags[P->ID] = 1;
Sim.MarkInstall(P, false);
}
}
// Look for broken conflicts+predepends.
for (PkgIterator I = Sim.PkgBegin(); I.end() == false; I++)
{
@ -131,9 +146,22 @@ bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/)
bool pkgSimulate::Configure(PkgIterator iPkg)
{
// Adapt the iterator
PkgIterator Pkg = Sim.FindPkg(iPkg.Name());
PkgIterator Pkg = Sim.FindPkg(iPkg.Name(), iPkg.Arch());
Flags[Pkg->ID] = 2;
if (strcmp(Pkg.Arch(),"all") == 0)
{
pkgCache::GrpIterator G = Pkg.Group();
for (pkgCache::PkgIterator P = G.FindPkg("any"); P.end() != true; P = G.NextPkg(P))
{
if (strcmp(P.Arch(), "all") == 0)
continue;
if (Flags[P->ID] == 1)
Flags[P->ID] = 2;
}
}
// Sim.MarkInstall(Pkg,false);
if (Sim[Pkg].InstBroken() == true)
{
@ -181,10 +209,26 @@ bool pkgSimulate::Configure(PkgIterator iPkg)
bool pkgSimulate::Remove(PkgIterator iPkg,bool Purge)
{
// Adapt the iterator
PkgIterator Pkg = Sim.FindPkg(iPkg.Name());
PkgIterator Pkg = Sim.FindPkg(iPkg.Name(), iPkg.Arch());
Flags[Pkg->ID] = 3;
Sim.MarkDelete(Pkg);
if (strcmp(Pkg.Arch(),"all") == 0)
{
pkgCache::GrpIterator G = Pkg.Group();
pkgCache::GrpIterator iG = iPkg.Group();
for (pkgCache::PkgIterator P = G.FindPkg("any"); P.end() != true; P = G.NextPkg(P))
{
if (strcmp(P.Arch(), "all") == 0)
continue;
if (iG.FindPkg(P.Arch())->CurrentVer == 0)
continue;
Flags[P->ID] = 3;
Sim.MarkDelete(P);
}
}
if (Purge == true)
cout << "Purg ";
else
@ -491,11 +535,11 @@ void pkgProblemResolver::MakeScores()
// Important Required Standard Optional Extra
signed short PrioMap[] = {
0,
_config->FindI("pkgProblemResolver::Scores::Important",3),
_config->FindI("pkgProblemResolver::Scores::Required",2),
_config->FindI("pkgProblemResolver::Scores::Standard",1),
_config->FindI("pkgProblemResolver::Scores::Optional",-1),
_config->FindI("pkgProblemResolver::Scores::Extra",-2)
(signed short) _config->FindI("pkgProblemResolver::Scores::Important",3),
(signed short) _config->FindI("pkgProblemResolver::Scores::Required",2),
(signed short) _config->FindI("pkgProblemResolver::Scores::Standard",1),
(signed short) _config->FindI("pkgProblemResolver::Scores::Optional",-1),
(signed short) _config->FindI("pkgProblemResolver::Scores::Extra",-2)
};
signed short PrioEssentials = _config->FindI("pkgProblemResolver::Scores::Essentials",100);
signed short PrioInstalledAndNotObsolete = _config->FindI("pkgProblemResolver::Scores::NotObsolete",1);

27
apt-pkg/aptconfiguration.cc

@ -152,6 +152,7 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
builtin.push_back(c);
}
}
closedir(D);
// get the environment language codes: LC_MESSAGES (and later LANGUAGE)
// we extract both, a long and a short code and then we will
@ -220,7 +221,7 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
const char *language_env = getenv("LANGUAGE") == 0 ? "" : getenv("LANGUAGE");
string envLang = Locale == 0 ? language_env : *(Locale+1);
if (envLang.empty() == false) {
std::vector<string> env = ExplodeString(envLang,':');
std::vector<string> env = VectorizeString(envLang,':');
short addedLangs = 0; // add a maximum of 3 fallbacks from the environment
for (std::vector<string>::const_iterator e = env.begin();
e != env.end() && addedLangs < 3; ++e) {
@ -318,4 +319,28 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
return codes;
}
/*}}}*/
// getArchitectures - Return Vector of prefered Architectures /*{{{*/
std::vector<std::string> const Configuration::getArchitectures(bool const &Cached) {
using std::string;
std::vector<string> static archs;
if (likely(Cached == true) && archs.empty() == false)
return archs;
string const arch = _config->Find("APT::Architecture");
archs = _config->FindVector("APT::Architectures");
if (archs.empty() == true ||
std::find(archs.begin(), archs.end(), arch) == archs.end())
archs.push_back(arch);
return archs;
}
/*}}}*/
// checkArchitecture - are we interested in the given Architecture? /*{{{*/
bool const Configuration::checkArchitecture(std::string const &Arch) {
if (Arch == "all")
return true;
std::vector<std::string> const archs = getArchitectures(true);
return (std::find(archs.begin(), archs.end(), Arch) != archs.end());
}
/*}}}*/
}

16
apt-pkg/aptconfiguration.h

@ -66,6 +66,22 @@ public: /*{{{*/
std::vector<std::string> static const getLanguages(bool const &All = false,
bool const &Cached = true, char const ** const Locale = 0);
/** \brief Returns a vector of Architectures we support
*
* \param Cached saves the result so we need to calculated it only once
* this parameter should ony be used for testing purposes.
*
* \return a vector of Architectures in prefered order
*/
std::vector<std::string> static const getArchitectures(bool const &Cached = true);
/** \brief Are we interested in the given Architecture?
*
* \param Arch we want to check
* \return true if we are interested, false otherwise
*/
bool static const checkArchitecture(std::string const &Arch);
/*}}}*/
};
/*}}}*/

723
apt-pkg/cacheiterators.h

@ -1,6 +1,5 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// $Id: cacheiterators.h,v 1.18.2.1 2004/05/08 22:44:27 mdz Exp $
/* ######################################################################
Cache Iterators - Iterators for navigating the cache structure
@ -30,417 +29,385 @@
/*}}}*/
#ifndef PKGLIB_CACHEITERATORS_H
#define PKGLIB_CACHEITERATORS_H
// abstract Iterator template /*{{{*/
/* This template provides the very basic iterator methods we
need to have for doing some walk-over-the-cache magic */
template<typename Str, typename Itr> class pkgCache::Iterator {
protected:
Str *S;
pkgCache *Owner;
/** \brief Returns the Pointer for this struct in the owner
* The implementation of this method should be pretty short
* as it will only return the Pointer into the mmap stored
* in the owner but the name of this pointer is different for
* each stucture and we want to abstract here at least for the
* basic methods from the actual structure.
* \return Pointer to the first structure of this type
*/
virtual Str* OwnerPointer() const = 0;
public:
// Iteration
virtual void operator ++(int) = 0;
virtual void operator ++() = 0; // Should be {operator ++(0);};
inline bool end() const {return Owner == 0 || S == OwnerPointer();};
// Comparison
inline bool operator ==(const Itr &B) const {return S == B.S;};
inline bool operator !=(const Itr &B) const {return S != B.S;};
// Accessors
inline Str *operator ->() {return S;};
inline Str const *operator ->() const {return S;};
inline operator Str *() {return S == OwnerPointer() ? 0 : S;};
inline operator Str const *() const {return S == OwnerPointer() ? 0 : S;};
inline Str &operator *() {return *S;};
inline Str const &operator *() const {return *S;};
inline pkgCache *Cache() {return Owner;};
// Mixed stuff
inline void operator =(const Itr &B) {S = B.S; Owner = B.Owner;};
inline bool IsGood() const { return S && Owner && ! end();};
inline unsigned long Index() const {return S - OwnerPointer();};
// Constructors - look out for the variable assigning
inline Iterator() : S(0), Owner(0) {};
inline Iterator(pkgCache &Owner,Str *T = 0) : S(T), Owner(&Owner) {};
};
/*}}}*/
// Group Iterator /*{{{*/
/* Packages with the same name are collected in a Group so someone only
interest in package names can iterate easily over the names, so the
different architectures can be treated as of the "same" package
(apt internally treat them as totally different packages) */
class pkgCache::GrpIterator: public Iterator<Group, GrpIterator> {
long HashIndex;
protected:
inline Group* OwnerPointer() const {
return Owner->GrpP;
};
public:
// This constructor is the 'begin' constructor, never use it.
inline GrpIterator(pkgCache &Owner) : Iterator<Group, GrpIterator>(Owner), HashIndex(-1) {
S = OwnerPointer();
operator ++(0);
};
virtual void operator ++(int);
virtual void operator ++() {operator ++(0);};
inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;};
inline PkgIterator PackageList() const;
PkgIterator FindPkg(string Arch = "any");
PkgIterator NextPkg(PkgIterator const &Pkg);
// Constructors
inline GrpIterator(pkgCache &Owner, Group *Trg) : Iterator<Group, GrpIterator>(Owner, Trg), HashIndex(0) {
if (S == 0)
S = OwnerPointer();
};
inline GrpIterator() : Iterator<Group, GrpIterator>(), HashIndex(0) {};
};
/*}}}*/
// Package Iterator /*{{{*/
class pkgCache::PkgIterator
{
friend class pkgCache;
Package *Pkg;
pkgCache *Owner;
long HashIndex;
protected:
// This constructor is the 'begin' constructor, never use it.
inline PkgIterator(pkgCache &Owner) : Owner(&Owner), HashIndex(-1)
{
Pkg = Owner.PkgP;
operator ++(0);
};
public:
enum OkState {NeedsNothing,NeedsUnpack,NeedsConfigure};
// Iteration
void operator ++(int);
inline void operator ++() {operator ++(0);};
inline bool end() const {return Owner == 0 || Pkg == Owner->PkgP?true:false;};
// Comparison
inline bool operator ==(const PkgIterator &B) const {return Pkg == B.Pkg;};
inline bool operator !=(const PkgIterator &B) const {return Pkg != B.Pkg;};
// Accessors
inline Package *operator ->() {return Pkg;};
inline Package const *operator ->() const {return Pkg;};
inline Package const &operator *() const {return *Pkg;};
inline operator Package *() {return Pkg == Owner->PkgP?0:Pkg;};
inline operator Package const *() const {return Pkg == Owner->PkgP?0:Pkg;};
inline pkgCache *Cache() {return Owner;};
inline const char *Name() const {return Pkg->Name == 0?0:Owner->StrP + Pkg->Name;};
inline const char *Section() const {return Pkg->Section == 0?0:Owner->StrP + Pkg->Section;};
inline bool Purge() const {return Pkg->CurrentState == pkgCache::State::Purge ||
(Pkg->CurrentVer == 0 && Pkg->CurrentState == pkgCache::State::NotInstalled);};
inline VerIterator VersionList() const;
inline VerIterator CurrentVer() const;
inline DepIterator RevDependsList() const;
inline PrvIterator ProvidesList() const;
inline unsigned long Index() const {return Pkg - Owner->PkgP;};
OkState State() const;
//Nice printable representation
friend std::ostream& operator<<(std::ostream& out, pkgCache::PkgIterator Pkg);
const char *CandVersion() const;
const char *CurVersion() const;
// Constructors
inline PkgIterator(pkgCache &Owner,Package *Trg) : Pkg(Trg), Owner(&Owner),
HashIndex(0)
{
if (Pkg == 0)
Pkg = Owner.PkgP;
};
inline PkgIterator() : Pkg(0), Owner(0), HashIndex(0) {};
class pkgCache::PkgIterator: public Iterator<Package, PkgIterator> {
long HashIndex;
protected:
inline Package* OwnerPointer() const {
return Owner->PkgP;
};
public:
// This constructor is the 'begin' constructor, never use it.
inline PkgIterator(pkgCache &Owner) : Iterator<Package, PkgIterator>(Owner), HashIndex(-1) {
S = OwnerPointer();
operator ++(0);
};
virtual void operator ++(int);
virtual void operator ++() {operator ++(0);};
enum OkState {NeedsNothing,NeedsUnpack,NeedsConfigure};
// Accessors
inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;};
inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;};
inline bool Purge() const {return S->CurrentState == pkgCache::State::Purge ||
(S->CurrentVer == 0 && S->CurrentState == pkgCache::State::NotInstalled);};
inline const char *Arch() const {return S->Arch == 0?0:Owner->StrP + S->Arch;};
inline GrpIterator Group() const { return GrpIterator(*Owner, Owner->GrpP + S->Group);};
inline VerIterator VersionList() const;
inline VerIterator CurrentVer() const;
inline DepIterator RevDependsList() const;
inline PrvIterator ProvidesList() const;
OkState State() const;
const char *CandVersion() const;
const char *CurVersion() const;
//Nice printable representation
friend std::ostream& operator <<(std::ostream& out, PkgIterator i);
std::string FullName(bool const &Pretty = false) const;
// Constructors
inline PkgIterator(pkgCache &Owner,Package *Trg) : Iterator<Package, PkgIterator>(Owner, Trg), HashIndex(0) {
if (S == 0)
S = OwnerPointer();
};
inline PkgIterator() : Iterator<Package, PkgIterator>(), HashIndex(0) {};
};
/*}}}*/
// Version Iterator /*{{{*/
class pkgCache::VerIterator
{
Version *Ver;
pkgCache *Owner;
void _dummy();
public:
// Iteration
void operator ++(int) {if (Ver != Owner->VerP) Ver = Owner->VerP + Ver->NextVer;};
inline void operator ++() {operator ++(0);};
inline bool end() const {return Owner == 0 || (Ver == Owner->VerP?true:false);};
inline void operator =(const VerIterator &B) {Ver = B.Ver; Owner = B.Owner;};
// Comparison
inline bool operator ==(const VerIterator &B) const {return Ver == B.Ver;};
inline bool operator !=(const VerIterator &B) const {return Ver != B.Ver;};
int CompareVer(const VerIterator &B) const;
// Testing
inline bool IsGood() const { return Ver && Owner && ! end();};
// Accessors
inline Version *operator ->() {return Ver;};
inline Version const *operator ->() const {return Ver;};
inline Version &operator *() {return *Ver;};
inline Version const &operator *() const {return *Ver;};
inline operator Version *() {return Ver == Owner->VerP?0:Ver;};
inline operator Version const *() const {return Ver == Owner->VerP?0:Ver;};
inline pkgCache *Cache() {return Owner;};
inline const char *VerStr() const {return Ver->VerStr == 0?0:Owner->StrP + Ver->VerStr;};
inline const char *Section() const {return Ver->Section == 0?0:Owner->StrP + Ver->Section;};
inline const char *Arch() const {return Ver->Arch == 0?0:Owner->StrP + Ver->Arch;};
inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Ver->ParentPkg);};
inline DescIterator DescriptionList() const;
DescIterator TranslatedDescription() const;
inline DepIterator DependsList() const;
inline PrvIterator ProvidesList() const;
inline VerFileIterator FileList() const;
inline unsigned long Index() const {return Ver - Owner->VerP;};
bool Downloadable() const;
inline const char *PriorityType() {return Owner->Priority(Ver->Priority);};
string RelStr();
bool Automatic() const;
VerFileIterator NewestFile() const;
inline VerIterator() : Ver(0), Owner(0) {};
inline VerIterator(pkgCache &Owner,Version *Trg = 0) : Ver(Trg),
Owner(&Owner)
{
if (Ver == 0)
Ver = Owner.VerP;
};
class pkgCache::VerIterator : public Iterator<Version, VerIterator> {
protected:
inline Version* OwnerPointer() const {
return Owner->VerP;
};
public:
// Iteration
void operator ++(int) {if (S != Owner->VerP) S = Owner->VerP + S->NextVer;};
inline void operator ++() {operator ++(0);};
// Comparison
int CompareVer(const VerIterator &B) const;
// Accessors
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)
return "all";
return S->ParentPkg == 0?0:Owner->StrP + ParentPkg()->Arch;
};
inline const char *Arch(bool const pseudo) const {
if(pseudo == false)
return Arch();
return S->ParentPkg == 0?0:Owner->StrP + ParentPkg()->Arch;
};
inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);};
inline DescIterator DescriptionList() const;
DescIterator TranslatedDescription() const;
inline DepIterator DependsList() const;
inline PrvIterator ProvidesList() const;
inline VerFileIterator FileList() const;
bool Downloadable() const;
inline const char *PriorityType() {return Owner->Priority(S->Priority);};
string RelStr();
bool Automatic() const;
bool Pseudo() const;
VerFileIterator NewestFile() const;
inline VerIterator(pkgCache &Owner,Version *Trg = 0) : Iterator<Version, VerIterator>(Owner, Trg) {
if (S == 0)
S = OwnerPointer();
};
inline VerIterator() : Iterator<Version, VerIterator>() {};
};
/*}}}*/
// Description Iterator /*{{{*/
class pkgCache::DescIterator
{
Description *Desc;
pkgCache *Owner;
void _dummy();
public:
// Iteration
void operator ++(int) {if (Desc != Owner->DescP) Desc = Owner->DescP + Desc->NextDesc;};
inline void operator ++() {operator ++(0);};
inline bool end() const {return Owner == 0 || Desc == Owner->DescP?true:false;};
inline void operator =(const DescIterator &B) {Desc = B.Desc; Owner = B.Owner;};
// Comparison
inline bool operator ==(const DescIterator &B) const {return Desc == B.Desc;};
inline bool operator !=(const DescIterator &B) const {return Desc != B.Desc;};
int CompareDesc(const DescIterator &B) const;
// Accessors
inline Description *operator ->() {return Desc;};
inline Description const *operator ->() const {return Desc;};
inline Description &operator *() {return *Desc;};
inline Description const &operator *() const {return *Desc;};
inline operator Description *() {return Desc == Owner->DescP?0:Desc;};
inline operator Description const *() const {return Desc == Owner->DescP?0:Desc;};
inline pkgCache *Cache() {return Owner;};
inline const char *LanguageCode() const {return Owner->StrP + Desc->language_code;};
inline const char *md5() const {return Owner->StrP + Desc->md5sum;};
inline DescFileIterator FileList() const;
inline unsigned long Index() const {return Desc - Owner->DescP;};
inline DescIterator() : Desc(0), Owner(0) {};
inline DescIterator(pkgCache &Owner,Description *Trg = 0) : Desc(Trg),
Owner(&Owner)
{
if (Desc == 0)
Desc = Owner.DescP;
};
class pkgCache::DescIterator : public Iterator<Description, DescIterator> {
protected:
inline Description* OwnerPointer() const {
return Owner->DescP;
};
public:
// Iteration
void operator ++(int) {if (S != Owner->DescP) S = Owner->DescP + S->NextDesc;};
inline void operator ++() {operator ++(0);};
// Comparison
int CompareDesc(const DescIterator &B) const;
// Accessors
inline const char *LanguageCode() const {return Owner->StrP + S->language_code;};
inline const char *md5() const {return Owner->StrP + S->md5sum;};
inline DescFileIterator FileList() const;
inline DescIterator() : Iterator<Description, DescIterator>() {};
inline DescIterator(pkgCache &Owner,Description *Trg = 0) : Iterator<Description, DescIterator>(Owner, Trg) {
if (S == 0)
S = Owner.DescP;
};
};
/*}}}*/
// Dependency iterator /*{{{*/
class pkgCache::DepIterator
{
Dependency *Dep;
enum {DepVer, DepRev} Type;
pkgCache *Owner;
void _dummy();
public:
// Iteration
void operator ++(int) {if (Dep != Owner->DepP) Dep = Owner->DepP +
(Type == DepVer?Dep->NextDepends:Dep->NextRevDepends);};
inline void operator ++() {operator ++(0);};
inline bool end() const {return Owner == 0 || Dep == Owner->DepP?true:false;};
// Comparison
inline bool operator ==(const DepIterator &B) const {return Dep == B.Dep;};
inline bool operator !=(const DepIterator &B) const {return Dep != B.Dep;};
// Accessors
inline Dependency *operator ->() {return Dep;};
inline Dependency const *operator ->() const {return Dep;};
inline Dependency &operator *() {return *Dep;};
inline Dependency const &operator *() const {return *Dep;};
inline operator Dependency *() {return Dep == Owner->DepP?0:Dep;};
inline operator Dependency const *() const {return Dep == Owner->DepP?0:Dep;};
inline pkgCache *Cache() {return Owner;};
inline const char *TargetVer() const {return Dep->Version == 0?0:Owner->StrP + Dep->Version;};
inline PkgIterator TargetPkg() {return PkgIterator(*Owner,Owner->PkgP + Dep->Package);};
inline PkgIterator SmartTargetPkg() {PkgIterator R(*Owner,0);SmartTargetPkg(R);return R;};
inline VerIterator ParentVer() {return VerIterator(*Owner,Owner->VerP + Dep->ParentVer);};
inline PkgIterator ParentPkg() {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[Dep->ParentVer].ParentPkg);};
inline bool Reverse() {return Type == DepRev;};
inline unsigned long Index() const {return Dep - Owner->DepP;};
bool IsCritical();
void GlobOr(DepIterator &Start,DepIterator &End);
Version **AllTargets();
bool SmartTargetPkg(PkgIterator &Result);
inline const char *CompType() {return Owner->CompType(Dep->CompareOp);};
inline const char *DepType() {return Owner->DepType(Dep->Type);};
inline DepIterator(pkgCache &Owner,Dependency *Trg,Version * = 0) :
Dep(Trg), Type(DepVer), Owner(&Owner)
{
if (Dep == 0)
Dep = Owner.DepP;
};
inline DepIterator(pkgCache &Owner,Dependency *Trg,Package *) :
Dep(Trg), Type(DepRev), Owner(&Owner)
{
if (Dep == 0)
Dep = Owner.DepP;
};
inline DepIterator() : Dep(0), Type(DepVer), Owner(0) {};
class pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {
enum {DepVer, DepRev} Type;
protected:
inline Dependency* OwnerPointer() const {
return Owner->DepP;
};
public:
// Iteration
void operator ++(int) {if (S != Owner->DepP) S = Owner->DepP +
(Type == DepVer ? S->NextDepends : S->NextRevDepends);};
inline void operator ++() {operator ++(0);};
// Accessors
inline const char *TargetVer() const {return S->Version == 0?0:Owner->StrP + S->Version;};
inline PkgIterator TargetPkg() {return PkgIterator(*Owner,Owner->PkgP + S->Package);};
inline PkgIterator SmartTargetPkg() {PkgIterator R(*Owner,0);SmartTargetPkg(R);return R;};
inline VerIterator ParentVer() {return VerIterator(*Owner,Owner->VerP + S->ParentVer);};
inline PkgIterator ParentPkg() {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->ParentVer].ParentPkg);};
inline bool Reverse() {return Type == DepRev;};
bool IsCritical();
void GlobOr(DepIterator &Start,DepIterator &End);
Version **AllTargets();
bool SmartTargetPkg(PkgIterator &Result);
inline const char *CompType() {return Owner->CompType(S->CompareOp);};
inline const char *DepType() {return Owner->DepType(S->Type);};
inline DepIterator(pkgCache &Owner, Dependency *Trg, Version* = 0) :
Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepVer) {
if (S == 0)
S = Owner.DepP;
};
inline DepIterator(pkgCache &Owner, Dependency *Trg, Package*) :
Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepRev) {
if (S == 0)
S = Owner.DepP;
};
inline DepIterator() : Iterator<Dependency, DepIterator>(), Type(DepVer) {};
};
/*}}}*/
// Provides iterator /*{{{*/
class pkgCache::PrvIterator
{
Provides *Prv;
enum {PrvVer, PrvPkg} Type;
pkgCache *Owner;
void _dummy();
public:
// Iteration
void operator ++(int) {if (Prv != Owner->ProvideP) Prv = Owner->ProvideP +
(Type == PrvVer?Prv->NextPkgProv:Prv->NextProvides);};
inline void operator ++() {operator ++(0);};
inline bool end() const {return Owner == 0 || Prv == Owner->ProvideP?true:false;};
// Comparison
inline bool operator ==(const PrvIterator &B) const {return Prv == B.Prv;};
inline bool operator !=(const PrvIterator &B) const {return Prv != B.Prv;};
// Accessors
inline Provides *operator ->() {return Prv;};
inline Provides const *operator ->() const {return Prv;};
inline Provides &operator *() {return *Prv;};
inline Provides const &operator *() const {return *Prv;};
inline operator Provides *() {return Prv == Owner->ProvideP?0:Prv;};
inline operator Provides const *() const {return Prv == Owner->ProvideP?0:Prv;};
inline pkgCache *Cache() {return Owner;};
inline const char *Name() const {return Owner->StrP + Owner->PkgP[Prv->ParentPkg].Name;};
inline const char *ProvideVersion() const {return Prv->ProvideVersion == 0?0:Owner->StrP + Prv->ProvideVersion;};
inline PkgIterator ParentPkg() {return PkgIterator(*Owner,Owner->PkgP + Prv->ParentPkg);};
inline VerIterator OwnerVer() {return VerIterator(*Owner,Owner->VerP + Prv->Version);};
inline PkgIterator OwnerPkg() {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[Prv->Version].ParentPkg);};
inline unsigned long Index() const {return Prv - Owner->ProvideP;};
inline PrvIterator() : Prv(0), Type(PrvVer), Owner(0) {};
inline PrvIterator(pkgCache &Owner,Provides *Trg,Version *) :
Prv(Trg), Type(PrvVer), Owner(&Owner)
{
if (Prv == 0)
Prv = Owner.ProvideP;
};
inline PrvIterator(pkgCache &Owner,Provides *Trg,Package *) :
Prv(Trg), Type(PrvPkg), Owner(&Owner)
{
if (Prv == 0)
Prv = Owner.ProvideP;
};
class pkgCache::PrvIterator : public Iterator<Provides, PrvIterator> {
enum {PrvVer, PrvPkg} Type;
protected:
inline Provides* OwnerPointer() const {
return Owner->ProvideP;
};
public:
// Iteration
void operator ++(int) {if (S != Owner->ProvideP) S = Owner->ProvideP +
(Type == PrvVer?S->NextPkgProv:S->NextProvides);};
inline void operator ++() {operator ++(0);};
// Accessors
inline const char *Name() const {return Owner->StrP + Owner->PkgP[S->ParentPkg].Name;};
inline const char *ProvideVersion() const {return S->ProvideVersion == 0?0:Owner->StrP + S->ProvideVersion;};
inline PkgIterator ParentPkg() {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);};
inline VerIterator OwnerVer() {return VerIterator(*Owner,Owner->VerP + S->Version);};
inline PkgIterator OwnerPkg() {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->Version].ParentPkg);};
inline PrvIterator() : Iterator<Provides, PrvIterator>(), Type(PrvVer) {};
inline PrvIterator(pkgCache &Owner, Provides *Trg, Version*) :
Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvVer) {
if (S == 0)
S = Owner.ProvideP;
};
inline PrvIterator(pkgCache &Owner, Provides *Trg, Package*) :
Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvPkg) {
if (S == 0)
S = Owner.ProvideP;
};
};
/*}}}*/
// Package file /*{{{*/
class pkgCache::PkgFileIterator
{
pkgCache *Owner;
PackageFile *File;
public:
// Iteration
void operator ++(int) {if (File!= Owner->PkgFileP) File = Owner->PkgFileP + File->NextFile;};
inline void operator ++() {operator ++(0);};
inline bool end() const {return Owner == 0 || File == Owner->PkgFileP?true:false;};
// Comparison
inline bool operator ==(const PkgFileIterator &B) const {return File == B.File;};
inline bool operator !=(const PkgFileIterator &B) const {return File != B.File;};
// Accessors
inline PackageFile *operator ->() {return File;};
inline PackageFile const *operator ->() const {return File;};
inline PackageFile const &operator *() const {return *File;};
inline operator PackageFile *() {return File == Owner->PkgFileP?0:File;};
inline operator PackageFile const *() const {return File == Owner->PkgFileP?0:File;};
inline pkgCache *Cache() {return Owner;};
inline const char *FileName() const {return File->FileName == 0?0:Owner->StrP + File->FileName;};
inline const char *Archive() const {return File->Archive == 0?0:Owner->StrP + File->Archive;};
inline const char *Component() const {return File->Component == 0?0:Owner->StrP + File->Component;};
inline const char *Version() const {return File->Version == 0?0:Owner->StrP + File->Version;};
inline const char *Origin() const {return File->Origin == 0?0:Owner->StrP + File->Origin;};
inline const char *Codename() const {return File->Codename ==0?0:Owner->StrP + File->Codename;};
inline const char *Label() const {return File->Label == 0?0:Owner->StrP + File->Label;};
inline const char *Site() const {return File->Site == 0?0:Owner->StrP + File->Site;};
inline const char *Architecture() const {return File->Architecture == 0?0:Owner->StrP + File->Architecture;};
inline const char *IndexType() const {return File->IndexType == 0?0:Owner->StrP + File->IndexType;};
inline unsigned long Index() const {return File - Owner->PkgFileP;};
bool IsOk();
string RelStr();
// Constructors
inline PkgFileIterator() : Owner(0), File(0) {};
inline PkgFileIterator(pkgCache &Owner) : Owner(&Owner), File(Owner.PkgFileP) {};
inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Owner(&Owner), File(Trg) {};
class pkgCache::PkgFileIterator : public Iterator<PackageFile, PkgFileIterator> {
protected:
inline PackageFile* OwnerPointer() const {
return Owner->PkgFileP;
};
public:
// Iteration
void operator ++(int) {if (S != Owner->PkgFileP) S = Owner->PkgFileP + S->NextFile;};
inline void operator ++() {operator ++(0);};
// Accessors
inline const char *FileName() const {return S->FileName == 0?0:Owner->StrP + S->FileName;};
inline const char *Archive() const {return S->Archive == 0?0:Owner->StrP + S->Archive;};
inline const char *Component() const {return S->Component == 0?0:Owner->StrP + S->Component;};
inline const char *Version() const {return S->Version == 0?0:Owner->StrP + S->Version;};
inline const char *Origin() const {return S->Origin == 0?0:Owner->StrP + S->Origin;};
inline const char *Codename() const {return S->Codename ==0?0:Owner->StrP + S->Codename;};
inline const char *Label() const {return S->Label == 0?0:Owner->StrP + S->Label;};
inline const char *Site() const {return S->Site == 0?0:Owner->StrP + S->Site;};
inline const char *Architecture() const {return S->Architecture == 0?0:Owner->StrP + S->Architecture;};
inline const char *IndexType() const {return S->IndexType == 0?0:Owner->StrP + S->IndexType;};
bool IsOk();
string RelStr();
// Constructors
inline PkgFileIterator() : Iterator<PackageFile, PkgFileIterator>() {};
inline PkgFileIterator(pkgCache &Owner) : Iterator<PackageFile, PkgFileIterator>(Owner, Owner.PkgFileP) {};
inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Iterator<PackageFile, PkgFileIterator>(Owner, Trg) {};
};
/*}}}*/
// Version File /*{{{*/
class pkgCache::VerFileIterator
{
pkgCache *Owner;
VerFile *FileP;
public:
// Iteration
void operator ++(int) {if (FileP != Owner->VerFileP) FileP = Owner->VerFileP + FileP->NextFile;};
inline void operator ++() {operator ++(0);};
inline bool end() const {return Owner == 0 || FileP == Owner->VerFileP?true:false;};
// Comparison
inline bool operator ==(const VerFileIterator &B) const {return FileP == B.FileP;};
inline bool operator !=(const VerFileIterator &B) const {return FileP != B.FileP;};
// Accessors
inline VerFile *operator ->() {return FileP;};
inline VerFile const *operator ->() const {return FileP;};
inline VerFile const &operator *() const {return *FileP;};
inline operator VerFile *() {return FileP == Owner->VerFileP?0:FileP;};
inline operator VerFile const *() const {return FileP == Owner->VerFileP?0:FileP;};
inline pkgCache *Cache() {return Owner;};
inline PkgFileIterator File() const {return PkgFileIterator(*Owner,FileP->File + Owner->PkgFileP);};
inline unsigned long Index() const {return FileP - Owner->VerFileP;};
inline VerFileIterator() : Owner(0), FileP(0) {};
inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Owner(&Owner), FileP(Trg) {};
class pkgCache::VerFileIterator : public pkgCache::Iterator<VerFile, VerFileIterator> {
protected:
inline VerFile* OwnerPointer() const {
return Owner->VerFileP;
};
public:
// Iteration
void operator ++(int) {if (S != Owner->VerFileP) S = Owner->VerFileP + S->NextFile;};
inline void operator ++() {operator ++(0);};
// Accessors
inline PkgFileIterator File() const {return PkgFileIterator(*Owner,S->File + Owner->PkgFileP);};
inline VerFileIterator() : Iterator<VerFile, VerFileIterator>() {};
inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Iterator<VerFile, VerFileIterator>(Owner, Trg) {};
};
/*}}}*/
// Description File /*{{{*/
class pkgCache::DescFileIterator
{
pkgCache *Owner;
DescFile *FileP;
public:
// Iteration
void operator ++(int) {if (FileP != Owner->DescFileP) FileP = Owner->DescFileP + FileP->NextFile;};
inline void operator ++() {operator ++(0);};
inline bool end() const {return Owner == 0 || FileP == Owner->DescFileP?true:false;};
// Comparison
inline bool operator ==(const DescFileIterator &B) const {return FileP == B.FileP;};
inline bool operator !=(const DescFileIterator &B) const {return FileP != B.FileP;};
// Accessors
inline DescFile *operator ->() {return FileP;};
inline DescFile const *operator ->() const {return FileP;};
inline DescFile const &operator *() const {return *FileP;};
inline operator DescFile *() {return FileP == Owner->DescFileP?0:FileP;};
inline operator DescFile const *() const {return FileP == Owner->DescFileP?0:FileP;};
inline pkgCache *Cache() {return Owner;};
inline PkgFileIterator File() const {return PkgFileIterator(*Owner,FileP->File + Owner->PkgFileP);};
inline unsigned long Index() const {return FileP - Owner->DescFileP;};
inline DescFileIterator() : Owner(0), FileP(0) {};
inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Owner(&Owner), FileP(Trg) {};
class pkgCache::DescFileIterator : public Iterator<DescFile, DescFileIterator> {
protected:
inline DescFile* OwnerPointer() const {
return Owner->DescFileP;
};
public:
// Iteration
void operator ++(int) {if (S != Owner->DescFileP) S = Owner->DescFileP + S->NextFile;};
inline void operator ++() {operator ++(0);};
// Accessors
inline PkgFileIterator File() const {return PkgFileIterator(*Owner,S->File + Owner->PkgFileP);};
inline DescFileIterator() : Iterator<DescFile, DescFileIterator>() {};
inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Iterator<DescFile, DescFileIterator>(Owner, Trg) {};
};
/*}}}*/
// Inlined Begin functions cant be in the class because of order problems /*{{{*/
inline pkgCache::PkgIterator pkgCache::GrpIterator::PackageList() const
{return PkgIterator(*Owner,Owner->PkgP + S->FirstPackage);};
inline pkgCache::VerIterator pkgCache::PkgIterator::VersionList() const
{return VerIterator(*Owner,Owner->VerP + Pkg->VersionList);};
{return VerIterator(*Owner,Owner->VerP + S->VersionList);};
inline pkgCache::VerIterator pkgCache::PkgIterator::CurrentVer() const
{return VerIterator(*Owner,Owner->VerP + Pkg->CurrentVer);};
{return VerIterator(*Owner,Owner->VerP + S->CurrentVer);};
inline pkgCache::DepIterator pkgCache::PkgIterator::RevDependsList() const
{return DepIterator(*Owner,Owner->DepP + Pkg->RevDepends,Pkg);};
{return DepIterator(*Owner,Owner->DepP + S->RevDepends,S);};
inline pkgCache::PrvIterator pkgCache::PkgIterator::ProvidesList() const
{return PrvIterator(*Owner,Owner->ProvideP + Pkg->ProvidesList,Pkg);};
{return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);};
inline pkgCache::DescIterator pkgCache::VerIterator::DescriptionList() const
{return DescIterator(*Owner,Owner->DescP + Ver->DescriptionList);};
{return DescIterator(*Owner,Owner->DescP + S->DescriptionList);};
inline pkgCache::PrvIterator pkgCache::VerIterator::ProvidesList() const
{return PrvIterator(*Owner,Owner->ProvideP + Ver->ProvidesList,Ver);};
{return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);};
inline pkgCache::DepIterator pkgCache::VerIterator::DependsList() const
{return DepIterator(*Owner,Owner->DepP + Ver->DependsList,Ver);};
{return DepIterator(*Owner,Owner->DepP + S->DependsList,S);};
inline pkgCache::VerFileIterator pkgCache::VerIterator::FileList() const
{return VerFileIterator(*Owner,Owner->VerFileP + Ver->FileList);};
{return VerFileIterator(*Owner,Owner->VerFileP + S->FileList);};
inline pkgCache::DescFileIterator pkgCache::DescIterator::FileList() const
{return DescFileIterator(*Owner,Owner->DescFileP + Desc->FileList);};
{return DescFileIterator(*Owner,Owner->DescFileP + S->FileList);};
/*}}}*/
#endif

37
apt-pkg/cdrom.cc

@ -6,6 +6,8 @@
#include<apt-pkg/cdromutl.h>
#include<apt-pkg/strutl.h>
#include<apt-pkg/cdrom.h>
#include<apt-pkg/aptconfiguration.h>
#include<sstream>
#include<fstream>
#include<config.h>
@ -216,33 +218,23 @@ int pkgCdrom::Score(string Path)
/* Here we drop everything that is not this machines arch */
bool pkgCdrom::DropBinaryArch(vector<string> &List)
{
char S[300];
snprintf(S,sizeof(S),"/binary-%s/",
_config->Find("Apt::Architecture").c_str());
for (unsigned int I = 0; I < List.size(); I++)
{
const char *Str = List[I].c_str();
const char *Res;
if ((Res = strstr(Str,"/binary-")) == 0)
const char *Start, *End;
if ((Start = strstr(Str,"/binary-")) == 0)
continue;
// Weird, remove it.
if (strlen(Res) < strlen(S))
{
List.erase(List.begin() + I);
I--;
continue;
}
// See if it is our arch
if (stringcmp(Res,Res + strlen(S),S) == 0)
continue;
// Erase it
// Between Start and End is the architecture
Start += 8;
if ((End = strstr(Start,"/")) != 0 && Start != End &&
APT::Configuration::checkArchitecture(string(Start, --End)) == true)
continue; // okay, architecture is accepted
// not accepted -> Erase it
List.erase(List.begin() + I);
I--;
--I; // the next entry is at the same index after the erase
}
return true;
@ -289,7 +281,8 @@ bool pkgCdrom::DropRepeats(vector<string> &List,const char *Name)
List[J] = string();
}
}
delete[] Inodes;
// Wipe erased entries
for (unsigned int I = 0; I < List.size();)
{

6
apt-pkg/clean.cc

@ -12,6 +12,7 @@
#include <apt-pkg/strutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/aptconfiguration.h>
#include <apti18n.h>
@ -26,7 +27,6 @@
bool pkgArchiveCleaner::Go(string Dir,pkgCache &Cache)
{
bool CleanInstalled = _config->FindB("APT::Clean-Installed",true);
string MyArch = _config->Find("APT::Architecture");
DIR *D = opendir(Dir.c_str());
if (D == 0)
@ -75,9 +75,9 @@ bool pkgArchiveCleaner::Go(string Dir,pkgCache &Cache)
for (I = Start; *I != 0 && *I != '.' ;I++);
if (*I != '.')
continue;
string Arch = DeQuoteString(string(Start,I-Start));
string const Arch = DeQuoteString(string(Start,I-Start));
if (Arch != "all" && Arch != MyArch)
if (APT::Configuration::checkArchitecture(Arch) == false)
continue;
// Lookup the package

42
apt-pkg/contrib/cmndline.cc

@ -135,7 +135,9 @@ bool CommandLine::Parse(int argc,const char **argv)
for (; I != argc; I++)
*Files++ = argv[I];
*Files = 0;
SaveInConfig(argc, argv);
return true;
}
/*}}}*/
@ -351,3 +353,41 @@ bool CommandLine::DispatchArg(Dispatch *Map,bool NoMatch)
return false;
}
/*}}}*/
// CommandLine::SaveInConfig - for output later in a logfile or so /*{{{*/
// ---------------------------------------------------------------------
/* We save the commandline here to have it around later for e.g. logging.
It feels a bit like a hack here and isn't bulletproof, but it is better
than nothing after all. */
void CommandLine::SaveInConfig(unsigned int const &argc, char const * const * const argv)
{
char cmdline[300];
unsigned int length = 0;
bool lastWasOption = false;
bool closeQuote = false;
for (unsigned int i = 0; i < argc; ++i, ++length)
{
for (unsigned int j = 0; argv[i][j] != '\0' && length < sizeof(cmdline)-1; ++j, ++length)
{
cmdline[length] = argv[i][j];
if (lastWasOption == true && argv[i][j] == '=')
{
// That is possibly an option: Quote it if it includes spaces,
// the benefit is that this will eliminate also most false positives
const char* c = &argv[i][j+1];
for (; *c != '\0' && *c != ' '; ++c);
if (*c == '\0') continue;
cmdline[++length] = '"';
closeQuote = true;
}
}
if (closeQuote == true)
cmdline[length++] = '"';
// Problem: detects also --hello
if (cmdline[length-1] == 'o')
lastWasOption = true;
cmdline[length] = ' ';
}
cmdline[--length] = '\0';
_config->Set("CommandLine::AsString", cmdline);
}
/*}}}*/

1
apt-pkg/contrib/cmndline.h

@ -60,6 +60,7 @@ class CommandLine
Configuration *Conf;
bool HandleOpt(int &I,int argc,const char *argv[],
const char *&Opt,Args *A,bool PreceedeMatch = false);
void static SaveInConfig(unsigned int const &argc, char const * const * const argv);
public:

8
apt-pkg/contrib/error.h

@ -60,13 +60,13 @@ class GlobalError
public:
// Call to generate an error from a library call.
bool Errno(const char *Function,const char *Description,...) __like_printf_2 __cold;
bool WarningE(const char *Function,const char *Description,...) __like_printf_2 __cold;
bool Errno(const char *Function,const char *Description,...) __like_printf(3) __cold;
bool WarningE(const char *Function,const char *Description,...) __like_printf(3) __cold;
/* A warning should be considered less severe than an error, and may be
ignored by the client. */
bool Error(const char *Description,...) __like_printf_1 __cold;
bool Warning(const char *Description,...) __like_printf_1 __cold;
bool Error(const char *Description,...) __like_printf(2) __cold;
bool Warning(const char *Description,...) __like_printf(2) __cold;
// Simple accessors
inline bool PendingError() {return PendingFlag;};

34
apt-pkg/contrib/macros.h

@ -56,33 +56,35 @@
// some nice optional GNUC features
#if __GNUC__ >= 3
#define __must_check __attribute__ ((warn_unused_result))
#define __deprecated __attribute__ ((deprecated))
/* likely() and unlikely() can be used to mark boolean expressions
as (not) likely true which will help the compiler to optimise */
#define likely(x) __builtin_expect (!!(x), 1)
#define unlikely(x) __builtin_expect (!!(x), 0)
#define __must_check __attribute__ ((warn_unused_result))
#define __deprecated __attribute__ ((deprecated))
#define __attrib_const __attribute__ ((__const__))
/* likely() and unlikely() can be used to mark boolean expressions
as (not) likely true which will help the compiler to optimise */
#define likely(x) __builtin_expect (!!(x), 1)
#define unlikely(x) __builtin_expect (!!(x), 0)
#else
#define __must_check /* no warn_unused_result */
#define __deprecated /* no deprecated */
#define likely(x) (x)
#define unlikely(x) (x)
#define __must_check /* no warn_unused_result */
#define __deprecated /* no deprecated */
#define __attrib_const /* no const attribute */
#define likely(x) (x)
#define unlikely(x) (x)
#endif
// cold functions are unlikely() to be called
#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4
#define __cold __attribute__ ((__cold__))
#define __cold __attribute__ ((__cold__))
#define __hot __attribute__ ((__hot__))
#else
#define __cold /* no cold marker */
#define __cold /* no cold marker */