summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc518
-rw-r--r--apt-pkg/acquire-item.h93
-rw-r--r--apt-pkg/acquire.cc6
-rw-r--r--apt-pkg/cacheiterators.h86
-rw-r--r--apt-pkg/cdrom.cc47
-rw-r--r--apt-pkg/cdrom.h7
-rw-r--r--apt-pkg/contrib/configuration.cc26
-rw-r--r--apt-pkg/contrib/configuration.h28
-rw-r--r--apt-pkg/contrib/md5.h1
-rw-r--r--apt-pkg/contrib/mmap.h2
-rw-r--r--apt-pkg/contrib/progress.cc4
-rw-r--r--apt-pkg/contrib/progress.h4
-rw-r--r--apt-pkg/contrib/strutl.cc110
-rw-r--r--apt-pkg/contrib/strutl.h29
-rw-r--r--apt-pkg/deb/debindexfile.cc174
-rw-r--r--apt-pkg/deb/debindexfile.h30
-rw-r--r--apt-pkg/deb/deblistparser.cc47
-rw-r--r--apt-pkg/deb/deblistparser.h4
-rw-r--r--apt-pkg/deb/debmetaindex.cc15
-rw-r--r--apt-pkg/deb/debrecords.cc23
-rw-r--r--apt-pkg/deb/debrecords.h2
-rw-r--r--apt-pkg/indexcopy.cc183
-rw-r--r--apt-pkg/indexcopy.h13
-rw-r--r--apt-pkg/indexfile.cc60
-rw-r--r--apt-pkg/indexfile.h7
-rw-r--r--apt-pkg/init.cc8
-rw-r--r--apt-pkg/packagemanager.cc4
-rw-r--r--apt-pkg/pkgcache.cc36
-rw-r--r--apt-pkg/pkgcache.h50
-rw-r--r--apt-pkg/pkgcachegen.cc133
-rw-r--r--apt-pkg/pkgcachegen.h23
-rw-r--r--apt-pkg/pkgrecords.cc9
-rw-r--r--apt-pkg/pkgrecords.h2
-rw-r--r--apt-pkg/sourcelist.cc113
-rw-r--r--apt-pkg/sourcelist.h5
35 files changed, 341 insertions, 1561 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 75a7faa2a..86f61dd00 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -24,8 +24,6 @@
#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/md5.h>
-#include <apt-pkg/sha1.h>
-#include <apt-pkg/tagfile.h>
#include <apti18n.h>
@@ -33,7 +31,6 @@
#include <unistd.h>
#include <errno.h>
#include <string>
-#include <sstream>
#include <stdio.h>
/*}}}*/
@@ -134,410 +131,14 @@ void pkgAcquire::Item::Rename(string From,string To)
}
/*}}}*/
-
-// AcqDiffIndex::AcqDiffIndex - Constructor
-// ---------------------------------------------------------------------
-/* Get the DiffIndex file first and see if there are patches availabe
- * If so, create a pkgAcqIndexDiffs fetcher that will get and apply the
- * patches. If anything goes wrong in that process, it will fall back to
- * the original packages file
- */
-pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire *Owner,
- string URI,string URIDesc,string ShortDesc,
- string ExpectedMD5)
- : Item(Owner), RealURI(URI), ExpectedMD5(ExpectedMD5), Description(URIDesc)
-{
-
- Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
-
- Desc.Description = URIDesc + "/DiffIndex";
- Desc.Owner = this;
- Desc.ShortDesc = ShortDesc;
- Desc.URI = URI + ".diff/Index";
-
- DestFile = _config->FindDir("Dir::State::lists") + "partial/";
- DestFile += URItoFileName(URI) + string(".DiffIndex");
-
- if(Debug)
- std::clog << "pkgAcqDiffIndex: " << Desc.URI << std::endl;
-
- // look for the current package file
- CurrentPackagesFile = _config->FindDir("Dir::State::lists");
- CurrentPackagesFile += URItoFileName(RealURI);
-
- if(!FileExists(CurrentPackagesFile) ||
- !_config->FindB("Acquire::Diffs",true)) {
- // we don't have a pkg file or we don't want to queue
- if(Debug)
- std::clog << "No index file or canceld by user" << std::endl;
- Failed("", NULL);
- return;
- }
-
- if(Debug) {
- std::clog << "pkgAcqIndexDiffs::pkgAcqIndexDiffs(): "
- << CurrentPackagesFile << std::endl;
- }
-
- QueueURI(Desc);
-
-}
-
-// AcqIndex::Custom600Headers - Insert custom request headers /*{{{*/
-// ---------------------------------------------------------------------
-/* The only header we use is the last-modified header. */
-string pkgAcqDiffIndex::Custom600Headers()
-{
- string Final = _config->FindDir("Dir::State::lists");
- Final += URItoFileName(RealURI) + string(".IndexDiff");
-
- if(Debug)
- std::clog << "Custom600Header-IMS: " << Final << std::endl;
-
- struct stat Buf;
- if (stat(Final.c_str(),&Buf) != 0)
- return "\nIndex-File: true";
-
- return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
-}
-
-
-bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile)
-{
- if(Debug)
- std::clog << "pkgAcqIndexDiffs::ParseIndexDiff() " << IndexDiffFile
- << std::endl;
-
- pkgTagSection Tags;
- string ServerSha1;
- vector<DiffInfo> available_patches;
-
- FileFd Fd(IndexDiffFile,FileFd::ReadOnly);
- pkgTagFile TF(&Fd);
- if (_error->PendingError() == true)
- return false;
-
- if(TF.Step(Tags) == true)
- {
- string local_sha1;
- bool found = false;
- DiffInfo d;
- string size;
-
- string tmp = Tags.FindS("SHA1-Current");
- std::stringstream ss(tmp);
- ss >> ServerSha1;
-
- FileFd fd(CurrentPackagesFile, FileFd::ReadOnly);
- SHA1Summation SHA1;
- SHA1.AddFD(fd.Fd(), fd.Size());
- local_sha1 = string(SHA1.Result());
-
- if(local_sha1 == ServerSha1) {
- if(Debug)
- std::clog << "Package file is up-to-date" << std::endl;
- // set found to true, this will queue a pkgAcqIndexDiffs with
- // a empty availabe_patches
- found = true;
- } else {
- if(Debug)
- std::clog << "SHA1-Current: " << ServerSha1 << std::endl;
-
- // check the historie and see what patches we need
- string history = Tags.FindS("SHA1-History");
- std::stringstream hist(history);
- while(hist >> d.sha1 >> size >> d.file) {
- d.size = atoi(size.c_str());
- // read until the first match is found
- if(d.sha1 == local_sha1)
- found=true;
- // from that point on, we probably need all diffs
- if(found) {
- if(Debug)
- std::clog << "Need to get diff: " << d.file << std::endl;
- available_patches.push_back(d);
- }
- }
- }
-
- // no information how to get the patches, bail out
- if(!found) {
- if(Debug)
- std::clog << "Can't find a patch in the index file" << std::endl;
- // Failed will queue a big package file
- Failed("", NULL);
- } else {
- // queue the diffs
- new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
- ExpectedMD5, available_patches);
- Complete = false;
- Status = StatDone;
- Dequeue();
- return true;
- }
- }
-
- return false;
-}
-
-void pkgAcqDiffIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
-{
- if(Debug)
- std::clog << "pkgAcqDiffIndex failed: " << Desc.URI << std::endl
- << "Falling back to normal index file aquire" << std::endl;
-
- new pkgAcqIndex(Owner, RealURI, Description, Desc.ShortDesc,
- ExpectedMD5);
-
- Complete = false;
- Status = StatDone;
- Dequeue();
-}
-
-void pkgAcqDiffIndex::Done(string Message,unsigned long Size,string Md5Hash,
- pkgAcquire::MethodConfig *Cnf)
-{
- if(Debug)
- std::clog << "pkgAcqDiffIndex::Done(): " << Desc.URI << std::endl;
-
- Item::Done(Message,Size,Md5Hash,Cnf);
-
- string FinalFile;
- FinalFile = _config->FindDir("Dir::State::lists")+URItoFileName(RealURI);
-
- // sucess in downloading the index
- // rename the index
- FinalFile += string(".IndexDiff");
- if(Debug)
- std::clog << "Renaming: " << DestFile << " -> " << FinalFile
- << std::endl;
- Rename(DestFile,FinalFile);
- chmod(FinalFile.c_str(),0644);
- DestFile = FinalFile;
-
- if(!ParseDiffIndex(DestFile))
- return Failed("", NULL);
-
- Complete = true;
- Status = StatDone;
- Dequeue();
- return;
-}
-
-
-
-// AcqIndexDiffs::AcqIndexDiffs - Constructor
-// ---------------------------------------------------------------------
-/* The package diff is added to the queue. one object is constructed
- * for each diff and the index
- */
-pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
- string URI,string URIDesc,string ShortDesc,
- string ExpectedMD5, vector<DiffInfo> diffs)
- : Item(Owner), RealURI(URI), ExpectedMD5(ExpectedMD5),
- available_patches(diffs)
-{
-
- DestFile = _config->FindDir("Dir::State::lists") + "partial/";
- DestFile += URItoFileName(URI);
-
- Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
-
- Desc.Description = URIDesc;
- Desc.Owner = this;
- Desc.ShortDesc = ShortDesc;
-
- if(available_patches.size() == 0) {
- // we are done (yeah!)
- Finish(true);
- } else {
- // get the next diff
- State = StateFetchDiff;
- QueueNextDiff();
- }
-}
-
-
-void pkgAcqIndexDiffs::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
-{
- if(Debug)
- std::clog << "pkgAcqIndexDiffs failed: " << Desc.URI << std::endl
- << "Falling back to normal index file aquire" << std::endl;
- new pkgAcqIndex(Owner, RealURI, Description,Desc.ShortDesc,
- ExpectedMD5);
- Finish();
-}
-
-
-// helper that cleans the item out of the fetcher queue
-void pkgAcqIndexDiffs::Finish(bool allDone)
-{
- // we restore the original name, this is required, otherwise
- // the file will be cleaned
- if(allDone) {
- DestFile = _config->FindDir("Dir::State::lists");
- DestFile += URItoFileName(RealURI);
-
- // do the final md5sum checking
- MD5Summation sum;
- FileFd Fd(DestFile, FileFd::ReadOnly);
- sum.AddFD(Fd.Fd(), Fd.Size());
- Fd.Close();
- string MD5 = (string)sum.Result();
-
- if (!ExpectedMD5.empty() && MD5 != ExpectedMD5)
- {
- Status = StatAuthError;
- ErrorText = _("MD5Sum mismatch");
- Rename(DestFile,DestFile + ".FAILED");
- Dequeue();
- return;
- }
-
- // this is for the "real" finish
- Complete = true;
- Status = StatDone;
- Dequeue();
- if(Debug)
- std::clog << "\n\nallDone: " << DestFile << "\n" << std::endl;
- return;
- }
-
- if(Debug)
- std::clog << "Finishing: " << Desc.URI << std::endl;
- Complete = false;
- Status = StatDone;
- Dequeue();
- return;
-}
-
-
-
-bool pkgAcqIndexDiffs::QueueNextDiff()
-{
-
- // calc sha1 of the just patched file
- string FinalFile = _config->FindDir("Dir::State::lists");
- FinalFile += URItoFileName(RealURI);
-
- FileFd fd(FinalFile, FileFd::ReadOnly);
- SHA1Summation SHA1;
- SHA1.AddFD(fd.Fd(), fd.Size());
- string local_sha1 = string(SHA1.Result());
- if(Debug)
- std::clog << "QueueNextDiff: "
- << FinalFile << " (" << local_sha1 << ")"<<std::endl;
-
- // remove all patches until the next matching patch is found
- // this requires the Index file to be ordered
- for(vector<DiffInfo>::iterator I=available_patches.begin();
- available_patches.size() > 0 && I != available_patches.end()
- && (*I).sha1 != local_sha1;
- I++) {
- available_patches.erase(I);
- }
-
- // error checking and falling back if no patch was found
- if(available_patches.size() == 0) {
- Failed("", NULL);
- return false;
- }
-
- // queue the right diff
- Desc.URI = string(RealURI) + ".diff/" + available_patches[0].file + ".gz";
- Desc.Description = available_patches[0].file + string(".pdiff");
-
- DestFile = _config->FindDir("Dir::State::lists") + "partial/";
- DestFile += URItoFileName(RealURI + ".diff/" + available_patches[0].file);
-
- if(Debug)
- std::clog << "pkgAcqIndexDiffs::QueueNextDiff(): " << Desc.URI << std::endl;
-
- QueueURI(Desc);
-
- return true;
-}
-
-
-
-void pkgAcqIndexDiffs::Done(string Message,unsigned long Size,string Md5Hash,
- pkgAcquire::MethodConfig *Cnf)
-{
- if(Debug)
- std::clog << "pkgAcqIndexDiffs::Done(): " << Desc.URI << std::endl;
-
- Item::Done(Message,Size,Md5Hash,Cnf);
-
- string FinalFile;
- FinalFile = _config->FindDir("Dir::State::lists")+URItoFileName(RealURI);
-
- // sucess in downloading a diff, enter ApplyDiff state
- if(State == StateFetchDiff)
- {
-
- if(Debug)
- std::clog << "Sending to gzip method: " << FinalFile << std::endl;
-
- string FileName = LookupTag(Message,"Filename");
- State = StateUnzipDiff;
- Desc.URI = "gzip:" + FileName;
- DestFile += ".decomp";
- QueueURI(Desc);
- Mode = "gzip";
- return;
- }
-
- // sucess in downloading a diff, enter ApplyDiff state
- if(State == StateUnzipDiff)
- {
-
- // rred excepts the patch as $FinalFile.ed
- Rename(DestFile,FinalFile+".ed");
-
- if(Debug)
- std::clog << "Sending to rred method: " << FinalFile << std::endl;
-
- State = StateApplyDiff;
- Desc.URI = "rred:" + FinalFile;
- QueueURI(Desc);
- Mode = "rred";
- return;
- }
-
-
- // success in download/apply a diff, queue next (if needed)
- if(State == StateApplyDiff)
- {
- // remove the just applied patch
- available_patches.erase(available_patches.begin());
-
- // move into place
- if(Debug)
- {
- std::clog << "Moving patched file in place: " << std::endl
- << DestFile << " -> " << FinalFile << std::endl;
- }
- Rename(DestFile,FinalFile);
-
- // see if there is more to download
- if(available_patches.size() > 0) {
- new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
- ExpectedMD5, available_patches);
- return Finish();
- } else
- return Finish(true);
- }
-}
-
-
// AcqIndex::AcqIndex - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* The package file is added to the queue and a second class is
instantiated to fetch the revision file */
pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
string URI,string URIDesc,string ShortDesc,
- string ExpectedMD5, string comprExt)
- : Item(Owner), RealURI(URI), ExpectedMD5(ExpectedMD5)
+ string ExpectedMD5, string comprExt) :
+ Item(Owner), RealURI(URI), ExpectedMD5(ExpectedMD5)
{
Decompression = false;
Erase = false;
@@ -583,7 +184,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
@@ -689,7 +290,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";
@@ -707,35 +308,6 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5,
Mode = decompProg;
}
-// AcqIndexTrans::pkgAcqIndexTrans - Constructor /*{{{*/
-// ---------------------------------------------------------------------
-/* The Translation file is added to the queue */
-pkgAcqIndexTrans::pkgAcqIndexTrans(pkgAcquire *Owner,
- string URI,string URIDesc,string ShortDesc) :
- pkgAcqIndex(Owner, URI, URIDesc, ShortDesc, "", "")
-{
-}
-
- /*}}}*/
-// AcqIndexTrans::Failed - Silence failure messages for missing files /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-void pkgAcqIndexTrans::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
-{
- if (Cnf->LocalOnly == true ||
- StringToBool(LookupTag(Message,"Transient-Failure"),false) == false)
- {
- // Ignore this
- Status = StatDone;
- Complete = false;
- Dequeue();
- return;
- }
-
- Item::Failed(Message,Cnf);
-}
- /*}}}*/
-
pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
string URI,string URIDesc,string ShortDesc,
string MetaIndexURI, string MetaIndexURIDesc,
@@ -743,10 +315,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);
@@ -858,11 +429,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);
@@ -954,6 +523,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");
@@ -982,7 +554,7 @@ void pkgAcqMetaIndex::AuthDone(string Message)
return;
}
- if (!VerifyVendor())
+ if (!VerifyVendor(Message))
{
return;
}
@@ -1035,12 +607,12 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify)
}
// Queue Packages file
- new pkgAcqDiffIndex(Owner, (*Target)->URI, (*Target)->Description,
- (*Target)->ShortDesc, ExpectedIndexMD5);
+ new pkgAcqIndex(Owner, (*Target)->URI, (*Target)->Description,
+ (*Target)->ShortDesc, ExpectedIndexMD5);
}
}
-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?
@@ -1065,6 +637,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 are 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();
@@ -1073,7 +661,7 @@ bool pkgAcqMetaIndex::VerifyVendor()
Transformed = "experimental";
}
- string::size_type pos = Transformed.rfind('/');
+ pos = Transformed.rfind('/');
if (pos != string::npos)
{
Transformed = Transformed.substr(0, pos);
@@ -1119,10 +707,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
@@ -1198,6 +806,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. "
@@ -1430,13 +1044,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;
@@ -1456,7 +1076,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 34fcc2a76..da1bea801 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -9,8 +9,8 @@
the Owner Acquire class. Derived classes will then call QueueURI to
register all the URI's they wish to fetch at the initial moment.
- Three item classes are provided to provide functionality for
- downloading of Index, Translation and Packages files.
+ Two item classes are provided to provide functionality for downloading
+ of Index files and downloading of Packages.
A Archive class is provided for downloading .deb files. It does Md5
checking and source location as well as a retry algorithm.
@@ -82,70 +82,6 @@ class pkgAcquire::Item
virtual ~Item();
};
-// item for index diffs
-
-struct DiffInfo {
- string file;
- string sha1;
- unsigned long size;
-};
-
-class pkgAcqDiffIndex : public pkgAcquire::Item
-{
- protected:
- bool Debug;
- pkgAcquire::ItemDesc Desc;
- string RealURI;
- string ExpectedMD5;
- string CurrentPackagesFile;
- string Description;
-
- public:
- // Specialized action members
- virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
- virtual void Done(string Message,unsigned long Size,string Md5Hash,
- pkgAcquire::MethodConfig *Cnf);
- virtual string DescURI() {return RealURI + "Index";};
- virtual string Custom600Headers();
-
- // helpers
- bool ParseDiffIndex(string IndexDiffFile);
-
- pkgAcqDiffIndex(pkgAcquire *Owner,string URI,string URIDesc,
- string ShortDesct, string ExpectedMD5);
-};
-
-class pkgAcqIndexDiffs : public pkgAcquire::Item
-{
- protected:
- bool Debug;
- pkgAcquire::ItemDesc Desc;
- string RealURI;
- string ExpectedMD5;
-
- // this is the SHA-1 sum we expect after the patching
- string Description;
- vector<DiffInfo> available_patches;
- enum {StateFetchIndex,StateFetchDiff,StateUnzipDiff,StateApplyDiff} State;
-
- public:
-
- // Specialized action members
- virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
- virtual void Done(string Message,unsigned long Size,string Md5Hash,
- pkgAcquire::MethodConfig *Cnf);
- virtual string DescURI() {return RealURI + "Index";};
-
- // various helpers
- bool QueueNextDiff();
- bool ApplyDiff(string PatchFile);
- void Finish(bool allDone=false);
-
- pkgAcqIndexDiffs(pkgAcquire *Owner,string URI,string URIDesc,
- string ShortDesct, string ExpectedMD5,
- vector<DiffInfo> diffs=vector<DiffInfo>());
-};
-
// Item class for index files
class pkgAcqIndex : public pkgAcquire::Item
{
@@ -171,16 +107,6 @@ class pkgAcqIndex : public pkgAcquire::Item
string ShortDesct, string ExpectedMD5, string compressExt="");
};
-// Item class for translated package index files
-class pkgAcqIndexTrans : public pkgAcqIndex
-{
- public:
-
- virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
- pkgAcqIndexTrans(pkgAcquire *Owner,string URI,string URIDesc,
- string ShortDesct);
-};
-
struct IndexTarget
{
string URI;
@@ -225,8 +151,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);
@@ -298,9 +226,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.cc b/apt-pkg/acquire.cc
index 62209e65b..57cf60bfe 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;
}
/*}}}*/
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h
index 64fa4636e..2b326bd65 100644
--- a/apt-pkg/cacheiterators.h
+++ b/apt-pkg/cacheiterators.h
@@ -99,7 +99,7 @@ class pkgCache::VerIterator
{
Version *Ver;
pkgCache *Owner;
-
+
void _dummy();
public:
@@ -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
@@ -128,8 +128,6 @@ class pkgCache::VerIterator
inline const char *Section() const {return Ver->Section == 0?0:Owner->StrP + Ver->Section;};
inline const char *Arch() const {return Ver->Arch == 0?0:Owner->StrP + Ver->Arch;};
inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Ver->ParentPkg);};
- inline DescIterator DescriptionList() const;
- DescIterator TranslatedDescription() const;
inline DepIterator DependsList() const;
inline PrvIterator ProvidesList() const;
inline VerFileIterator FileList() const;
@@ -150,50 +148,6 @@ class pkgCache::VerIterator
};
};
-// Description Iterator
-class pkgCache::DescIterator
-{
- Description *Desc;
- pkgCache *Owner;
-
- void _dummy();
-
- public:
-
- // Iteration
- void operator ++(int) {if (Desc != Owner->DescP) Desc = Owner->DescP + Desc->NextDesc;};
- inline void operator ++() {operator ++(0);};
- inline bool end() const {return Desc == Owner->DescP?true:false;};
- inline void operator =(const DescIterator &B) {Desc = B.Desc; Owner = B.Owner;};
-
- // Comparison
- inline bool operator ==(const DescIterator &B) const {return Desc == B.Desc;};
- inline bool operator !=(const DescIterator &B) const {return Desc != B.Desc;};
- int CompareDesc(const DescIterator &B) const;
-
- // Accessors
- inline Description *operator ->() {return Desc;};
- inline Description const *operator ->() const {return Desc;};
- inline Description &operator *() {return *Desc;};
- inline Description const &operator *() const {return *Desc;};
- inline operator Description *() {return Desc == Owner->DescP?0:Desc;};
- inline operator Description const *() const {return Desc == Owner->DescP?0:Desc;};
- inline pkgCache *Cache() {return Owner;};
-
- inline const char *LanguageCode() const {return Owner->StrP + Desc->language_code;};
- inline const char *md5() const {return Owner->StrP + Desc->md5sum;};
- inline DescFileIterator FileList() const;
- inline unsigned long Index() const {return Desc - Owner->DescP;};
-
- inline DescIterator() : Desc(0), Owner(0) {};
- inline DescIterator(pkgCache &Owner,Description *Trg = 0) : Desc(Trg),
- Owner(&Owner)
- {
- if (Desc == 0)
- Desc = Owner.DescP;
- };
-};
-
// Dependency iterator
class pkgCache::DepIterator
{
@@ -384,38 +338,6 @@ class pkgCache::VerFileIterator
inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Owner(&Owner), FileP(Trg) {};
};
-// Description File
-class pkgCache::DescFileIterator
-{
- pkgCache *Owner;
- DescFile *FileP;
-
- public:
-
- // Iteration
- void operator ++(int) {if (FileP != Owner->DescFileP) FileP = Owner->DescFileP + FileP->NextFile;};
- inline void operator ++() {operator ++(0);};
- inline bool end() const {return FileP == Owner->DescFileP?true:false;};
-
- // Comparison
- inline bool operator ==(const DescFileIterator &B) const {return FileP == B.FileP;};
- inline bool operator !=(const DescFileIterator &B) const {return FileP != B.FileP;};
-
- // Accessors
- inline DescFile *operator ->() {return FileP;};
- inline DescFile const *operator ->() const {return FileP;};
- inline DescFile const &operator *() const {return *FileP;};
- inline operator DescFile *() {return FileP == Owner->DescFileP?0:FileP;};
- inline operator DescFile const *() const {return FileP == Owner->DescFileP?0:FileP;};
- inline pkgCache *Cache() {return Owner;};
-
- inline PkgFileIterator File() const {return PkgFileIterator(*Owner,FileP->File + Owner->PkgFileP);};
- inline unsigned long Index() const {return FileP - Owner->DescFileP;};
-
- inline DescFileIterator() : Owner(0), FileP(0) {};
- inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Owner(&Owner), FileP(Trg) {};
-};
-
// Inlined Begin functions cant be in the class because of order problems
inline pkgCache::VerIterator pkgCache::PkgIterator::VersionList() const
{return VerIterator(*Owner,Owner->VerP + Pkg->VersionList);};
@@ -425,15 +347,11 @@ inline pkgCache::DepIterator pkgCache::PkgIterator::RevDependsList() const
{return DepIterator(*Owner,Owner->DepP + Pkg->RevDepends,Pkg);};
inline pkgCache::PrvIterator pkgCache::PkgIterator::ProvidesList() const
{return PrvIterator(*Owner,Owner->ProvideP + Pkg->ProvidesList,Pkg);};
-inline pkgCache::DescIterator pkgCache::VerIterator::DescriptionList() const
- {return DescIterator(*Owner,Owner->DescP + Ver->DescriptionList);};
inline pkgCache::PrvIterator pkgCache::VerIterator::ProvidesList() const
{return PrvIterator(*Owner,Owner->ProvideP + Ver->ProvidesList,Ver);};
inline pkgCache::DepIterator pkgCache::VerIterator::DependsList() const
{return DepIterator(*Owner,Owner->DepP + Ver->DependsList,Ver);};
inline pkgCache::VerFileIterator pkgCache::VerIterator::FileList() const
{return VerFileIterator(*Owner,Owner->VerFileP + Ver->FileList);};
-inline pkgCache::DescFileIterator pkgCache::DescIterator::FileList() const
- {return DescFileIterator(*Owner,Owner->DescFileP + Desc->FileList);};
#endif
diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc
index b42c82dd0..ce1beb39b 100644
--- a/apt-pkg/cdrom.cc
+++ b/apt-pkg/cdrom.cc
@@ -30,16 +30,12 @@ using namespace std;
search that short circuits when it his a package file in the dir.
This speeds it up greatly as the majority of the size is in the
binary-* sub dirs. */
-bool pkgCdrom::FindPackages(string CD,
- vector<string> &List,
- vector<string> &SList,
- vector<string> &SigList,
- vector<string> &TransList,
+bool pkgCdrom::FindPackages(string CD,vector<string> &List,
+ vector<string> &SList, vector<string> &SigList,
string &InfoDir, pkgCdromStatus *log,
unsigned int Depth)
{
static ino_t Inodes[9];
- DIR *D;
// if we have a look we "pulse" now
if(log)
@@ -94,28 +90,8 @@ bool pkgCdrom::FindPackages(string CD,
if (_config->FindB("APT::CDROM::Thorough",false) == false)
return true;
}
-
- // see if we find translatin indexes
- if (stat("i18n",&Buf) == 0)
- {
- D = opendir("i18n");
- for (struct dirent *Dir = readdir(D); Dir != 0; Dir = readdir(D))
- {
- if(strstr(Dir->d_name,"Translation") != NULL)
- {
- if (_config->FindB("Debug::aptcdrom",false) == true)
- std::clog << "found translations: " << Dir->d_name << "\n";
- string file = Dir->d_name;
- if(file.substr(file.size()-3,file.size()) == ".gz")
- file = file.substr(0,file.size()-3);
- TransList.push_back(CD+"i18n/"+ file);
- }
- }
- closedir(D);
- }
-
- D = opendir(".");
+ DIR *D = opendir(".");
if (D == 0)
return _error->Errno("opendir","Unable to read %s",CD.c_str());
@@ -151,7 +127,7 @@ bool pkgCdrom::FindPackages(string CD,
Inodes[Depth] = Buf.st_ino;
// Descend
- if (FindPackages(CD + Dir->d_name,List,SList,SigList,TransList,InfoDir,log,Depth+1) == false)
+ if (FindPackages(CD + Dir->d_name,List,SList,SigList,InfoDir,log,Depth+1) == false)
break;
if (chdir(CD.c_str()) != 0)
@@ -636,10 +612,9 @@ bool pkgCdrom::Add(pkgCdromStatus *log)
vector<string> List;
vector<string> SourceList;
vector<string> SigList;
- vector<string> TransList;
string StartDir = SafeGetCWD();
string InfoDir;
- if (FindPackages(CDROM,List,SourceList, SigList,TransList,InfoDir,log) == false)
+ if (FindPackages(CDROM,List,SourceList, SigList,InfoDir,log) == false)
{
log->Update("\n");
return false;
@@ -667,13 +642,11 @@ bool pkgCdrom::Add(pkgCdromStatus *log)
DropRepeats(List,"Packages");
DropRepeats(SourceList,"Sources");
DropRepeats(SigList,"Release.gpg");
- DropRepeats(TransList,"");
if(log) {
msg.str("");
- ioprintf(msg, _("Found %i package indexes, %i source indexes, "
- "%i translation indexes and %i signatures\n"),
- List.size(), SourceList.size(), TransList.size(),
- SigList.size());
+ ioprintf(msg, _("Found %i package indexes, %i source indexes and "
+ "%i signatures\n"),
+ List.size(), SourceList.size(), SigList.size());
log->Update(msg.str(), STEP_SCAN);
}
@@ -763,10 +736,8 @@ bool pkgCdrom::Add(pkgCdromStatus *log)
// Copy the package files to the state directory
PackageCopy Copy;
SourceCopy SrcCopy;
- TranslationsCopy TransCopy;
if (Copy.CopyPackages(CDROM,Name,List, log) == false ||
- SrcCopy.CopyPackages(CDROM,Name,SourceList, log) == false ||
- TransCopy.CopyTranslations(CDROM,Name,TransList, log) == false)
+ SrcCopy.CopyPackages(CDROM,Name,SourceList, log) == false)
return false;
// reduce the List so that it takes less space in sources.list
diff --git a/apt-pkg/cdrom.h b/apt-pkg/cdrom.h
index e18aaff3e..085eb64e2 100644
--- a/apt-pkg/cdrom.h
+++ b/apt-pkg/cdrom.h
@@ -50,11 +50,8 @@ class pkgCdrom
};
- bool FindPackages(string CD,
- vector<string> &List,
- vector<string> &SList,
- vector<string> &SigList,
- vector<string> &TransList,
+ bool FindPackages(string CD,vector<string> &List,
+ vector<string> &SList, vector<string> &SigList,
string &InfoDir, pkgCdromStatus *log,
unsigned int Depth = 0);
bool DropBinaryArch(vector<string> &List);
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/md5.h b/apt-pkg/contrib/md5.h
index 9447e9956..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;
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..cb272e389 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;
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/strutl.cc b/apt-pkg/contrib/strutl.cc
index 303cb27db..d96155917 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -32,55 +32,12 @@
#include <regex.h>
#include <errno.h>
#include <stdarg.h>
-#include <iconv.h>
#include "config.h"
using namespace std;
/*}}}*/
-// UTF8ToCodeset - Convert some UTF-8 string for some codeset /*{{{*/
-// ---------------------------------------------------------------------
-/* This is handy to use before display some information for enduser */
-bool UTF8ToCodeset(const char *codeset, const string &orig, string *dest)
-{
- iconv_t cd;
- const char *inbuf;
- char *inptr, *outbuf, *outptr;
- size_t insize, outsize;
-
- cd = iconv_open(codeset, "UTF-8");
- if (cd == (iconv_t)(-1)) {
- // Something went wrong
- if (errno == EINVAL)
- _error->Error("conversion from 'UTF-8' to '%s' not available",
- codeset);
- else
- perror("iconv_open");
-
- // Clean the destination string
- *dest = "";
-
- return false;
- }
-
- insize = outsize = orig.size();
- inbuf = orig.data();
- inptr = (char *)inbuf;
- outbuf = new char[insize+1];
- outptr = outbuf;
-
- iconv(cd, &inptr, &insize, &outptr, &outsize);
- *outptr = '\0';
-
- *dest = outbuf;
- delete[] outbuf;
-
- iconv_close(cd);
-
- return true;
-}
- /*}}}*/
// strstrip - Remove white space from the front and back of a string /*{{{*/
// ---------------------------------------------------------------------
/* This is handy to use when parsing a file. It also removes \n's left
@@ -242,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)
@@ -263,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++)
@@ -360,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;
@@ -391,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 /*{{{*/
@@ -414,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',
@@ -583,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++);
@@ -615,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);
@@ -781,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];
@@ -868,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;
@@ -1029,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++)
@@ -1052,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();
@@ -1081,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 = "/";
@@ -1113,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.
@@ -1148,7 +1102,7 @@ void URI::CopyFrom(string U)
// Tsk, weird.
if (InBracket == true)
{
- Host = string();
+ Host.clear();
return;
}
@@ -1159,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 /*{{{*/
@@ -1214,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 72fc34d6d..6ec2b7811 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -38,30 +38,29 @@ using std::ostream;
#define APT_FORMAT2
#define APT_FORMAT3
#endif
-
-bool UTF8ToCodeset(const char *codeset, const string &orig, string *dest);
+
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));}; \
@@ -102,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:
@@ -114,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) {};
@@ -128,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 38ecdd16a..ff8bce85d 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -320,170 +320,6 @@ pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
}
/*}}}*/
-// TranslationsIndex::debTranslationsIndex - Contructor /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-debTranslationsIndex::debTranslationsIndex(string URI,string Dist,string Section) :
- pkgIndexFile(true), URI(URI), Dist(Dist), Section(Section)
-{
-}
- /*}}}*/
-// TranslationIndex::Trans* - Return the URI to the translation files /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-inline string debTranslationsIndex::IndexFile(const char *Type) const
-{
- return _config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
-}
-string debTranslationsIndex::IndexURI(const char *Type) const
-{
- string Res;
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Res = URI + Dist;
- else
- Res = URI;
- }
- else
- Res = URI + "dists/" + Dist + '/' + Section +
- "/i18n/Translation-";
-
- Res += Type;
- return Res;
-}
- /*}}}*/
-// TranslationsIndex::GetIndexes - Fetch the index files /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debTranslationsIndex::GetIndexes(pkgAcquire *Owner) const
-{
- if (TranslationsAvailable()) {
- string TranslationFile = "Translation-" + LanguageCode();
- new pkgAcqIndexTrans(Owner, IndexURI(LanguageCode().c_str()),
- Info(TranslationFile.c_str()),
- TranslationFile);
- }
-
- return true;
-}
- /*}}}*/
-// TranslationsIndex::Describe - Give a descriptive path to the index /*{{{*/
-// ---------------------------------------------------------------------
-/* This should help the user find the index in the sources.list and
- in the filesystem for problem solving */
-string debTranslationsIndex::Describe(bool Short) const
-{
- char S[300];
- if (Short == true)
- snprintf(S,sizeof(S),"%s",Info(TranslationFile().c_str()).c_str());
- else
- snprintf(S,sizeof(S),"%s (%s)",Info(TranslationFile().c_str()).c_str(),
- IndexFile(LanguageCode().c_str()).c_str());
- return S;
-}
- /*}}}*/
-// TranslationsIndex::Info - One liner describing the index URI /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debTranslationsIndex::Info(const char *Type) const
-{
- string Info = ::URI::SiteOnly(URI) + ' ';
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Info += Dist;
- }
- else
- Info += Dist + '/' + Section;
- Info += " ";
- Info += Type;
- return Info;
-}
- /*}}}*/
-bool debTranslationsIndex::HasPackages() const
-{
- if(!TranslationsAvailable())
- return false;
-
- return FileExists(IndexFile(LanguageCode().c_str()));
-}
-
-// TranslationsIndex::Exists - Check if the index is available /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debTranslationsIndex::Exists() const
-{
- return FileExists(IndexFile(LanguageCode().c_str()));
-}
- /*}}}*/
-// TranslationsIndex::Size - Return the size of the index /*{{{*/
-// ---------------------------------------------------------------------
-/* This is really only used for progress reporting. */
-unsigned long debTranslationsIndex::Size() const
-{
- struct stat S;
- if (stat(IndexFile(LanguageCode().c_str()).c_str(),&S) != 0)
- return 0;
- return S.st_size;
-}
- /*}}}*/
-// TranslationsIndex::Merge - Load the index file into a cache /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
-{
- // Check the translation file, if in use
- string TranslationFile = IndexFile(LanguageCode().c_str());
- if (TranslationsAvailable() && FileExists(TranslationFile))
- {
- FileFd Trans(TranslationFile,FileFd::ReadOnly);
- debListParser TransParser(&Trans);
- if (_error->PendingError() == true)
- return false;
-
- Prog.SubProgress(0, Info(TranslationFile.c_str()));
- if (Gen.SelectFile(TranslationFile,string(),*this) == false)
- return _error->Error("Problem with SelectFile %s",TranslationFile.c_str());
-
- // Store the IMS information
- pkgCache::PkgFileIterator TransFile = Gen.GetCurFile();
- struct stat TransSt;
- if (fstat(Trans.Fd(),&TransSt) != 0)
- return _error->Errno("fstat","Failed to stat");
- TransFile->Size = TransSt.st_size;
- TransFile->mtime = TransSt.st_mtime;
-
- if (Gen.MergeList(TransParser) == false)
- return _error->Error("Problem with MergeList %s",TranslationFile.c_str());
- }
-
- return true;
-}
- /*}}}*/
-// TranslationsIndex::FindInCache - Find this index /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) const
-{
- string FileName = IndexFile(LanguageCode().c_str());
-
- pkgCache::PkgFileIterator File = Cache.FileBegin();
- for (; File.end() == false; File++)
- {
- if (FileName != File.FileName())
- continue;
-
- struct stat St;
- if (stat(File.FileName(),&St) != 0)
- return pkgCache::PkgFileIterator(Cache);
- if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
- return pkgCache::PkgFileIterator(Cache);
- return File;
- }
- return File;
-}
- /*}}}*/
// StatusIndex::debStatusIndex - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -580,11 +416,6 @@ class debIFTypePkg : public pkgIndexFile::Type
};
debIFTypePkg() {Label = "Debian Package Index";};
};
-class debIFTypeTrans : public debIFTypePkg
-{
- public:
- debIFTypeTrans() {Label = "Debian Translation Index";};
-};
class debIFTypeStatus : public pkgIndexFile::Type
{
public:
@@ -597,7 +428,6 @@ class debIFTypeStatus : public pkgIndexFile::Type
};
static debIFTypeSrc _apt_Src;
static debIFTypePkg _apt_Pkg;
-static debIFTypeTrans _apt_Trans;
static debIFTypeStatus _apt_Status;
const pkgIndexFile::Type *debSourcesIndex::GetType() const
@@ -608,10 +438,6 @@ const pkgIndexFile::Type *debPackagesIndex::GetType() const
{
return &_apt_Pkg;
}
-const pkgIndexFile::Type *debTranslationsIndex::GetType() const
-{
- return &_apt_Trans;
-}
const pkgIndexFile::Type *debStatusIndex::GetType() const
{
return &_apt_Status;
diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h
index 57005222f..a1b9583a4 100644
--- a/apt-pkg/deb/debindexfile.h
+++ b/apt-pkg/deb/debindexfile.h
@@ -74,36 +74,6 @@ class debPackagesIndex : public pkgIndexFile
debPackagesIndex(string URI,string Dist,string Section,bool Trusted);
};
-class debTranslationsIndex : public pkgIndexFile
-{
- string URI;
- string Dist;
- string Section;
-
- string Info(const char *Type) const;
- string IndexFile(const char *Type) const;
- string IndexURI(const char *Type) const;
-
- inline string TranslationFile() const {return "Translation-" + LanguageCode();};
-
- public:
-
- virtual const Type *GetType() const;
-
- // Interface for acquire
- virtual string Describe(bool Short) const;
- virtual bool GetIndexes(pkgAcquire *Owner) const;
-
- // Interface for the Cache Generator
- virtual bool Exists() const;
- virtual bool HasPackages() const;
- virtual unsigned long Size() const;
- virtual bool Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const;
- virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
-
- debTranslationsIndex(string URI,string Dist,string Section);
-};
-
class debSourcesIndex : public pkgIndexFile
{
string URI;
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 97553ab82..b11d2531c 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -15,7 +15,6 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/crc-16.h>
-#include <apt-pkg/md5.h>
#include <ctype.h>
@@ -118,48 +117,6 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver)
return true;
}
/*}}}*/
-// ListParser::Description - Return the description string /*{{{*/
-// ---------------------------------------------------------------------
-/* This is to return the string describing the package in debian
- form. If this returns the blank string then the entry is assumed to
- only describe package properties */
-string debListParser::Description()
-{
- if (DescriptionLanguage().empty())
- return Section.FindS("Description");
- else
- return Section.FindS(("Description-" + pkgIndexFile::LanguageCode()).c_str());
-}
- /*}}}*/
-// ListParser::DescriptionLanguage - Return the description lang string /*{{{*/
-// ---------------------------------------------------------------------
-/* This is to return the string describing the language of
- description. If this returns the blank string then the entry is
- assumed to describe original description. */
-string debListParser::DescriptionLanguage()
-{
- return Section.FindS("Description").empty() ? pkgIndexFile::LanguageCode() : "";
-}
- /*}}}*/
-// ListParser::Description - Return the description_md5 MD5SumValue /*{{{*/
-// ---------------------------------------------------------------------
-/* This is to return the md5 string to allow the check if it is the right
- description. If no Description-md5 is found in the section it will be
- calculated.
- */
-MD5SumValue debListParser::Description_md5()
-{
- string value = Section.FindS("Description-md5");
-
- if (value.empty())
- {
- MD5Summation md5;
- md5.Add((Description() + "\n").c_str());
- return md5.Result();
- } else
- return MD5SumValue(value);
-}
- /*}}}*/
// ListParser::UsePackage - Update a package structure /*{{{*/
// ---------------------------------------------------------------------
/* This is called to update the package with any new information
@@ -420,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;
}
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index 34bb29c72..3a0e0421b 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -12,7 +12,6 @@
#define PKGLIB_DEBLISTPARSER_H
#include <apt-pkg/pkgcachegen.h>
-#include <apt-pkg/indexfile.h>
#include <apt-pkg/tagfile.h>
class debListParser : public pkgCacheGenerator::ListParser
@@ -48,9 +47,6 @@ class debListParser : public pkgCacheGenerator::ListParser
virtual string Package();
virtual string Version();
virtual bool NewVersion(pkgCache::VerIterator Ver);
- virtual string Description();
- virtual string DescriptionLanguage();
- virtual MD5SumValue Description_md5();
virtual unsigned short VersionHash();
virtual bool UsePackage(pkgCache::PkgIterator Pkg,
pkgCache::VerIterator Ver);
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index d3b6ed957..85e5b16b3 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -157,14 +157,6 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool GetAll) const
ComputeIndexTargets(),
new indexRecords (Dist));
- // Queue the translations
- for (vector<const debSectionEntry *>::const_iterator I = SectionEntries.begin();
- I != SectionEntries.end(); I++) {
-
- debTranslationsIndex i = debTranslationsIndex(URI,Dist,(*I)->Section);
- i.GetIndexes(Owner);
- }
-
return true;
}
@@ -189,16 +181,11 @@ vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles()
Indexes = new vector <pkgIndexFile*>;
for (vector<const debSectionEntry *>::const_iterator I = SectionEntries.begin();
- I != SectionEntries.end(); I++) {
+ I != SectionEntries.end(); I++)
if ((*I)->IsSrc)
Indexes->push_back(new debSourcesIndex (URI, Dist, (*I)->Section, IsTrusted()));
else
- {
Indexes->push_back(new debPackagesIndex (URI, Dist, (*I)->Section, IsTrusted()));
- Indexes->push_back(new debTranslationsIndex(URI, Dist, (*I)->Section));
- }
- }
-
return Indexes;
}
diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc
index 518988bb6..6652a6ad9 100644
--- a/apt-pkg/deb/debrecords.cc
+++ b/apt-pkg/deb/debrecords.cc
@@ -12,9 +12,7 @@
#pragma implementation "apt-pkg/debrecords.h"
#endif
#include <apt-pkg/debrecords.h>
-#include <apt-pkg/strutl.h>
#include <apt-pkg/error.h>
-#include <langinfo.h>
/*}}}*/
// RecordParser::debRecordParser - Constructor /*{{{*/
@@ -33,10 +31,6 @@ bool debRecordParser::Jump(pkgCache::VerFileIterator const &Ver)
{
return Tags.Jump(Section,Ver->Offset);
}
-bool debRecordParser::Jump(pkgCache::DescFileIterator const &Desc)
-{
- return Tags.Jump(Section,Desc->Offset);
-}
/*}}}*/
// RecordParser::FileName - Return the archive filename on the site /*{{{*/
// ---------------------------------------------------------------------
@@ -83,7 +77,7 @@ string debRecordParser::Maintainer()
/* */
string debRecordParser::ShortDesc()
{
- string Res = LongDesc();
+ string Res = Section.FindS("Description");
string::size_type Pos = Res.find('\n');
if (Pos == string::npos)
return Res;
@@ -95,20 +89,7 @@ string debRecordParser::ShortDesc()
/* */
string debRecordParser::LongDesc()
{
- string orig, dest;
- char *codeset = nl_langinfo(CODESET);
-
- if (!Section.FindS("Description").empty())
- orig = Section.FindS("Description").c_str();
- else
- orig = Section.FindS(("Description-" + pkgIndexFile::LanguageCode()).c_str()).c_str();
-
- if (strcmp(codeset,"UTF-8") != 0) {
- UTF8ToCodeset(codeset, orig, &dest);
- orig = dest;
- }
-
- return orig;
+ return Section.FindS("Description");
}
/*}}}*/
// RecordParser::SourcePkg - Return the source package name if any /*{{{*/
diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h
index 24e5aab88..efef2e588 100644
--- a/apt-pkg/deb/debrecords.h
+++ b/apt-pkg/deb/debrecords.h
@@ -19,7 +19,6 @@
#endif
#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/indexfile.h>
#include <apt-pkg/tagfile.h>
class debRecordParser : public pkgRecords::Parser
@@ -31,7 +30,6 @@ class debRecordParser : public pkgRecords::Parser
protected:
virtual bool Jump(pkgCache::VerFileIterator const &Ver);
- virtual bool Jump(pkgCache::DescFileIterator const &Desc);
public:
diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc
index c9dded134..1f65062f7 100644
--- a/apt-pkg/indexcopy.cc
+++ b/apt-pkg/indexcopy.cc
@@ -32,8 +32,6 @@
using namespace std;
-
-
// IndexCopy::CopyPackages - Copy the package files from the CD /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -514,10 +512,10 @@ bool SourceCopy::RewriteEntry(FILE *Target,string File)
fputc('\n',Target);
return true;
}
+
+
/*}}}*/
-// SigVerify::Verify - Verify a files md5sum against its metaindex /*{{{*/
-// ---------------------------------------------------------------------
-/* */
+
bool SigVerify::Verify(string prefix, string file, indexRecords *MetaIndex)
{
const indexRecords::checkSum *Record = MetaIndex->Lookup(file);
@@ -672,178 +670,3 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
return true;
}
-
-
-bool TranslationsCopy::CopyTranslations(string CDROM,string Name,vector<string> &List,
- pkgCdromStatus *log)
-{
- OpProgress *Progress = NULL;
- if (List.size() == 0)
- return true;
-
- if(log)
- Progress = log->GetOpProgress();
-
- bool Debug = _config->FindB("Debug::aptcdrom",false);
-
- // Prepare the progress indicator
- unsigned long TotalSize = 0;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
- {
- struct stat Buf;
- if (stat(string(*I).c_str(),&Buf) != 0 &&
- stat(string(*I + ".gz").c_str(),&Buf) != 0)
- return _error->Errno("stat","Stat failed for %s",
- string(*I).c_str());
- TotalSize += Buf.st_size;
- }
-
- unsigned long CurrentSize = 0;
- unsigned int NotFound = 0;
- unsigned int WrongSize = 0;
- unsigned int Packages = 0;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
- {
- string OrigPath = string(*I,CDROM.length());
- unsigned long FileSize = 0;
-
- // Open the package file
- FileFd Pkg;
- if (FileExists(*I) == true)
- {
- Pkg.Open(*I,FileFd::ReadOnly);
- FileSize = Pkg.Size();
- }
- else
- {
- FileFd From(*I + ".gz",FileFd::ReadOnly);
- if (_error->PendingError() == true)
- return false;
- FileSize = From.Size();
-
- // Get a temp file
- FILE *tmp = tmpfile();
- if (tmp == 0)
- return _error->Errno("tmpfile","Unable to create a tmp file");
- Pkg.Fd(dup(fileno(tmp)));
- fclose(tmp);
-
- // Fork gzip
- pid_t Process = fork();
- if (Process < 0)
- return _error->Errno("fork","Couldn't fork gzip");
-
- // The child
- if (Process == 0)
- {
- dup2(From.Fd(),STDIN_FILENO);
- dup2(Pkg.Fd(),STDOUT_FILENO);
- SetCloseExec(STDIN_FILENO,false);
- SetCloseExec(STDOUT_FILENO,false);
-
- const char *Args[3];
- string Tmp = _config->Find("Dir::bin::gzip","gzip");
- Args[0] = Tmp.c_str();
- Args[1] = "-d";
- Args[2] = 0;
- execvp(Args[0],(char **)Args);
- exit(100);
- }
-
- // Wait for gzip to finish
- if (ExecWait(Process,_config->Find("Dir::bin::gzip","gzip").c_str(),false) == false)
- return _error->Error("gzip failed, perhaps the disk is full.");
-
- Pkg.Seek(0);
- }
- pkgTagFile Parser(&Pkg);
- if (_error->PendingError() == true)
- return false;
-
- // Open the output file
- char S[400];
- snprintf(S,sizeof(S),"cdrom:[%s]/%s",Name.c_str(),
- (*I).c_str() + CDROM.length());
- string TargetF = _config->FindDir("Dir::State::lists") + "partial/";
- TargetF += URItoFileName(S);
- if (_config->FindB("APT::CDROM::NoAct",false) == true)
- TargetF = "/dev/null";
- FileFd Target(TargetF,FileFd::WriteEmpty);
- FILE *TargetFl = fdopen(dup(Target.Fd()),"w");
- if (_error->PendingError() == true)
- return false;
- if (TargetFl == 0)
- return _error->Errno("fdopen","Failed to reopen fd");
-
- // Setup the progress meter
- if(Progress)
- Progress->OverallProgress(CurrentSize,TotalSize,FileSize,
- string("Reading Translation Indexes"));
-
- // Parse
- if(Progress)
- Progress->SubProgress(Pkg.Size());
- pkgTagSection Section;
- this->Section = &Section;
- string Prefix;
- unsigned long Hits = 0;
- unsigned long Chop = 0;
- while (Parser.Step(Section) == true)
- {
- if(Progress)
- Progress->Progress(Parser.Offset());
-
- const char *Start;
- const char *Stop;
- Section.GetSection(Start,Stop);
- fwrite(Start,Stop-Start, 1, TargetFl);
- fputc('\n',TargetFl);
-
- Packages++;
- Hits++;
- }
- fclose(TargetFl);
-
- if (Debug == true)
- cout << " Processed by using Prefix '" << Prefix << "' and chop " << Chop << endl;
-
- if (_config->FindB("APT::CDROM::NoAct",false) == false)
- {
- // Move out of the partial directory
- Target.Close();
- string FinalF = _config->FindDir("Dir::State::lists");
- FinalF += URItoFileName(S);
- if (rename(TargetF.c_str(),FinalF.c_str()) != 0)
- return _error->Errno("rename","Failed to rename");
- }
-
-
- CurrentSize += FileSize;
- }
- if(Progress)
- Progress->Done();
-
- // Some stats
- if(log) {
- stringstream msg;
- if(NotFound == 0 && WrongSize == 0)
- ioprintf(msg, _("Wrote %i records.\n"), Packages);
- else if (NotFound != 0 && WrongSize == 0)
- ioprintf(msg, _("Wrote %i records with %i missing files.\n"),
- Packages, NotFound);
- else if (NotFound == 0 && WrongSize != 0)
- ioprintf(msg, _("Wrote %i records with %i mismatched files\n"),
- Packages, WrongSize);
- if (NotFound != 0 && WrongSize != 0)
- ioprintf(msg, _("Wrote %i records with %i missing files and %i mismatched files\n"), Packages, NotFound, WrongSize);
- }
-
- if (Packages == 0)
- _error->Warning("No valid records were found.");
-
- if (NotFound + WrongSize > 10)
- _error->Warning("Alot of entries were discarded, something may be wrong.\n");
-
-
- return true;
-}
diff --git a/apt-pkg/indexcopy.h b/apt-pkg/indexcopy.h
index 7778ae595..4dcb2b46d 100644
--- a/apt-pkg/indexcopy.h
+++ b/apt-pkg/indexcopy.h
@@ -70,17 +70,6 @@ class SourceCopy : public IndexCopy
public:
};
-class TranslationsCopy
-{
- protected:
- pkgTagSection *Section;
-
- public:
- bool CopyTranslations(string CDROM,string Name,vector<string> &List,
- pkgCdromStatus *log);
-};
-
-
class SigVerify
{
bool Verify(string prefix,string file, indexRecords *records);
@@ -92,6 +81,4 @@ class SigVerify
vector<string> PkgList,vector<string> SrcList);
};
-
-
#endif
diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc
index 496e68b8b..49665161d 100644
--- a/apt-pkg/indexfile.cc
+++ b/apt-pkg/indexfile.cc
@@ -12,11 +12,8 @@
#pragma implementation "apt-pkg/indexfile.h"
#endif
-#include <apt-pkg/configuration.h>
#include <apt-pkg/indexfile.h>
#include <apt-pkg/error.h>
-
-#include <clocale>
/*}}}*/
// Global list of Item supported
@@ -70,60 +67,3 @@ string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &Record,
return string();
}
/*}}}*/
-// IndexFile::TranslationsAvailable - Check if will use Translation /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool pkgIndexFile::TranslationsAvailable()
-{
- const string Translation = _config->Find("APT::Acquire::Translation");
-
- if (Translation.compare("none") != 0)
- return CheckLanguageCode(LanguageCode().c_str());
- else
- return false;
-}
- /*}}}*/
-// IndexFile::CheckLanguageCode - Check the Language Code /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-/* common cases: de_DE, de_DE@euro, de_DE.UTF-8, de_DE.UTF-8@euro,
- de_DE.ISO8859-1, tig_ER
- more in /etc/gdm/locale.conf
-*/
-
-bool pkgIndexFile::CheckLanguageCode(const char *Lang)
-{
- if (strlen(Lang) == 2 || (strlen(Lang) == 5 && Lang[2] == '_'))
- return true;
-
- if (strcmp(Lang,"C") != 0)
- _error->Warning("Wrong language code %s", Lang);
-
- return false;
-}
- /*}}}*/
-// IndexFile::LanguageCode - Return the Language Code /*{{{*/
-// ---------------------------------------------------------------------
-/* return the language code */
-string pkgIndexFile::LanguageCode()
-{
- const string Translation = _config->Find("APT::Acquire::Translation");
-
- if (Translation.compare("environment") == 0)
- {
- string lang = std::setlocale(LC_MESSAGES,NULL);
-
- // FIXME: this needs to be added
- // we have a mapping of the language codes that contains all the language
- // codes that need the country code as well
- // (like pt_BR, pt_PT, sv_SE, zh_*, en_*)
-
- if(lang.size() > 2)
- return lang.substr(0,2);
- else
- return lang;
- }
- else
- return Translation;
-}
- /*}}}*/
diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h
index d5d1cf57a..61049f4bd 100644
--- a/apt-pkg/indexfile.h
+++ b/apt-pkg/indexfile.h
@@ -5,11 +5,10 @@
Index File - Abstraction for an index of archive/source file.
- There are 4 primary sorts of index files, all represented by this
+ There are 3 primary sorts of index files, all represented by this
class:
Binary index files
- Binary translation files
Bianry index files decribing the local system
Source index files
@@ -81,10 +80,6 @@ class pkgIndexFile
virtual bool MergeFileProvides(pkgCacheGenerator &/*Gen*/,OpProgress &/*Prog*/) const {return true;};
virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
- static bool TranslationsAvailable();
- static bool CheckLanguageCode(const char *Lang);
- static string LanguageCode();
-
bool IsTrusted() const { return Trusted; };
pkgIndexFile(bool Trusted): Trusted(Trusted) {};
diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc
index 6118845e8..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
@@ -101,9 +102,6 @@ bool pkgInitConfig(Configuration &Cnf)
bindtextdomain(textdomain(0),Cnf.FindDir("Dir::Locale").c_str());
}
#endif
-
- // Translation
- Cnf.Set("APT::Acquire::Translation", "environment");
return true;
}
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 4452079a2..9926befe9 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -26,7 +26,6 @@
#endif
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/indexfile.h>
#include <apt-pkg/version.h>
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
@@ -44,7 +43,6 @@
using std::string;
-
// Cache::Header::Header - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* Simply initialize the header */
@@ -54,7 +52,7 @@ pkgCache::Header::Header()
/* Whenever the structures change the major version should be bumped,
whenever the generator changes the minor version should be bumped. */
- MajorVersion = 5;
+ MajorVersion = 4;
MinorVersion = 0;
Dirty = false;
@@ -62,22 +60,17 @@ pkgCache::Header::Header()
PackageSz = sizeof(pkgCache::Package);
PackageFileSz = sizeof(pkgCache::PackageFile);
VersionSz = sizeof(pkgCache::Version);
- DescriptionSz = sizeof(pkgCache::Description);
DependencySz = sizeof(pkgCache::Dependency);
ProvidesSz = sizeof(pkgCache::Provides);
VerFileSz = sizeof(pkgCache::VerFile);
- DescFileSz = sizeof(pkgCache::DescFile);
PackageCount = 0;
VersionCount = 0;
- DescriptionCount = 0;
DependsCount = 0;
PackageFileCount = 0;
VerFileCount = 0;
- DescFileCount = 0;
ProvidesCount = 0;
MaxVerFileSize = 0;
- MaxDescFileSize = 0;
FileList = 0;
StringList = 0;
@@ -96,10 +89,8 @@ bool pkgCache::Header::CheckSizes(Header &Against) const
PackageSz == Against.PackageSz &&
PackageFileSz == Against.PackageFileSz &&
VersionSz == Against.VersionSz &&
- DescriptionSz == Against.DescriptionSz &&
DependencySz == Against.DependencySz &&
VerFileSz == Against.VerFileSz &&
- DescFileSz == Against.DescFileSz &&
ProvidesSz == Against.ProvidesSz)
return true;
return false;
@@ -124,10 +115,8 @@ bool pkgCache::ReMap()
HeaderP = (Header *)Map.Data();
PkgP = (Package *)Map.Data();
VerFileP = (VerFile *)Map.Data();
- DescFileP = (DescFile *)Map.Data();
PkgFileP = (PackageFile *)Map.Data();
VerP = (Version *)Map.Data();
- DescP = (Description *)Map.Data();
ProvideP = (Provides *)Map.Data();
DepP = (Dependency *)Map.Data();
StringItemP = (StringItem *)Map.Data();
@@ -164,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++)
@@ -184,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)];
@@ -246,11 +235,11 @@ const char *pkgCache::Priority(unsigned char Prio)
return 0;
}
/*}}}*/
+
// Bases for iterator classes /*{{{*/
void pkgCache::VerIterator::_dummy() {}
void pkgCache::DepIterator::_dummy() {}
void pkgCache::PrvIterator::_dummy() {}
-void pkgCache::DescIterator::_dummy() {}
/*}}}*/
// PkgIterator::operator ++ - Postfix incr /*{{{*/
// ---------------------------------------------------------------------
@@ -610,20 +599,3 @@ string pkgCache::PkgFileIterator::RelStr()
return Res;
}
/*}}}*/
-// VerIterator::TranslatedDescription - Return the a DescIter for locale/*{{{*/
-// ---------------------------------------------------------------------
-/* return a DescIter for the current locale or the default if none is
- * found
- */
-pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const
-{
- pkgCache::DescIterator DescDefault = DescriptionList();
- pkgCache::DescIterator Desc = DescDefault;
- for (; Desc.end() == false; Desc++)
- if (pkgIndexFile::LanguageCode() == Desc.LanguageCode())
- break;
- if (Desc.end() == true) Desc = DescDefault;
- return Desc;
-};
-
- /*}}}*/
diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h
index 6a54ad5ba..587d97534 100644
--- a/apt-pkg/pkgcache.h
+++ b/apt-pkg/pkgcache.h
@@ -38,30 +38,24 @@ class pkgCache
struct Package;
struct PackageFile;
struct Version;
- struct Description;
struct Provides;
struct Dependency;
struct StringItem;
struct VerFile;
- struct DescFile;
// Iterators
class PkgIterator;
class VerIterator;
- class DescIterator;
class DepIterator;
class PrvIterator;
class PkgFileIterator;
class VerFileIterator;
- class DescFileIterator;
friend class PkgIterator;
friend class VerIterator;
- friend class DescInterator;
friend class DepIterator;
friend class PrvIterator;
friend class PkgFileIterator;
friend class VerFileIterator;
- friend class DescFileIterator;
class Namespace;
@@ -95,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:
@@ -104,10 +98,8 @@ class pkgCache
Header *HeaderP;
Package *PkgP;
VerFile *VerFileP;
- DescFile *DescFileP;
PackageFile *PkgFileP;
Version *VerP;
- Description *DescP;
Provides *ProvideP;
Dependency *DepP;
StringItem *StringItemP;
@@ -119,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();
@@ -159,20 +151,16 @@ struct pkgCache::Header
unsigned short PackageSz;
unsigned short PackageFileSz;
unsigned short VersionSz;
- unsigned short DescriptionSz;
unsigned short DependencySz;
unsigned short ProvidesSz;
unsigned short VerFileSz;
- unsigned short DescFileSz;
// Structure counts
unsigned long PackageCount;
unsigned long VersionCount;
- unsigned long DescriptionCount;
unsigned long DependsCount;
unsigned long PackageFileCount;
unsigned long VerFileCount;
- unsigned long DescFileCount;
unsigned long ProvidesCount;
// Offsets
@@ -181,11 +169,10 @@ struct pkgCache::Header
map_ptrloc VerSysName; // StringTable
map_ptrloc Architecture; // StringTable
unsigned long MaxVerFileSize;
- unsigned long MaxDescFileSize;
/* Allocation pools, there should be one of these for each structure
excluding the header */
- DynamicMMap::Pool Pools[8];
+ DynamicMMap::Pool Pools[7];
// Rapid package name lookup
map_ptrloc HashTable[2*1048];
@@ -206,7 +193,7 @@ struct pkgCache::Package
map_ptrloc NextPackage; // Package
map_ptrloc RevDepends; // Dependency
map_ptrloc ProvidesList; // Provides
-
+
// Install/Remove/Purge etc
unsigned char SelectedState; // What
unsigned char InstState; // Flags
@@ -245,14 +232,6 @@ struct pkgCache::VerFile
unsigned short Size;
};
-struct pkgCache::DescFile
-{
- map_ptrloc File; // PackageFile
- map_ptrloc NextFile; // PkgVerFile
- map_ptrloc Offset; // File offset
- unsigned short Size;
-};
-
struct pkgCache::Version
{
map_ptrloc VerStr; // Stringtable
@@ -262,7 +241,6 @@ struct pkgCache::Version
// Lists
map_ptrloc FileList; // VerFile
map_ptrloc NextVer; // Version
- map_ptrloc DescriptionList; // Description
map_ptrloc DependsList; // Dependency
map_ptrloc ParentPkg; // Package
map_ptrloc ProvidesList; // Provides
@@ -274,22 +252,6 @@ struct pkgCache::Version
unsigned char Priority;
};
-struct pkgCache::Description
-{
- // Language Code store the description translation language code. If
- // the value has a 0 lenght then this is readed using the Package
- // file else the Translation-CODE are used.
- map_ptrloc language_code; // StringTable
- map_ptrloc md5sum; // StringTable
-
- // Linked list
- map_ptrloc FileList; // DescFile
- map_ptrloc NextDesc; // Description
- map_ptrloc ParentPkg; // Package
-
- unsigned short ID;
-};
-
struct pkgCache::Dependency
{
map_ptrloc Version; // Stringtable
@@ -337,13 +299,11 @@ class pkgCache::Namespace
typedef pkgCache::PkgIterator PkgIterator;
typedef pkgCache::VerIterator VerIterator;
- typedef pkgCache::DescIterator DescIterator;
typedef pkgCache::DepIterator DepIterator;
typedef pkgCache::PrvIterator PrvIterator;
typedef pkgCache::PkgFileIterator PkgFileIterator;
typedef pkgCache::VerFileIterator VerFileIterator;
typedef pkgCache::Version Version;
- typedef pkgCache::Description Description;
typedef pkgCache::Package Package;
typedef pkgCache::Header Header;
typedef pkgCache::Dep Dep;
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index 1ba791b45..de854bee5 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -125,46 +125,16 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
string Version = List.Version();
if (Version.empty() == true)
{
- // we first process the package, then the descriptions
- // (this has the bonus that we get MMap error when we run out
- // of MMap space)
if (List.UsePackage(Pkg,pkgCache::VerIterator(Cache)) == false)
return _error->Error(_("Error occurred while processing %s (UsePackage1)"),
PackageName.c_str());
-
- // Find the right version to write the description
- MD5SumValue CurMd5 = List.Description_md5();
- pkgCache::VerIterator Ver = Pkg.VersionList();
- map_ptrloc *LastVer = &Pkg->VersionList;
-
- for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++)
- {
- pkgCache::DescIterator Desc = Ver.DescriptionList();
- map_ptrloc *LastDesc = &Ver->DescriptionList;
-
- for (; Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++)
- {
-
- if (MD5SumValue(Desc.md5()) == CurMd5)
- {
- // Add new description
- *LastDesc = NewDescription(Desc, List.DescriptionLanguage(), CurMd5, *LastDesc);
- Desc->ParentPkg = Pkg.Index();
-
- if (NewFileDesc(Desc,List) == false)
- return _error->Error(_("Error occured while processing %s (NewFileDesc1)"),PackageName.c_str());
- break;
- }
- }
- }
-
continue;
}
pkgCache::VerIterator Ver = Pkg.VersionList();
- map_ptrloc *LastVer = &Pkg->VersionList;
+ map_ptrloc *Last = &Pkg->VersionList;
int Res = 1;
- for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++)
+ for (; Ver.end() == false; Last = &Ver->NextVer, Ver++)
{
Res = Cache.VS->CmpVersion(Version,Ver.VerStr());
if (Res >= 0)
@@ -198,7 +168,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
// Skip to the end of the same version set.
if (Res == 0)
{
- for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++)
+ for (; Ver.end() == false; Last = &Ver->NextVer, Ver++)
{
Res = Cache.VS->CmpVersion(Version,Ver.VerStr());
if (Res != 0)
@@ -207,10 +177,9 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
}
// Add a new version
- *LastVer = NewVersion(Ver,Version,*LastVer);
+ *Last = NewVersion(Ver,Version,*Last);
Ver->ParentPkg = Pkg.Index();
Ver->Hash = Hash;
-
if (List.NewVersion(Ver) == false)
return _error->Error(_("Error occurred while processing %s (NewVersion1)"),
PackageName.c_str());
@@ -230,21 +199,6 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
FoundFileDeps |= List.HasFileDeps();
return true;
}
-
- /* Record the Description data. Description data always exist in
- Packages and Translation-* files. */
- pkgCache::DescIterator Desc = Ver.DescriptionList();
- map_ptrloc *LastDesc = &Ver->DescriptionList;
-
- // Skip to the end of description set
- for (; Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++);
-
- // Add new description
- *LastDesc = NewDescription(Desc, List.DescriptionLanguage(), List.Description_md5(), *LastDesc);
- Desc->ParentPkg = Pkg.Index();
-
- if (NewFileDesc(Desc,List) == false)
- return _error->Error(_("Error occured while processing %s (NewFileDesc2)"),PackageName.c_str());
}
FoundFileDeps |= List.HasFileDeps();
@@ -255,9 +209,6 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
if (Cache.HeaderP->VersionCount >= (1ULL<<(sizeof(Cache.VerP->ID)*8))-1)
return _error->Error(_("Wow, you exceeded the number of versions "
"this APT is capable of."));
- if (Cache.HeaderP->DescriptionCount >= (1ULL<<(sizeof(Cache.DescP->ID)*8))-1)
- return _error->Error(_("Wow, you exceeded the number of descriptions "
- "this APT is capable of."));
if (Cache.HeaderP->DependsCount >= (1ULL<<(sizeof(Cache.DepP->ID)*8))-1ULL)
return _error->Error(_("Wow, you exceeded the number of dependencies "
"this APT is capable of."));
@@ -315,12 +266,12 @@ 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)
return true;
-
+
// Get a structure
unsigned long Package = Map.Allocate(sizeof(pkgCache::Package));
if (Package == 0)
@@ -379,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
@@ -398,69 +349,13 @@ unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
return Version;
}
/*}}}*/
-// CacheGenerator::NewFileDesc - Create a new File<->Desc association /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool pkgCacheGenerator::NewFileDesc(pkgCache::DescIterator &Desc,
- ListParser &List)
-{
- if (CurrentFile == 0)
- return true;
-
- // Get a structure
- unsigned long DescFile = Map.Allocate(sizeof(pkgCache::DescFile));
- if (DescFile == 0)
- return 0;
-
- pkgCache::DescFileIterator DF(Cache,Cache.DescFileP + DescFile);
- DF->File = CurrentFile - Cache.PkgFileP;
-
- // Link it to the end of the list
- map_ptrloc *Last = &Desc->FileList;
- for (pkgCache::DescFileIterator D = Desc.FileList(); D.end() == false; D++)
- Last = &D->NextFile;
-
- DF->NextFile = *Last;
- *Last = DF.Index();
-
- DF->Offset = List.Offset();
- DF->Size = List.Size();
- if (Cache.HeaderP->MaxDescFileSize < DF->Size)
- Cache.HeaderP->MaxDescFileSize = DF->Size;
- Cache.HeaderP->DescFileCount++;
-
- return true;
-}
- /*}}}*/
-// CacheGenerator::NewDescription - Create a new Description /*{{{*/
-// ---------------------------------------------------------------------
-/* This puts a description structure in the linked list */
-map_ptrloc pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc,
- const string &Lang, const MD5SumValue &md5sum,
- map_ptrloc Next)
-{
- // Get a structure
- map_ptrloc Description = Map.Allocate(sizeof(pkgCache::Description));
- if (Description == 0)
- return 0;
-
- // Fill it in
- Desc = pkgCache::DescIterator(Cache,Cache.DescP + Description);
- Desc->NextDesc = Next;
- Desc->ID = Cache.HeaderP->DescriptionCount++;
- Desc->language_code = Map.WriteString(Lang);
- Desc->md5sum = Map.WriteString(md5sum.Value());
-
- return Description;
-}
- /*}}}*/
// ListParser::NewDepends - Create a dependency element /*{{{*/
// ---------------------------------------------------------------------
/* 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)
{
@@ -524,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;
@@ -564,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)
{
@@ -648,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
@@ -685,7 +580,7 @@ static bool CheckValidity(string CacheFile, FileIterator Start,
pkgCache::PkgFileIterator File = (*Start)->FindInCache(Cache);
if (File.end() == true)
return false;
-
+
Visited[File->ID] = true;
}
diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h
index 6ab8594d9..9a729eea4 100644
--- a/apt-pkg/pkgcachegen.h
+++ b/apt-pkg/pkgcachegen.h
@@ -24,7 +24,6 @@
#endif
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/md5.h>
class pkgSourceList;
class OpProgress;
@@ -54,19 +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);
- bool NewFileDesc(pkgCache::DescIterator &Desc,ListParser &List);
- unsigned long NewVersion(pkgCache::VerIterator &Ver,string VerStr,unsigned long Next);
- map_ptrloc NewDescription(pkgCache::DescIterator &Desc,const string &Lang,const MD5SumValue &md5sum,map_ptrloc 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;};
@@ -97,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:
@@ -110,9 +108,6 @@ class pkgCacheGenerator::ListParser
virtual string Package() = 0;
virtual string Version() = 0;
virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
- virtual string Description() = 0;
- virtual string DescriptionLanguage() = 0;
- virtual MD5SumValue Description_md5() = 0;
virtual unsigned short VersionHash() = 0;
virtual bool UsePackage(pkgCache::PkgIterator Pkg,
pkgCache::VerIterator Ver) = 0;
diff --git a/apt-pkg/pkgrecords.cc b/apt-pkg/pkgrecords.cc
index b22f3e73f..9c2655d6a 100644
--- a/apt-pkg/pkgrecords.cc
+++ b/apt-pkg/pkgrecords.cc
@@ -63,12 +63,3 @@ pkgRecords::Parser &pkgRecords::Lookup(pkgCache::VerFileIterator const &Ver)
return *Files[Ver.File()->ID];
}
/*}}}*/
-// Records::Lookup - Get a parser for the package description file /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-pkgRecords::Parser &pkgRecords::Lookup(pkgCache::DescFileIterator const &Desc)
-{
- Files[Desc.File()->ID]->Jump(Desc);
- return *Files[Desc.File()->ID];
-}
- /*}}}*/
diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h
index 31c444dbf..08f004414 100644
--- a/apt-pkg/pkgrecords.h
+++ b/apt-pkg/pkgrecords.h
@@ -38,7 +38,6 @@ class pkgRecords
// Lookup function
Parser &Lookup(pkgCache::VerFileIterator const &Ver);
- Parser &Lookup(pkgCache::DescFileIterator const &Desc);
// Construct destruct
pkgRecords(pkgCache &Cache);
@@ -50,7 +49,6 @@ class pkgRecords::Parser
protected:
virtual bool Jump(pkgCache::VerFileIterator const &Ver) = 0;
- virtual bool Jump(pkgCache::DescFileIterator const &Desc) = 0;
public:
friend class pkgRecords;
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();};