summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/apt-cache.cc29
-rw-r--r--cmdline/apt-cdrom.cc12
-rw-r--r--cmdline/apt-config.cc4
-rw-r--r--cmdline/apt-extracttemplates.cc4
-rw-r--r--cmdline/apt-get.cc383
-rwxr-xr-xcmdline/apt-key18
-rwxr-xr-xcmdline/apt-mark15
-rw-r--r--cmdline/apt-sortpkgs.cc8
8 files changed, 291 insertions, 182 deletions
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index 425df6994..7d7f58a62 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -399,7 +399,7 @@ bool DumpAvail(CommandLine &Cmd)
pkgCache &Cache = *GCache;
pkgPolicy Plcy(&Cache);
- if (ReadPinFile(Plcy) == false)
+ if (ReadPinFile(Plcy) == false || ReadPinDir(Plcy) == false)
return false;
unsigned long Count = Cache.HeaderP->PackageCount+1;
@@ -626,7 +626,7 @@ bool Depends(CommandLine &CmdL)
return true;
}
-
+ /*}}}*/
// RDepends - Print out a reverse dependency tree - mbc /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -714,10 +714,7 @@ bool RDepends(CommandLine &CmdL)
return true;
}
-
/*}}}*/
-
-
// xvcg - Generate a graph for xvcg /*{{{*/
// ---------------------------------------------------------------------
// Code contributed from Junichi Uekawa <dancer@debian.org> on 20 June 2002.
@@ -932,13 +929,15 @@ bool XVcg(CommandLine &CmdL)
Shapes[ShapeMap[Pkg->ID]]);
}
-
+
+ delete[] Show;
+ delete[] Flags;
+ delete[] ShapeMap;
+
printf("}\n");
return true;
}
/*}}}*/
-
-
// Dotty - Generate a graph for Dotty /*{{{*/
// ---------------------------------------------------------------------
/* Dotty is the graphvis program for generating graphs. It is a fairly
@@ -1274,15 +1273,16 @@ bool DisplayRecord(pkgCache::VerIterator V)
return true;
}
/*}}}*/
-// Search - Perform a search /*{{{*/
-// ---------------------------------------------------------------------
-/* This searches the package names and package descriptions for a pattern */
+
struct ExDescFile
{
pkgCache::DescFile *Df;
bool NameMatch;
};
+// Search - Perform a search /*{{{*/
+// ---------------------------------------------------------------------
+/* This searches the package names and package descriptions for a pattern */
bool Search(CommandLine &CmdL)
{
pkgCache &Cache = *GCache;
@@ -1519,7 +1519,7 @@ bool Policy(CommandLine &CmdL)
pkgCache &Cache = *GCache;
pkgPolicy Plcy(&Cache);
- if (ReadPinFile(Plcy) == false)
+ if (ReadPinFile(Plcy) == false || ReadPinDir(Plcy) == false)
return false;
// Print out all of the package files
@@ -1696,7 +1696,6 @@ bool Madison(CommandLine &CmdL)
return true;
}
-
/*}}}*/
// GenCaches - Call the main cache generator /*{{{*/
// ---------------------------------------------------------------------
@@ -1770,8 +1769,7 @@ void CacheInitialize()
_config->Set("help",false);
}
/*}}}*/
-
-int main(int argc,const char *argv[])
+int main(int argc,const char *argv[]) /*{{{*/
{
CommandLine::Args Args[] = {
{'h',"help","help",0},
@@ -1878,3 +1876,4 @@ int main(int argc,const char *argv[])
return 0;
}
+ /*}}}*/
diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc
index 379a433ea..d804c55e5 100644
--- a/cmdline/apt-cdrom.cc
+++ b/cmdline/apt-cdrom.cc
@@ -40,8 +40,7 @@
using namespace std;
- /*{{{*/
-class pkgCdromTextStatus : public pkgCdromStatus
+class pkgCdromTextStatus : public pkgCdromStatus /*{{{*/
{
protected:
OpTextProgress Progress;
@@ -75,7 +74,7 @@ string pkgCdromTextStatus::PromptLine(const char *Text)
bool pkgCdromTextStatus::AskCdromName(string &name)
{
- cout << _("Please provide a name for this Disc, such as 'Debian 2.1r1 Disk 1'") << flush;
+ cout << _("Please provide a name for this Disc, such as 'Debian 5.0.3 Disk 1'") << flush;
name = PromptLine("");
return true;
@@ -98,9 +97,7 @@ OpProgress* pkgCdromTextStatus::GetOpProgress()
{
return &Progress;
};
-
/*}}}*/
-
// DoAdd - Add a new CDROM /*{{{*/
// ---------------------------------------------------------------------
/* This does the main add bit.. We show some status and things. The
@@ -129,7 +126,6 @@ bool DoIdent(CommandLine &)
return cdrom.Ident(ident, &log);
}
/*}}}*/
-
// ShowHelp - Show the help screen /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -164,8 +160,7 @@ int ShowHelp()
return 0;
}
/*}}}*/
-
-int main(int argc,const char *argv[])
+int main(int argc,const char *argv[]) /*{{{*/
{
CommandLine::Args Args[] = {
{'h',"help","help",0},
@@ -222,3 +217,4 @@ int main(int argc,const char *argv[])
return 0;
}
+ /*}}}*/
diff --git a/cmdline/apt-config.cc b/cmdline/apt-config.cc
index 63fa0867c..9919a9c94 100644
--- a/cmdline/apt-config.cc
+++ b/cmdline/apt-config.cc
@@ -88,8 +88,7 @@ int ShowHelp()
return 0;
}
/*}}}*/
-
-int main(int argc,const char *argv[])
+int main(int argc,const char *argv[]) /*{{{*/
{
CommandLine::Args Args[] = {
{'h',"help","help",0},
@@ -133,3 +132,4 @@ int main(int argc,const char *argv[])
return 0;
}
+ /*}}}*/
diff --git a/cmdline/apt-extracttemplates.cc b/cmdline/apt-extracttemplates.cc
index de22386b9..21ef1a050 100644
--- a/cmdline/apt-extracttemplates.cc
+++ b/cmdline/apt-extracttemplates.cc
@@ -348,8 +348,7 @@ bool Go(CommandLine &CmdL)
return !_error->PendingError();
}
/*}}}*/
-
-int main(int argc, const char **argv)
+int main(int argc, const char **argv) /*{{{*/
{
CommandLine::Args Args[] = {
{'h',"help","help",0},
@@ -391,3 +390,4 @@ int main(int argc, const char **argv)
return 0;
}
+ /*}}}*/
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 27e16d3f3..dede0137e 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
@@ -860,14 +862,21 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
{
struct statvfs Buf;
string OutputDir = _config->FindDir("Dir::Cache::Archives");
- if (statvfs(OutputDir.c_str(),&Buf) != 0)
- return _error->Errno("statvfs",_("Couldn't determine free space in %s"),
- OutputDir.c_str());
- if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize)
+ if (statvfs(OutputDir.c_str(),&Buf) != 0) {
+ if (errno == EOVERFLOW)
+ return _error->WarningE("statvfs",_("Couldn't determine free space in %s"),
+ OutputDir.c_str());
+ else
+ return _error->Errno("statvfs",_("Couldn't determine free space in %s"),
+ OutputDir.c_str());
+ } else if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize)
{
struct statfs Stat;
- if (statfs(OutputDir.c_str(),&Stat) != 0 ||
- unsigned(Stat.f_type) != RAMFS_MAGIC)
+ if (statfs(OutputDir.c_str(),&Stat) != 0
+#if HAVE_STRUCT_STATFS_F_TYPE
+ || unsigned(Stat.f_type) != RAMFS_MAGIC
+#endif
+ )
return _error->Error(_("You don't have enough free space in %s."),
OutputDir.c_str());
}
@@ -1044,17 +1053,42 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache,
pkgProblemResolver &Fix,bool Remove,bool BrokenFix,
unsigned int &ExpectedInst,bool AllowFail = true)
{
- /* This is a pure virtual package and there is a single available
- provides */
- if (Cache[Pkg].CandidateVer == 0 && Pkg->ProvidesList != 0 &&
- Pkg.ProvidesList()->NextProvides == 0)
+ /* This is a pure virtual package and there is a single available
+ candidate providing it. */
+ if (Cache[Pkg].CandidateVer == 0 && Pkg->ProvidesList != 0)
{
- pkgCache::PkgIterator Tmp = Pkg.ProvidesList().OwnerPkg();
- ioprintf(c1out,_("Note, selecting %s instead of %s\n"),
- Tmp.Name(),Pkg.Name());
- Pkg = Tmp;
+ pkgCache::PkgIterator Prov;
+ bool found_one = false;
+
+ for (pkgCache::PrvIterator P = Pkg.ProvidesList(); P; P++)
+ {
+ pkgCache::VerIterator const PVer = P.OwnerVer();
+ pkgCache::PkgIterator const PPkg = PVer.ParentPkg();
+
+ /* Ignore versions that are not a candidate. */
+ if (Cache[PPkg].CandidateVer != PVer)
+ continue;
+
+ if (found_one == false)
+ {
+ Prov = PPkg;
+ found_one = true;
+ }
+ else if (PPkg != Prov)
+ {
+ found_one = false; // we found at least two
+ break;
+ }
+ }
+
+ if (found_one == true)
+ {
+ ioprintf(c1out,_("Note, selecting %s instead of %s\n"),
+ Prov.Name(),Pkg.Name());
+ Pkg = Prov;
+ }
}
-
+
// Handle the no-upgrade case
if (_config->FindB("APT::Get::upgrade",true) == false &&
Pkg->CurrentVer != 0)
@@ -1213,129 +1247,155 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
pkgSrcRecords &SrcRecs,string &Src,
pkgDepCache &Cache)
{
- // We want to pull the version off the package specification..
string VerTag;
+ string DefRel = _config->Find("APT::Default-Release");
string TmpSrc = Name;
- string::size_type Slash = TmpSrc.rfind('=');
- // honor default release
- string DefRel = _config->Find("APT::Default-Release");
- pkgCache::PkgIterator Pkg = Cache.FindPkg(TmpSrc);
+ // extract the version/release from the pkgname
+ const size_t found = TmpSrc.find_last_of("/=");
+ if (found != string::npos) {
+ if (TmpSrc[found] == '/')
+ DefRel = TmpSrc.substr(found+1);
+ else
+ VerTag = TmpSrc.substr(found+1);
+ TmpSrc = TmpSrc.substr(0,found);
+ }
- if (Slash != string::npos)
- {
- VerTag = string(TmpSrc.begin() + Slash + 1,TmpSrc.end());
- TmpSrc = string(TmpSrc.begin(),TmpSrc.begin() + Slash);
- }
- else if(!Pkg.end() && DefRel.empty() == false)
+ /* 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. */
+ bool MatchSrcOnly = _config->FindB("APT::Get::Only-Source");
+ const pkgCache::PkgIterator Pkg = Cache.FindPkg(TmpSrc);
+ if (MatchSrcOnly == false && Pkg.end() == 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++)
+ if(VerTag.empty() == false || DefRel.empty() == false)
{
- for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false;
- VF++)
+ // 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++)
{
- /* 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() && (VF.File().Archive() == DefRel))
+ for (pkgCache::VerFileIterator VF = Ver.FileList();
+ VF.end() == false; VF++)
{
- VerTag = Ver.VerStr();
- break;
+ /* 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;
+
+ // We match against a concrete version (or a part of this version)
+ if (VerTag.empty() == false && strncmp(VerTag.c_str(), Ver.VerStr(), VerTag.size()) != 0)
+ continue;
+
+ // or we match against a release
+ if(VerTag.empty() == false ||
+ (VF.File().Archive() != 0 && VF.File().Archive() == DefRel) ||
+ (VF.File().Codename() != 0 && VF.File().Codename() == DefRel))
+ {
+ pkgRecords::Parser &Parse = Recs.Lookup(VF);
+ Src = Parse.SourcePkg();
+ // no SourcePkg name, so it is the "binary" name
+ if (Src.empty() == true)
+ Src = TmpSrc;
+ // no Version, so we try the Version of the SourcePkg -
+ // and after that the version of the binary package
+ if (VerTag.empty() == true)
+ VerTag = Parse.SourceVer();
+ if (VerTag.empty() == true)
+ VerTag = Ver.VerStr();
+ break;
+ }
}
+ if (Src.empty() == false)
+ break;
+ }
+ if (Src.empty() == true)
+ {
+ // Sources files have no codename information
+ if (VerTag.empty() == true && DefRel.empty() == false)
+ _error->Warning(_("Ignore unavailable target release '%s' of package '%s'"), DefRel.c_str(), TmpSrc.c_str());
+ DefRel.clear();
}
}
- }
-
- /* 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)
- {
- if (Pkg.end() == false)
+ if (Src.empty() == true)
{
+ // if we don't have found a fitting package yet so we will
+ // choose a good candidate and proceed with that.
+ // Maybe we will find a source later on with the right VerTag
pkgCache::VerIterator Ver = Cache.GetCandidateVer(Pkg);
- if (Ver.end() == false)
+ if (Ver.end() == false)
{
pkgRecords::Parser &Parse = Recs.Lookup(Ver.FileList());
Src = Parse.SourcePkg();
+ if (VerTag.empty() == true)
+ VerTag = Parse.SourceVer();
}
- }
+ }
+ }
+
+ 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 (Src != TmpSrc)
+ {
+ ioprintf(c1out, _("Picking '%s' as source package instead of '%s'\n"), Src.c_str(), TmpSrc.c_str());
+ }
}
// The best hit
pkgSrcRecords::Parser *Last = 0;
unsigned long Offset = 0;
string Version;
- bool IsMatch = false;
- bool MatchSrcOnly = 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)
- IsMatch = true;
-
/* Iterate over all of the hits, which includes the resulting
binary packages in the search */
pkgSrcRecords::Parser *Parse;
- SrcRecs.Restart();
- while ((Parse = SrcRecs.Find(Src.c_str(), MatchSrcOnly)) != 0)
+ while (true)
{
- string Ver = Parse->Version();
-
- // 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)
+ SrcRecs.Restart();
+ while ((Parse = SrcRecs.Find(Src.c_str(), MatchSrcOnly)) != 0)
{
- /* Don't want to fall through because we are doing exact version
- matching. */
- if (Cache.VS().CmpVersion(VerTag,Ver) != 0)
+ const string Ver = Parse->Version();
+
+ // Ignore all versions which doesn't fit
+ if (VerTag.empty() == false && strncmp(VerTag.c_str(), Ver.c_str(), VerTag.size()) != 0)
continue;
-
- Last = Parse;
- Offset = Parse->Offset();
- break;
+
+ // Newer version or an exact match? Save the hit
+ if (Last == 0 || Cache.VS().CmpVersion(Version,Ver) < 0) {
+ Last = Parse;
+ Offset = Parse->Offset();
+ Version = Ver;
+ }
+
+ // was the version check above an exact match? If so, we don't need to look further
+ if (VerTag.empty() == false && VerTag.size() == Ver.size())
+ break;
}
-
- // Newer version or an exact match
- if (Last == 0 || Cache.VS().CmpVersion(Version,Ver) < 0 ||
- (Parse->Package() == Src && IsMatch == false))
- {
- IsMatch = Parse->Package() == Src;
- Last = Parse;
- Offset = Parse->Offset();
- Version = Ver;
- }
+ if (Last != 0 || VerTag.empty() == true)
+ break;
+ //if (VerTag.empty() == false && Last == 0)
+ _error->Warning(_("Ignore unavailable version '%s' of package '%s'"), VerTag.c_str(), TmpSrc.c_str());
+ VerTag.clear();
}
-
+
if (Last == 0 || Last->Jump(Offset) == false)
return 0;
-
+
return Last;
}
/*}}}*/
-
// DoUpdate - Update the package lists /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -1399,20 +1459,29 @@ bool DoAutomaticRemove(CacheFile &Cache)
bool Debug = _config->FindI("Debug::pkgAutoRemove",false);
bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove", false);
bool hideAutoRemove = _config->FindB("APT::Get::HideAutoRemove");
- pkgDepCache::ActionGroup group(*Cache);
+ pkgDepCache::ActionGroup group(*Cache);
if(Debug)
std::cout << "DoAutomaticRemove()" << std::endl;
- if (_config->FindB("APT::Get::Remove",true) == false &&
- doAutoRemove == true)
+ // we don't want to autoremove and we don't want to see it, so why calculating?
+ if (doAutoRemove == false && hideAutoRemove == true)
+ return true;
+
+ if (doAutoRemove == true &&
+ _config->FindB("APT::Get::Remove",true) == false)
{
c1out << _("We are not supposed to delete stuff, can't start "
"AutoRemover") << std::endl;
- doAutoRemove = false;
+ return false;
}
+ bool purgePkgs = _config->FindB("APT::Get::Purge", false);
+ bool smallList = (hideAutoRemove == false &&
+ strcasecmp(_config->Find("APT::Get::HideAutoRemove","").c_str(),"small") == 0);
+
string autoremovelist, autoremoveversions;
+ unsigned long autoRemoveCount = 0;
// look over the cache to see what can be removed
for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg)
{
@@ -1421,30 +1490,43 @@ bool DoAutomaticRemove(CacheFile &Cache)
if(Pkg.CurrentVer() != 0 || Cache[Pkg].Install())
if(Debug)
std::cout << "We could delete %s" << Pkg.Name() << std::endl;
-
- // only show stuff in the list that is not yet marked for removal
- if(Cache[Pkg].Delete() == false)
- {
- autoremovelist += string(Pkg.Name()) + " ";
- autoremoveversions += string(Cache[Pkg].CandVersion) + "\n";
- }
+
if (doAutoRemove)
{
if(Pkg.CurrentVer() != 0 &&
Pkg->CurrentState != pkgCache::State::ConfigFiles)
- Cache->MarkDelete(Pkg, _config->FindB("APT::Get::Purge", false));
+ Cache->MarkDelete(Pkg, purgePkgs);
else
Cache->MarkKeep(Pkg, false, false);
}
+ else
+ {
+ // only show stuff in the list that is not yet marked for removal
+ if(Cache[Pkg].Delete() == false)
+ {
+ // we don't need to fill the strings if we don't need them
+ if (smallList == true)
+ ++autoRemoveCount;
+ else
+ {
+ autoremovelist += string(Pkg.Name()) + " ";
+ autoremoveversions += string(Cache[Pkg].CandVersion) + "\n";
+ }
+ }
+ }
}
}
- if (!hideAutoRemove)
- ShowList(c1out, _("The following packages were automatically installed and are no longer required:"), autoremovelist, autoremoveversions);
- if (!doAutoRemove && !hideAutoRemove && autoremovelist.size() > 0)
+ // if we don't remove them, we should show them!
+ if (doAutoRemove == false && (autoremovelist.empty() == false || autoRemoveCount != 0))
+ {
+ if (smallList == false)
+ ShowList(c1out, _("The following packages were automatically installed and are no longer required:"), autoremovelist, autoremoveversions);
+ else
+ ioprintf(c1out, _("%lu packages were automatically installed and are no longer required.\n"), autoRemoveCount);
c1out << _("Use 'apt-get autoremove' to remove them.") << std::endl;
-
- // Now see if we destroyed anything
- if (Cache->BrokenCount() != 0)
+ }
+ // Now see if we had destroyed anything (if we had done anything)
+ else if (Cache->BrokenCount() != 0)
{
c1out << _("Hmm, seems like the AutoRemover destroyed something which really\n"
"shouldn't happen. Please file a bug report against apt.") << endl;
@@ -1457,7 +1539,7 @@ bool DoAutomaticRemove(CacheFile &Cache)
}
return true;
}
-
+ /*}}}*/
// DoUpgrade - Upgrade all packages /*{{{*/
// ---------------------------------------------------------------------
/* Upgrade all packages without installing new packages or erasing old
@@ -1532,7 +1614,7 @@ bool TryInstallTask(pkgDepCache &Cache, pkgProblemResolver &Fix,
regfree(&Pattern);
return res;
}
-
+ /*}}}*/
// DoInstall - Install packages from the command line /*{{{*/
// ---------------------------------------------------------------------
/* Install named packages */
@@ -1870,7 +1952,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
@@ -2171,14 +2254,21 @@ bool DoSource(CommandLine &CmdL)
// Check for enough free space
struct statvfs Buf;
string OutputDir = ".";
- if (statvfs(OutputDir.c_str(),&Buf) != 0)
- return _error->Errno("statvfs",_("Couldn't determine free space in %s"),
- OutputDir.c_str());
- if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize)
+ if (statvfs(OutputDir.c_str(),&Buf) != 0) {
+ if (errno == EOVERFLOW)
+ return _error->WarningE("statvfs",_("Couldn't determine free space in %s"),
+ OutputDir.c_str());
+ else
+ return _error->Errno("statvfs",_("Couldn't determine free space in %s"),
+ OutputDir.c_str());
+ } else if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize)
{
struct statfs Stat;
- if (statfs(OutputDir.c_str(),&Stat) != 0 ||
- unsigned(Stat.f_type) != RAMFS_MAGIC)
+ if (statfs(OutputDir.c_str(),&Stat) != 0
+#if HAVE_STRUCT_STATFS_F_TYPE
+ || unsigned(Stat.f_type) != RAMFS_MAGIC
+#endif
+ )
return _error->Error(_("You don't have enough free space in %s"),
OutputDir.c_str());
}
@@ -2522,7 +2612,7 @@ bool DoBuildDep(CommandLine &CmdL)
{
// We successfully installed something; skip remaining alternatives
skipAlternatives = hasAlternatives;
- if(_config->FindB("APT::Get::Build-Dep-Automatic", true) == true)
+ if(_config->FindB("APT::Get::Build-Dep-Automatic", false) == true)
Cache->MarkAuto(Pkg, true);
continue;
}
@@ -2548,7 +2638,10 @@ bool DoBuildDep(CommandLine &CmdL)
// Now we check the state of the packages,
if (Cache->BrokenCount() != 0)
- return _error->Error(_("Build-dependencies for %s could not be satisfied."),*I);
+ {
+ ShowBroken(cout, Cache, false);
+ return _error->Error(_("Build-dependencies for %s could not be satisfied."),*I);
+ }
}
if (InstallPackages(Cache, false, true) == false)
@@ -2698,8 +2791,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},
@@ -2729,6 +2821,7 @@ int main(int argc,const char *argv[])
{0,"force-yes","APT::Get::force-yes",0},
{0,"print-uris","APT::Get::Print-URIs",0},
{0,"diff-only","APT::Get::Diff-Only",0},
+ {0,"debian-only","APT::Get::Diff-Only",0},
{0,"tar-only","APT::Get::Tar-Only",0},
{0,"dsc-only","APT::Get::Dsc-Only",0},
{0,"purge","APT::Get::Purge",0},
@@ -2739,7 +2832,6 @@ int main(int argc,const char *argv[])
{0,"only-source","APT::Get::Only-Source",0},
{0,"arch-only","APT::Get::Arch-Only",0},
{0,"auto-remove","APT::Get::AutomaticRemove",0},
- {0,"build-dep-automatic","APT::Get::Build-Dep-Automatic",0},
{0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0},
{0,"install-recommends","APT::Install-Recommends",CommandLine::Boolean},
{0,"fix-policy","APT::Get::Fix-Policy-Broken",0},
@@ -2789,7 +2881,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");
@@ -2821,3 +2925,4 @@ int main(int argc,const char *argv[])
return 0;
}
+ /*}}}*/
diff --git a/cmdline/apt-key b/cmdline/apt-key
index 7bb30240e..5f4e02fdf 100755
--- a/cmdline/apt-key
+++ b/cmdline/apt-key
@@ -93,13 +93,17 @@ update() {
# add any security. we *need* this check on net-update though
$GPG_CMD --quiet --batch --keyring $ARCHIVE_KEYRING --export | $GPG --import
- # remove no-longer supported/used keys
- keys=`$GPG_CMD --keyring $REMOVED_KEYS --with-colons --list-keys | grep ^pub | cut -d: -f5`
- for key in $keys; do
- if $GPG --list-keys --with-colons | grep ^pub | cut -d: -f5 | grep -q $key; then
- $GPG --quiet --batch --delete-key --yes ${key}
- fi
- done
+ if [ -r "$REMOVED_KEYS" ]; then
+ # remove no-longer supported/used keys
+ keys=`$GPG_CMD --keyring $REMOVED_KEYS --with-colons --list-keys | grep ^pub | cut -d: -f5`
+ for key in $keys; do
+ if $GPG --list-keys --with-colons | grep ^pub | cut -d: -f5 | grep -q $key; then
+ $GPG --quiet --batch --delete-key --yes ${key}
+ fi
+ done
+ else
+ echo "Warning: removed keys keyring $REMOVED_KEYS missing or not readable" >&2
+ fi
}
diff --git a/cmdline/apt-mark b/cmdline/apt-mark
index 226d2079b..3a818a3db 100755
--- a/cmdline/apt-mark
+++ b/cmdline/apt-mark
@@ -2,13 +2,14 @@
from optparse import OptionParser
+import sys
+import os.path
+
try:
import apt_pkg
except ImportError:
print "Error importing apt_pkg, is python-apt installed?"
-
-import sys
-import os.path
+ sys.exit(1)
actions = { "markauto" : 1,
"unmarkauto": 0
@@ -31,8 +32,12 @@ def mark_unmark_automatic(filename, action, pkgs):
" mark or unmark automatic flag"
# open the statefile
if os.path.exists(STATE_FILE):
- tagfile = apt_pkg.ParseTagFile(open(STATE_FILE))
- outfile = open(STATE_FILE+".tmp","w")
+ try:
+ tagfile = apt_pkg.ParseTagFile(open(STATE_FILE))
+ outfile = open(STATE_FILE+".tmp","w")
+ except IOError, msg:
+ print "%s, are you root?" % (msg)
+ sys.exit(1)
while tagfile.Step():
pkgname = tagfile.Section.get("Package")
autoInst = tagfile.Section.get("Auto-Installed")
diff --git a/cmdline/apt-sortpkgs.cc b/cmdline/apt-sortpkgs.cc
index 7b2a74aed..171b0ba13 100644
--- a/cmdline/apt-sortpkgs.cc
+++ b/cmdline/apt-sortpkgs.cc
@@ -31,7 +31,7 @@
using namespace std;
-struct PkgName
+struct PkgName /*{{{*/
{
string Name;
string Ver;
@@ -55,7 +55,7 @@ struct PkgName
bool operator >(const PkgName &x) const {return Compare3(x) > 0;};
bool operator ==(const PkgName &x) const {return Compare3(x) == 0;};
};
-
+ /*}}}*/
// DoIt - Sort a single file /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -161,8 +161,7 @@ int ShowHelp()
return 0;
}
/*}}}*/
-
-int main(int argc,const char *argv[])
+int main(int argc,const char *argv[]) /*{{{*/
{
CommandLine::Args Args[] = {
{'h',"help","help",0},
@@ -206,3 +205,4 @@ int main(int argc,const char *argv[])
return 0;
}
+ /*}}}*/