summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/apt-cache.cc100
-rw-r--r--cmdline/apt-get.cc34
2 files changed, 50 insertions, 84 deletions
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index cb1aeb514..0014563b8 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -71,12 +71,6 @@ void LocalitySort(pkgCache::VerFile **begin,
{
qsort(begin,Count,Size,LocalityCompare);
}
-
-void LocalitySort(pkgCache::DescFile **begin,
- unsigned long Count,size_t Size)
-{
- qsort(begin,Count,Size,LocalityCompare);
-}
/*}}}*/
// UnMet - Show unmet dependencies /*{{{*/
// ---------------------------------------------------------------------
@@ -188,14 +182,7 @@ bool DumpPackage(CommandLine &CmdL)
{
cout << Cur.VerStr();
for (pkgCache::VerFileIterator Vf = Cur.FileList(); Vf.end() == false; Vf++)
- cout << " (" << Vf.File().FileName() << ")";
- cout << endl;
- for (pkgCache::DescIterator D = Cur.DescriptionList(); D.end() == false; D++)
- {
- cout << " Description Language: " << D.LanguageCode() << endl
- << " File: " << D.FileList().File().FileName() << endl
- << " MD5: " << D.md5() << endl;
- }
+ cout << "(" << Vf.File().FileName() << ")";
cout << endl;
}
@@ -290,15 +277,11 @@ bool Stats(CommandLine &Cmd)
cout << _("Total distinct versions: ") << Cache.Head().VersionCount << " (" <<
SizeToStr(Cache.Head().VersionCount*Cache.Head().VersionSz) << ')' << endl;
- cout << _("Total Distinct Descriptions: ") << Cache.Head().DescriptionCount << " (" <<
- SizeToStr(Cache.Head().DescriptionCount*Cache.Head().DescriptionSz) << ')' << endl;
cout << _("Total dependencies: ") << Cache.Head().DependsCount << " (" <<
SizeToStr(Cache.Head().DependsCount*Cache.Head().DependencySz) << ')' << endl;
cout << _("Total ver/file relations: ") << Cache.Head().VerFileCount << " (" <<
SizeToStr(Cache.Head().VerFileCount*Cache.Head().VerFileSz) << ')' << endl;
- cout << _("Total Desc/File relations: ") << Cache.Head().DescFileCount << " (" <<
- SizeToStr(Cache.Head().DescFileCount*Cache.Head().DescFileSz) << ')' << endl;
cout << _("Total Provides mappings: ") << Cache.Head().ProvidesCount << " (" <<
SizeToStr(Cache.Head().ProvidesCount*Cache.Head().ProvidesSz) << ')' << endl;
@@ -361,12 +344,6 @@ bool Dump(CommandLine &Cmd)
for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; D++)
cout << " Depends: " << D.TargetPkg().Name() << ' ' <<
DeNull(D.TargetVer()) << endl;
- for (pkgCache::DescIterator D = V.DescriptionList(); D.end() == false; D++)
- {
- cout << " Description Language: " << D.LanguageCode() << endl
- << " File: " << D.FileList().File().FileName() << endl
- << " MD5: " << D.md5() << endl;
- }
}
}
@@ -1215,50 +1192,17 @@ bool DisplayRecord(pkgCache::VerIterator V)
if (_error->PendingError() == true)
return false;
- // Read the record
+ // Read the record and then write it out again.
unsigned char *Buffer = new unsigned char[GCache->HeaderP->MaxVerFileSize+1];
Buffer[V.FileList()->Size] = '\n';
if (PkgF.Seek(V.FileList()->Offset) == false ||
- PkgF.Read(Buffer,V.FileList()->Size) == false)
- {
- delete [] Buffer;
- return false;
- }
-
- // Get a pointer to start of Description field
- const unsigned char *DescP = (unsigned char*)strstr((char*)Buffer, "Description:");
-
- // Write all but Description
- if (fwrite(Buffer,1,DescP - Buffer,stdout) < (size_t)(DescP - Buffer))
+ PkgF.Read(Buffer,V.FileList()->Size) == false ||
+ fwrite(Buffer,1,V.FileList()->Size+1,stdout) < (size_t)(V.FileList()->Size+1))
{
delete [] Buffer;
return false;
}
-
- // Show the right description
- pkgRecords Recs(*GCache);
- pkgCache::DescIterator Desc = V.TranslatedDescription();
- pkgRecords::Parser &P = Recs.Lookup(Desc.FileList());
- cout << "Description" << ( (strcmp(Desc.LanguageCode(),"") != 0) ? "-" : "" ) << Desc.LanguageCode() << ": " << P.LongDesc();
-
- // Find the first field after the description (if there is any)
- for(DescP++;DescP != &Buffer[V.FileList()->Size];DescP++)
- {
- if(*DescP == '\n' && *(DescP+1) != ' ')
- {
- // write the rest of the buffer
- const unsigned char *end=&Buffer[V.FileList()->Size];
- if (fwrite(DescP,1,end-DescP,stdout) < (size_t)(end-DescP))
- {
- delete [] Buffer;
- return false;
- }
-
- break;
- }
- }
- // write a final newline (after the description)
- cout<<endl;
+
delete [] Buffer;
return true;
@@ -1267,9 +1211,9 @@ bool DisplayRecord(pkgCache::VerIterator V)
// Search - Perform a search /*{{{*/
// ---------------------------------------------------------------------
/* This searches the package names and pacakge descriptions for a pattern */
-struct ExDescFile
+struct ExVerFile
{
- pkgCache::DescFile *Df;
+ pkgCache::VerFile *Vf;
bool NameMatch;
};
@@ -1309,35 +1253,35 @@ bool Search(CommandLine &CmdL)
return false;
}
- ExDescFile *DFList = new ExDescFile[Cache.HeaderP->PackageCount+1];
- memset(DFList,0,sizeof(*DFList)*Cache.HeaderP->PackageCount+1);
+ ExVerFile *VFList = new ExVerFile[Cache.HeaderP->PackageCount+1];
+ memset(VFList,0,sizeof(*VFList)*Cache.HeaderP->PackageCount+1);
// Map versions that we want to write out onto the VerList array.
for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++)
{
- DFList[P->ID].NameMatch = NumPatterns != 0;
+ VFList[P->ID].NameMatch = NumPatterns != 0;
for (unsigned I = 0; I != NumPatterns; I++)
{
if (regexec(&Patterns[I],P.Name(),0,0,0) == 0)
- DFList[P->ID].NameMatch &= true;
+ VFList[P->ID].NameMatch &= true;
else
- DFList[P->ID].NameMatch = false;
+ VFList[P->ID].NameMatch = false;
}
// Doing names only, drop any that dont match..
- if (NamesOnly == true && DFList[P->ID].NameMatch == false)
+ if (NamesOnly == true && VFList[P->ID].NameMatch == false)
continue;
// Find the proper version to use.
pkgCache::VerIterator V = Plcy.GetCandidateVer(P);
if (V.end() == false)
- DFList[P->ID].Df = V.DescriptionList().FileList();
+ VFList[P->ID].Vf = V.FileList();
}
// Include all the packages that provide matching names too
for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++)
{
- if (DFList[P->ID].NameMatch == false)
+ if (VFList[P->ID].NameMatch == false)
continue;
for (pkgCache::PrvIterator Prv = P.ProvidesList() ; Prv.end() == false; Prv++)
@@ -1345,18 +1289,18 @@ bool Search(CommandLine &CmdL)
pkgCache::VerIterator V = Plcy.GetCandidateVer(Prv.OwnerPkg());
if (V.end() == false)
{
- DFList[Prv.OwnerPkg()->ID].Df = V.DescriptionList().FileList();
- DFList[Prv.OwnerPkg()->ID].NameMatch = true;
+ VFList[Prv.OwnerPkg()->ID].Vf = V.FileList();
+ VFList[Prv.OwnerPkg()->ID].NameMatch = true;
}
}
}
-
- LocalitySort(&DFList->Df,Cache.HeaderP->PackageCount,sizeof(*DFList));
+
+ LocalitySort(&VFList->Vf,Cache.HeaderP->PackageCount,sizeof(*VFList));
// Iterate over all the version records and check them
- for (ExDescFile *J = DFList; J->Df != 0; J++)
+ for (ExVerFile *J = VFList; J->Vf != 0; J++)
{
- pkgRecords::Parser &P = Recs.Lookup(pkgCache::DescFileIterator(Cache,J->Df));
+ pkgRecords::Parser &P = Recs.Lookup(pkgCache::VerFileIterator(Cache,J->Vf));
bool Match = true;
if (J->NameMatch == false)
@@ -1387,7 +1331,7 @@ bool Search(CommandLine &CmdL)
}
}
- delete [] DFList;
+ delete [] VFList;
for (unsigned I = 0; I != NumPatterns; I++)
regfree(&Patterns[I]);
if (ferror(stdout))
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 040f670b1..abeb57c6f 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -38,6 +38,7 @@
#include <apt-pkg/version.h>
#include <apt-pkg/cachefile.h>
#include <apt-pkg/sptr.h>
+#include <apt-pkg/md5.h>
#include <apt-pkg/versionmatch.h>
#include <config.h>
@@ -45,6 +46,7 @@
#include "acqprogress.h"
+#include <set>
#include <locale.h>
#include <langinfo.h>
#include <fstream>
@@ -1200,7 +1202,7 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
VerTag = string(TmpSrc.begin() + Slash + 1,TmpSrc.end());
TmpSrc = string(TmpSrc.begin(),TmpSrc.begin() + Slash);
}
- else if(DefRel.empty() == false)
+ else if(!Pkg.end() && DefRel.empty() == false)
{
// we have a default release, try to locate the pkg. we do it like
// this because GetCandidateVer() will not "downgrade", that means
@@ -1211,10 +1213,6 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false;
VF++)
{
- // extra paranioa
- if(VF.File() == NULL)
- continue;
-
/* 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
@@ -1903,6 +1901,9 @@ bool DoSource(CommandLine &CmdL)
DscFile *Dsc = new DscFile[CmdL.FileSize()];
+ // insert all downloaded uris into this set to avoid downloading them
+ // twice
+ set<string> queued;
// Load the requestd sources into the fetcher
unsigned J = 0;
for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
@@ -1939,7 +1940,28 @@ bool DoSource(CommandLine &CmdL)
if (_config->FindB("APT::Get::Tar-Only",false) == true &&
I->Type != "tar")
continue;
-
+
+ // don't download the same uri twice (should this be moved to
+ // the fetcher interface itself?)
+ if(queued.find(Last->Index().ArchiveURI(I->Path)) != queued.end())
+ continue;
+ queued.insert(Last->Index().ArchiveURI(I->Path));
+
+ // check if we have a file with that md5 sum already localy
+ if(!I->MD5Hash.empty() && FileExists(flNotDir(I->Path)))
+ {
+ FileFd Fd(flNotDir(I->Path), FileFd::ReadOnly);
+ MD5Summation sum;
+ sum.AddFD(Fd.Fd(), Fd.Size());
+ Fd.Close();
+ if((string)sum.Result() == I->MD5Hash)
+ {
+ ioprintf(c1out,_("Skipping already downloaded file '%s'\n"),
+ flNotDir(I->Path).c_str());
+ continue;
+ }
+ }
+
new pkgAcqFile(&Fetcher,Last->Index().ArchiveURI(I->Path),
I->MD5Hash,I->Size,
Last->Index().SourceInfo(*Last,*I),Src);