#include <list>
#include <map>
#include <set>
+#include <list>
#include <string>
#include <iterator>
Container _cont;
public: /*{{{*/
/** \brief smell like a pkgCache::PkgIterator */
- class const_iterator : public PackageContainerInterface::const_iterator,
- public std::iterator<std::forward_iterator_tag, typename Container::const_iterator> {/*{{{*/
+ class const_iterator : public PackageContainerInterface::const_iterator,/*{{{*/
+ public std::iterator<std::forward_iterator_tag, typename Container::const_iterator> {
typename Container::const_iterator _iter;
public:
const_iterator(typename Container::const_iterator i) : _iter(i) {}
inline bool operator==(const_iterator const &i) const { return _iter == i._iter; };
friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, *i); }
};
- // we are not going to allow modify our pkgiterators (it doesn't make sense)…
- typedef APT::PackageContainer<Container>::const_iterator iterator;
+ class iterator : public PackageContainerInterface::const_iterator,
+ public std::iterator<std::forward_iterator_tag, typename Container::iterator> {
+ typename Container::iterator _iter;
+ public:
+ iterator(typename Container::iterator i) : _iter(i) {}
+ pkgCache::PkgIterator getPkg(void) const { return *_iter; }
+ inline pkgCache::PkgIterator operator*(void) const { return *_iter; };
+ operator typename Container::iterator(void) const { return _iter; }
+ operator typename PackageContainer<Container>::const_iterator() { return PackageContainer<Container>::const_iterator(_iter); }
+ inline void operator++(void) { ++_iter; };
+ inline bool operator!=(iterator const &i) const { return _iter != i._iter; };
+ inline bool operator==(iterator const &i) const { return _iter == i._iter; };
+ friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); }
+ };
/*}}}*/
bool insert(pkgCache::PkgIterator const &P) { if (P.end() == true) return false; _cont.insert(P); return true; };
template<class Cont> void insert(PackageContainer<Cont> const &pkgcont) { _cont.insert((typename Cont::const_iterator)pkgcont.begin(), (typename Cont::const_iterator)pkgcont.end()); };
void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); };
+
bool empty() const { return _cont.empty(); };
void clear() { return _cont.clear(); };
- void erase(iterator position) { _cont.erase((typename Container::const_iterator)position); };
+ void erase(iterator position) { _cont.erase((typename Container::iterator)position); };
size_t erase(const pkgCache::PkgIterator x) { return _cont.erase(x); };
void erase(iterator first, iterator last) { _cont.erase(first, last); };
size_t size() const { return _cont.size(); };
const_iterator begin() const { return const_iterator(_cont.begin()); };
const_iterator end() const { return const_iterator(_cont.end()); };
+ iterator begin() { return iterator(_cont.begin()); };
+ iterator end() { return iterator(_cont.end()); };
const_iterator find(pkgCache::PkgIterator const &P) const { return const_iterator(_cont.find(P)); };
void setConstructor(Constructor const &by) { ConstructedBy = by; };
Constructor ConstructedBy;
/*}}}*/
}; /*}}}*/
+
+template<> template<class Cont> void PackageContainer<std::list<pkgCache::PkgIterator> >::insert(PackageContainer<Cont> const &pkgcont) {
+ for (typename PackageContainer<Cont>::const_iterator p = pkgcont.begin(); p != pkgcont.end(); ++p)
+ _cont.push_back(*p);
+};
+// these two are 'inline' as otherwise the linker has problems with seeing these untemplated
+// specializations again and again - but we need to see them, so that library users can use them
+template<> inline bool PackageContainer<std::list<pkgCache::PkgIterator> >::insert(pkgCache::PkgIterator const &P) {
+ if (P.end() == true)
+ return false;
+ _cont.push_back(P);
+ return true;
+};
+template<> inline void PackageContainer<std::list<pkgCache::PkgIterator> >::insert(const_iterator begin, const_iterator end) {
+ for (const_iterator p = begin; p != end; ++p)
+ _cont.push_back(*p);
+};
typedef PackageContainer<std::set<pkgCache::PkgIterator> > PackageSet;
+typedef PackageContainer<std::list<pkgCache::PkgIterator> > PackageList;
class VersionContainerInterface { /*{{{*/
/** \class APT::VersionContainerInterface
std::list<Modifier> const &mods,
CacheSetHelper &helper);
+
+ static bool FromDependency(VersionContainerInterface * const vci,
+ pkgCacheFile &Cache,
+ pkgCache::DepIterator const &D,
+ Version const &selector,
+ CacheSetHelper &helper);
+
protected: /*{{{*/
/** \brief returns the candidate version of the package
};
/*}}}*/
template<class Container> class VersionContainer : public VersionContainerInterface {/*{{{*/
-/** \class APT::PackageContainer
+/** \class APT::VersionContainer
Simple wrapper around a container class like std::set to provide a similar
interface to a set of versions as to the complete set of all versions in the
inline bool operator==(const_iterator const &i) const { return _iter == i._iter; };
friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, *i); }
};
- // we are not going to allow modify our veriterators (it doesn't make sense)…
- typedef APT::VersionContainer<Container>::const_iterator iterator;
+ class iterator : public VersionContainerInterface::const_iterator,
+ public std::iterator<std::forward_iterator_tag, typename Container::iterator> {
+ typename Container::iterator _iter;
+ public:
+ iterator(typename Container::iterator i) : _iter(i) {}
+ pkgCache::VerIterator getVer(void) const { return *_iter; }
+ inline pkgCache::VerIterator operator*(void) const { return *_iter; };
+ operator typename Container::iterator(void) const { return _iter; }
+ operator typename VersionContainer<Container>::const_iterator() { return VersionContainer<Container>::const_iterator(_iter); }
+ inline void operator++(void) { ++_iter; };
+ inline bool operator!=(iterator const &i) const { return _iter != i._iter; };
+ inline bool operator==(iterator const &i) const { return _iter == i._iter; };
+ friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); }
+ };
/*}}}*/
bool insert(pkgCache::VerIterator const &V) { if (V.end() == true) return false; _cont.insert(V); return true; };
void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); };
bool empty() const { return _cont.empty(); };
void clear() { return _cont.clear(); };
- void erase(iterator position) { _cont.erase((typename Container::const_iterator)position); };
- size_t erase(const pkgCache::PkgIterator x) { return _cont.erase(x); };
+ void erase(iterator position) { _cont.erase((typename Container::iterator)position); };
+ size_t erase(const pkgCache::VerIterator x) { return _cont.erase(x); };
void erase(iterator first, iterator last) { _cont.erase(first, last); };
size_t size() const { return _cont.size(); };
const_iterator begin() const { return const_iterator(_cont.begin()); };
const_iterator end() const { return const_iterator(_cont.end()); };
+ iterator begin() { return iterator(_cont.begin()); };
+ iterator end() { return iterator(_cont.end()); };
const_iterator find(pkgCache::VerIterator const &V) const { return const_iterator(_cont.find(V)); };
/** \brief returns all versions specified on the commandline
return FromPackage(Cache, P, fallback, helper);
}
static VersionContainer FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &P) {
- return FromPackage(Cache, P, CANDINST);
+ return FromPackage(Cache, P, CANDIDATE);
}
static std::map<unsigned short, VersionContainer> GroupedFromCommandLine(
return GroupedFromCommandLine(Cache, cmdline,
mods, fallback, helper);
}
+
+ static VersionContainer FromDependency(pkgCacheFile &Cache, pkgCache::DepIterator const &D,
+ Version const &selector, CacheSetHelper &helper) {
+ VersionContainer vercon;
+ VersionContainerInterface::FromDependency(&vercon, Cache, D, selector, helper);
+ return vercon;
+ }
+ static VersionContainer FromDependency(pkgCacheFile &Cache, pkgCache::DepIterator const &D,
+ Version const &selector) {
+ CacheSetHelper helper;
+ return FromPackage(Cache, D, selector, helper);
+ }
+ static VersionContainer FromDependency(pkgCacheFile &Cache, pkgCache::DepIterator const &D) {
+ return FromPackage(Cache, D, CANDIDATE);
+ }
/*}}}*/
}; /*}}}*/
+
+template<> template<class Cont> void VersionContainer<std::list<pkgCache::VerIterator> >::insert(VersionContainer<Cont> const &vercont) {
+ for (typename VersionContainer<Cont>::const_iterator v = vercont.begin(); v != vercont.end(); ++v)
+ _cont.push_back(*v);
+};
+// these two are 'inline' as otherwise the linker has problems with seeing these untemplated
+// specializations again and again - but we need to see them, so that library users can use them
+template<> inline bool VersionContainer<std::list<pkgCache::VerIterator> >::insert(pkgCache::VerIterator const &V) {
+ if (V.end() == true)
+ return false;
+ _cont.push_back(V);
+ return true;
+};
+template<> inline void VersionContainer<std::list<pkgCache::VerIterator> >::insert(const_iterator begin, const_iterator end) {
+ for (const_iterator v = begin; v != end; ++v)
+ _cont.push_back(*v);
+};
typedef VersionContainer<std::set<pkgCache::VerIterator> > VersionSet;
+typedef VersionContainer<std::list<pkgCache::VerIterator> > VersionList;
}
#endif
else
{
CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
- APT::VersionSet verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1,
- APT::VersionSet::CANDIDATE, helper);
- for (APT::VersionSet::iterator V = verset.begin(); V != verset.end(); ++V)
+ APT::VersionList verset = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1,
+ APT::VersionList::CANDIDATE, helper);
+ for (APT::VersionList::iterator V = verset.begin(); V != verset.end(); ++V)
if (ShowUnMet(V, Important) == false)
return false;
}
{
pkgCacheFile CacheFile;
APT::CacheSetHelper helper(true, GlobalError::NOTICE);
- APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1, helper);
+ APT::PackageList pkgset = APT::PackageList::FromCommandLine(CacheFile, CmdL.FileList + 1, helper);
- for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+ for (APT::PackageList::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
{
cout << "Package: " << Pkg.FullName(true) << endl;
cout << "Versions: " << endl;
return false;
CacheSetHelperVirtuals helper(false);
- APT::VersionSet verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1, APT::VersionSet::CANDIDATE, helper);
+ APT::VersionList verset = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, APT::VersionList::CANDIDATE, helper);
if (verset.empty() == true && helper.virtualPkgs.empty() == true)
return _error->Error(_("No packages found"));
std::vector<bool> Shown(Cache->Head().PackageCount);
{
pkgCacheFile CacheFile;
CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
- APT::VersionSet::Version const select = _config->FindB("APT::Cache::AllVersions", true) ?
- APT::VersionSet::ALL : APT::VersionSet::CANDIDATE;
- APT::VersionSet const verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1, select, helper);
- for (APT::VersionSet::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver)
+ APT::VersionList::Version const select = _config->FindB("APT::Cache::AllVersions", true) ?
+ APT::VersionList::ALL : APT::VersionList::CANDIDATE;
+ APT::VersionList const verset = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, select, helper);
+ for (APT::VersionList::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver)
if (DisplayRecord(CacheFile, Ver) == false)
return false;
// Print out detailed information for each package
APT::CacheSetHelper helper(true, GlobalError::NOTICE);
- APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1, helper);
- for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+ APT::PackageList pkgset = APT::PackageList::FromCommandLine(CacheFile, CmdL.FileList + 1, helper);
+ for (APT::PackageList::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
{
cout << Pkg.FullName(true) << ":" << endl;
for (const char **I = CmdL.FileList + 1; *I != 0; I++)
{
_error->PushToStack();
- APT::PackageSet pkgset = APT::PackageSet::FromString(CacheFile, *I, helper);
- for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+ APT::PackageList pkgset = APT::PackageList::FromString(CacheFile, *I, helper);
+ for (APT::PackageList::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
{
for (pkgCache::VerIterator V = Pkg.VersionList(); V.end() == false; ++V)
{
return false;
APT::CacheSetHelper helper(c0out);
- APT::VersionSet verset = APT::VersionSet::FromCommandLine(Cache,
- CmdL.FileList + 1, APT::VersionSet::CANDIDATE, helper);
+ APT::VersionList verset = APT::VersionList::FromCommandLine(Cache,
+ CmdL.FileList + 1, APT::VersionList::CANDIDATE, helper);
if (verset.empty() == true)
return false;
pkgRecords Recs(Cache);
pkgSourceList *SrcList = Cache.GetSourceList();
- for (APT::VersionSet::const_iterator Ver = verset.begin();
+ for (APT::VersionList::const_iterator Ver = verset.begin();
Ver != verset.end();
++Ver)
{
return false;
APT::CacheSetHelper helper(c0out);
- APT::VersionSet verset = APT::VersionSet::FromCommandLine(Cache,
- CmdL.FileList + 1, APT::VersionSet::CANDIDATE, helper);
+ APT::VersionList verset = APT::VersionList::FromCommandLine(Cache,
+ CmdL.FileList + 1, APT::VersionList::CANDIDATE, helper);
if (verset.empty() == true)
return false;
pkgAcquire Fetcher;
if (_config->FindB("APT::Get::Print-URIs", false) == true)
- for (APT::VersionSet::const_iterator Ver = verset.begin();
+ for (APT::VersionList::const_iterator Ver = verset.begin();
Ver != verset.end(); ++Ver)
return DownloadChangelog(Cache, Fetcher, Ver, "");
return _error->Errno("mkdtemp", "mkdtemp failed");
}
- for (APT::VersionSet::const_iterator Ver = verset.begin();
+ for (APT::VersionList::const_iterator Ver = verset.begin();
Ver != verset.end();
++Ver)
{
if (unlikely(Cache == NULL || DepCache == NULL))
return false;
- APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1);
+ APT::PackageList pkgset = APT::PackageList::FromCommandLine(CacheFile, CmdL.FileList + 1);
if (pkgset.empty() == true)
return _error->Error(_("No packages found"));
bool MarkAuto = strcasecmp(CmdL.FileList[0],"auto") == 0;
int AutoMarkChanged = 0;
- for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+ for (APT::PackageList::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
{
if (Pkg->CurrentVer == 0)
{
if (unlikely(Cache == NULL || DepCache == NULL))
return false;
- APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1);
+ APT::PackageList pkgset = APT::PackageList::FromCommandLine(CacheFile, CmdL.FileList + 1);
if (pkgset.empty() == true)
return _error->Error(_("No packages found"));
bool const Verbose = _config->FindB("APT::MarkAuto::Verbose", false);
int AutoMarkChanged = 0;
- for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+ for (APT::PackageList::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
{
if (Pkg->CurrentVer == 0 ||
(((*DepCache)[Pkg].Flags & pkgCache::Flag::Auto) == pkgCache::Flag::Auto) == MarkAuto)
if (unlikely(Cache == NULL))
return false;
- APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1);
+ APT::PackageList pkgset = APT::PackageList::FromCommandLine(CacheFile, CmdL.FileList + 1);
if (pkgset.empty() == true)
return _error->Error(_("No packages found"));
bool const MarkHold = strcasecmp(CmdL.FileList[0],"hold") == 0;
- for (APT::PackageSet::iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+ for (APT::PackageList::iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
{
if ((Pkg->SelectedState == pkgCache::State::Hold) == MarkHold)
{
if (_config->FindB("APT::Mark::Simulate", false) == true)
{
- for (APT::PackageSet::iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+ for (APT::PackageList::iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
{
if (MarkHold == false)
ioprintf(c1out,_("%s set on hold.\n"), Pkg.FullName(true).c_str());
if (dpkg == NULL)
return _error->Errno("DoHold", "fdopen on dpkg stdin failed");
- for (APT::PackageSet::iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+ for (APT::PackageList::iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
{
if (MarkHold == true)
{
* apt-pkg/cacheset.cc:
- make the cachesets real containers which can embedding any container
to be able to use the same interface regardless of set or list usage
+ - provide a {Package,Version}List similar to {Package,Version}Set
+ * cmdline/apt-{get,cache,mark}.cc:
+ - use Lists instead of Sets if input order should be preserved for
+ commands accepting lists of packages, e.g. policy (Closes: #625960)
- -- David Kalnischkies <kalnischkies@gmail.com> Wed, 09 Nov 2011 17:21:02 +0100
+ -- David Kalnischkies <kalnischkies@gmail.com> Fri, 11 Nov 2011 15:55:13 +0100
apt (0.8.16~exp7) experimental; urgency=low
-Package: newstuff
-Version: 1.0
-Architecture: i386
-Maintainer: Joe Sixpack <joe@example.org>
-Installed-Size: 101
-Filename: pool/newstuff_1.0_i386.deb
-Size: 101100
-MD5sum: 311aeeadf78324aaff1ceaf3e1f76671
-SHA1: 3c695e028f7a1ae324deeddaaa1242desa81088c
-SHA256: b46fd154615edefab321cc56a5cc0e7deaef23e2da3e4f129727fd660f28f050
-Description: some cool and shiny new stuff
- This package will appear in the next mirror update
-
Package: apt
Priority: important
Section: admin
.
APT features complete installation ordering, multiple source capability
and several other unique features, see the Users Guide in apt-doc.
+
+Package: newstuff
+Version: 1.0
+Architecture: i386
+Maintainer: Joe Sixpack <joe@example.org>
+Installed-Size: 101
+Filename: pool/newstuff_1.0_i386.deb
+Size: 101100
+MD5sum: 311aeeadf78324aaff1ceaf3e1f76671
+SHA1: 3c695e028f7a1ae324deeddaaa1242desa81088c
+SHA256: b46fd154615edefab321cc56a5cc0e7deaef23e2da3e4f129727fd660f28f050
+Description: some cool and shiny new stuff
+ This package will appear in the next mirror update