- } else if(_config->Find("APT::Default-Release") != "") {
- // if we have a Default-Release (-t) we want a exact match
- // FIXME: we won't support downgrades
- // (i.e. -t stable won't work on a unstable system
- pkgCache::PkgIterator Pkg = Cache.FindPkg(TmpSrc);
- if(Pkg.end() == false) {
- pkgCache::VerIterator Ver = Cache.GetCandidateVer(Pkg);
- VerTag = Ver.VerStr();
+ }
+ else if(DefRel.empty() == false)
+ {
+ // we have a default release, try to locate the pkg. we do it like
+ // this because GetCandidateVer() will not "downgrade", that means
+ // "apt-get source -t stable apt" won't work on a unstable system
+ for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false;
+ Ver++)
+ {
+ for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false;
+ VF++)
+ {
+ /* If this is the status file, and the current version is not the
+ version in the status file (ie it is not installed, or somesuch)
+ then it is not a candidate for installation, ever. This weeds
+ out bogus entries that may be due to config-file states, or
+ other. */
+ if ((VF.File()->Flags & pkgCache::Flag::NotSource) ==
+ pkgCache::Flag::NotSource && Pkg.CurrentVer() != Ver)
+ continue;
+
+ //std::cout << VF.File().Archive() << std::endl;
+ if(VF.File().Archive() == DefRel)
+ {
+ VerTag = Ver.VerStr();
+ break;
+ }
+ }