summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-03-10 15:45:47 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2011-03-10 15:45:47 +0100
commit67da93c38eb3904b36537e025e2f63f77d830e20 (patch)
tree8ff57ccafb2f471fc97f97bfe8f0da11ca1eb7b1 /cmdline
parentc9952021ba65db0581f6053cd6d6e8bf7d563e8f (diff)
parenta75b8cfeb6d7e2468b19534d5b5872c3885f0e1c (diff)
merged from debian-sid
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/apt-cache.cc69
-rw-r--r--cmdline/apt-get.cc153
-rwxr-xr-xcmdline/apt-key2
3 files changed, 115 insertions, 109 deletions
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index 45ea50433..01e0d22e0 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -1118,58 +1118,6 @@ bool Dotty(CommandLine &CmdL)
return true;
}
/*}}}*/
-// DoAdd - Perform an adding operation /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool DoAdd(CommandLine &CmdL)
-{
- return _error->Error("Unimplemented");
-#if 0
- // Make sure there is at least one argument
- if (CmdL.FileSize() <= 1)
- return _error->Error("You must give at least one file name");
-
- // Open the cache
- FileFd CacheF(_config->FindFile("Dir::Cache::pkgcache"),FileFd::WriteAny);
- if (_error->PendingError() == true)
- return false;
-
- DynamicMMap Map(CacheF,MMap::Public);
- if (_error->PendingError() == true)
- return false;
-
- OpTextProgress Progress(*_config);
- pkgCacheGenerator Gen(Map,Progress);
- if (_error->PendingError() == true)
- return false;
-
- unsigned long Length = CmdL.FileSize() - 1;
- for (const char **I = CmdL.FileList + 1; *I != 0; I++)
- {
- Progress.OverallProgress(I - CmdL.FileList,Length,1,"Generating cache");
- Progress.SubProgress(Length);
-
- // Do the merge
- FileFd TagF(*I,FileFd::ReadOnly);
- debListParser Parser(TagF);
- if (_error->PendingError() == true)
- return _error->Error("Problem opening %s",*I);
-
- if (Gen.SelectFile(*I,"") == false)
- return _error->Error("Problem with SelectFile");
-
- if (Gen.MergeList(Parser) == false)
- return _error->Error("Problem with MergeList");
- }
-
- Progress.Done();
- GCache = &Gen.GetCache();
- Stats(CmdL);
-
- return true;
-#endif
-}
- /*}}}*/
// DisplayRecord - Displays the complete record for the package /*{{{*/
// ---------------------------------------------------------------------
/* This displays the package record from the proper package index file.
@@ -1571,7 +1519,6 @@ bool Policy(CommandLine &CmdL)
return true;
}
- string const myArch = _config->Find("APT::Architecture");
char const * const msgInstalled = _(" Installed: ");
char const * const msgCandidate = _(" Candidate: ");
short const InstalledLessCandidate =
@@ -1584,14 +1531,8 @@ bool Policy(CommandLine &CmdL)
// 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 I = pkgset.begin(); I != pkgset.end(); ++I)
+ for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
{
- pkgCache::PkgIterator Pkg = I.Group().FindPkg("any");
-
- for (; Pkg.end() != true; Pkg = I.Group().NextPkg(Pkg)) {
- if (strcmp(Pkg.Arch(),"all") == 0)
- continue;
-
cout << Pkg.FullName(true) << ":" << endl;
// Installed version
@@ -1640,7 +1581,6 @@ bool Policy(CommandLine &CmdL)
Indx->Describe(true).c_str());
}
}
- }
}
return true;
@@ -1743,15 +1683,13 @@ bool ShowHelp(CommandLine &Cmd)
cout <<
_("Usage: apt-cache [options] command\n"
- " apt-cache [options] add file1 [file2 ...]\n"
" apt-cache [options] showpkg pkg1 [pkg2 ...]\n"
" apt-cache [options] showsrc pkg1 [pkg2 ...]\n"
"\n"
- "apt-cache is a low-level tool used to manipulate APT's binary\n"
- "cache files, and query information from them\n"
+ "apt-cache is a low-level tool used to query information\n"
+ "from APT's binary cache files\n"
"\n"
"Commands:\n"
- " add - Add a package file to the source cache\n"
" gencaches - Build both the package and source cache\n"
" showpkg - Show some general information for a single package\n"
" showsrc - Show source records\n"
@@ -1811,7 +1749,6 @@ int main(int argc,const char *argv[]) /*{{{*/
{0,"enhances","APT::Cache::ShowEnhances",0},
{0,0,0,0}};
CommandLine::Dispatch CmdsA[] = {{"help",&ShowHelp},
- {"add",&DoAdd},
{"gencaches",&GenCaches},
{"showsrc",&ShowSrcPackage},
{0,0}};
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index e93d12c2b..6a30c5a50 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -382,8 +382,6 @@ void ShowNew(ostream &out,CacheFile &Cache)
{
pkgCache::PkgIterator I(Cache,Cache.List[J]);
if (Cache[I].NewInstall() == true) {
- if (Cache[I].CandidateVerIter(Cache).Pseudo() == true)
- continue;
List += I.FullName(true) + " ";
VersionsList += string(Cache[I].CandVersion) + "\n";
}
@@ -406,8 +404,6 @@ void ShowDel(ostream &out,CacheFile &Cache)
pkgCache::PkgIterator I(Cache,Cache.List[J]);
if (Cache[I].Delete() == true)
{
- if (Cache[I].CandidateVerIter(Cache).Pseudo() == true)
- continue;
if ((Cache[I].iFlags & pkgDepCache::Purge) == pkgDepCache::Purge)
List += I.FullName(true) + "* ";
else
@@ -456,8 +452,6 @@ void ShowUpgraded(ostream &out,CacheFile &Cache)
// Not interesting
if (Cache[I].Upgrade() == false || Cache[I].NewInstall() == true)
continue;
- if (Cache[I].CandidateVerIter(Cache).Pseudo() == true)
- continue;
List += I.FullName(true) + " ";
VersionsList += string(Cache[I].CurVersion) + " => " + Cache[I].CandVersion + "\n";
@@ -479,8 +473,6 @@ bool ShowDowngraded(ostream &out,CacheFile &Cache)
// Not interesting
if (Cache[I].Downgrade() == false || Cache[I].NewInstall() == true)
continue;
- if (Cache[I].CandidateVerIter(Cache).Pseudo() == true)
- continue;
List += I.FullName(true) + " ";
VersionsList += string(Cache[I].CurVersion) + " => " + Cache[I].CandVersion + "\n";
@@ -584,9 +576,6 @@ void Stats(ostream &out,pkgDepCache &Dep)
unsigned long ReInstall = 0;
for (pkgCache::PkgIterator I = Dep.PkgBegin(); I.end() == false; I++)
{
- if (pkgCache::VerIterator(Dep, Dep[I].CandidateVer).Pseudo() == true)
- continue;
-
if (Dep[I].NewInstall() == true)
Install++;
else
@@ -895,7 +884,11 @@ struct TryToRemove {
if ((Pkg->CurrentVer == 0 && PurgePkgs == false) ||
(PurgePkgs == true && Pkg->CurrentState == pkgCache::State::NotInstalled))
+ {
ioprintf(c1out,_("Package %s is not installed, so not removed\n"),Pkg.FullName(true).c_str());
+ // MarkInstall refuses to install packages on hold
+ Pkg->SelectedState = pkgCache::State::Hold;
+ }
else
Cache->GetDepCache()->MarkDelete(Pkg, PurgePkgs);
}
@@ -1655,6 +1648,7 @@ bool DoAutomaticRemove(CacheFile &Cache)
string autoremovelist, autoremoveversions;
unsigned long autoRemoveCount = 0;
+ APT::PackageSet tooMuch;
// look over the cache to see what can be removed
for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg)
{
@@ -1677,7 +1671,10 @@ bool DoAutomaticRemove(CacheFile &Cache)
// if the package is a new install and already garbage we don't need to
// install it in the first place, so nuke it instead of show it
if (Cache[Pkg].Install() == true && Pkg.CurrentVer() == 0)
+ {
Cache->MarkDelete(Pkg, false);
+ tooMuch.insert(Pkg);
+ }
// only show stuff in the list that is not yet marked for removal
else if(hideAutoRemove == false && Cache[Pkg].Delete() == false)
{
@@ -1693,6 +1690,45 @@ bool DoAutomaticRemove(CacheFile &Cache)
}
}
+ // we could have removed a new dependency of a garbage package,
+ // so check if a reverse depends is broken and if so install it again.
+ if (tooMuch.empty() == false && Cache->BrokenCount() != 0)
+ {
+ bool Changed;
+ do {
+ Changed = false;
+ for (APT::PackageSet::const_iterator P = tooMuch.begin();
+ P != tooMuch.end() && Changed == false; ++P)
+ {
+ for (pkgCache::DepIterator R = P.RevDependsList();
+ R.end() == false; ++R)
+ {
+ if (R->Type != pkgCache::Dep::Depends &&
+ R->Type != pkgCache::Dep::PreDepends)
+ continue;
+ pkgCache::PkgIterator N = R.ParentPkg();
+ if (N.end() == true || (N->CurrentVer == 0 && (*Cache)[N].Install() == false))
+ continue;
+ if (Debug == true)
+ std::clog << "Save " << P << " as another installed garbage package depends on it" << std::endl;
+ Cache->MarkInstall(P, false);
+ if(hideAutoRemove == false)
+ {
+ ++autoRemoveCount;
+ if (smallList == false)
+ {
+ autoremovelist += P.FullName(true) + " ";
+ autoremoveversions += string(Cache[P].CandVersion) + "\n";
+ }
+ }
+ tooMuch.erase(P);
+ Changed = true;
+ break;
+ }
+ }
+ } while (Changed == true);
+ }
+
// Now see if we had destroyed anything (if we had done anything)
if (Cache->BrokenCount() != 0)
{
@@ -1790,14 +1826,7 @@ bool DoInstall(CommandLine &CmdL)
return false;
}
- unsigned short order[] = { 0, 0, 0 };
- if (fallback == MOD_INSTALL) {
- order[0] = MOD_INSTALL;
- order[1] = MOD_REMOVE;
- } else {
- order[0] = MOD_REMOVE;
- order[1] = MOD_INSTALL;
- }
+ unsigned short const order[] = { MOD_REMOVE, MOD_INSTALL, 0 };
TryToInstall InstallAction(Cache, Fix, BrokenFix);
TryToRemove RemoveAction(Cache, Fix);
@@ -1876,8 +1905,6 @@ bool DoInstall(CommandLine &CmdL)
if ((*Cache)[I].Install() == false)
continue;
pkgCache::VerIterator Cand = Cache[I].CandidateVerIter(Cache);
- if (Cand.Pseudo() == true)
- continue;
if (verset[MOD_INSTALL].find(Cand) != verset[MOD_INSTALL].end())
continue;
@@ -2211,13 +2238,15 @@ bool DoDownload(CommandLine &CmdL)
APT::CacheSetHelper helper(c0out);
APT::VersionSet verset = APT::VersionSet::FromCommandLine(Cache,
CmdL.FileList + 1, APT::VersionSet::CANDIDATE, helper);
- pkgAcquire Fetcher;
- AcqTextStatus Stat(ScreenWidth, _config->FindI("quiet",0));
- Fetcher.Setup(&Stat);
if (verset.empty() == true)
return false;
+ pkgAcquire Fetcher;
+ AcqTextStatus Stat(ScreenWidth, _config->FindI("quiet",0));
+ if (_config->FindB("APT::Get::Print-URIs") == true)
+ Fetcher.Setup(&Stat);
+
pkgRecords Recs(Cache);
pkgSourceList *SrcList = Cache.GetSourceList();
for (APT::VersionSet::const_iterator Ver = verset.begin();
@@ -2248,9 +2277,18 @@ bool DoDownload(CommandLine &CmdL)
// get the file
new pkgAcqFile(&Fetcher, uri, hash.toStr(), (*Ver)->Size, descr, Pkg.Name(), ".");
}
- bool result = (Fetcher.Run() == pkgAcquire::Continue);
- return result;
+ // Just print out the uris and exit if the --print-uris flag was used
+ if (_config->FindB("APT::Get::Print-URIs") == true)
+ {
+ pkgAcquire::UriIterator I = Fetcher.UriBegin();
+ for (; I != Fetcher.UriEnd(); I++)
+ cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
+ I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
+ return true;
+ }
+
+ return (Fetcher.Run() == pkgAcquire::Continue);
}
/*}}}*/
// DoCheck - Perform the check operation /*{{{*/
@@ -2879,6 +2917,7 @@ bool GuessThirdPartyChangelogUri(CacheFile &Cache,
// now strip away the filename and add srcpkg_srcver.changelog
return true;
}
+ /*}}}*/
// DownloadChangelog - Download the changelog /*{{{*/
// ---------------------------------------------------------------------
bool DownloadChangelog(CacheFile &CacheFile, pkgAcquire &Fetcher,
@@ -2903,13 +2942,19 @@ bool DownloadChangelog(CacheFile &CacheFile, pkgAcquire &Fetcher,
"http://packages.debian.org/changelogs");
path = GetChangelogPath(CacheFile, Pkg, Ver);
strprintf(changelog_uri, "%s/%s/changelog", server.c_str(), path.c_str());
+ if (_config->FindB("APT::Get::Print-URIs", false) == true)
+ {
+ std::cout << '\'' << changelog_uri << '\'' << std::endl;
+ return true;
+ }
+
strprintf(descr, _("Changelog for %s (%s)"), Pkg.Name(), changelog_uri.c_str());
// queue it
new pkgAcqFile(&Fetcher, changelog_uri, "", 0, descr, Pkg.Name(), "ignored", targetfile);
- // try downloading it, if that fails, they third-party-changelogs location
- // FIXME: res is "Continue" even if I get a 404?!?
- int res = Fetcher.Run();
+ // try downloading it, if that fails, try third-party-changelogs location
+ // FIXME: Fetcher.Run() is "Continue" even if I get a 404?!?
+ Fetcher.Run();
if (!FileExists(targetfile))
{
string third_party_uri;
@@ -2917,7 +2962,7 @@ bool DownloadChangelog(CacheFile &CacheFile, pkgAcquire &Fetcher,
{
strprintf(descr, _("Changelog for %s (%s)"), Pkg.Name(), third_party_uri.c_str());
new pkgAcqFile(&Fetcher, third_party_uri, "", 0, descr, Pkg.Name(), "ignored", targetfile);
- res = Fetcher.Run();
+ Fetcher.Run();
}
}
@@ -2957,30 +3002,53 @@ bool DoChangelog(CommandLine &CmdL)
APT::CacheSetHelper helper(c0out);
APT::VersionSet verset = APT::VersionSet::FromCommandLine(Cache,
CmdL.FileList + 1, APT::VersionSet::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();
+ Ver != verset.end(); ++Ver)
+ return DownloadChangelog(Cache, Fetcher, Ver, "");
+
AcqTextStatus Stat(ScreenWidth, _config->FindI("quiet",0));
Fetcher.Setup(&Stat);
- if (verset.empty() == true)
- return false;
- char *tmpdir = mkdtemp(strdup("/tmp/apt-changelog-XXXXXX"));
- if (tmpdir == NULL) {
- return _error->Errno("mkdtemp", "mkdtemp failed");
+ bool const downOnly = _config->FindB("APT::Get::Download-Only", false);
+
+ char tmpname[100];
+ char* tmpdir = NULL;
+ if (downOnly == false)
+ {
+ const char* const tmpDir = getenv("TMPDIR");
+ if (tmpDir != NULL && *tmpDir != '\0')
+ snprintf(tmpname, sizeof(tmpname), "%s/apt-changelog-XXXXXX", tmpDir);
+ else
+ strncpy(tmpname, "/tmp/apt-changelog-XXXXXX", sizeof(tmpname));
+ tmpdir = mkdtemp(tmpname);
+ if (tmpdir == NULL)
+ return _error->Errno("mkdtemp", "mkdtemp failed");
}
-
+
for (APT::VersionSet::const_iterator Ver = verset.begin();
Ver != verset.end();
++Ver)
{
- string changelogfile = string(tmpdir) + "changelog";
- if (DownloadChangelog(Cache, Fetcher, Ver, changelogfile))
+ string changelogfile;
+ if (downOnly == false)
+ changelogfile.append(tmpname).append("changelog");
+ else
+ changelogfile.append(Ver.ParentPkg().Name()).append(".changelog");
+ if (DownloadChangelog(Cache, Fetcher, Ver, changelogfile) && downOnly == false)
+ {
DisplayFileInPager(changelogfile);
- // cleanup temp file
- unlink(changelogfile.c_str());
+ // cleanup temp file
+ unlink(changelogfile.c_str());
+ }
}
// clenaup tmp dir
- rmdir(tmpdir);
- free(tmpdir);
+ if (tmpdir != NULL)
+ rmdir(tmpdir);
return true;
}
/*}}}*/
@@ -3157,6 +3225,7 @@ int main(int argc,const char *argv[]) /*{{{*/
{0,"auto-remove","APT::Get::AutomaticRemove",0},
{0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0},
{0,"install-recommends","APT::Install-Recommends",CommandLine::Boolean},
+ {0,"install-suggests","APT::Install-Suggests",CommandLine::Boolean},
{0,"fix-policy","APT::Get::Fix-Policy-Broken",0},
{'c',"config-file",0,CommandLine::ConfigFile},
{'o',"option",0,CommandLine::ArbItem},
diff --git a/cmdline/apt-key b/cmdline/apt-key
index c1e01a776..3838fafcd 100755
--- a/cmdline/apt-key
+++ b/cmdline/apt-key
@@ -7,7 +7,7 @@ unset GREP_OPTIONS
# implodes if there isn't one available
GPG_CMD='gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /etc/apt/secring.gpg'
-if ! id -u > /dev/null; then
+if [ "$(id -u)" -eq 0 ]; then
GPG_CMD="$GPG_CMD --trustdb-name /etc/apt/trustdb.gpg"
fi