summaryrefslogtreecommitdiff
path: root/cmdline/apt-get.cc
diff options
context:
space:
mode:
Diffstat (limited to 'cmdline/apt-get.cc')
-rw-r--r--cmdline/apt-get.cc69
1 files changed, 45 insertions, 24 deletions
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index a7221d47d..ab6dca388 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -111,6 +111,9 @@ class CacheFile : public pkgCacheFile
return Open(true);
}
CacheFile() : List(0) {};
+ ~CacheFile() {
+ delete[] List;
+ }
};
/*}}}*/
@@ -594,7 +597,6 @@ void Stats(ostream &out,pkgDepCache &Dep)
Dep.BadCount());
}
/*}}}*/
-
// CacheFile::NameComp - QSort compare by name /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -687,7 +689,10 @@ bool CacheFile::CheckDeps(bool AllowBroken)
return true;
}
-
+ /*}}}*/
+// CheckAuth - check if each download comes form a trusted source /*{{{*/
+// ---------------------------------------------------------------------
+/* */
static bool CheckAuth(pkgAcquire& Fetcher)
{
string UntrustedList;
@@ -728,10 +733,7 @@ static bool CheckAuth(pkgAcquire& Fetcher)
return _error->Error(_("There are problems and -y was used without --force-yes"));
}
-
-
/*}}}*/
-
// InstallPackages - Actually download and install the packages /*{{{*/
// ---------------------------------------------------------------------
/* This displays the informative messages describing what is going to
@@ -1260,7 +1262,8 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
/* Lookup the version of the package we would install if we were to
install a version and determine the source package name, then look
in the archive for a source package of the same name. */
- if (_config->FindB("APT::Get::Only-Source") == false)
+ bool MatchSrcOnly = _config->FindB("APT::Get::Only-Source");
+ if (MatchSrcOnly == false)
{
if (Pkg.end() == false)
{
@@ -1272,16 +1275,22 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
}
}
}
-
- // No source package name..
- if (Src.empty() == true)
- Src = TmpSrc;
-
+
// The best hit
pkgSrcRecords::Parser *Last = 0;
unsigned long Offset = 0;
string Version;
bool IsMatch = false;
+
+ // No source package name..
+ if (Src.empty() == true)
+ Src = TmpSrc;
+ else
+ // if we have a source pkg name, make sure to only search
+ // for srcpkg names, otherwise apt gets confused if there
+ // is a binary package "pkg1" and a source package "pkg1"
+ // with the same name but that comes from different packages
+ MatchSrcOnly = true;
// If we are matching by version then we need exact matches to be happy
if (VerTag.empty() == false)
@@ -1291,13 +1300,13 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
binary packages in the search */
pkgSrcRecords::Parser *Parse;
SrcRecs.Restart();
- while ((Parse = SrcRecs.Find(Src.c_str(),false)) != 0)
+ while ((Parse = SrcRecs.Find(Src.c_str(), MatchSrcOnly)) != 0)
{
string Ver = Parse->Version();
-
- // Skip name mismatches
- if (IsMatch == true && Parse->Package() != Src)
- continue;
+
+ // show name mismatches
+ if (IsMatch == true && Parse->Package() != Src)
+ ioprintf(c1out, _("No source package '%s' picking '%s' instead\n"), Parse->Package().c_str(), Src.c_str());
if (VerTag.empty() == false)
{
@@ -1328,7 +1337,6 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
return Last;
}
/*}}}*/
-
// DoUpdate - Update the package lists /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -1450,7 +1458,7 @@ bool DoAutomaticRemove(CacheFile &Cache)
}
return true;
}
-
+ /*}}}*/
// DoUpgrade - Upgrade all packages /*{{{*/
// ---------------------------------------------------------------------
/* Upgrade all packages without installing new packages or erasing old
@@ -1525,7 +1533,7 @@ bool TryInstallTask(pkgDepCache &Cache, pkgProblemResolver &Fix,
regfree(&Pattern);
return res;
}
-
+ /*}}}*/
// DoInstall - Install packages from the command line /*{{{*/
// ---------------------------------------------------------------------
/* Install named packages */
@@ -1863,7 +1871,8 @@ bool DoInstall(CommandLine &CmdL)
// cache.commit()
if (AutoMarkChanged > 0 &&
Cache->DelCount() == 0 && Cache->InstCount() == 0 &&
- Cache->BadCount() == 0)
+ Cache->BadCount() == 0 &&
+ _config->FindB("APT::Get::Simulate",false) == false)
Cache->writeStateFile(NULL);
// See if we need to prompt
@@ -2632,7 +2641,7 @@ bool ShowHelp(CommandLine &CmdL)
" install - Install new packages (pkg is libc6 not libc6.deb)\n"
" remove - Remove packages\n"
" autoremove - Remove automatically all unused packages\n"
- " purge - Remove and purge packages\n"
+ " purge - Remove packages and config files\n"
" source - Download source archives\n"
" build-dep - Configure build-dependencies for source packages\n"
" dist-upgrade - Distribution upgrade, see apt-get(8)\n"
@@ -2691,8 +2700,7 @@ void SigWinch(int)
#endif
}
/*}}}*/
-
-int main(int argc,const char *argv[])
+int main(int argc,const char *argv[]) /*{{{*/
{
CommandLine::Args Args[] = {
{'h',"help","help",0},
@@ -2781,7 +2789,19 @@ int main(int argc,const char *argv[])
ShowHelp(CmdL);
return 0;
}
-
+
+ // simulate user-friendly if apt-get has no root privileges
+ if (getuid() != 0 && _config->FindB("APT::Get::Simulate") == true)
+ {
+ if (_config->FindB("APT::Get::Show-User-Simulation-Note",true) == true)
+ cout << _("NOTE: This is only a simulation!\n"
+ " apt-get needs root privileges for real execution.\n"
+ " Keep also in mind that locking is deactivated,\n"
+ " so don't depend on the relevance to the real current situation!"
+ ) << std::endl;
+ _config->Set("Debug::NoLocking",true);
+ }
+
// Deal with stdout not being a tty
if (!isatty(STDOUT_FILENO) && _config->FindI("quiet",0) < 1)
_config->Set("quiet","1");
@@ -2813,3 +2833,4 @@ int main(int argc,const char *argv[])
return 0;
}
+ /*}}}*/