diff options
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire-item.cc | 25 | ||||
-rw-r--r-- | apt-pkg/acquire-item.h | 5 | ||||
-rw-r--r-- | apt-pkg/acquire-method.cc | 2 | ||||
-rw-r--r-- | apt-pkg/acquire-worker.cc | 19 | ||||
-rw-r--r-- | apt-pkg/algorithms.h | 3 | ||||
-rw-r--r-- | apt-pkg/cacheiterators.h | 4 | ||||
-rw-r--r-- | apt-pkg/cdrom.cc | 19 | ||||
-rw-r--r-- | apt-pkg/deb/debsystem.cc | 7 | ||||
-rw-r--r-- | apt-pkg/pkgrecords.cc | 5 | ||||
-rw-r--r-- | apt-pkg/pkgrecords.h | 1 | ||||
-rw-r--r-- | apt-pkg/policy.h | 4 |
11 files changed, 75 insertions, 19 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 12dc811a6..e0e0611f0 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -142,20 +142,21 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, { Decompression = false; Erase = false; - + DestFile = _config->FindDir("Dir::State::lists") + "partial/"; DestFile += URItoFileName(URI); if(comprExt.empty()) { - // autoselect - if(FileExists("/usr/bin/bzip2")) - Desc.URI = URI + ".bz2"; - else - Desc.URI = URI + ".gz"; + // autoselect the compression method + if(FileExists("/usr/bin/bzip2")) + CompressionExtension = ".bz2"; + else + CompressionExtension = ".gz"; } else { - Desc.URI = URI + comprExt; + CompressionExtension = comprExt; } + Desc.URI = URI + CompressionExtension; Desc.Description = URIDesc; Desc.Owner = this; @@ -429,6 +430,13 @@ void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf) string Final = _config->FindDir("Dir::State::lists") + URItoFileName(RealURI); unlink(Final.c_str()); + // if we get a timeout if fail + if(LookupTag(Message,"FailReason") == "Timeout" || + LookupTag(Message,"FailReason") == "TmpResolveFailure") { + Item::Failed(Message,Cnf); + return; + } + // queue a pkgAcqMetaIndex with no sigfile new pkgAcqMetaIndex(Owner, MetaIndexURI, MetaIndexURIDesc, MetaIndexShortDesc, "", IndexTargets, MetaIndexParser); @@ -927,7 +935,8 @@ void pkgAcqArchive::Done(string Message,unsigned long Size,string Md5Hash, { Status = StatError; ErrorText = _("MD5Sum mismatch"); - Rename(DestFile,DestFile + ".FAILED"); + if(FileExists(DestFile)) + Rename(DestFile,DestFile + ".FAILED"); return; } } diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 2f7c71a81..ae2fba4d5 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -92,7 +92,8 @@ class pkgAcqIndex : public pkgAcquire::Item pkgAcquire::ItemDesc Desc; string RealURI; string ExpectedMD5; - + string CompressionExtension; + public: // Specialized action members @@ -100,7 +101,7 @@ class pkgAcqIndex : public pkgAcquire::Item virtual void Done(string Message,unsigned long Size,string Md5Hash, pkgAcquire::MethodConfig *Cnf); virtual string Custom600Headers(); - virtual string DescURI() {return RealURI + ".gz";}; + virtual string DescURI() {return RealURI + CompressionExtension;}; pkgAcqIndex(pkgAcquire *Owner,string URI,string URIDesc, string ShortDesct, string ExpectedMD5, string compressExt=""); diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc index 04c62eaaa..41b832f3b 100644 --- a/apt-pkg/acquire-method.cc +++ b/apt-pkg/acquire-method.cc @@ -277,7 +277,7 @@ bool pkgAcqMethod::MediaFail(string Required,string Drive) MyMessages.erase(MyMessages.begin()); } - return !StringToBool(LookupTag(Message,"Fail"),false); + return !StringToBool(LookupTag(Message,"Failed"),false); } Messages.push_back(Message); diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc index 5cd7d6f1e..d06024178 100644 --- a/apt-pkg/acquire-worker.cc +++ b/apt-pkg/acquire-worker.cc @@ -25,6 +25,7 @@ #include <apti18n.h> #include <iostream> +#include <sstream> #include <fstream> #include <sys/stat.h> @@ -367,6 +368,24 @@ bool pkgAcquire::Worker::Capabilities(string Message) /* */ bool pkgAcquire::Worker::MediaChange(string Message) { + int status_fd = _config->FindI("APT::Status-Fd",-1); + if(status_fd > 0) + { + string Media = LookupTag(Message,"Media"); + string Drive = LookupTag(Message,"Drive"); + ostringstream msg,status; + ioprintf(msg,_("Please insert the disc labeled: " + "'%s' " + "in the drive '%s' and press enter."), + Media.c_str(),Drive.c_str()); + status << "media-change: " // message + << Media << ":" // media + << Drive << ":" // drive + << msg.str() // l10n message + << endl; + write(status_fd, status.str().c_str(), status.str().size()); + } + if (Log == 0 || Log->MediaChange(LookupTag(Message,"Media"), LookupTag(Message,"Drive")) == false) { diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h index 174a7f58d..b95218061 100644 --- a/apt-pkg/algorithms.h +++ b/apt-pkg/algorithms.h @@ -118,7 +118,8 @@ class pkgProblemResolver // Try to resolve problems only by using keep bool ResolveByKeep(); - + + // Install all protected packages void InstallProtect(); pkgProblemResolver(pkgDepCache *Cache); diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index e34920032..f0aafb52d 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -267,7 +267,7 @@ class pkgCache::PrvIterator void operator ++(int) {if (Prv != Owner->ProvideP) Prv = Owner->ProvideP + (Type == PrvVer?Prv->NextPkgProv:Prv->NextProvides);}; inline void operator ++() {operator ++(0);}; - inline bool end() const {return Prv == Owner->ProvideP?true:false;}; + inline bool end() const {return Owner == 0 || Prv == Owner->ProvideP?true:false;}; // Comparison inline bool operator ==(const PrvIterator &B) const {return Prv == B.Prv;}; @@ -289,6 +289,8 @@ class pkgCache::PrvIterator inline PkgIterator OwnerPkg() {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[Prv->Version].ParentPkg);}; inline unsigned long Index() const {return Prv - Owner->ProvideP;}; + inline PrvIterator() : Prv(0), Type(PrvVer), Owner(0) {}; + inline PrvIterator(pkgCache &Owner,Provides *Trg,Version *) : Prv(Trg), Type(PrvVer), Owner(&Owner) { diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 7e194e253..b42c82dd0 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -446,6 +446,9 @@ bool pkgCdrom::WriteSourceList(string Name,vector<string> &List,bool Source) { F.getline(Buffer,sizeof(Buffer)); CurLine++; + if (F.fail() && !F.eof()) + return _error->Error(_("Line %u too long in source list %s."), + CurLine,File.c_str()); _strtabexpand(Buffer,sizeof(Buffer)); _strstrip(Buffer); @@ -588,7 +591,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) string DFile = _config->FindFile("Dir::State::cdroms"); if (FileExists(DFile) == true) { - if (ReadConfigFile(Database,DFile) == false) + if (ReadConfigFile(Database,DFile) == false) return _error->Error("Unable to read the cdrom database %s", DFile.c_str()); } @@ -674,8 +677,11 @@ bool pkgCdrom::Add(pkgCdromStatus *log) log->Update(msg.str(), STEP_SCAN); } - if (List.size() == 0 && SourceList.size() == 0) + if (List.size() == 0 && SourceList.size() == 0) + { + UnmountCdrom(CDROM); return _error->Error("Unable to locate any package files, perhaps this is not a Debian Disc"); + } // Check if the CD is in the database string Name; @@ -711,7 +717,10 @@ bool pkgCdrom::Add(pkgCdromStatus *log) Name.empty() == true) { if(!log) + { + UnmountCdrom(CDROM); return _error->Error("No disc name found and no way to ask for it"); + } while(true) { if(!log->AskCdromName(Name)) { @@ -786,7 +795,10 @@ bool pkgCdrom::Add(pkgCdromStatus *log) { string::size_type Space = (*I).find(' '); if (Space == string::npos) + { + UnmountCdrom(CDROM); return _error->Error("Internal error"); + } if(log) { msg.str(""); @@ -800,7 +812,10 @@ bool pkgCdrom::Add(pkgCdromStatus *log) { string::size_type Space = (*I).find(' '); if (Space == string::npos) + { + UnmountCdrom(CDROM); return _error->Error("Internal error"); + } if(log) { msg.str(""); diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index 0b3a4f742..2d805ea6f 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -164,7 +164,12 @@ bool debSystem::Initialize(Configuration &Cnf) Cnf.CndSet("Dir::State::userstatus","status.user"); // Defunct Cnf.CndSet("Dir::State::status","/var/lib/dpkg/status"); Cnf.CndSet("Dir::Bin::dpkg","/usr/bin/dpkg"); - + + if (StatusFile) { + delete StatusFile; + StatusFile = 0; + } + return true; } /*}}}*/ diff --git a/apt-pkg/pkgrecords.cc b/apt-pkg/pkgrecords.cc index b22f3e73f..f62f945b5 100644 --- a/apt-pkg/pkgrecords.cc +++ b/apt-pkg/pkgrecords.cc @@ -42,6 +42,9 @@ pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), Files(0) if (Files[I->ID] == 0) return; } + // We store that to make sure that the destructor won't segfault, + // even if the Cache object was destructed before this instance. + PackageFileCount = Cache.HeaderP->PackageFileCount; } /*}}}*/ // Records::~pkgRecords - Destructor /*{{{*/ @@ -49,7 +52,7 @@ pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), Files(0) /* */ pkgRecords::~pkgRecords() { - for (unsigned I = 0; I != Cache.HeaderP->PackageFileCount; I++) + for (unsigned I = 0; I != PackageFileCount; I++) delete Files[I]; delete [] Files; } diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h index 31c444dbf..ece91680e 100644 --- a/apt-pkg/pkgrecords.h +++ b/apt-pkg/pkgrecords.h @@ -33,6 +33,7 @@ class pkgRecords pkgCache &Cache; Parser **Files; + int PackageFileCount; public: diff --git a/apt-pkg/policy.h b/apt-pkg/policy.h index 15f204798..40ebd3f70 100644 --- a/apt-pkg/policy.h +++ b/apt-pkg/policy.h @@ -45,6 +45,8 @@ using std::vector; class pkgPolicy : public pkgDepCache::Policy { + protected: + struct Pin { pkgVersionMatch::MatchType Type; @@ -58,8 +60,6 @@ class pkgPolicy : public pkgDepCache::Policy string Pkg; }; - protected: - Pin *Pins; signed short *PFPriority; vector<Pin> Defaults; |