summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <egon@tas>2006-12-07 11:45:13 +0100
committerMichael Vogt <egon@tas>2006-12-07 11:45:13 +0100
commit207825063be51d68768e242f06b26ee6fccd3aaf (patch)
tree4c755597279d2574e787460c5d0f3bc34d132a64 /apt-pkg
parent7106240056767caad5a55fe9c542842065cb5829 (diff)
parent1c05ebd6da9491d316997a98db1451f7b0526603 (diff)
merged with apt--mvo
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc103
-rw-r--r--apt-pkg/acquire-item.h15
-rw-r--r--apt-pkg/acquire-method.cc2
-rw-r--r--apt-pkg/acquire.cc14
-rw-r--r--apt-pkg/cacheiterators.h2
-rw-r--r--apt-pkg/cdrom.cc16
-rw-r--r--apt-pkg/contrib/configuration.cc26
-rw-r--r--apt-pkg/contrib/configuration.h28
-rw-r--r--apt-pkg/contrib/hashes.cc1
-rw-r--r--apt-pkg/contrib/hashes.h4
-rw-r--r--apt-pkg/contrib/md5.h3
-rw-r--r--apt-pkg/contrib/mmap.cc4
-rw-r--r--apt-pkg/contrib/mmap.h2
-rw-r--r--apt-pkg/contrib/progress.cc7
-rw-r--r--apt-pkg/contrib/progress.h4
-rw-r--r--apt-pkg/contrib/sha256.cc430
-rw-r--r--apt-pkg/contrib/sha256.h74
-rw-r--r--apt-pkg/contrib/strutl.cc67
-rw-r--r--apt-pkg/contrib/strutl.h26
-rw-r--r--apt-pkg/deb/debindexfile.cc2
-rw-r--r--apt-pkg/deb/deblistparser.cc15
-rw-r--r--apt-pkg/deb/debmetaindex.cc4
-rw-r--r--apt-pkg/deb/debsrcrecords.cc28
-rw-r--r--apt-pkg/deb/debsrcrecords.h10
-rw-r--r--apt-pkg/deb/debversion.cc23
-rw-r--r--apt-pkg/deb/dpkgpm.cc62
-rw-r--r--apt-pkg/depcache.cc7
-rw-r--r--apt-pkg/init.cc5
-rw-r--r--apt-pkg/makefile6
-rw-r--r--apt-pkg/packagemanager.cc4
-rw-r--r--apt-pkg/pkgcache.cc4
-rw-r--r--apt-pkg/pkgcache.h6
-rw-r--r--apt-pkg/pkgcachegen.cc16
-rw-r--r--apt-pkg/pkgcachegen.h17
-rw-r--r--apt-pkg/sourcelist.cc113
-rw-r--r--apt-pkg/sourcelist.h5
-rw-r--r--apt-pkg/tagfile.cc48
-rw-r--r--apt-pkg/tagfile.h5
-rw-r--r--apt-pkg/vendorlist.cc2
39 files changed, 991 insertions, 219 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 6831abd54..46c9d6c2c 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -569,7 +569,7 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
if(comprExt.empty())
{
// autoselect the compression method
- if(FileExists("/usr/bin/bzip2"))
+ if(FileExists("/bin/bzip2"))
CompressionExtension = ".bz2";
else
CompressionExtension = ".gz";
@@ -604,7 +604,7 @@ string pkgAcqIndex::Custom600Headers()
void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
{
// no .bz2 found, retry with .gz
- if(Desc.URI.substr(Desc.URI.size()-3,Desc.URI.size()-1) == "bz2") {
+ if(Desc.URI.substr(Desc.URI.size()-3) == "bz2") {
Desc.URI = Desc.URI.substr(0,Desc.URI.size()-3) + "gz";
// retry with a gzip one
@@ -710,7 +710,7 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5,
else
Local = true;
- string compExt = Desc.URI.substr(Desc.URI.size()-3,Desc.URI.size()-1);
+ string compExt = Desc.URI.substr(Desc.URI.size()-3);
char *decompProg;
if(compExt == "bz2")
decompProg = "bzip2";
@@ -735,10 +735,9 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
const vector<IndexTarget*>* IndexTargets,
indexRecords* MetaIndexParser) :
Item(Owner), RealURI(URI), MetaIndexURI(MetaIndexURI),
- MetaIndexURIDesc(MetaIndexURIDesc), MetaIndexShortDesc(MetaIndexShortDesc)
+ MetaIndexURIDesc(MetaIndexURIDesc), MetaIndexShortDesc(MetaIndexShortDesc),
+ MetaIndexParser(MetaIndexParser), IndexTargets(IndexTargets)
{
- this->MetaIndexParser = MetaIndexParser;
- this->IndexTargets = IndexTargets;
DestFile = _config->FindDir("Dir::State::lists") + "partial/";
DestFile += URItoFileName(URI);
@@ -761,12 +760,6 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
// File was already in place. It needs to be re-verified
// because Release might have changed, so Move it into partial
Rename(Final,DestFile);
- // unlink the file and do not try to use I-M-S and Last-Modified
- // if the users proxy is broken
- if(_config->FindB("Acquire::BrokenProxy", false) == true) {
- std::cerr << "forcing re-get of the signature file as requested" << std::endl;
- unlink(DestFile.c_str());
- }
}
QueueURI(Desc);
@@ -816,18 +809,19 @@ void pkgAcqMetaSig::Done(string Message,unsigned long Size,string MD5,
/*}}}*/
void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
{
- // Delete any existing sigfile, so that this source isn't
- // mistakenly trusted
- string Final = _config->FindDir("Dir::State::lists") + URItoFileName(RealURI);
- unlink(Final.c_str());
- // if we get a timeout if fail
+ // if we get a network error we fail gracefully
if(LookupTag(Message,"FailReason") == "Timeout" ||
- LookupTag(Message,"FailReason") == "TmpResolveFailure") {
+ LookupTag(Message,"FailReason") == "TmpResolveFailure" ||
+ LookupTag(Message,"FailReason") == "ConnectionRefused") {
Item::Failed(Message,Cnf);
return;
}
+ // Delete any existing sigfile when the acquire failed
+ string Final = _config->FindDir("Dir::State::lists") + URItoFileName(RealURI);
+ unlink(Final.c_str());
+
// queue a pkgAcqMetaIndex with no sigfile
new pkgAcqMetaIndex(Owner, MetaIndexURI, MetaIndexURIDesc, MetaIndexShortDesc,
"", IndexTargets, MetaIndexParser);
@@ -850,11 +844,9 @@ pkgAcqMetaIndex::pkgAcqMetaIndex(pkgAcquire *Owner,
string SigFile,
const vector<struct IndexTarget*>* IndexTargets,
indexRecords* MetaIndexParser) :
- Item(Owner), RealURI(URI), SigFile(SigFile)
+ Item(Owner), RealURI(URI), SigFile(SigFile), AuthPass(false),
+ MetaIndexParser(MetaIndexParser), IndexTargets(IndexTargets), IMSHit(false)
{
- this->AuthPass = false;
- this->MetaIndexParser = MetaIndexParser;
- this->IndexTargets = IndexTargets;
DestFile = _config->FindDir("Dir::State::lists") + "partial/";
DestFile += URItoFileName(URI);
@@ -946,6 +938,9 @@ void pkgAcqMetaIndex::RetrievalDone(string Message)
return;
}
+ // see if the download was a IMSHit
+ IMSHit = StringToBool(LookupTag(Message,"IMS-Hit"),false);
+
Complete = true;
string FinalFile = _config->FindDir("Dir::State::lists");
@@ -975,7 +970,7 @@ void pkgAcqMetaIndex::AuthDone(string Message)
return;
}
- if (!VerifyVendor())
+ if (!VerifyVendor(Message))
{
return;
}
@@ -1038,7 +1033,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify)
}
}
-bool pkgAcqMetaIndex::VerifyVendor()
+bool pkgAcqMetaIndex::VerifyVendor(string Message)
{
// // Maybe this should be made available from above so we don't have
// // to read and parse it every time?
@@ -1063,6 +1058,22 @@ bool pkgAcqMetaIndex::VerifyVendor()
// break;
// }
// }
+ string::size_type pos;
+
+ // check for missing sigs (that where not fatal because otherwise we had
+ // bombed earlier)
+ string missingkeys;
+ string msg = _("There is no public key available for the "
+ "following key IDs:\n");
+ pos = Message.find("NO_PUBKEY ");
+ if (pos != std::string::npos)
+ {
+ string::size_type start = pos+strlen("NO_PUBKEY ");
+ string Fingerprint = Message.substr(start, Message.find("\n")-start);
+ missingkeys += (Fingerprint);
+ }
+ if(!missingkeys.empty())
+ _error->Warning("%s", string(msg+missingkeys).c_str());
string Transformed = MetaIndexParser->GetExpectedDist();
@@ -1071,7 +1082,7 @@ bool pkgAcqMetaIndex::VerifyVendor()
Transformed = "experimental";
}
- string::size_type pos = Transformed.rfind('/');
+ pos = Transformed.rfind('/');
if (pos != string::npos)
{
Transformed = Transformed.substr(0, pos);
@@ -1117,10 +1128,30 @@ void pkgAcqMetaIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
{
if (AuthPass == true)
{
- // gpgv method failed
+ // if we fail the authentication but got the file via a IMS-Hit
+ // this means that the file wasn't downloaded and that it might be
+ // just stale (server problem, proxy etc). we delete what we have
+ // queue it again without i-m-s
+ // alternatively we could just unlink the file and let the user try again
+ if (IMSHit)
+ {
+ Complete = false;
+ Local = false;
+ AuthPass = false;
+ unlink(DestFile.c_str());
+
+ DestFile = _config->FindDir("Dir::State::lists") + "partial/";
+ DestFile += URItoFileName(RealURI);
+ Desc.URI = RealURI;
+ QueueURI(Desc);
+ return;
+ }
+
+ // gpgv method failed
_error->Warning("GPG error: %s: %s",
Desc.Description.c_str(),
LookupTag(Message,"Message").c_str());
+
}
// No Release file was present, or verification failed, so fall
@@ -1196,6 +1227,12 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
}
}
+ // "allow-unauthenticated" restores apts old fetching behaviour
+ // that means that e.g. unauthenticated file:// uris are higher
+ // priority than authenticated http:// uris
+ if (_config->FindB("APT::Get::AllowUnauthenticated",false) == true)
+ Trusted = false;
+
// Select a source
if (QueueNext() == false && _error->PendingError() == false)
_error->Error(_("I wasn't able to locate file for the %s package. "
@@ -1428,13 +1465,19 @@ void pkgAcqArchive::Finished()
// ---------------------------------------------------------------------
/* The file is added to the queue */
pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string MD5,
- unsigned long Size,string Dsc,string ShortDesc) :
+ unsigned long Size,string Dsc,string ShortDesc,
+ const string &DestDir, const string &DestFilename) :
Item(Owner), Md5Hash(MD5)
{
Retries = _config->FindI("Acquire::Retries",0);
- DestFile = flNotDir(URI);
-
+ if(!DestFilename.empty())
+ DestFile = DestFilename;
+ else if(!DestDir.empty())
+ DestFile = DestDir + "/" + flNotDir(URI);
+ else
+ DestFile = flNotDir(URI);
+
// Create the item
Desc.URI = URI;
Desc.Description = Dsc;
@@ -1454,7 +1497,7 @@ pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string MD5,
else
PartialSize = Buf.st_size;
}
-
+
QueueURI(Desc);
}
/*}}}*/
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index 3a6e93b1a..3649d7a03 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -215,8 +215,10 @@ class pkgAcqMetaIndex : public pkgAcquire::Item
const vector<struct IndexTarget*>* IndexTargets;
indexRecords* MetaIndexParser;
bool AuthPass;
+ // required to deal gracefully with problems caused by incorrect ims hits
+ bool IMSHit;
- bool VerifyVendor();
+ bool VerifyVendor(string Message);
void RetrievalDone(string Message);
void AuthDone(string Message);
void QueueIndexes(bool verify);
@@ -288,9 +290,14 @@ class pkgAcqFile : public pkgAcquire::Item
pkgAcquire::MethodConfig *Cnf);
virtual string MD5Sum() {return Md5Hash;};
virtual string DescURI() {return Desc.URI;};
-
- pkgAcqFile(pkgAcquire *Owner,string URI,string MD5,unsigned long Size,
- string Desc,string ShortDesc);
+
+ // If DestFilename is empty, download to DestDir/<basename> if
+ // DestDir is non-empty, $CWD/<basename> otherwise. If
+ // DestFilename is NOT empty, DestDir is ignored and DestFilename
+ // is the absolute name to which the file should be downloaded.
+ pkgAcqFile(pkgAcquire *Owner, string URI, string MD5, unsigned long Size,
+ string Desc, string ShortDesc,
+ const string &DestDir="", const string &DestFilename="");
};
#endif
diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc
index 04c62eaaa..41b832f3b 100644
--- a/apt-pkg/acquire-method.cc
+++ b/apt-pkg/acquire-method.cc
@@ -277,7 +277,7 @@ bool pkgAcqMethod::MediaFail(string Required,string Drive)
MyMessages.erase(MyMessages.begin());
}
- return !StringToBool(LookupTag(Message,"Fail"),false);
+ return !StringToBool(LookupTag(Message,"Failed"),false);
}
Messages.push_back(Message);
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 62209e65b..fff1b2b6a 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -266,7 +266,11 @@ pkgAcquire::MethodConfig *pkgAcquire::GetConfig(string Access)
Worker Work(Conf);
if (Work.Start() == false)
return 0;
-
+
+ /* if a method uses DownloadLimit, we switch to SingleInstance mode */
+ if(_config->FindI("Acquire::"+Access+"::DlLimit",0) > 0)
+ Conf->SingleInstance = true;
+
return Conf;
}
/*}}}*/
@@ -814,7 +818,13 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
unsigned long ETA =
(unsigned long)((TotalBytes - CurrentBytes) / CurrentCPS);
- snprintf(msg,sizeof(msg), _("Downloading file %li of %li (%s remaining)"), i, TotalItems, TimeToStr(ETA).c_str());
+ // only show the ETA if it makes sense
+ if (ETA > 0 && ETA < 172800 /* two days */ )
+ snprintf(msg,sizeof(msg), _("Retrieving file %li of %li (%s remaining)"), i, TotalItems, TimeToStr(ETA).c_str());
+ else
+ snprintf(msg,sizeof(msg), _("Retrieving file %li of %li"), i, TotalItems);
+
+
// build the status str
status << "dlstatus:" << i
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h
index c3a0d0a5a..2b326bd65 100644
--- a/apt-pkg/cacheiterators.h
+++ b/apt-pkg/cacheiterators.h
@@ -107,7 +107,7 @@ class pkgCache::VerIterator
// Iteration
void operator ++(int) {if (Ver != Owner->VerP) Ver = Owner->VerP + Ver->NextVer;};
inline void operator ++() {operator ++(0);};
- inline bool end() const {return Ver == Owner->VerP?true:false;};
+ inline bool end() const {return Owner == NULL || (Ver == Owner->VerP?true:false);};
inline void operator =(const VerIterator &B) {Ver = B.Ver; Owner = B.Owner;};
// Comparison
diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc
index c067cf1ee..ce1beb39b 100644
--- a/apt-pkg/cdrom.cc
+++ b/apt-pkg/cdrom.cc
@@ -567,7 +567,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log)
string DFile = _config->FindFile("Dir::State::cdroms");
if (FileExists(DFile) == true)
{
- if (ReadConfigFile(Database,DFile) == false)
+ if (ReadConfigFile(Database,DFile) == false)
return _error->Error("Unable to read the cdrom database %s",
DFile.c_str());
}
@@ -650,8 +650,11 @@ bool pkgCdrom::Add(pkgCdromStatus *log)
log->Update(msg.str(), STEP_SCAN);
}
- if (List.size() == 0 && SourceList.size() == 0)
+ if (List.size() == 0 && SourceList.size() == 0)
+ {
+ UnmountCdrom(CDROM);
return _error->Error("Unable to locate any package files, perhaps this is not a Debian Disc");
+ }
// Check if the CD is in the database
string Name;
@@ -687,7 +690,10 @@ bool pkgCdrom::Add(pkgCdromStatus *log)
Name.empty() == true)
{
if(!log)
+ {
+ UnmountCdrom(CDROM);
return _error->Error("No disc name found and no way to ask for it");
+ }
while(true) {
if(!log->AskCdromName(Name)) {
@@ -760,7 +766,10 @@ bool pkgCdrom::Add(pkgCdromStatus *log)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
+ {
+ UnmountCdrom(CDROM);
return _error->Error("Internal error");
+ }
if(log) {
msg.str("");
@@ -774,7 +783,10 @@ bool pkgCdrom::Add(pkgCdromStatus *log)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
+ {
+ UnmountCdrom(CDROM);
return _error->Error("Internal error");
+ }
if(log) {
msg.str("");
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index 09e454be9..14a000fa5 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -110,7 +110,7 @@ Configuration::Item *Configuration::Lookup(Item *Head,const char *S,
return 0;
I = new Item;
- I->Tag = string(S,Len);
+ I->Tag.assign(S,Len);
I->Next = *Last;
I->Parent = Head;
*Last = I;
@@ -161,7 +161,7 @@ string Configuration::Find(const char *Name,const char *Default) const
if (Itm == 0 || Itm->Value.empty() == true)
{
if (Default == 0)
- return string();
+ return "";
else
return Default;
}
@@ -180,7 +180,7 @@ string Configuration::FindFile(const char *Name,const char *Default) const
if (Itm == 0 || Itm->Value.empty() == true)
{
if (Default == 0)
- return string();
+ return "";
else
return Default;
}
@@ -294,7 +294,7 @@ string Configuration::FindAny(const char *Name,const char *Default) const
// Configuration::CndSet - Conditinal Set a value /*{{{*/
// ---------------------------------------------------------------------
/* This will not overwrite */
-void Configuration::CndSet(const char *Name,string Value)
+void Configuration::CndSet(const char *Name,const string &Value)
{
Item *Itm = Lookup(Name,true);
if (Itm == 0)
@@ -306,7 +306,7 @@ void Configuration::CndSet(const char *Name,string Value)
// Configuration::Set - Set a value /*{{{*/
// ---------------------------------------------------------------------
/* */
-void Configuration::Set(const char *Name,string Value)
+void Configuration::Set(const char *Name,const string &Value)
{
Item *Itm = Lookup(Name,true);
if (Itm == 0)
@@ -330,7 +330,7 @@ void Configuration::Set(const char *Name,int Value)
// Configuration::Clear - Clear an single value from a list /*{{{*/
// ---------------------------------------------------------------------
/* */
-void Configuration::Clear(string Name, int Value)
+void Configuration::Clear(const string Name, int Value)
{
char S[300];
snprintf(S,sizeof(S),"%i",Value);
@@ -340,7 +340,7 @@ void Configuration::Clear(string Name, int Value)
// Configuration::Clear - Clear an single value from a list /*{{{*/
// ---------------------------------------------------------------------
/* */
-void Configuration::Clear(string Name, string Value)
+void Configuration::Clear(const string Name, string Value)
{
Item *Top = Lookup(Name.c_str(),false);
if (Top == 0 || Top->Child == 0)
@@ -377,7 +377,7 @@ void Configuration::Clear(string Name)
if (Top == 0)
return;
- Top->Value = string();
+ Top->Value.clear();
Item *Stop = Top;
Top = Top->Child;
Stop->Child = 0;
@@ -485,7 +485,7 @@ string Configuration::Item::FullTag(const Item *Stop) const
sections like 'zone "foo.org" { .. };' This causes each section to be
added in with a tag like "zone::foo.org" instead of being split
tag/value. AsSectional enables Sectional parsing.*/
-bool ReadConfigFile(Configuration &Conf,string FName,bool AsSectional,
+bool ReadConfigFile(Configuration &Conf,const string &FName,bool AsSectional,
unsigned Depth)
{
// Open the stream for reading
@@ -711,13 +711,13 @@ bool ReadConfigFile(Configuration &Conf,string FName,bool AsSectional,
}
// Empty the buffer
- LineBuffer = string();
+ LineBuffer.clear();
// Move up a tag, but only if there is no bit to parse
if (TermChar == '}')
{
if (StackPos == 0)
- ParentTag = string();
+ ParentTag.clear();
else
ParentTag = Stack[--StackPos];
}
@@ -742,8 +742,8 @@ bool ReadConfigFile(Configuration &Conf,string FName,bool AsSectional,
// ReadConfigDir - Read a directory of config files /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool ReadConfigDir(Configuration &Conf,string Dir,bool AsSectional,
- unsigned Depth)
+bool ReadConfigDir(Configuration &Conf,const string &Dir,bool AsSectional,
+ unsigned Depth)
{
DIR *D = opendir(Dir.c_str());
if (D == 0)
diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h
index 789bc82cf..0d4078dab 100644
--- a/apt-pkg/contrib/configuration.h
+++ b/apt-pkg/contrib/configuration.h
@@ -69,30 +69,30 @@ class Configuration
public:
string Find(const char *Name,const char *Default = 0) const;
- string Find(string Name,const char *Default = 0) const {return Find(Name.c_str(),Default);};
+ string Find(const string Name,const char *Default = 0) const {return Find(Name.c_str(),Default);};
string FindFile(const char *Name,const char *Default = 0) const;
string FindDir(const char *Name,const char *Default = 0) const;
int FindI(const char *Name,int Default = 0) const;
- int FindI(string Name,int Default = 0) const {return FindI(Name.c_str(),Default);};
+ int FindI(const string Name,int Default = 0) const {return FindI(Name.c_str(),Default);};
bool FindB(const char *Name,bool Default = false) const;
- bool FindB(string Name,bool Default = false) const {return FindB(Name.c_str(),Default);};
+ bool FindB(const string Name,bool Default = false) const {return FindB(Name.c_str(),Default);};
string FindAny(const char *Name,const char *Default = 0) const;
- inline void Set(string Name,string Value) {Set(Name.c_str(),Value);};
- void CndSet(const char *Name,string Value);
- void Set(const char *Name,string Value);
+ inline void Set(const string Name,string Value) {Set(Name.c_str(),Value);};
+ void CndSet(const char *Name,const string &Value);
+ void Set(const char *Name,const string &Value);
void Set(const char *Name,int Value);
- inline bool Exists(string Name) const {return Exists(Name.c_str());};
+ inline bool Exists(const string Name) const {return Exists(Name.c_str());};
bool Exists(const char *Name) const;
bool ExistsAny(const char *Name) const;
// clear a whole tree
- void Clear(string Name);
+ void Clear(const string Name);
// remove a certain value from a list (e.g. the list of "APT::Keep-Fds")
- void Clear(string List, string Value);
- void Clear(string List, int Value);
+ void Clear(const string List, string Value);
+ void Clear(const string List, int Value);
inline const Item *Tree(const char *Name) const {return Lookup(Name);};
@@ -106,10 +106,12 @@ class Configuration
extern Configuration *_config;
-bool ReadConfigFile(Configuration &Conf,string FName,bool AsSectional = false,
+bool ReadConfigFile(Configuration &Conf,const string &FName,
+ bool AsSectional = false,
unsigned Depth = 0);
-bool ReadConfigDir(Configuration &Conf,string Dir,bool AsSectional = false,
- unsigned Depth = 0);
+bool ReadConfigDir(Configuration &Conf,const string &Dir,
+ bool AsSectional = false,
+ unsigned Depth = 0);
#endif
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index b17b94319..9b22a90d3 100644
--- a/apt-pkg/contrib/hashes.cc
+++ b/apt-pkg/contrib/hashes.cc
@@ -36,6 +36,7 @@ bool Hashes::AddFD(int Fd,unsigned long Size)
Size -= Res;
MD5.Add(Buf,Res);
SHA1.Add(Buf,Res);
+ SHA256.Add(Buf,Res);
}
return true;
}
diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h
index 40bbe00a0..eefa7bf41 100644
--- a/apt-pkg/contrib/hashes.h
+++ b/apt-pkg/contrib/hashes.h
@@ -19,6 +19,7 @@
#include <apt-pkg/md5.h>
#include <apt-pkg/sha1.h>
+#include <apt-pkg/sha256.h>
#include <algorithm>
@@ -30,10 +31,11 @@ class Hashes
MD5Summation MD5;
SHA1Summation SHA1;
+ SHA256Summation SHA256;
inline bool Add(const unsigned char *Data,unsigned long Size)
{
- return MD5.Add(Data,Size) && SHA1.Add(Data,Size);
+ return MD5.Add(Data,Size) && SHA1.Add(Data,Size) && SHA256.Add(Data,Size);
};
inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));};
bool AddFD(int Fd,unsigned long Size);
diff --git a/apt-pkg/contrib/md5.h b/apt-pkg/contrib/md5.h
index 9e20f7cef..e280d714e 100644
--- a/apt-pkg/contrib/md5.h
+++ b/apt-pkg/contrib/md5.h
@@ -29,6 +29,7 @@
#include <string>
#include <algorithm>
+#include <stdint.h>
using std::string;
using std::min;
@@ -58,7 +59,7 @@ class MD5SumValue
class MD5Summation
{
- unsigned char Buf[4*4];
+ uint32_t Buf[4];
unsigned char Bytes[2*4];
unsigned char In[16*4];
bool Done;
diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc
index bc22fba67..e395e6cc7 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -155,9 +155,9 @@ DynamicMMap::DynamicMMap(FileFd &F,unsigned long Flags,unsigned long WorkSpace)
unsigned long EndOfFile = Fd->Size();
if (EndOfFile > WorkSpace)
WorkSpace = EndOfFile;
- else
+ else if(WorkSpace > 0)
{
- Fd->Seek(WorkSpace);
+ Fd->Seek(WorkSpace - 1);
char C = 0;
Fd->Write(&C,sizeof(C));
}
diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h
index caffa0f90..e329b167a 100644
--- a/apt-pkg/contrib/mmap.h
+++ b/apt-pkg/contrib/mmap.h
@@ -94,7 +94,7 @@ class DynamicMMap : public MMap
unsigned long RawAllocate(unsigned long Size,unsigned long Aln = 0);
unsigned long Allocate(unsigned long ItemSize);
unsigned long WriteString(const char *String,unsigned long Len = (unsigned long)-1);
- inline unsigned long WriteString(string S) {return WriteString(S.c_str(),S.length());};
+ inline unsigned long WriteString(const string &S) {return WriteString(S.c_str(),S.length());};
void UsePools(Pool &P,unsigned int Count) {Pools = &P; PoolCount = Count;};
DynamicMMap(FileFd &F,unsigned long Flags,unsigned long WorkSpace = 2*1024*1024);
diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc
index 8eb36fc20..e3db9a45a 100644
--- a/apt-pkg/contrib/progress.cc
+++ b/apt-pkg/contrib/progress.cc
@@ -50,7 +50,7 @@ void OpProgress::Progress(unsigned long Cur)
// ---------------------------------------------------------------------
/* */
void OpProgress::OverallProgress(unsigned long Current, unsigned long Total,
- unsigned long Size,string Op)
+ unsigned long Size,const string &Op)
{
this->Current = Current;
this->Total = Total;
@@ -67,7 +67,7 @@ void OpProgress::OverallProgress(unsigned long Current, unsigned long Total,
// OpProgress::SubProgress - Set the sub progress state /*{{{*/
// ---------------------------------------------------------------------
/* */
-void OpProgress::SubProgress(unsigned long SubTotal,string Op)
+void OpProgress::SubProgress(unsigned long SubTotal,const string &Op)
{
this->SubTotal = SubTotal;
SubOp = Op;
@@ -115,6 +115,8 @@ bool OpProgress::CheckChange(float Interval)
if ((int)LastPercent == (int)Percent)
return false;
+
+ LastPercent = Percent;
if (Interval == 0)
return false;
@@ -126,7 +128,6 @@ bool OpProgress::CheckChange(float Interval)
if (Diff < Interval)
return false;
LastTime = Now;
- LastPercent = Percent;
return true;
}
/*}}}*/
diff --git a/apt-pkg/contrib/progress.h b/apt-pkg/contrib/progress.h
index d0b1f5f94..20caf4cdf 100644
--- a/apt-pkg/contrib/progress.h
+++ b/apt-pkg/contrib/progress.h
@@ -59,9 +59,9 @@ class OpProgress
void Progress(unsigned long Current);
void SubProgress(unsigned long SubTotal);
- void SubProgress(unsigned long SubTotal,string Op);
+ void SubProgress(unsigned long SubTotal,const string &Op);
void OverallProgress(unsigned long Current,unsigned long Total,
- unsigned long Size,string Op);
+ unsigned long Size,const string &Op);
virtual void Done() {};
OpProgress();
diff --git a/apt-pkg/contrib/sha256.cc b/apt-pkg/contrib/sha256.cc
new file mode 100644
index 000000000..ecda3d8e8
--- /dev/null
+++ b/apt-pkg/contrib/sha256.cc
@@ -0,0 +1,430 @@
+/*
+ * Cryptographic API.
+ *
+ * SHA-256, as specified in
+ * http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf
+ *
+ * SHA-256 code by Jean-Luc Cooke <jlcooke@certainkey.com>.
+ *
+ * Copyright (c) Jean-Luc Cooke <jlcooke@certainkey.com>
+ * Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk>
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ *
+ * Ported from the Linux kernel to Apt by Anthony Towns <ajt@debian.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+
+#ifdef __GNUG__
+#pragma implementation "apt-pkg/sha256.h"
+#endif
+
+
+#define SHA256_DIGEST_SIZE 32
+#define SHA256_HMAC_BLOCK_SIZE 64
+
+#define ror32(value,bits) (((value) >> (bits)) | ((value) << (32 - (bits))))
+
+#include <apt-pkg/sha256.h>
+#include <apt-pkg/strutl.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <arpa/inet.h>
+
+typedef uint32_t u32;
+typedef uint8_t u8;
+
+static inline u32 Ch(u32 x, u32 y, u32 z)
+{
+ return z ^ (x & (y ^ z));
+}
+
+static inline u32 Maj(u32 x, u32 y, u32 z)
+{
+ return (x & y) | (z & (x | y));
+}
+
+#define e0(x) (ror32(x, 2) ^ ror32(x,13) ^ ror32(x,22))
+#define e1(x) (ror32(x, 6) ^ ror32(x,11) ^ ror32(x,25))
+#define s0(x) (ror32(x, 7) ^ ror32(x,18) ^ (x >> 3))
+#define s1(x) (ror32(x,17) ^ ror32(x,19) ^ (x >> 10))
+
+#define H0 0x6a09e667
+#define H1 0xbb67ae85
+#define H2 0x3c6ef372
+#define H3 0xa54ff53a
+#define H4 0x510e527f
+#define H5 0x9b05688c
+#define H6 0x1f83d9ab
+#define H7 0x5be0cd19
+
+static inline void LOAD_OP(int I, u32 *W, const u8 *input)
+{
+ W[I] = ( ((u32) input[I * 4 + 0] << 24)
+ | ((u32) input[I * 4 + 1] << 16)
+ | ((u32) input[I * 4 + 2] << 8)
+ | ((u32) input[I * 4 + 3]));
+}
+
+static inline void BLEND_OP(int I, u32 *W)
+{
+ W[I] = s1(W[I-2]) + W[I-7] + s0(W[I-15]) + W[I-16];
+}
+
+static void sha256_transform(u32 *state, const u8 *input)
+{
+ u32 a, b, c, d, e, f, g, h, t1, t2;
+ u32 W[64];
+ int i;
+
+ /* load the input */
+ for (i = 0; i < 16; i++)
+ LOAD_OP(i, W, input);
+
+ /* now blend */
+ for (i = 16; i < 64; i++)
+ BLEND_OP(i, W);
+
+ /* load the state into our registers */
+ a=state[0]; b=state[1]; c=state[2]; d=state[3];
+ e=state[4]; f=state[5]; g=state[6]; h=state[7];
+
+ /* now iterate */
+ t1 = h + e1(e) + Ch(e,f,g) + 0x428a2f98 + W[ 0];
+ t2 = e0(a) + Maj(a,b,c); d+=t1; h=t1+t2;
+ t1 = g + e1(d) + Ch(d,e,f) + 0x71374491 + W[ 1];
+ t2 = e0(h) + Maj(h,a,b); c+=t1; g=t1+t2;
+ t1 = f + e1(c) + Ch(c,d,e) + 0xb5c0fbcf + W[ 2];
+ t2 = e0(g) + Maj(g,h,a); b+=t1; f=t1+t2;
+ t1 = e + e1(b) + Ch(b,c,d) + 0xe9b5dba5 + W[ 3];
+ t2 = e0(f) + Maj(f,g,h); a+=t1; e=t1+t2;
+ t1 = d + e1(a) + Ch(a,b,c) + 0x3956c25b + W[ 4];
+ t2 = e0(e) + Maj(e,f,g); h+=t1; d=t1+t2;
+ t1 = c + e1(h) + Ch(h,a,b) + 0x59f111f1 + W[ 5];
+ t2 = e0(d) + Maj(d,e,f); g+=t1; c=t1+t2;
+ t1 = b + e1(g) + Ch(g,h,a) + 0x923f82a4 + W[ 6];
+ t2 = e0(c) + Maj(c,d,e); f+=t1; b=t1+t2;
+ t1 = a + e1(f) + Ch(f,g,h) + 0xab1c5ed5 + W[ 7];
+ t2 = e0(b) + Maj(b,c,d); e+=t1; a=t1+t2;
+
+ t1 = h + e1(e) + Ch(e,f,g) + 0xd807aa98 + W[ 8];
+ t2 = e0(a) + Maj(a,b,c); d+=t1; h=t1+t2;
+ t1 = g + e1(d) + Ch(d,e,f) + 0x12835b01 + W[ 9];
+ t2 = e0(h) + Maj(h,a,b); c+=t1; g=t1+t2;
+ t1 = f + e1(c) + Ch(c,d,e) + 0x243185be + W[10];
+ t2 = e0(g) + Maj(g,h,a); b+=t1; f=t1+t2;
+ t1 = e + e1(b) + Ch(b,c,d) + 0x550c7dc3 + W[11];
+ t2 = e0(f) + Maj(f,g,h); a+=t1; e=t1+t2;
+ t1 = d + e1(a) + Ch(a,b,c) + 0x72be5d74 + W[12];
+ t2 = e0(e) + Maj(e,f,g); h+=t1; d=t1+t2;
+ t1 = c + e1(h) + Ch(h,a,b) + 0x80deb1fe + W[13];
+ t2 = e0(d) + Maj(d,e,f); g+=t1; c=t1+t2;
+ t1 = b + e1(g) + Ch(g,h,a) + 0x9bdc06a7 + W[14];
+ t2 = e0(c) + Maj(c,d,e); f+=t1; b=t1+t2;
+ t1 = a + e1(f) + Ch(f,g,h) + 0xc19bf174 + W[15];
+ t2 = e0(b) + Maj(b,c,d); e+=t1; a=t1+t2;
+
+ t1 = h + e1(e) + Ch(e,f,g) + 0xe49b69c1 + W[16];
+ t2 = e0(a) + Maj(a,b,c); d+=t1; h=t1+t2;
+ t1 = g + e1(d) + Ch(d,e,f) + 0xefbe4786 + W[17];
+ t2 = e0(h) + Maj(h,a,b); c+=t1; g=t1+t2;
+ t1 = f + e1(c) + Ch(c,d,e) + 0x0fc19dc6 + W[18];
+ t2 = e0(g) + Maj(g,h,a); b+=t1; f=t1+t2;
+ t1 = e + e1(b) + Ch(b,c,d) + 0x240ca1cc + W[19];
+ t2 = e0(f) + Maj(f,g,h); a+=t1; e=t1+t2;
+ t1 = d + e1(a) + Ch(a,b,c) + 0x2de92c6f + W[20];
+ t2 = e0(e) + Maj(e,f,g); h+=t1; d=t1+t2;
+ t1 = c + e1(h) + Ch(h,a,b) + 0x4a7484aa + W[21];
+ t2 = e0(d) + Maj(d,e,f); g+=t1; c=t1+t2;
+ t1 = b + e1(g) + Ch(g,h,a) + 0x5cb0a9dc + W[22];
+ t2 = e0(c) + Maj(c,d,e); f+=t1; b=t1+t2;
+ t1 = a + e1(f) + Ch(f,g,h) + 0x76f988da + W[23];
+ t2 = e0(b) + Maj(b,c,d); e+=t1; a=t1+t2;
+
+ t1 = h + e1(e) + Ch(e,f,g) + 0x983e5152 + W[24];
+ t2 = e0(a) + Maj(a,b,c); d+=t1; h=t1+t2;
+ t1 = g + e1(d) + Ch(d,e,f) + 0xa831c66d + W[25];
+ t2 = e0(h) + Maj(h,a,b); c+=t1; g=t1+t2;
+ t1 = f + e1(c) + Ch(c,d,e) + 0xb00327c8 + W[26];
+ t2 = e0(g) + Maj(g,h,a); b+=t1; f=t1+t2;
+ t1 = e + e1(b) + Ch(b,c,d) + 0xbf597fc7 + W[27];
+ t2 = e0(f) + Maj(f,g,h); a+=t1; e=t1+t2;
+ t1 = d + e1(a) + Ch(a,b,c) + 0xc6e00bf3 + W[28];
+ t2 = e0(e) + Maj(e,f,g); h+=t1; d=t1+t2;
+ t1 = c + e1(h) + Ch(h,a,b) + 0xd5a79147 + W[29];
+ t2 = e0(d) + Maj(d,e,f); g+=t1; c=t1+t2;
+ t1 = b + e1(g) + Ch(g,h,a) + 0x06ca6351 + W[30];
+ t2 = e0(c) + Maj(c,d,e); f+=t1; b=t1+t2;
+ t1 = a + e1(f) + Ch(f,g,h) + 0x14292967 + W[31];
+ t2 = e0(b) + Maj(b,c,d); e+=t1; a=t1+t2;
+
+ t1 = h + e1(e) + Ch(e,f,g) + 0x27b70a85 + W[32];
+ t2 = e0(a) + Maj(a,b,c); d+=t1; h=t1+t2;
+ t1 = g + e1(d) + Ch(d,e,f) + 0x2e1b2138 + W[33];
+ t2 = e0(h) + Maj(h,a,b); c+=t1; g=t1+t2;
+ t1 = f + e1(c) + Ch(c,d,e) + 0x4d2c6dfc + W[34];
+ t2 = e0(g) + Maj(g,h,a); b+=t1; f=t1+t2;
+ t1 = e + e1(b) + Ch(b,c,d) + 0x53380d13 + W[35];
+ t2 = e0(f) + Maj(f,g,h); a+=t1; e=t1+t2;
+ t1 = d + e1(a) + Ch(a,b,c) + 0x650a7354 + W[36];
+ t2 = e0(e) + Maj(e,f,g); h+=t1; d=t1+t2;
+ t1 = c + e1(h) + Ch(h,a,b) + 0x766a0abb + W[37];
+ t2 = e0(d) + Maj(d,e,f); g+=t1; c=t1+t2;
+ t1 = b + e1(g) + Ch(g,h,a) + 0x81c2c92e + W[38];
+ t2 = e0(c) + Maj(c,d,e); f+=t1; b=t1+t2;
+ t1 = a + e1(f) + Ch(f,g,h) + 0x92722c85 + W[39];
+ t2 = e0(b) + Maj(b,c,d); e+=t1; a=t1+t2;
+
+ t1 = h + e1(e) + Ch(e,f,g) + 0xa2bfe8a1 + W[40];
+ t2 = e0(a) + Maj(a,b,c); d+=t1; h=t1+t2;
+ t1 = g + e1(d) + Ch(d,e,f) + 0xa81a664b + W[41];
+ t2 = e0(h) + Maj(h,a,b); c+=t1; g=t1+t2;
+ t1 = f + e1(c) + Ch(c,d,e) + 0xc24b8b70 + W[42];
+ t2 = e0(g) + Maj(g,h,a); b+=t1; f=t1+t2;
+ t1 = e + e1(b) + Ch(b,c,d) + 0xc76c51a3 + W[43];
+ t2 = e0(f) + Maj(f,g,h); a+=t1; e=t1+t2;
+ t1 = d + e1(a) + Ch(a,b,c) + 0xd192e819 + W[44];
+ t2 = e0(e) + Maj(e,f,g); h+=t1; d=t1+t2;
+ t1 = c + e1(h) + Ch(h,a,b) + 0xd6990624 + W[45];
+ t2 = e0(d) + Maj(d,e,f); g+=t1; c=t1+t2;
+ t1 = b + e1(g) + Ch(g,h,a) + 0xf40e3585 + W[46];
+ t2 = e0(c) + Maj(c,d,e); f+=t1; b=t1+t2;
+ t1 = a + e1(f) + Ch(f,g,h) + 0x106aa070 + W[47];
+ t2 = e0(b) + Maj(b,c,d); e+=t1; a=t1+t2;
+
+ t1 = h + e1(e) + Ch(e,f,g) + 0x19a4c116 + W[48];
+ t2 = e0(a) + Maj(a,b,c); d+=t1; h=t1+t2;
+ t1 = g + e1(d) + Ch(d,e,f) + 0x1e376c08 + W[49];
+ t2 = e0(h) + Maj(h,a,b); c+=t1; g=t1+t2;
+ t1 = f + e1(c) + Ch(c,d,e) + 0x2748774c + W[50];
+ t2 = e0(g) + Maj(g,h,a); b+=t1; f=t1+t2;
+ t1 = e + e1(b) + Ch(b,c,d) + 0x34b0bcb5 + W[51];
+ t2 = e0(f) + Maj(f,g,h); a+=t1; e=t1+t2;
+ t1 = d + e1(a) + Ch(a,b,c) + 0x391c0cb3 + W[52];
+ t2 = e0(e) + Maj(e,f,g); h+=t1; d=t1+t2;
+ t1 = c + e1(h) + Ch(h,a,b) + 0x4ed8aa4a + W[53];
+ t2 = e0(d) + Maj(d,e,f); g+=t1; c=t1+t2;
+ t1 = b + e1(g) + Ch(g,h,a) + 0x5b9cca4f + W[54];
+ t2 = e0(c) + Maj(c,d,e); f+=t1; b=t1+t2;
+ t1 = a + e1(f) + Ch(f,g,h) + 0x682e6ff3 + W[55];
+ t2 = e0(b) + Maj(b,c,d); e+=t1; a=t1+t2;
+
+ t1 = h + e1(e) + Ch(e,f,g) + 0x748f82ee + W[56];
+ t2 = e0(a) + Maj(a,b,c); d+=t1; h=t1+t2;
+ t1 = g + e1(d) + Ch(d,e,f) + 0x78a5636f + W[57];
+ t2 = e0(h) + Maj(h,a,b); c+=t1; g=t1+t2;
+ t1 = f + e1(c) + Ch(c,d,e) + 0x84c87814 + W[58];
+ t2 = e0(g) + Maj(g,h,a); b+=t1; f=t1+t2;
+ t1 = e + e1(b) + Ch(b,c,d) + 0x8cc70208 + W[59];
+ t2 = e0(f) + Maj(f,g,h); a+=t1; e=t1+t2;
+ t1 = d + e1(a) + Ch(a,b,c) + 0x90befffa + W[60];
+ t2 = e0(e) + Maj(e,f,g); h+=t1; d=t1+t2;
+ t1 = c + e1(h) + Ch(h,a,b) + 0xa4506ceb + W[61];
+ t2 = e0(d) + Maj(d,e,f); g+=t1; c=t1+t2;
+ t1 = b + e1(g) + Ch(g,h,a) + 0xbef9a3f7 + W[62];
+ t2 = e0(c) + Maj(c,d,e); f+=t1; b=t1+t2;
+ t1 = a + e1(f) + Ch(f,g,h) + 0xc67178f2 + W[63];
+ t2 = e0(b) + Maj(b,c,d); e+=t1; a=t1+t2;
+
+ state[0] += a; state[1] += b; state[2] += c; state[3] += d;
+ state[4] += e; state[5] += f; state[6] += g; state[7] += h;
+
+ /* clear any sensitive info... */
+ a = b = c = d = e = f = g = h = t1 = t2 = 0;
+ memset(W, 0, 64 * sizeof(u32));
+}
+
+SHA256Summation::SHA256Summation()
+{
+ Sum.state[0] = H0;
+ Sum.state[1] = H1;
+ Sum.state[2] = H2;
+ Sum.state[3] = H3;
+ Sum.state[4] = H4;
+ Sum.state[5] = H5;
+ Sum.state[6] = H6;
+ Sum.state[7] = H7;
+ Sum.count[0] = Sum.count[1] = 0;
+ memset(Sum.buf, 0, sizeof(Sum.buf));
+ Done = false;
+}
+
+bool SHA256Summation::Add(const u8 *data, unsigned long len)
+{
+ struct sha256_ctx *sctx = &Sum;
+ unsigned int i, index, part_len;
+
+ if (Done) return false;
+
+ /* Compute number of bytes mod 128 */
+ index = (unsigned int)((sctx->count[0] >> 3) & 0x3f);
+
+ /* Update number of bits */
+ if ((sctx->count[0] += (len << 3)) < (len << 3)) {
+ sctx->count[1]++;
+ sctx->count[1] += (len >> 29);
+ }
+
+ part_len = 64 - index;
+
+ /* Transform as many times as possible. */
+ if (len >= part_len) {
+ memcpy(&sctx->buf[index], data, part_len);
+ sha256_transform(sctx->state, sctx->buf);
+
+ for (i = part_len; i + 63 < len; i += 64)
+ sha256_transform(sctx->state, &data[i]);
+ index = 0;
+ } else {
+ i = 0;
+ }
+
+ /* Buffer remaining input */
+ memcpy(&sctx->buf[index], &data[i], len-i);
+
+ return true;
+}
+
+SHA256SumValue SHA256Summation::Result()
+{
+ struct sha256_ctx *sctx = &Sum;
+ if (!Done) {
+ u8 bits[8];
+ unsigned int index, pad_len, t;
+ static const u8 padding[64] = { 0x80, };
+
+ /* Save number of bits */
+ t = sctx->count[0];
+ bits[7] = t; t >>= 8;
+ bits[6] = t; t >>= 8;
+ bits[5] = t; t >>= 8;
+ bits[4] = t;
+ t = sctx->count[1];
+ bits[3] = t; t >>= 8;
+ bits[2] = t; t >>= 8;
+ bits[1] = t; t >>= 8;
+ bits[0] = t;
+
+ /* Pad out to 56 mod 64. */
+ index = (sctx->count[0] >> 3) & 0x3f;
+ pad_len = (index < 56) ? (56 - index) : ((64+56) - index);
+ Add(padding, pad_len);
+
+ /* Append length (before padding) */
+ Add(bits, 8);
+ }
+
+ Done = true;
+
+ /* Store state in digest */
+
+ SHA256SumValue res;
+ u8 *out = res.Sum;
+
+ int i, j;
+ unsigned int t;
+ for (i = j = 0; i < 8; i++, j += 4) {
+ t = sctx->state[i];
+ out[j+3] = t; t >>= 8;
+ out[j+2] = t; t >>= 8;
+ out[j+1] = t; t >>= 8;
+ out[j ] = t;
+ }
+
+ return res;
+}
+
+// SHA256SumValue::SHA256SumValue - Constructs the sum from a string /*{{{*/
+// ---------------------------------------------------------------------
+/* The string form of a SHA256 is a 64 character hex number */
+SHA256SumValue::SHA256SumValue(string Str)
+{
+ memset(Sum,0,sizeof(Sum));
+ Set(Str);
+}
+
+ /*}}}*/
+// SHA256SumValue::SHA256SumValue - Default constructor /*{{{*/
+// ---------------------------------------------------------------------
+/* Sets the value to 0 */
+SHA256SumValue::SHA256SumValue()
+{
+ memset(Sum,0,sizeof(Sum));
+}
+
+ /*}}}*/
+// SHA256SumValue::Set - Set the sum from a string /*{{{*/
+// ---------------------------------------------------------------------
+/* Converts the hex string into a set of chars */
+bool SHA256SumValue::Set(string Str)
+{
+ return Hex2Num(Str,Sum,sizeof(Sum));
+}
+ /*}}}*/
+// SHA256SumValue::Value - Convert the number into a string /*{{{*/
+// ---------------------------------------------------------------------
+/* Converts the set of chars into a hex string in lower case */
+string SHA256SumValue::Value() const
+{
+ char Conv[16] =
+ { '0','1','2','3','4','5','6','7','8','9','a','b',
+ 'c','d','e','f'
+ };
+ char Result[65];
+ Result[64] = 0;
+
+ // Convert each char into two letters
+ int J = 0;
+ int I = 0;
+ for (; I != 64; J++,I += 2)
+ {
+ Result[I] = Conv[Sum[J] >> 4];
+ Result[I + 1] = Conv[Sum[J] & 0xF];
+ }
+
+ return string(Result);
+}
+
+
+
+// SHA256SumValue::operator == - Comparator /*{{{*/
+// ---------------------------------------------------------------------
+/* Call memcmp on the buffer */
+bool SHA256SumValue::operator == (const SHA256SumValue & rhs) const
+{
+ return memcmp(Sum,rhs.Sum,sizeof(Sum)) == 0;
+}
+ /*}}}*/
+
+
+// SHA256Summation::AddFD - Add content of file into the checksum /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool SHA256Summation::AddFD(int Fd,unsigned long Size)
+{
+ unsigned char Buf[64 * 64];
+ int Res = 0;
+ int ToEOF = (Size == 0);
+ while (Size != 0 || ToEOF)
+ {
+ unsigned n = sizeof(Buf);
+ if (!ToEOF) n = min(Size,(unsigned long)n);
+ Res = read(Fd,Buf,n);
+ if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read
+ return false;
+ if (ToEOF && Res == 0) // EOF
+ break;
+ Size -= Res;
+ Add(Buf,Res);
+ }
+ return true;
+}
+ /*}}}*/
+
diff --git a/apt-pkg/contrib/sha256.h b/apt-pkg/contrib/sha256.h
new file mode 100644
index 000000000..70b3ae2ad
--- /dev/null
+++ b/apt-pkg/contrib/sha256.h
@@ -0,0 +1,74 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+// $Id: sha1.h,v 1.3 2001/05/07 05:05:47 jgg Exp $
+/* ######################################################################
+
+ SHA256SumValue - Storage for a SHA-256 hash.
+ SHA256Summation - SHA-256 Secure Hash Algorithm.
+
+ This is a C++ interface to a set of SHA256Sum functions, that mirrors
+ the equivalent MD5 & SHA1 classes.
+
+ ##################################################################### */
+ /*}}}*/
+#ifndef APTPKG_SHA256_H
+#define APTPKG_SHA256_H
+
+#ifdef __GNUG__
+#pragma interface "apt-pkg/sha256.h"
+#endif
+
+#include <string>
+#include <algorithm>
+
+using std::string;
+using std::min;
+
+class SHA256Summation;
+
+class SHA256SumValue
+{
+ friend class SHA256Summation;
+ unsigned char Sum[32];
+
+ public:
+
+ // Accessors
+ bool operator ==(const SHA256SumValue &rhs) const;
+ string Value() const;
+ inline void Value(unsigned char S[32])
+ {for (int I = 0; I != sizeof(Sum); I++) S[I] = Sum[I];};
+ inline operator string() const {return Value();};
+ bool Set(string Str);
+ inline void Set(unsigned char S[32])
+ {for (int I = 0; I != sizeof(Sum); I++) Sum[I] = S[I];};
+
+ SHA256SumValue(string Str);
+ SHA256SumValue();
+};
+
+struct sha256_ctx {
+ uint32_t count[2];
+ uint32_t state[8];
+ uint8_t buf[128];
+};
+
+class SHA256Summation
+{
+ struct sha256_ctx Sum;
+
+ bool Done;
+
+ public:
+
+ bool Add(const unsigned char *inbuf,unsigned long inlen);
+ inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));};
+ bool AddFD(int Fd,unsigned long Size);
+ inline bool Add(const unsigned char *Beg,const unsigned char *End)
+ {return Add(Beg,End-Beg);};
+ SHA256SumValue Result();
+
+ SHA256Summation();
+};
+
+#endif
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index a75fbdf92..d96155917 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -199,10 +199,10 @@ bool ParseCWord(const char *&String,string &Res)
// QuoteString - Convert a string into quoted from /*{{{*/
// ---------------------------------------------------------------------
/* */
-string QuoteString(string Str,const char *Bad)
+string QuoteString(const string &Str, const char *Bad)
{
string Res;
- for (string::iterator I = Str.begin(); I != Str.end(); I++)
+ for (string::const_iterator I = Str.begin(); I != Str.end(); I++)
{
if (strchr(Bad,*I) != 0 || isprint(*I) == 0 ||
*I <= 0x20 || *I >= 0x7F)
@@ -220,7 +220,7 @@ string QuoteString(string Str,const char *Bad)
// DeQuoteString - Convert a string from quoted from /*{{{*/
// ---------------------------------------------------------------------
/* This undoes QuoteString */
-string DeQuoteString(string Str)
+string DeQuoteString(const string &Str)
{
string Res;
for (string::const_iterator I = Str.begin(); I != Str.end(); I++)
@@ -317,7 +317,7 @@ string TimeToStr(unsigned long Sec)
// SubstVar - Substitute a string for another string /*{{{*/
// ---------------------------------------------------------------------
/* This replaces all occurances of Subst with Contents in Str. */
-string SubstVar(string Str,string Subst,string Contents)
+string SubstVar(const string &Str,const string &Subst,const string &Contents)
{
string::size_type Pos = 0;
string::size_type OldPos = 0;
@@ -348,21 +348,18 @@ string SubstVar(string Str,const struct SubstVar *Vars)
/* This converts a URI into a safe filename. It quotes all unsafe characters
and converts / to _ and removes the scheme identifier. The resulting
file name should be unique and never occur again for a different file */
-string URItoFileName(string URI)
+string URItoFileName(const string &URI)
{
// Nuke 'sensitive' items
::URI U(URI);
- U.User = string();
- U.Password = string();
- U.Access = "";
+ U.User.clear();
+ U.Password.clear();
+ U.Access.clear();
// "\x00-\x20{}|\\\\^\\[\\]<>\"\x7F-\xFF";
- URI = QuoteString(U,"\\|{}[]<>\"^~_=!@#$%^&*");
- string::iterator J = URI.begin();
- for (; J != URI.end(); J++)
- if (*J == '/')
- *J = '_';
- return URI;
+ string NewURI = QuoteString(U,"\\|{}[]<>\"^~_=!@#$%^&*");
+ replace(NewURI.begin(),NewURI.end(),'/','_');
+ return NewURI;
}
/*}}}*/
// Base64Encode - Base64 Encoding routine for short strings /*{{{*/
@@ -371,7 +368,7 @@ string URItoFileName(string URI)
from wget and then patched and bug fixed.
This spec can be found in rfc2045 */
-string Base64Encode(string S)
+string Base64Encode(const string &S)
{
// Conversion table.
static char tbl[64] = {'A','B','C','D','E','F','G','H',
@@ -540,17 +537,17 @@ int stringcasecmp(string::const_iterator A,string::const_iterator AEnd,
// ---------------------------------------------------------------------
/* The format is like those used in package files and the method
communication system */
-string LookupTag(string Message,const char *Tag,const char *Default)
+string LookupTag(const string &Message,const char *Tag,const char *Default)
{
// Look for a matching tag.
int Length = strlen(Tag);
- for (string::iterator I = Message.begin(); I + Length < Message.end(); I++)
+ for (string::const_iterator I = Message.begin(); I + Length < Message.end(); I++)
{
// Found the tag
if (I[Length] == ':' && stringcasecmp(I,I+Length,Tag) == 0)
{
// Find the end of line and strip the leading/trailing spaces
- string::iterator J;
+ string::const_iterator J;
I += Length + 1;
for (; isspace(*I) != 0 && I < Message.end(); I++);
for (J = I; *J != '\n' && J < Message.end(); J++);
@@ -572,7 +569,7 @@ string LookupTag(string Message,const char *Tag,const char *Default)
// ---------------------------------------------------------------------
/* This inspects the string to see if it is true or if it is false and
then returns the result. Several varients on true/false are checked. */
-int StringToBool(string Text,int Default)
+int StringToBool(const string &Text,int Default)
{
char *End;
int Res = strtol(Text.c_str(),&End,0);
@@ -738,7 +735,7 @@ static time_t timegm(struct tm *t)
'timegm' to convert a struct tm in UTC to a time_t. For some bizzar
reason the C library does not provide any such function :< This also
handles the weird, but unambiguous FTP time format*/
-bool StrToTime(string Val,time_t &Result)
+bool StrToTime(const string &Val,time_t &Result)
{
struct tm Tm;
char Month[10];
@@ -825,7 +822,7 @@ static int HexDigit(int c)
// Hex2Num - Convert a long hex number into a buffer /*{{{*/
// ---------------------------------------------------------------------
/* The length of the buffer must be exactly 1/2 the length of the string. */
-bool Hex2Num(string Str,unsigned char *Num,unsigned int Length)
+bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length)
{
if (Str.length() != Length*2)
return false;
@@ -986,7 +983,7 @@ char *safe_snprintf(char *Buffer,char *End,const char *Format,...)
// ---------------------------------------------------------------------
/* The domain list is a comma seperate list of domains that are suffix
matched against the argument */
-bool CheckDomainList(string Host,string List)
+bool CheckDomainList(const string &Host,const string &List)
{
string::const_iterator Start = List.begin();
for (string::const_iterator Cur = List.begin(); Cur <= List.end(); Cur++)
@@ -1009,7 +1006,7 @@ bool CheckDomainList(string Host,string List)
// URI::CopyFrom - Copy from an object /*{{{*/
// ---------------------------------------------------------------------
/* This parses the URI into all of its components */
-void URI::CopyFrom(string U)
+void URI::CopyFrom(const string &U)
{
string::const_iterator I = U.begin();
@@ -1038,9 +1035,9 @@ void URI::CopyFrom(string U)
SingleSlash = U.end();
// We can now write the access and path specifiers
- Access = string(U,0,FirstColon - U.begin());
+ Access.assign(U.begin(),FirstColon);
if (SingleSlash != U.end())
- Path = string(U,SingleSlash - U.begin());
+ Path.assign(SingleSlash,U.end());
if (Path.empty() == true)
Path = "/";
@@ -1070,14 +1067,14 @@ void URI::CopyFrom(string U)
if (At == SingleSlash)
{
if (FirstColon < SingleSlash)
- Host = string(U,FirstColon - U.begin(),SingleSlash - FirstColon);
+ Host.assign(FirstColon,SingleSlash);
}
else
{
- Host = string(U,At - U.begin() + 1,SingleSlash - At - 1);
- User = string(U,FirstColon - U.begin(),SecondColon - FirstColon);
+ Host.assign(At+1,SingleSlash);
+ User.assign(FirstColon,SecondColon);
if (SecondColon < At)
- Password = string(U,SecondColon - U.begin() + 1,At - SecondColon - 1);
+ Password.assign(SecondColon+1,At);
}
// Now we parse the RFC 2732 [] hostnames.
@@ -1105,7 +1102,7 @@ void URI::CopyFrom(string U)
// Tsk, weird.
if (InBracket == true)
{
- Host = string();
+ Host.clear();
return;
}
@@ -1116,7 +1113,7 @@ void URI::CopyFrom(string U)
return;
Port = atoi(string(Host,Pos+1).c_str());
- Host = string(Host,0,Pos);
+ Host.assign(Host,0,Pos);
}
/*}}}*/
// URI::operator string - Convert the URI to a string /*{{{*/
@@ -1171,12 +1168,12 @@ URI::operator string()
// URI::SiteOnly - Return the schema and site for the URI /*{{{*/
// ---------------------------------------------------------------------
/* */
-string URI::SiteOnly(string URI)
+string URI::SiteOnly(const string &URI)
{
::URI U(URI);
- U.User = string();
- U.Password = string();
- U.Path = string();
+ U.User.clear();
+ U.Password.clear();
+ U.Path.clear();
U.Port = 0;
return U;
}
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index 353e78ac9..6ec2b7811 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -43,24 +43,24 @@ char *_strstrip(char *String);
char *_strtabexpand(char *String,size_t Len);
bool ParseQuoteWord(const char *&String,string &Res);
bool ParseCWord(const char *&String,string &Res);
-string QuoteString(string Str,const char *Bad);
-string DeQuoteString(string Str);
+string QuoteString(const string &Str,const char *Bad);
+string DeQuoteString(const string &Str);
string SizeToStr(double Bytes);
string TimeToStr(unsigned long Sec);
-string Base64Encode(string Str);
-string URItoFileName(string URI);
+string Base64Encode(const string &Str);
+string URItoFileName(const string &URI);
string TimeRFC1123(time_t Date);
-bool StrToTime(string Val,time_t &Result);
-string LookupTag(string Message,const char *Tag,const char *Default = 0);
-int StringToBool(string Text,int Default = -1);
+bool StrToTime(const string &Val,time_t &Result);
+string LookupTag(const string &Message,const char *Tag,const char *Default = 0);
+int StringToBool(const string &Text,int Default = -1);
bool ReadMessages(int Fd, vector<string> &List);
bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base = 0);
-bool Hex2Num(string Str,unsigned char *Num,unsigned int Length);
+bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length);
bool TokSplitString(char Tok,char *Input,char **List,
unsigned long ListMax);
void ioprintf(ostream &out,const char *format,...) APT_FORMAT2;
char *safe_snprintf(char *Buffer,char *End,const char *Format,...) APT_FORMAT3;
-bool CheckDomainList(string Host,string List);
+bool CheckDomainList(const string &Host, const string &List);
#define APT_MKSTRCMP(name,func) \
inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \
@@ -101,7 +101,7 @@ inline const char *DeNull(const char *s) {return (s == 0?"(null)":s);};
class URI
{
- void CopyFrom(string From);
+ void CopyFrom(const string &From);
public:
@@ -113,9 +113,9 @@ class URI
unsigned int Port;
operator string();
- inline void operator =(string From) {CopyFrom(From);};
+ inline void operator =(const string &From) {CopyFrom(From);};
inline bool empty() {return Access.empty();};
- static string SiteOnly(string URI);
+ static string SiteOnly(const string &URI);
URI(string Path) {CopyFrom(Path);};
URI() : Port(0) {};
@@ -127,7 +127,7 @@ struct SubstVar
const string *Contents;
};
string SubstVar(string Str,const struct SubstVar *Vars);
-string SubstVar(string Str,string Subst,string Contents);
+string SubstVar(const string &Str,const string &Subst,const string &Contents);
struct RxChoiceList
{
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index ff8bce85d..234521efe 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -305,7 +305,7 @@ pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
pkgCache::PkgFileIterator File = Cache.FileBegin();
for (; File.end() == false; File++)
{
- if (FileName != File.FileName())
+ if (File.FileName() == NULL || FileName != File.FileName())
continue;
struct stat St;
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 25b533773..d0dc7a260 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -377,12 +377,12 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
const char *End = I;
for (; End > Start && isspace(End[-1]); End--);
- Ver = string(Start,End-Start);
+ Ver.assign(Start,End-Start);
I++;
}
else
{
- Ver = string();
+ Ver.clear();
Op = pkgCache::Dep::NoOp;
}
@@ -504,11 +504,12 @@ bool debListParser::ParseProvides(pkgCache::VerIterator Ver)
Start = ParseDepends(Start,Stop,Package,Version,Op);
if (Start == 0)
return _error->Error("Problem parsing Provides line");
- if (Op != pkgCache::Dep::NoOp)
- return _error->Error("Malformed provides line");
-
- if (NewProvides(Ver,Package,Version) == false)
- return false;
+ if (Op != pkgCache::Dep::NoOp) {
+ _error->Warning("Ignoring Provides line with DepCompareOp for package %s", Package.c_str());
+ } else {
+ if (NewProvides(Ver,Package,Version) == false)
+ return false;
+ }
if (Start == Stop)
break;
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index 526c8c0b2..85e5b16b3 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -165,6 +165,10 @@ bool debReleaseIndex::IsTrusted() const
string VerifiedSigFile = _config->FindDir("Dir::State::lists") +
URItoFileName(MetaIndexURI("Release")) + ".gpg";
+ if(_config->FindB("APT::Authentication::TrustCDROM", false))
+ if(URI.substr(0,strlen("cdrom:")) == "cdrom:")
+ return true;
+
if (FileExists(VerifiedSigFile))
return true;
return false;
diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc
index cac36c2e6..9e87ee5da 100644
--- a/apt-pkg/deb/debsrcrecords.cc
+++ b/apt-pkg/deb/debsrcrecords.cc
@@ -18,6 +18,8 @@
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/configuration.h>
+
+using std::max;
/*}}}*/
// SrcRecordParser::Binaries - Return the binaries field /*{{{*/
@@ -34,31 +36,19 @@ const char **debSrcRecordParser::Binaries()
if (Bins.empty() == true || Bins.length() >= 102400)
return 0;
- // Workaround for #236688. Only allocate a new buffer if the field
- // is large, to avoid a performance penalty
- char *BigBuf = NULL;
- char *Buf;
- if (Bins.length() > sizeof(Buffer))
- {
- BigBuf = new char[Bins.length()];
- Buf = BigBuf;
- }
- else
+ if (Bins.length() >= BufSize)
{
- Buf = Buffer;
+ delete [] Buffer;
+ // allocate new size based on buffer (but never smaller than 4000)
+ BufSize = max((unsigned long)4000, max((unsigned long)Bins.length()+1,2*BufSize));
+ Buffer = new char[BufSize];
}
- strcpy(Buf,Bins.c_str());
- if (TokSplitString(',',Buf,StaticBinList,
+ strcpy(Buffer,Bins.c_str());
+ if (TokSplitString(',',Buffer,StaticBinList,
sizeof(StaticBinList)/sizeof(StaticBinList[0])) == false)
- {
- if (BigBuf != NULL)
- delete BigBuf;
return 0;
- }
- if (BigBuf != NULL)
- delete BigBuf;
return (const char **)StaticBinList;
}
/*}}}*/
diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h
index f899993df..f4e2cb46c 100644
--- a/apt-pkg/deb/debsrcrecords.h
+++ b/apt-pkg/deb/debsrcrecords.h
@@ -24,9 +24,10 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
FileFd Fd;
pkgTagFile Tags;
pkgTagSection Sect;
- char Buffer[10000];
char *StaticBinList[400];
unsigned long iOffset;
+ char *Buffer;
+ unsigned long BufSize;
public:
@@ -49,10 +50,9 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
};
virtual bool Files(vector<pkgSrcRecords::File> &F);
- debSrcRecordParser(string File,pkgIndexFile const *Index) :
- Parser(Index),
- Fd(File,FileFd::ReadOnly),
- Tags(&Fd,102400) {};
+ debSrcRecordParser(string File,pkgIndexFile const *Index)
+ : Parser(Index), Fd(File,FileFd::ReadOnly), Tags(&Fd,102400),
+ Buffer(0), BufSize(0) {}
};
#endif
diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc
index aeee61929..064d8fa5b 100644
--- a/apt-pkg/deb/debversion.cc
+++ b/apt-pkg/deb/debversion.cc
@@ -59,7 +59,7 @@ int debVersioningSystem::CmpFragment(const char *A,const char *AEnd,
}
/* Iterate over the whole string
- What this does is to spilt the whole string into groups of
+ What this does is to split the whole string into groups of
numeric and non numeric portions. For instance:
a67bhgs89
Has 4 portions 'a', '67', 'bhgs', '89'. A more normal:
@@ -140,6 +140,27 @@ int debVersioningSystem::DoCmpVersion(const char *A,const char *AEnd,
if (rhs == BEnd)
rhs = B;
+ // Special case: a zero epoch is the same as no epoch,
+ // so remove it.
+ if (lhs != A)
+ {
+ for (; *A == '0'; ++A);
+ if (A == lhs)
+ {
+ ++A;
+ ++lhs;
+ }
+ }
+ if (rhs != B)
+ {
+ for (; *B == '0'; ++B);
+ if (B == rhs)
+ {
+ ++B;
+ ++rhs;
+ }
+ }
+
// Compare the epoch
int Res = CmpFragment(A,lhs,B,rhs);
if (Res != 0)
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index fe8fbca74..3204fc1bb 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -355,28 +355,28 @@ bool pkgDPkgPM::Go(int OutStatusFd)
static const struct DpkgState DpkgStatesOpMap[][5] = {
// Install operation
{
- {"half-installed", _("Preparing %s")},
- {"unpacked", _("Unpacking %s") },
+ {"half-installed", N_("Preparing %s")},
+ {"unpacked", N_("Unpacking %s") },
{NULL, NULL}
},
// Configure operation
{
- {"unpacked",_("Preparing to configure %s") },
- {"half-configured", _("Configuring %s") },
- { "installed", _("Installed %s")},
+ {"unpacked",N_("Preparing to configure %s") },
+ {"half-configured", N_("Configuring %s") },
+ { "installed", N_("Installed %s")},
{NULL, NULL}
},
// Remove operation
{
- {"half-configured", _("Preparing for removal of %s")},
- {"half-installed", _("Removing %s")},
- {"config-files", _("Removed %s")},
+ {"half-configured", N_("Preparing for removal of %s")},
+ {"half-installed", N_("Removing %s")},
+ {"config-files", N_("Removed %s")},
{NULL, NULL}
},
// Purge operation
{
- {"config-files", _("Preparing for remove with config %s")},
- {"not-installed", _("Removed with config %s")},
+ {"config-files", N_("Preparing to completely remove %s")},
+ {"not-installed", N_("Completely removed %s")},
{NULL, NULL}
},
};
@@ -623,10 +623,23 @@ bool pkgDPkgPM::Go(int OutStatusFd)
'status: conffile-prompt: conffile : 'current-conffile' 'new-conffile' useredited distedited
*/
- char* list[4];
- TokSplitString(':', line, list, 5);
+ char* list[5];
+ // dpkg sends multiline error messages sometimes (see
+ // #374195 for a example. we should support this by
+ // either patching dpkg to not send multiline over the
+ // statusfd or by rewriting the code here to deal with
+ // it. for now we just ignore it and not crash
+ TokSplitString(':', line, list, sizeof(list)/sizeof(list[0]));
char *pkg = list[1];
char *action = _strstrip(list[2]);
+ if( pkg == NULL || action == NULL)
+ {
+ if (_config->FindB("Debug::pkgDPkgProgressReporting",false) == true)
+ std::clog << "ignoring line: not enough ':'" << std::endl;
+ // reset the line buffer
+ line[0]=0;
+ continue;
+ }
if(strncmp(action,"error",strlen("error")) == 0)
{
@@ -664,7 +677,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
{
// only read the translation if there is actually a next
// action
- const char *translation = states[PackageOpsDone[pkg]].str;
+ const char *translation = _(states[PackageOpsDone[pkg]].str);
char s[200];
snprintf(s, sizeof(s), translation, pkg);
@@ -698,14 +711,23 @@ bool pkgDPkgPM::Go(int OutStatusFd)
// Check for an error code.
if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)
{
- RunScripts("DPkg::Post-Invoke");
- if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV)
- return _error->Error("Sub-process %s received a segmentation fault.",Args[0]);
-
- if (WIFEXITED(Status) != 0)
- return _error->Error("Sub-process %s returned an error code (%u)",Args[0],WEXITSTATUS(Status));
+ // if it was set to "keep-dpkg-runing" then we won't return
+ // here but keep the loop going and just report it as a error
+ // for later
+ bool stopOnError = _config->FindB("Dpkg::StopOnError",true);
- return _error->Error("Sub-process %s exited unexpectedly",Args[0]);
+ if(stopOnError)
+ RunScripts("DPkg::Post-Invoke");
+
+ if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV)
+ _error->Error("Sub-process %s received a segmentation fault.",Args[0]);
+ else if (WIFEXITED(Status) != 0)
+ _error->Error("Sub-process %s returned an error code (%u)",Args[0],WEXITSTATUS(Status));
+ else
+ _error->Error("Sub-process %s exited unexpectedly",Args[0]);
+
+ if(stopOnError)
+ return false;
}
}
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index dd1c794c9..58d1d25e5 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -16,7 +16,8 @@
#include <apt-pkg/error.h>
#include <apt-pkg/sptr.h>
#include <apt-pkg/algorithms.h>
-
+#include <apt-pkg/configuration.h>
+
#include <apti18n.h>
/*}}}*/
@@ -712,6 +713,10 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
if (InstPkg.end() == false)
{
+ if(_config->FindB("Debug::pkgDepCache::AutoInstall",false) == true)
+ std::clog << "Installing " << InstPkg.Name()
+ << " as dep of " << Pkg.Name()
+ << std::endl;
MarkInstall(InstPkg,true,Depth + 1);
// Set the autoflag, after MarkInstall because MarkInstall unsets it
diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc
index f4b816c0b..b47378d4a 100644
--- a/apt-pkg/init.cc
+++ b/apt-pkg/init.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: init.cc,v 1.21 2004/02/27 00:46:44 mdz Exp $
+// $Id: init.cc,v 1.20 2003/02/09 20:31:05 doogie Exp $
/* ######################################################################
Init - Initialize the package library
@@ -64,13 +64,14 @@ bool pkgInitConfig(Configuration &Cnf)
// Configuration
Cnf.Set("Dir::Etc","etc/apt/");
Cnf.Set("Dir::Etc::sourcelist","sources.list");
+ Cnf.Set("Dir::Etc::sourceparts","sources.list.d");
Cnf.Set("Dir::Etc::vendorlist","vendors.list");
Cnf.Set("Dir::Etc::vendorparts","vendors.list.d");
Cnf.Set("Dir::Etc::main","apt.conf");
Cnf.Set("Dir::Etc::parts","apt.conf.d");
Cnf.Set("Dir::Etc::preferences","preferences");
Cnf.Set("Dir::Bin::methods","/usr/lib/apt/methods");
-
+
bool Res = true;
// Read an alternate config file
diff --git a/apt-pkg/makefile b/apt-pkg/makefile
index 8de7d945e..7e5feae53 100644
--- a/apt-pkg/makefile
+++ b/apt-pkg/makefile
@@ -13,7 +13,7 @@ include ../buildlib/defaults.mak
# methods/makefile - FIXME
LIBRARY=apt-pkg
LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER)
-MAJOR=3.10
+MAJOR=3.11
MINOR=0
SLIBS=$(PTHREADLIB) $(INTLLIBS)
APT_DOMAIN:=libapt-pkg$(MAJOR)
@@ -21,11 +21,11 @@ APT_DOMAIN:=libapt-pkg$(MAJOR)
# Source code for the contributed non-core things
SOURCE = contrib/mmap.cc contrib/error.cc contrib/strutl.cc \
contrib/configuration.cc contrib/progress.cc contrib/cmndline.cc \
- contrib/md5.cc contrib/sha1.cc contrib/hashes.cc \
+ contrib/md5.cc contrib/sha1.cc contrib/sha256.cc contrib/hashes.cc \
contrib/cdromutl.cc contrib/crc-16.cc \
contrib/fileutl.cc
HEADERS = mmap.h error.h configuration.h fileutl.h cmndline.h \
- md5.h crc-16.h cdromutl.h strutl.h sptr.h sha1.h hashes.h
+ md5.h crc-16.h cdromutl.h strutl.h sptr.h sha1.h sha256.h hashes.h
# Source code for the core main library
SOURCE+= pkgcache.cc version.cc depcache.cc \
diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index 155408bb4..4b3dd8be2 100644
--- a/apt-pkg/packagemanager.cc
+++ b/apt-pkg/packagemanager.cc
@@ -593,7 +593,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
Pkg.State() == pkgCache::PkgIterator::NeedsNothing &&
(Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)
{
- _error->Error("Internal Error, trying to manipulate a kept package");
+ _error->Error("Internal Error, trying to manipulate a kept package (%s)",Pkg.Name());
return Failed;
}
@@ -634,6 +634,8 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
pkgPackageManager::OrderResult pkgPackageManager::DoInstall(int status_fd)
{
OrderResult Res = OrderInstall();
+ if(Debug)
+ std::clog << "OrderInstall() returned: " << Res << std::endl;
if (Res != Failed)
if (Go(status_fd) == false)
return Failed;
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index 6ef7cafb0..9926befe9 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -153,7 +153,7 @@ bool pkgCache::ReMap()
/* This is used to generate the hash entries for the HashTable. With my
package list from bo this function gets 94% table usage on a 512 item
table (480 used items) */
-unsigned long pkgCache::sHash(string Str) const
+unsigned long pkgCache::sHash(const string &Str) const
{
unsigned long Hash = 0;
for (string::const_iterator I = Str.begin(); I != Str.end(); I++)
@@ -173,7 +173,7 @@ unsigned long pkgCache::sHash(const char *Str) const
// Cache::FindPkg - Locate a package by name /*{{{*/
// ---------------------------------------------------------------------
/* Returns 0 on error, pointer to the package otherwise */
-pkgCache::PkgIterator pkgCache::FindPkg(string Name)
+pkgCache::PkgIterator pkgCache::FindPkg(const string &Name)
{
// Look at the hash bucket
Package *Pkg = PkgP + HeaderP->HashTable[Hash(Name)];
diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h
index b07951dfb..587d97534 100644
--- a/apt-pkg/pkgcache.h
+++ b/apt-pkg/pkgcache.h
@@ -89,7 +89,7 @@ class pkgCache
string CacheFile;
MMap &Map;
- unsigned long sHash(string S) const;
+ unsigned long sHash(const string &S) const;
unsigned long sHash(const char *S) const;
public:
@@ -111,14 +111,14 @@ class pkgCache
inline void *DataEnd() {return ((unsigned char *)Map.Data()) + Map.Size();};
// String hashing function (512 range)
- inline unsigned long Hash(string S) const {return sHash(S);};
+ inline unsigned long Hash(const string &S) const {return sHash(S);};
inline unsigned long Hash(const char *S) const {return sHash(S);};
// Usefull transformation things
const char *Priority(unsigned char Priority);
// Accessors
- PkgIterator FindPkg(string Name);
+ PkgIterator FindPkg(const string &Name);
Header &Head() {return *HeaderP;};
inline PkgIterator PkgBegin();
inline PkgIterator PkgEnd();
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index 2340f97fd..de854bee5 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -266,7 +266,7 @@ bool pkgCacheGenerator::MergeFileProvides(ListParser &List)
// CacheGenerator::NewPackage - Add a new package /*{{{*/
// ---------------------------------------------------------------------
/* This creates a new package structure and adds it to the hash table */
-bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,string Name)
+bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name)
{
Pkg = Cache.FindPkg(Name);
if (Pkg.end() == false)
@@ -330,7 +330,7 @@ bool pkgCacheGenerator::NewFileVer(pkgCache::VerIterator &Ver,
// ---------------------------------------------------------------------
/* This puts a version structure in the linked list */
unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
- string VerStr,
+ const string &VerStr,
unsigned long Next)
{
// Get a structure
@@ -354,8 +354,8 @@ unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
/* This creates a dependency element in the tree. It is linked to the
version and to the package that it is pointing to. */
bool pkgCacheGenerator::ListParser::NewDepends(pkgCache::VerIterator Ver,
- string PackageName,
- string Version,
+ const string &PackageName,
+ const string &Version,
unsigned int Op,
unsigned int Type)
{
@@ -419,8 +419,8 @@ bool pkgCacheGenerator::ListParser::NewDepends(pkgCache::VerIterator Ver,
// ---------------------------------------------------------------------
/* */
bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator Ver,
- string PackageName,
- string Version)
+ const string &PackageName,
+ const string &Version)
{
pkgCache &Cache = Owner->Cache;
@@ -459,7 +459,7 @@ bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator Ver,
// ---------------------------------------------------------------------
/* This is used to select which file is to be associated with all newly
added versions. The caller is responsible for setting the IMS fields. */
-bool pkgCacheGenerator::SelectFile(string File,string Site,
+bool pkgCacheGenerator::SelectFile(const string &File,const string &Site,
const pkgIndexFile &Index,
unsigned long Flags)
{
@@ -543,7 +543,7 @@ unsigned long pkgCacheGenerator::WriteUniqString(const char *S,
/* This just verifies that each file in the list of index files exists,
has matching attributes with the cache and the cache does not have
any extra files. */
-static bool CheckValidity(string CacheFile, FileIterator Start,
+static bool CheckValidity(const string &CacheFile, FileIterator Start,
FileIterator End,MMap **OutMap = 0)
{
// No file, certainly invalid
diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h
index 7d0920629..9a729eea4 100644
--- a/apt-pkg/pkgcachegen.h
+++ b/apt-pkg/pkgcachegen.h
@@ -53,17 +53,17 @@ class pkgCacheGenerator
// Flag file dependencies
bool FoundFileDeps;
- bool NewPackage(pkgCache::PkgIterator &Pkg,string Pkg);
+ bool NewPackage(pkgCache::PkgIterator &Pkg,const string &Pkg);
bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List);
- unsigned long NewVersion(pkgCache::VerIterator &Ver,string VerStr,unsigned long Next);
+ unsigned long NewVersion(pkgCache::VerIterator &Ver,const string &VerStr,unsigned long Next);
public:
unsigned long WriteUniqString(const char *S,unsigned int Size);
- inline unsigned long WriteUniqString(string S) {return WriteUniqString(S.c_str(),S.length());};
+ inline unsigned long WriteUniqString(const string &S) {return WriteUniqString(S.c_str(),S.length());};
void DropProgress() {Progress = 0;};
- bool SelectFile(string File,string Site,pkgIndexFile const &Index,
+ bool SelectFile(const string &File,const string &Site,pkgIndexFile const &Index,
unsigned long Flags = 0);
bool MergeList(ListParser &List,pkgCache::VerIterator *Ver = 0);
inline pkgCache &GetCache() {return Cache;};
@@ -94,12 +94,13 @@ class pkgCacheGenerator::ListParser
inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);};
inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
- inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);};
+ inline unsigned long WriteString(const string &S) {return Owner->Map.WriteString(S);};
inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
- bool NewDepends(pkgCache::VerIterator Ver,string Package,
- string Version,unsigned int Op,
+ bool NewDepends(pkgCache::VerIterator Ver,const string &Package,
+ const string &Version,unsigned int Op,
unsigned int Type);
- bool NewProvides(pkgCache::VerIterator Ver,string Package,string Version);
+ bool NewProvides(pkgCache::VerIterator Ver,const string &Package,
+ const string &Version);
public:
diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc
index 95aba0cb5..e3b4d94f8 100644
--- a/apt-pkg/sourcelist.cc
+++ b/apt-pkg/sourcelist.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: sourcelist.cc,v 1.25 2004/06/07 23:08:00 mdz Exp $
+// $Id: sourcelist.cc,v 1.3 2002/08/15 20:51:37 niemeyer Exp $
/* ######################################################################
List of Sources
@@ -21,6 +21,13 @@
#include <apti18n.h>
#include <fstream>
+
+// CNC:2003-03-03 - This is needed for ReadDir stuff.
+#include <algorithm>
+#include <stdio.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <unistd.h>
/*}}}*/
using namespace std;
@@ -142,23 +149,66 @@ pkgSourceList::~pkgSourceList()
/* */
bool pkgSourceList::ReadMainList()
{
- return Read(_config->FindFile("Dir::Etc::sourcelist"));
+ // CNC:2003-03-03 - Multiple sources list support.
+ bool Res = true;
+#if 0
+ Res = ReadVendors();
+ if (Res == false)
+ return false;
+#endif
+
+ Reset();
+ // CNC:2003-11-28 - Entries in sources.list have priority over
+ // entries in sources.list.d.
+ string Main = _config->FindFile("Dir::Etc::sourcelist");
+ if (FileExists(Main) == true)
+ Res &= ReadAppend(Main);
+
+ string Parts = _config->FindDir("Dir::Etc::sourceparts");
+ if (FileExists(Parts) == true)
+ Res &= ReadSourceDir(Parts);
+
+ return Res;
}
/*}}}*/
+// CNC:2003-03-03 - Needed to preserve backwards compatibility.
+// SourceList::Reset - Clear the sourcelist contents /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgSourceList::Reset()
+{
+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+ delete *I;
+ SrcList.erase(SrcList.begin(),SrcList.end());
+}
+ /*}}}*/
+// CNC:2003-03-03 - Function moved to ReadAppend() and Reset().
// SourceList::Read - Parse the sourcelist file /*{{{*/
// ---------------------------------------------------------------------
/* */
bool pkgSourceList::Read(string File)
{
+ Reset();
+ return ReadAppend(File);
+}
+ /*}}}*/
+// SourceList::ReadAppend - Parse a sourcelist file /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool pkgSourceList::ReadAppend(string File)
+{
// Open the stream for reading
ifstream F(File.c_str(),ios::in /*| ios::nocreate*/);
if (!F != 0)
return _error->Errno("ifstream::ifstream",_("Opening %s"),File.c_str());
+#if 0 // Now Reset() does this.
for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
delete *I;
SrcList.erase(SrcList.begin(),SrcList.end());
- char Buffer[300];
+#endif
+ // CNC:2003-12-10 - 300 is too short.
+ char Buffer[1024];
int CurLine = 0;
while (F.eof() == false)
@@ -172,7 +222,10 @@ bool pkgSourceList::Read(string File)
char *I;
- for (I = Buffer; *I != 0 && *I != '#'; I++);
+ // CNC:2003-02-20 - Do not break if '#' is inside [].
+ for (I = Buffer; *I != 0 && *I != '#'; I++)
+ if (*I == '[')
+ for (I++; *I != 0 && *I != ']'; I++);
*I = 0;
const char *C = _strstrip(Buffer);
@@ -259,3 +312,55 @@ bool pkgSourceList::GetIndexes(pkgAcquire *Owner, bool GetAll) const
return true;
}
/*}}}*/
+// CNC:2003-03-03 - By Anton V. Denisov <avd@altlinux.org>.
+// SourceList::ReadSourceDir - Read a directory with sources files
+// Based on ReadConfigDir() /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool pkgSourceList::ReadSourceDir(string Dir)
+{
+ DIR *D = opendir(Dir.c_str());
+ if (D == 0)
+ return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
+
+ vector<string> List;
+
+ for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D))
+ {
+ if (Ent->d_name[0] == '.')
+ continue;
+
+ // CNC:2003-12-02 Only accept .list files as valid sourceparts
+ if (flExtension(Ent->d_name) != "list")
+ continue;
+
+ // Skip bad file names ala run-parts
+ const char *C = Ent->d_name;
+ for (; *C != 0; C++)
+ if (isalpha(*C) == 0 && isdigit(*C) == 0
+ && *C != '_' && *C != '-' && *C != '.')
+ break;
+ if (*C != 0)
+ continue;
+
+ // Make sure it is a file and not something else
+ string File = flCombine(Dir,Ent->d_name);
+ struct stat St;
+ if (stat(File.c_str(),&St) != 0 || S_ISREG(St.st_mode) == 0)
+ continue;
+
+ List.push_back(File);
+ }
+ closedir(D);
+
+ sort(List.begin(),List.end());
+
+ // Read the files
+ for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)
+ if (ReadAppend(*I) == false)
+ return false;
+ return true;
+
+}
+ /*}}}*/
+
diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h
index 5d8427017..123ae6984 100644
--- a/apt-pkg/sourcelist.h
+++ b/apt-pkg/sourcelist.h
@@ -77,6 +77,11 @@ class pkgSourceList
bool ReadMainList();
bool Read(string File);
+
+ // CNC:2003-03-03
+ void Reset();
+ bool ReadAppend(string File);
+ bool ReadSourceDir(string Dir);
// List accessors
inline const_iterator begin() const {return SrcList.begin();};
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc
index cae0fa819..223618cd1 100644
--- a/apt-pkg/tagfile.cc
+++ b/apt-pkg/tagfile.cc
@@ -59,19 +59,52 @@ pkgTagFile::~pkgTagFile()
delete [] Buffer;
}
/*}}}*/
+// TagFile::Resize - Resize the internal buffer /*{{{*/
+// ---------------------------------------------------------------------
+/* Resize the internal buffer (double it in size). Fail if a maximum size
+ * size is reached.
+ */
+bool pkgTagFile::Resize()
+{
+ char *tmp;
+ unsigned long EndSize = End - Start;
+
+ // fail is the buffer grows too big
+ if(Size > 1024*1024+1)
+ return false;
+
+ // get new buffer and use it
+ tmp = new char[2*Size];
+ memcpy(tmp, Buffer, Size);
+ Size = Size*2;
+ delete [] Buffer;
+ Buffer = tmp;
+
+ // update the start/end pointers to the new buffer
+ Start = Buffer;
+ End = Start + EndSize;
+ return true;
+}
+
// TagFile::Step - Advance to the next section /*{{{*/
// ---------------------------------------------------------------------
-/* If the Section Scanner fails we refill the buffer and try again. */
+/* If the Section Scanner fails we refill the buffer and try again.
+ * If that fails too, double the buffer size and try again until a
+ * maximum buffer is reached.
+ */
bool pkgTagFile::Step(pkgTagSection &Tag)
{
- if (Tag.Scan(Start,End - Start) == false)
+ while (Tag.Scan(Start,End - Start) == false)
{
if (Fill() == false)
return false;
- if (Tag.Scan(Start,End - Start) == false)
+ if(Tag.Scan(Start,End - Start))
+ break;
+
+ if (Resize() == false)
return _error->Error(_("Unable to parse package file %s (1)"),
- Fd.Name().c_str());
+ Fd.Name().c_str());
}
Start += Tag.size();
iOffset += Tag.size();
@@ -166,12 +199,12 @@ bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long Offset)
// ---------------------------------------------------------------------
/* This looks for the first double new line in the data stream. It also
indexes the tags in the section. This very simple hash function for the
- first 3 letters gives very good performance on the debian package files */
+ last 8 letters gives very good performance on the debian package files */
inline static unsigned long AlphaHash(const char *Text, const char *End = 0)
{
unsigned long Res = 0;
for (; Text != End && *Text != ':' && *Text != 0; Text++)
- Res = (unsigned long)(*Text) ^ (Res << 2);
+ Res = ((unsigned long)(*Text) & 0xDF) ^ (Res << 1);
return Res & 0xFF;
}
@@ -394,7 +427,8 @@ static const char *iTFRewritePackageOrder[] = {
"Filename",
"Size",
"MD5Sum",
- "SHA1Sum",
+ "SHA1",
+ "SHA256",
"MSDOS-Filename", // Obsolete
"Description",
0};
diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h
index 8c948754d..70381ad13 100644
--- a/apt-pkg/tagfile.h
+++ b/apt-pkg/tagfile.h
@@ -75,9 +75,10 @@ class pkgTagFile
bool Done;
unsigned long iOffset;
unsigned long Size;
-
+
bool Fill();
-
+ bool Resize();
+
public:
bool Step(pkgTagSection &Section);
diff --git a/apt-pkg/vendorlist.cc b/apt-pkg/vendorlist.cc
index 72694dd75..8e5d09e8a 100644
--- a/apt-pkg/vendorlist.cc
+++ b/apt-pkg/vendorlist.cc
@@ -113,7 +113,7 @@ bool pkgVendorList::CreateList(Configuration& Cnf)
const Vendor* pkgVendorList::LookupFingerprint(string Fingerprint)
{
- for (const_iterator I = begin(); I != end(); ++I)
+ for (const_iterator I = VendorList.begin(); I != VendorList.end(); ++I)
{
if ((*I)->LookupFingerprint(Fingerprint) != "")
return *I;