summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/acquire-item.cc56
-rw-r--r--apt-pkg/acquire-item.h3
-rw-r--r--apt-pkg/acquire.cc33
-rw-r--r--apt-pkg/acquire.h8
-rw-r--r--apt-pkg/algorithms.cc4
-rw-r--r--apt-pkg/depcache.h30
-rw-r--r--cmdline/apt-get.cc60
7 files changed, 159 insertions, 35 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index ef5863646..532d4e6f2 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire-item.cc,v 1.11 1998/11/13 04:23:26 jgg Exp $
+// $Id: acquire-item.cc,v 1.12 1998/11/13 07:08:48 jgg Exp $
/* ######################################################################
Acquire Item - Item to acquire
@@ -32,7 +32,8 @@
// ---------------------------------------------------------------------
/* */
pkgAcquire::Item::Item(pkgAcquire *Owner) : Owner(Owner), FileSize(0),
- Mode(0), ID(0), Complete(false), QueueCounter(0)
+ Mode(0), ID(0), Complete(false), Local(false),
+ QueueCounter(0)
{
Owner->Add(this);
Status = StatIdle;
@@ -192,7 +193,7 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5)
return;
Decompression = true;
- FileSize = 0;
+ Local = true;
DestFile += ".decomp";
Desc.URI = "copy:" + FileName;
QueueURI(Desc);
@@ -214,7 +215,7 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5)
if (FileName == DestFile)
Erase = true;
else
- FileSize = 0;
+ Local = true;
Decompression = true;
DestFile += ".decomp";
@@ -289,7 +290,7 @@ void pkgAcqIndexRel::Done(string Message,unsigned long Size,string MD5)
// We have to copy it into place
if (FileName != DestFile)
{
- FileSize = 0;
+ Local = true;
Desc.URI = "copy:" + FileName;
QueueURI(Desc);
return;
@@ -341,6 +342,29 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
Version.ParentPkg().Name());
return;
}
+
+ // See if we already have the file.
+ FileSize = Version->Size;
+ string FinalFile = _config->FindDir("Dir::Cache::Archives") + flNotDir(PkgFile);
+ struct stat Buf;
+ if (stat(FinalFile.c_str(),&Buf) == 0)
+ {
+ // Make sure the size matches
+ if ((unsigned)Buf.st_size == Version->Size)
+ {
+ Complete = true;
+ Local = true;
+ Status = StatDone;
+ DestFile = FinalFile;
+ return;
+ }
+
+ /* Hmm, we have a file and its size does not match, this shouldnt
+ happen.. */
+ unlink(FinalFile.c_str());
+ }
+
+ DestFile = _config->FindDir("Dir::Cache::Archives") + "partial/" + flNotDir(PkgFile);
// Create the item
Desc.URI = Location->ArchiveURI(PkgFile);
@@ -349,7 +373,6 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
Desc.ShortDesc = Version.ParentPkg().Name();
QueueURI(Desc);
- DestFile = _config->FindDir("Dir::Cache::Archives") + "partial/" + flNotDir(PkgFile);
return;
}
@@ -381,8 +404,8 @@ void pkgAcqArchive::Done(string Message,unsigned long Size,string Md5Hash)
return;
}
}
-
- // Store the destination filename
+
+ // Grab the output filename
string FileName = LookupTag(Message,"Filename");
if (FileName.empty() == true)
{
@@ -390,8 +413,23 @@ void pkgAcqArchive::Done(string Message,unsigned long Size,string Md5Hash)
ErrorText = "Method gave a blank filename";
return;
}
+
+ Complete = true;
+
+ // We have to copy it into place
+ if (FileName != DestFile)
+ {
+ DestFile = FileName;
+ Local = true;
+ return;
+ }
+
+ // Done, move it into position
+ string FinalFile = _config->FindDir("Dir::Cache::Archives");
+ FinalFile += flNotDir(DestFile);
+ Rename(DestFile,FinalFile);
- DestFile = FileName;
+ DestFile = FinalFile;
Complete = true;
}
/*}}}*/
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index 2de1e409e..67e202355 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire-item.h,v 1.8 1998/11/13 04:23:28 jgg Exp $
+// $Id: acquire-item.h,v 1.9 1998/11/13 07:08:50 jgg Exp $
/* ######################################################################
Acquire Item - Item to acquire
@@ -45,6 +45,7 @@ class pkgAcquire::Item
char *Mode;
unsigned long ID;
bool Complete;
+ bool Local;
// Number of queues we are inserted into
unsigned int QueueCounter;
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 972a466c5..9a546c7e2 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire.cc,v 1.14 1998/11/12 04:10:54 jgg Exp $
+// $Id: acquire.cc,v 1.15 1998/11/13 07:08:54 jgg Exp $
/* ######################################################################
Acquire - File Acquiration
@@ -344,7 +344,7 @@ pkgAcquire::Worker *pkgAcquire::WorkerStep(Worker *I)
return I->NextAcquire;
};
/*}}}*/
-// pkgAcquire::Clean - Cleans a directory /*{{{*/
+// Acquire::Clean - Cleans a directory /*{{{*/
// ---------------------------------------------------------------------
/* This is a bit simplistic, it looks at every file in the dir and sees
if it is part of the download set. */
@@ -398,6 +398,29 @@ pkgAcquire::MethodConfig::MethodConfig()
Next = 0;
}
/*}}}*/
+// Acquire::TotalNeeded - Number of bytes to fetch /*{{{*/
+// ---------------------------------------------------------------------
+/* This is the total number of bytes needed */
+unsigned long pkgAcquire::TotalNeeded()
+{
+ unsigned long Total = 0;
+ for (pkgAcquire::Item **I = ItemsBegin(); I != ItemsEnd(); I++)
+ Total += (*I)->FileSize;
+ return Total;
+}
+ /*}}}*/
+// Acquire::FetchNeeded - Number of bytes needed to get /*{{{*/
+// ---------------------------------------------------------------------
+/* This is the number of bytes that is not local */
+unsigned long pkgAcquire::FetchNeeded()
+{
+ unsigned long Total = 0;
+ for (pkgAcquire::Item **I = ItemsBegin(); I != ItemsEnd(); I++)
+ if ((*I)->Local == false)
+ Total += (*I)->FileSize;
+ return Total;
+}
+ /*}}}*/
// Queue::Queue - Constructor /*{{{*/
// ---------------------------------------------------------------------
@@ -587,6 +610,10 @@ void pkgAcquireStatus::Pulse(pkgAcquire *Owner)
for (pkgAcquire::Item **I = Owner->ItemsBegin(); I != Owner->ItemsEnd();
I++, Count++)
{
+ // Totally ignore local items
+ if ((*I)->Local == true)
+ continue;
+
TotalBytes += (*I)->FileSize;
if ((*I)->Complete == true)
CurrentBytes += (*I)->FileSize;
@@ -648,7 +675,7 @@ void pkgAcquireStatus::Start()
ElapsedTime = 0;
}
/*}}}*/
-// pkgAcquireStatus::Stop - Finished downloading /*{{{*/
+// AcquireStatus::Stop - Finished downloading /*{{{*/
// ---------------------------------------------------------------------
/* This accurately computes the elapsed time and the total overall CPS. */
void pkgAcquireStatus::Stop()
diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h
index c85a7aef7..036a497f4 100644
--- a/apt-pkg/acquire.h
+++ b/apt-pkg/acquire.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire.h,v 1.11 1998/11/12 04:10:55 jgg Exp $
+// $Id: acquire.h,v 1.12 1998/11/13 07:08:55 jgg Exp $
/* ######################################################################
Acquire - File Acquiration
@@ -101,6 +101,10 @@ class pkgAcquire
// Cleans out the download dir
bool Clean(string Dir);
+
+ // Returns the size of the total download set
+ unsigned long TotalNeeded();
+ unsigned long FetchNeeded();
pkgAcquire(pkgAcquireStatus *Log = 0);
~pkgAcquire();
@@ -210,7 +214,7 @@ class pkgAcquireStatus
virtual void Pulse(pkgAcquire *Owner);
virtual void Start();
virtual void Stop();
-
+
pkgAcquireStatus();
virtual ~pkgAcquireStatus() {};
};
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index 350b57468..a65062a9b 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: algorithms.cc,v 1.8 1998/10/24 04:58:04 jgg Exp $
+// $Id: algorithms.cc,v 1.9 1998/11/13 07:08:57 jgg Exp $
/* ######################################################################
Algorithms - A set of misc algorithms
@@ -644,7 +644,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
{
if (Debug == true)
clog << " Try to Re-Instate " << I.Name() << endl;
- int OldBreaks = Cache.BrokenCount();
+ unsigned long OldBreaks = Cache.BrokenCount();
pkgCache::Version *OldVer = Cache[I].InstallVer;
Flags[I->ID] &= ReInstateTried;
diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h
index bd64ee5a2..62ab2d8c3 100644
--- a/apt-pkg/depcache.h
+++ b/apt-pkg/depcache.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: depcache.h,v 1.5 1998/10/02 04:39:45 jgg Exp $
+// $Id: depcache.h,v 1.6 1998/11/13 07:08:58 jgg Exp $
/* ######################################################################
DepCache - Dependency Extension data for the cache
@@ -118,13 +118,13 @@ class pkgDepCache : public pkgCache
StateCache *PkgState;
unsigned char *DepState;
- long iUsrSize;
- long iDownloadSize;
- long iInstCount;
- long iDelCount;
- long iKeepCount;
- long iBrokenCount;
- long iBadCount;
+ signed long iUsrSize;
+ unsigned long iDownloadSize;
+ unsigned long iInstCount;
+ unsigned long iDelCount;
+ unsigned long iKeepCount;
+ unsigned long iBrokenCount;
+ unsigned long iBadCount;
// Check for a matching provides
bool CheckDep(DepIterator Dep,int Type,PkgIterator &Res);
@@ -169,13 +169,13 @@ class pkgDepCache : public pkgCache
void Update(OpProgress *Prog = 0);
// Size queries
- inline long UsrSize() {return iUsrSize;};
- inline long DebSize() {return iDownloadSize;};
- inline long DelCount() {return iDelCount;};
- inline long KeepCount() {return iKeepCount;};
- inline long InstCount() {return iInstCount;};
- inline long BrokenCount() {return iBrokenCount;};
- inline long BadCount() {return iBadCount;};
+ inline signed long UsrSize() {return iUsrSize;};
+ inline unsigned long DebSize() {return iDownloadSize;};
+ inline unsigned long DelCount() {return iDelCount;};
+ inline unsigned long KeepCount() {return iKeepCount;};
+ inline unsigned long InstCount() {return iInstCount;};
+ inline unsigned long BrokenCount() {return iBrokenCount;};
+ inline unsigned long BadCount() {return iBadCount;};
pkgDepCache(MMap &Map,OpProgress &Prog);
virtual ~pkgDepCache();
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 85373d874..cc73339fd 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.9 1998/11/13 04:24:03 jgg Exp $
+// $Id: apt-get.cc,v 1.10 1998/11/13 07:09:02 jgg Exp $
/* ######################################################################
apt-get - Cover for dpkg
@@ -34,6 +34,7 @@
#include <apt-pkg/algorithms.h>
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/dpkgpm.h>
+#include <strutl.h>
#include <config.h>
@@ -51,6 +52,27 @@ ostream c2out;
ofstream devnull("/dev/null");
unsigned int ScreenWidth = 80;
+// YnPrompt - Yes No Prompt. /*{{{*/
+// ---------------------------------------------------------------------
+/* Returns true on a Yes.*/
+bool YnPrompt()
+{
+ if (_config->FindB("APT::Get::Assume-Yes",false) == true)
+ {
+ c2out << 'Y' << endl;
+ return true;
+ }
+
+ char C = 0;
+ char Jnk = 0;
+ read(STDIN_FILENO,&C,1);
+ while (C != '\n' && Jnk != '\n') read(STDIN_FILENO,&Jnk,1);
+
+ if (!(C == 'Y' || C == 'y' || C == '\n' || C == '\r'))
+ return false;
+ return true;
+}
+ /*}}}*/
// ShowList - Show a list /*{{{*/
// ---------------------------------------------------------------------
/* This prints out a string of space seperated words with a title and
@@ -424,6 +446,7 @@ bool CacheFile::Open()
happen and then calls the download routines */
bool InstallPackages(pkgDepCache &Cache,bool ShwKept,bool Ask = true)
{
+ // Show all the various warning indicators
ShowDel(c1out,Cache);
ShowNew(c1out,Cache);
if (ShwKept == true)
@@ -469,6 +492,37 @@ bool InstallPackages(pkgDepCache &Cache,bool ShwKept,bool Ask = true)
if (PM.GetArchives(&Fetcher,&List,&Recs) == false)
return false;
+ unsigned long FetchBytes = Fetcher.FetchNeeded();
+ unsigned long DebBytes = Fetcher.TotalNeeded();
+ if (DebBytes != Cache.DebSize())
+ c0out << "How odd.. The sizes didn't match, email apt@packages.debian.org" << endl;
+
+ c1out << "Need to get ";
+ if (DebBytes != FetchBytes)
+ c1out << SizeToStr(FetchBytes) << '/' << SizeToStr(DebBytes);
+ else
+ c1out << SizeToStr(DebBytes);
+
+ c1out << " of archives. After unpacking ";
+
+ if (Cache.UsrSize() >= 0)
+ c1out << SizeToStr(Cache.UsrSize()) << " will be used." << endl;
+ else
+ c1out << SizeToStr(-1*Cache.UsrSize()) << " will be freed." << endl;
+
+ if (_error->PendingError() == true)
+ return false;
+
+ if (Ask == true)
+ {
+
+ if (_config->FindI("quiet",0) < 2 ||
+ _config->FindB("APT::Get::Assume-Yes",false) == false)
+ c2out << "Do you want to continue? [Y/n] " << flush;
+ if (YnPrompt() == false)
+ exit(1);
+ }
+
// Run it
if (Fetcher.Run() == false)
return false;
@@ -546,8 +600,8 @@ bool DoInstall(CommandLine &CmdL)
if (Cache.Open() == false)
return false;
- int ExpectedInst = 0;
- int Packages = 0;
+ unsigned int ExpectedInst = 0;
+ unsigned int Packages = 0;
pkgProblemResolver Fix(Cache);
bool DefRemove = false;