diff options
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire-item.cc | 36 | ||||
-rw-r--r-- | apt-pkg/acquire.cc | 2 | ||||
-rw-r--r-- | apt-pkg/algorithms.cc | 11 | ||||
-rw-r--r-- | apt-pkg/algorithms.h | 1 | ||||
-rw-r--r-- | apt-pkg/contrib/cmndline.cc | 2 | ||||
-rw-r--r-- | apt-pkg/contrib/cmndline.h | 2 | ||||
-rw-r--r-- | apt-pkg/contrib/strutl.cc | 6 | ||||
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 58 | ||||
-rw-r--r-- | apt-pkg/deb/dpkgpm.h | 6 | ||||
-rw-r--r-- | apt-pkg/depcache.cc | 2 | ||||
-rw-r--r-- | apt-pkg/orderlist.cc | 2 | ||||
-rw-r--r-- | apt-pkg/packagemanager.cc | 4 | ||||
-rw-r--r-- | apt-pkg/pkgcache.cc | 3 | ||||
-rw-r--r-- | apt-pkg/pkgcachegen.cc | 20 | ||||
-rw-r--r-- | apt-pkg/versionmatch.cc | 2 |
15 files changed, 115 insertions, 42 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index aee187227..91f3d0605 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -618,9 +618,9 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, else CompressionExtension = ".gz"; } else { - CompressionExtension = comprExt; + CompressionExtension = (comprExt == "plain" ? "" : comprExt); } - Desc.URI = URI + CompressionExtension; + Desc.URI = URI + CompressionExtension; Desc.Description = URIDesc; Desc.Owner = this; @@ -646,19 +646,30 @@ string pkgAcqIndex::Custom600Headers() void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) { + bool descChanged = false; // no .bz2 found, retry with .gz if(Desc.URI.substr(Desc.URI.size()-3) == "bz2") { - Desc.URI = Desc.URI.substr(0,Desc.URI.size()-3) + "gz"; + Desc.URI = Desc.URI.substr(0,Desc.URI.size()-3) + "gz"; - // retry with a gzip one - new pkgAcqIndex(Owner, RealURI, Desc.Description,Desc.ShortDesc, + new pkgAcqIndex(Owner, RealURI, Desc.Description,Desc.ShortDesc, ExpectedHash, string(".gz")); + descChanged = true; + } + // no .gz found, retry with uncompressed + else if(Desc.URI.substr(Desc.URI.size()-2) == "gz") { + Desc.URI = Desc.URI.substr(0,Desc.URI.size()-2); + + new pkgAcqIndex(Owner, RealURI, Desc.Description,Desc.ShortDesc, + ExpectedHash, string("plain")); + descChanged = true; + } + if (descChanged) { Status = StatDone; Complete = false; Dequeue(); return; - } - + } + // on decompression failure, remove bad versions in partial/ if(Decompression && Erase) { string s = _config->FindDir("Dir::State::lists") + "partial/"; @@ -750,12 +761,19 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string Hash, else Local = true; - string compExt = Desc.URI.substr(Desc.URI.size()-3); + string compExt = flExtension(flNotDir(URI(Desc.URI).Path)); const char *decompProg; if(compExt == "bz2") decompProg = "bzip2"; - else if(compExt == ".gz") + else if(compExt == "gz") decompProg = "gzip"; + // flExtensions returns the full name if no extension is found + // this is why we have this complicated compare operation here + // FIMXE: add a new flJustExtension() that return "" if no + // extension is found and use that above so that it can + // be tested against "" + else if(compExt == flNotDir(URI(Desc.URI).Path)) + decompProg = "copy"; else { _error->Error("Unsupported extension: %s", compExt.c_str()); return; diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 91f603889..38944bbac 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -797,7 +797,7 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) // Compute the CPS struct timeval NewTime; gettimeofday(&NewTime,0); - if (NewTime.tv_sec - Time.tv_sec == 6 && NewTime.tv_usec > Time.tv_usec || + if ((NewTime.tv_sec - Time.tv_sec == 6 && NewTime.tv_usec > Time.tv_usec) || NewTime.tv_sec - Time.tv_sec > 6) { double Delta = NewTime.tv_sec - Time.tv_sec + diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 158564baf..8bd98a620 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -37,7 +37,8 @@ pkgProblemResolver *pkgProblemResolver::This = 0; this is not necessary since the pkgCaches are fully shared now. */ pkgSimulate::pkgSimulate(pkgDepCache *Cache) : pkgPackageManager(Cache), iPolicy(Cache), - Sim(&Cache->GetCache(),&iPolicy) + Sim(&Cache->GetCache(),&iPolicy), + group(Sim) { Sim.Init(0); Flags = new unsigned char[Cache->Head().PackageCount]; @@ -496,7 +497,7 @@ void pkgProblemResolver::MakeScores() signed short &Score = Scores[I->ID]; - /* This is arbitary, it should be high enough to elevate an + /* This is arbitrary, it should be high enough to elevate an essantial package above most other packages but low enough to allow an obsolete essential packages to be removed by a conflicts on a powerfull normal package (ie libc6) */ @@ -1340,7 +1341,11 @@ bool ListUpdate(pkgAcquireStatus &Stat, (*I)->Finished(); - _error->Warning(_("Failed to fetch %s %s\n"),(*I)->DescURI().c_str(), + ::URI uri((*I)->DescURI()); + uri.User.clear(); + uri.Password.clear(); + string descUri = string(uri); + _error->Warning(_("Failed to fetch %s %s\n"), descUri.c_str(), (*I)->ErrorText.c_str()); if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError) diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h index defaed57d..d183cd213 100644 --- a/apt-pkg/algorithms.h +++ b/apt-pkg/algorithms.h @@ -60,6 +60,7 @@ class pkgSimulate : public pkgPackageManager Policy iPolicy; pkgDepCache Sim; + pkgDepCache::ActionGroup group; // The Actuall installation implementation virtual bool Install(PkgIterator Pkg,string File); diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc index 54c91d67d..bfd53695e 100644 --- a/apt-pkg/contrib/cmndline.cc +++ b/apt-pkg/contrib/cmndline.cc @@ -189,7 +189,7 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[], if ((A->Flags & ConfigFile) == ConfigFile) return ReadConfigFile(*Conf,Argument); - // Arbitary item specification + // Arbitrary item specification if ((A->Flags & ArbItem) == ArbItem) { const char *J; diff --git a/apt-pkg/contrib/cmndline.h b/apt-pkg/contrib/cmndline.h index fad6d1da9..e28071e81 100644 --- a/apt-pkg/contrib/cmndline.h +++ b/apt-pkg/contrib/cmndline.h @@ -34,7 +34,7 @@ ConfigFile - Means this flag should be interprited as the name of a config file to read in at this point in option processing. Implies HasArg. - ArbItem - Means the item is an arbitary configuration string of + ArbItem - Means the item is an arbitrary configuration string of the form item=value, where item is passed directly to the configuration class. The default, if the flags are 0 is to use Boolean diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index eacc7077a..bd374fd1e 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -459,9 +459,9 @@ string Base64Encode(const string &S) return Final; } /*}}}*/ -// stringcmp - Arbitary string compare /*{{{*/ +// stringcmp - Arbitrary string compare /*{{{*/ // --------------------------------------------------------------------- -/* This safely compares two non-null terminated strings of arbitary +/* This safely compares two non-null terminated strings of arbitrary length */ int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd) { @@ -517,7 +517,7 @@ int stringcmp(string::const_iterator A,string::const_iterator AEnd, } #endif /*}}}*/ -// stringcasecmp - Arbitary case insensitive string compare /*{{{*/ +// stringcasecmp - Arbitrary case insensitive string compare /*{{{*/ // --------------------------------------------------------------------- /* */ int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd) diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index a88e23081..ae99e4324 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -27,6 +27,8 @@ #include <errno.h> #include <string.h> #include <stdio.h> +#include <string.h> +#include <algorithm> #include <sstream> #include <map> @@ -41,7 +43,38 @@ using namespace std; - +namespace +{ + // Maps the dpkg "processing" info to human readable names. Entry 0 + // of each array is the key, entry 1 is the value. + const std::pair<const char *, const char *> PackageProcessingOps[] = { + std::make_pair("install", N_("Installing %s")), + std::make_pair("configure", N_("Configuring %s")), + std::make_pair("remove", N_("Removing %s")), + std::make_pair("trigproc", N_("Running post-installation trigger %s")) + }; + + const std::pair<const char *, const char *> * const PackageProcessingOpsBegin = PackageProcessingOps; + const std::pair<const char *, const char *> * const PackageProcessingOpsEnd = PackageProcessingOps + sizeof(PackageProcessingOps) / sizeof(PackageProcessingOps[0]); + + // Predicate to test whether an entry in the PackageProcessingOps + // array matches a string. + class MatchProcessingOp + { + const char *target; + + public: + MatchProcessingOp(const char *the_target) + : target(the_target) + { + } + + bool operator()(const std::pair<const char *, const char *> &pair) const + { + return strcmp(pair.first, target) == 0; + } + }; +} // DPkgPM::pkgDPkgPM - Constructor /*{{{*/ // --------------------------------------------------------------------- @@ -363,17 +396,19 @@ void pkgDPkgPM::ProcessDpkgStatusLine(int OutStatusFd, char *line) if(strncmp(list[0], "processing", strlen("processing")) == 0) { char s[200]; - map<string,string>::iterator iter; char *pkg_or_trigger = _strstrip(list[2]); action =_strstrip( list[1]); - iter = PackageProcessingOps.find(action); - if(iter == PackageProcessingOps.end()) + const std::pair<const char *, const char *> * const iter = + std::find_if(PackageProcessingOpsBegin, + PackageProcessingOpsEnd, + MatchProcessingOp(action)); + if(iter == PackageProcessingOpsEnd) { if (_config->FindB("Debug::pkgDPkgProgressReporting",false) == true) std::clog << "ignoring unknwon action: " << action << std::endl; return; } - snprintf(s, sizeof(s), _(iter->second.c_str()), pkg_or_trigger); + snprintf(s, sizeof(s), _(iter->second), pkg_or_trigger); status << "pmstatus:" << pkg_or_trigger << ":" << (PackagesDone/float(PackagesTotal)*100.0) @@ -617,12 +652,6 @@ bool pkgDPkgPM::Go(int OutStatusFd) }, }; - // populate the "processing" map - PackageProcessingOps.insert( make_pair("install",N_("Installing %s")) ); - PackageProcessingOps.insert( make_pair("configure",N_("Configuring %s")) ); - PackageProcessingOps.insert( make_pair("remove",N_("Removing %s")) ); - PackageProcessingOps.insert( make_pair("trigproc",N_("Running post-installation trigger %s")) ); - // init the PackageOps map, go over the list of packages that // that will be [installed|configured|removed|purged] and add // them to the PackageOps map (the dpkg states it goes through) @@ -760,6 +789,9 @@ bool pkgDPkgPM::Go(int OutStatusFd) sighandler_t old_SIGQUIT = signal(SIGQUIT,SIG_IGN); sighandler_t old_SIGINT = signal(SIGINT,SIG_IGN); + // ignore SIGHUP as well (debian #463030) + sighandler_t old_SIGHUP = signal(SIGHUP,SIG_IGN); + struct termios tt; struct termios tt_out; struct winsize win; @@ -871,6 +903,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // Restore sig int/quit signal(SIGQUIT,old_SIGQUIT); signal(SIGINT,old_SIGINT); + signal(SIGHUP,old_SIGHUP); return _error->Errno("waitpid","Couldn't wait for subprocess"); } // wait for input or output here @@ -909,6 +942,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // Restore sig int/quit signal(SIGQUIT,old_SIGQUIT); signal(SIGINT,old_SIGINT); + signal(SIGHUP,old_SIGHUP); if(master >= 0) { @@ -945,6 +979,8 @@ bool pkgDPkgPM::Go(int OutStatusFd) if (RunScripts("DPkg::Post-Invoke") == false) return false; + + Cache.writeStateFile(NULL); return true; } /*}}}*/ diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index 51668bdf7..62d3d893d 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -48,8 +48,12 @@ class pkgDPkgPM : public pkgPackageManager // the int is the state that is already done (e.g. a package that is // going to be install is already in state "half-installed") map<string,unsigned int> PackageOpsDone; - // map the dpkg "processing" info to human readable names + + +#if 1 // FIXME: BINARY COMPATIBILITY ONLY, remove on next ABI break map<string,string> PackageProcessingOps; +#endif + // progress reporting unsigned int PackagesDone; unsigned int PackagesTotal; diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 17864c76c..8584419e1 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1001,7 +1001,7 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, if(Pkg.Section() && ConfigValueInSubTree("APT::Never-MarkAuto-Sections", Pkg.Section())) { if(_config->FindB("Debug::pkgDepCache::AutoInstall",false) == true) - std::clog << "Setting NOT as auto-installed (direct dep of pkg in APT::Never-MarkAuto-Section)" << std::endl; + std::clog << "Setting NOT as auto-installed (direct dep of pkg in APT::Never-MarkAuto-Sections)" << std::endl; MarkInstall(InstPkg,true,Depth + 1, true); } else diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index 616714e29..ca18f1d75 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -39,7 +39,7 @@ ordering. Each of the features can be enabled in the sorting routine at an - arbitary priority to give quite abit of control over the final unpacking + arbitrary priority to give quite abit of control over the final unpacking order. The rules listed above may never be violated and are called Critical. diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index c391a6036..304d1c653 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -666,10 +666,6 @@ pkgPackageManager::DoInstallPostFork(int statusFd) if(goResult == false) return Failed; - // if all was fine update the state file - if(Res == Completed) { - Cache.writeStateFile(NULL); - } return Res; }; diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 133899a27..8eb62089a 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -622,7 +622,8 @@ pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const for (; Desc.end() == false; Desc++) if (pkgIndexFile::LanguageCode() == Desc.LanguageCode()) break; - if (Desc.end() == true) Desc = DescDefault; + if (Desc.end() == true) + Desc = DescDefault; return Desc; }; diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index d00cd4e64..f71547f39 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -139,10 +139,21 @@ bool pkgCacheGenerator::MergeList(ListParser &List, { pkgCache::DescIterator Desc = Ver.DescriptionList(); map_ptrloc *LastDesc = &Ver->DescriptionList; - - for (; Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++) + bool duplicate=false; + + // don't add a new description if we have one for the given + // md5 && language + for ( ; Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++) + if (MD5SumValue(Desc.md5()) == CurMd5 && + Desc.LanguageCode() == List.DescriptionLanguage()) + duplicate=true; + if(duplicate) + continue; + + for (Desc = Ver.DescriptionList(); + Desc.end() == false; + LastDesc = &Desc->NextDesc, Desc++) { - if (MD5SumValue(Desc.md5()) == CurMd5) { // Add new description @@ -434,7 +445,8 @@ bool pkgCacheGenerator::NewFileDesc(pkgCache::DescIterator &Desc, // --------------------------------------------------------------------- /* This puts a description structure in the linked list */ map_ptrloc pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc, - const string &Lang, const MD5SumValue &md5sum, + const string &Lang, + const MD5SumValue &md5sum, map_ptrloc Next) { // Get a structure diff --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc index 4a426809c..5c25c2f7b 100644 --- a/apt-pkg/versionmatch.cc +++ b/apt-pkg/versionmatch.cc @@ -124,7 +124,7 @@ bool pkgVersionMatch::MatchVer(const char *A,string B,bool Prefix) const char *Ae = Ab + strlen(A); // Strings are not a compatible size. - if ((unsigned)(Ae - Ab) != B.length() && Prefix == false || + if (((unsigned)(Ae - Ab) != B.length() && Prefix == false) || (unsigned)(Ae - Ab) < B.length()) return false; |