X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/1bc849af8f694ab80887bd0e9b94280f78771dbc..2b154e536a0df3afb318ddcf9b7daf9337de3c23:/cmdline/apt-get.cc diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 1225ece96..da364e03c 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: apt-get.cc,v 1.38 1999/02/01 08:11:57 jgg Exp $ +// $Id: apt-get.cc,v 1.43 1999/02/21 08:38:53 jgg Exp $ /* ###################################################################### apt-get - Cover for dpkg @@ -46,7 +46,9 @@ #include #include #include +#include #include +#include #include /*}}}*/ @@ -521,7 +523,8 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true) // Create the package manager and prepare to download pkgDPkgPM PM(Cache); - if (PM.GetArchives(&Fetcher,&List,&Recs) == false) + if (PM.GetArchives(&Fetcher,&List,&Recs) == false || + _error->PendingError() == true) return false; // Display statistics @@ -532,21 +535,31 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true) c0out << DebBytes << ',' << Cache->DebSize() << endl; c0out << "How odd.. The sizes didn't match, email apt@packages.debian.org" << endl; } - + + // Check for enough free space + struct statfs Buf; + string OutputDir = _config->FindDir("Dir::Cache::Archives"); + if (statfs(OutputDir.c_str(),&Buf) != 0) + return _error->Errno("statfs","Couldn't determine free space in %s", + OutputDir.c_str()); + if (unsigned(Buf.f_bfree) < FetchBytes/Buf.f_bsize) + return _error->Error("Sorry, you don't have enough free space in %s", + OutputDir.c_str()); + // Number of bytes - c2out << "Need to get "; + c1out << "Need to get "; if (DebBytes != FetchBytes) - c2out << SizeToStr(FetchBytes) << "b/" << SizeToStr(DebBytes) << 'b'; + c1out << SizeToStr(FetchBytes) << "b/" << SizeToStr(DebBytes) << 'b'; else - c2out << SizeToStr(DebBytes) << 'b'; + c1out << SizeToStr(DebBytes) << 'b'; c1out << " of archives. After unpacking "; // Size delta if (Cache->UsrSize() >= 0) - c2out << SizeToStr(Cache->UsrSize()) << "b will be used." << endl; + c1out << SizeToStr(Cache->UsrSize()) << "b will be used." << endl; else - c2out << SizeToStr(-1*Cache->UsrSize()) << "b will be freed." << endl; + c1out << SizeToStr(-1*Cache->UsrSize()) << "b will be freed." << endl; if (_error->PendingError() == true) return false; @@ -773,11 +786,13 @@ bool DoInstall(CommandLine &CmdL) pkgCache::PkgIterator Pkg = I.OwnerPkg(); if ((*Cache)[Pkg].CandidateVerIter(*Cache) == I.OwnerVer()) - c1out << " " << Pkg.Name() << " " << I.OwnerVer().VerStr() << endl; - - if ((*Cache)[Pkg].InstVerIter(*Cache) == I.OwnerVer()) - c1out << " " << Pkg.Name() << " " << I.OwnerVer().VerStr() << - " [Installed]"<< endl; + { + if ((*Cache)[Pkg].Install() == true && (*Cache)[Pkg].NewInstall() == false) + c1out << " " << Pkg.Name() << " " << I.OwnerVer().VerStr() << + " [Installed]"<< endl; + else + c1out << " " << Pkg.Name() << " " << I.OwnerVer().VerStr() << endl; + } } c1out << "You should explicly select one to install." << endl; } @@ -999,20 +1014,22 @@ bool DoClean(CommandLine &CmdL) // --------------------------------------------------------------------- /* This is similar to clean but it only purges things that cannot be downloaded, that is old versions of cached packages. */ +class LogCleaner : public pkgArchiveCleaner +{ + protected: + virtual void Erase(const char *File,string Pkg,string Ver,struct stat &St) + { + cout << "Del " << Pkg << " " << Ver << " [" << SizeToStr(St.st_size) << "b]" << endl; + }; +}; + bool DoAutoClean(CommandLine &CmdL) { CacheFile Cache; if (Cache.Open(true) == false) return false; - class LogCleaner : public pkgArchiveCleaner - { - protected: - virtual void Erase(const char *File,string Pkg,string Ver,struct stat &St) - { - cout << "Del " << Pkg << " " << Ver << " [" << SizeToStr(St.st_size) << "b]" << endl; - }; - } Cleaner; + LogCleaner Cleaner; return Cleaner.Go(_config->FindDir("Dir::Cache::archives"),*Cache) && Cleaner.Go(_config->FindDir("Dir::Cache::archives") + "partial/",*Cache);