// -*- 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
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
+#include <sys/vfs.h>
#include <signal.h>
+#include <unistd.h>
#include <stdio.h>
/*}}}*/
// 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
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;
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;
}
// ---------------------------------------------------------------------
/* 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);