#include <apt-pkg/sptr.h>
#include <apt-pkg/md5.h>
#include <apt-pkg/versionmatch.h>
-
+#include <apt-pkg/packageset.h>
+
#include <config.h>
#include <apti18n.h>
if (Res == pkgPackageManager::Failed || _error->PendingError() == true)
return false;
if (Res == pkgPackageManager::Completed)
- return true;
+ break;
// Reload the fetcher object and loop again for media swapping
Fetcher.Shutdown();
return false;
_system->Lock();
- }
+ }
+
+ std::set<std::string> const disappearedPkgs = PM->GetDisappearedPackages();
+ if (disappearedPkgs.empty() == true)
+ return true;
+
+ string disappear;
+ for (std::set<std::string>::const_iterator d = disappearedPkgs.begin();
+ d != disappearedPkgs.end(); ++d)
+ disappear.append(*d).append(" ");
+
+ ShowList(c1out, P_("The following package disappeared from your system as\n"
+ "all files have been overwritten by other packages:",
+ "The following packages disappeared from your system as\n"
+ "all files have been overwritten by other packages:", disappearedPkgs.size()), disappear, "");
+ c0out << _("Note: This is done automatic and on purpose by dpkg.") << std::endl;
+
+ return true;
}
/*}}}*/
// TryToInstall - Try to install a single package /*{{{*/
Packages++;
if (Pkg.end() == true)
{
- // Check if the name is a regex
- const char *I;
- for (I = S; *I != 0; I++)
- if (*I == '?' || *I == '*' || *I == '|' ||
- *I == '[' || *I == '^' || *I == '$')
- break;
- if (*I == 0)
+ APT::PackageSet pkgset = APT::PackageSet::FromRegEx(Cache, S, c1out);
+ if (pkgset.empty() == true)
return _error->Error(_("Couldn't find package %s"),S);
// Regexs must always be confirmed
ExpectedInst += 1000;
-
- // Compile the regex pattern
- regex_t Pattern;
- int Res;
- if ((Res = regcomp(&Pattern,S,REG_EXTENDED | REG_ICASE |
- REG_NOSUB)) != 0)
- {
- char Error[300];
- regerror(Res,&Pattern,Error,sizeof(Error));
- return _error->Error(_("Regex compilation error - %s"),Error);
- }
-
- // Run over the matches
+
bool Hit = false;
- for (pkgCache::GrpIterator Grp = Cache->GrpBegin(); Grp.end() == false; ++Grp)
+ for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
{
- if (regexec(&Pattern,Grp.Name(),0,0,0) != 0)
- continue;
- Pkg = Grp.FindPkg("native");
- if (unlikely(Pkg.end() == true))
- continue;
-
- ioprintf(c1out,_("Note, selecting %s for regex '%s'\n"),
- Pkg.Name(),S);
-
if (VerTag != 0)
if (TryToChangeVer(Pkg,Cache,VerTag,VerIsRel) == false)
return false;
-
+
Hit |= TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix,
ExpectedInst,false);
}
- regfree(&Pattern);
-
+
if (Hit == false)
return _error->Error(_("Couldn't find package %s"),S);
}
// insert all downloaded uris into this set to avoid downloading them
// twice
set<string> queued;
+
+ // Diff only mode only fetches .diff files
+ bool const diffOnly = _config->FindB("APT::Get::Diff-Only", false);
+ // Tar only mode only fetches .tar files
+ bool const tarOnly = _config->FindB("APT::Get::Tar-Only", false);
+ // Dsc only mode only fetches .dsc files
+ bool const dscOnly = _config->FindB("APT::Get::Dsc-Only", false);
+
// Load the requestd sources into the fetcher
unsigned J = 0;
for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
Dsc[J].Version = Last->Version();
Dsc[J].Dsc = flNotDir(I->Path);
}
-
- // Diff only mode only fetches .diff files
- if (_config->FindB("APT::Get::Diff-Only",false) == true &&
- I->Type != "diff")
- continue;
-
- // Tar only mode only fetches .tar files
- if (_config->FindB("APT::Get::Tar-Only",false) == true &&
- I->Type != "tar")
- continue;
- // Dsc only mode only fetches .dsc files
- if (_config->FindB("APT::Get::Dsc-Only",false) == true &&
- I->Type != "dsc")
- continue;
+ // Handle the only options so that multiple can be used at once
+ if (diffOnly == true || tarOnly == true || dscOnly == true)
+ {
+ if ((diffOnly == true && I->Type == "diff") ||
+ (tarOnly == true && I->Type == "tar") ||
+ (dscOnly == true && I->Type == "dsc"))
+ ; // Fine, we want this file downloaded
+ else
+ continue;
+ }
// don't download the same uri twice (should this be moved to
// the fetcher interface itself?)