diff options
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/cachefilter.cc | 6 | ||||
-rw-r--r-- | apt-pkg/cacheset.cc | 2 | ||||
-rw-r--r-- | apt-pkg/cdrom.cc | 4 | ||||
-rw-r--r-- | apt-pkg/clean.cc | 5 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 2 | ||||
-rw-r--r-- | apt-pkg/contrib/mmap.cc | 31 | ||||
-rw-r--r-- | apt-pkg/contrib/netrc.cc | 21 | ||||
-rw-r--r-- | apt-pkg/deb/deblistparser.cc | 3 | ||||
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 62 | ||||
-rw-r--r-- | apt-pkg/indexcopy.cc | 7 | ||||
-rw-r--r-- | apt-pkg/init.cc | 1 | ||||
-rw-r--r-- | apt-pkg/packagemanager.cc | 6 |
12 files changed, 111 insertions, 39 deletions
diff --git a/apt-pkg/cachefilter.cc b/apt-pkg/cachefilter.cc index 35f95fe22..58cc812bf 100644 --- a/apt-pkg/cachefilter.cc +++ b/apt-pkg/cachefilter.cc @@ -66,12 +66,6 @@ static std::string CompleteArch(std::string const &arch) { complete = complete.substr(1, complete.size()-2); return complete; } - else if (arch == "armel") return "linux-arm"; - else if (arch == "armhf") return "linux-arm"; - else if (arch == "lpia") return "linux-i386"; - else if (arch == "powerpcspe") return "linux-powerpc"; - else if (arch == "uclibc-linux-armel") return "linux-arm"; - else if (arch == "uclinux-armel") return "uclinux-arm"; else if (arch == "any") return "*-*"; else return "linux-" + arch; } diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index 784d1f0bf..1fea4f94a 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -193,6 +193,8 @@ bool PackageContainerInterface::FromGroup(PackageContainerInterface * const pci, if (archfound != std::string::npos) { arch = pkg.substr(archfound+1); pkg.erase(archfound); + if (arch == "all" || arch == "native") + arch = _config->Find("APT::Architecture"); } pkgCache::GrpIterator Grp = Cache.GetPkgCache()->FindGrp(pkg); diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 8462e8286..699f66fb3 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -413,8 +413,8 @@ bool pkgCdrom::WriteDatabase(Configuration &Cnf) Out.close(); - if (FileExists(DFile) == true && link(DFile.c_str(),string(DFile + '~').c_str()) != 0) - return _error->Errno("link", "Failed to link %s to %s~", DFile.c_str(), DFile.c_str()); + if (FileExists(DFile) == true) + rename(DFile.c_str(), string(DFile + '~').c_str()); if (rename(NewFile.c_str(),DFile.c_str()) != 0) return _error->Errno("rename","Failed to rename %s.new to %s", DFile.c_str(),DFile.c_str()); diff --git a/apt-pkg/clean.cc b/apt-pkg/clean.cc index 9c167eaa5..eae419e34 100644 --- a/apt-pkg/clean.cc +++ b/apt-pkg/clean.cc @@ -81,12 +81,13 @@ bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache) if (*I != '.') continue; std::string const Arch = DeQuoteString(std::string(Start,I-Start)); - + + // ignore packages of unconfigured architectures if (APT::Configuration::checkArchitecture(Arch) == false) continue; // Lookup the package - pkgCache::PkgIterator P = Cache.FindPkg(Pkg); + pkgCache::PkgIterator P = Cache.FindPkg(Pkg, Arch); if (P.end() != true) { pkgCache::VerIterator V = P.VersionList(); diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 960616f33..4c224337e 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1768,13 +1768,11 @@ bool FileFd::Close() /* */ bool FileFd::Sync() { -#ifdef _POSIX_SYNCHRONIZED_IO if (fsync(iFd) != 0) { Flags |= Fail; return _error->Errno("sync",_("Problem syncing the file")); } -#endif return true; } /*}}}*/ diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc index 593bb063b..a176da636 100644 --- a/apt-pkg/contrib/mmap.cc +++ b/apt-pkg/contrib/mmap.cc @@ -102,6 +102,7 @@ bool MMap::Map(FileFd &Fd) { // for readonly, we don't need sync, so make it simple Base = malloc(iSize); + SyncToFd = new FileFd(); return Fd.Read(Base, iSize); } // FIXME: Writing to compressed fd's ? @@ -155,11 +156,10 @@ bool MMap::Close(bool DoSync) /* This is done in syncronous mode - the docs indicate that this will not return till all IO is complete */ bool MMap::Sync() -{ +{ if ((Flags & UnMapped) == UnMapped) return true; - -#ifdef _POSIX_SYNCHRONIZED_IO + if ((Flags & ReadOnly) != ReadOnly) { if (SyncToFd != NULL) @@ -169,11 +169,12 @@ bool MMap::Sync() } else { +#ifdef _POSIX_SYNCHRONIZED_IO if (msync((char *)Base, iSize, MS_SYNC) < 0) return _error->Errno("msync", _("Unable to synchronize mmap")); +#endif } } -#endif return true; } /*}}}*/ @@ -184,9 +185,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop) { if ((Flags & UnMapped) == UnMapped) return true; - -#ifdef _POSIX_SYNCHRONIZED_IO - unsigned long long PSize = sysconf(_SC_PAGESIZE); + if ((Flags & ReadOnly) != ReadOnly) { if (SyncToFd != 0) @@ -197,11 +196,13 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop) } else { +#ifdef _POSIX_SYNCHRONIZED_IO + unsigned long long const PSize = sysconf(_SC_PAGESIZE); if (msync((char *)Base+(unsigned long long)(Start/PSize)*PSize,Stop - Start,MS_SYNC) < 0) return _error->Errno("msync", _("Unable to synchronize mmap")); +#endif } } -#endif return true; } /*}}}*/ @@ -216,7 +217,17 @@ DynamicMMap::DynamicMMap(FileFd &F,unsigned long Flags,unsigned long const &Work { if (_error->PendingError() == true) return; - + + // disable Moveable if we don't grow + if (Grow == 0) + this->Flags &= ~Moveable; + +#ifndef __linux__ + // kfreebsd doesn't have mremap, so we use the fallback + if ((this->Flags & Moveable) == Moveable) + this->Flags |= Fallback; +#endif + unsigned long long EndOfFile = Fd->Size(); if (EndOfFile > WorkSpace) WorkSpace = EndOfFile; @@ -328,7 +339,7 @@ unsigned long DynamicMMap::RawAllocate(unsigned long long Size,unsigned long Aln if(!Grow()) { _error->Fatal(_("Dynamic MMap ran out of room. Please increase the size " - "of APT::Cache-Limit. Current value: %lu. (man 5 apt.conf)"), WorkSpace); + "of APT::Cache-Start. Current value: %lu. (man 5 apt.conf)"), WorkSpace); return 0; } } diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc index 56e59d84b..2321ef063 100644 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@ -15,6 +15,7 @@ #include <apt-pkg/configuration.h> #include <apt-pkg/strutl.h> +#include <apt-pkg/error.h> #include <apt-pkg/fileutl.h> #include <iostream> @@ -39,8 +40,8 @@ enum { }; /* make sure we have room for at least this size: */ -#define LOGINSIZE 64 -#define PASSWORDSIZE 64 +#define LOGINSIZE 256 +#define PASSWORDSIZE 256 #define NETRC DOT_CHAR "netrc" /* returns -1 on failure, 0 if the host is found, 1 is the host isn't found */ @@ -122,11 +123,21 @@ int parsenetrc (char *host, char *login, char *password, char *netrcfile = NULL) if (specific_login) state_our_login = !strcasecmp (login, tok); else + { + if (strlen(tok) > LOGINSIZE) + _error->Error("login token too long %i (max: %i)", + strlen(tok), LOGINSIZE); strncpy (login, tok, LOGINSIZE - 1); + } state_login = 0; } else if (state_password) { - if (state_our_login || !specific_login) + if (state_our_login || !specific_login) + { + if (strlen(tok) > PASSWORDSIZE) + _error->Error("password token too long %i (max %i)", + strlen(tok), PASSWORDSIZE); strncpy (password, tok, PASSWORDSIZE - 1); + } state_password = 0; } else if (!strcasecmp ("login", tok)) state_login = 1; @@ -162,8 +173,8 @@ void maybe_add_auth (URI &Uri, string NetRCFile) { if (NetRCFile.empty () == false) { - char login[64] = ""; - char password[64] = ""; + char login[LOGINSIZE] = ""; + char password[PASSWORDSIZE] = ""; char *netrcfile = strdup(NetRCFile.c_str()); // first check for a generic host based netrc entry diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index e93e51af3..12c6ab4c9 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -635,7 +635,8 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver, return _error->Error("Problem parsing dependency %s",Tag); size_t const found = Package.rfind(':'); - if (MultiArchEnabled == true && + // If negative is unspecific it needs to apply on all architectures + if (MultiArchEnabled == true && found == string::npos && (Type == pkgCache::Dep::Conflicts || Type == pkgCache::Dep::DpkgBreaks || Type == pkgCache::Dep::Replaces)) diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 296426c80..7e937a85b 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -29,7 +29,6 @@ #include <sys/wait.h> #include <signal.h> #include <errno.h> -#include <string.h> #include <stdio.h> #include <string.h> #include <algorithm> @@ -1461,7 +1460,7 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) string::size_type pos; FILE *report; - if (_config->FindB("Dpkg::ApportFailureReport", false) == false) + if (_config->FindB("Dpkg::ApportFailureReport", true) == false) { std::clog << "configured to not write apport reports" << std::endl; return; @@ -1488,18 +1487,49 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) } // do not report out-of-memory failures - if(strstr(errormsg, strerror(ENOMEM)) != NULL) { + if(strstr(errormsg, strerror(ENOMEM)) != NULL || + strstr(errormsg, "failed to allocate memory") != NULL) { std::clog << _("No apport report written because the error message indicates a out of memory error") << std::endl; return; } - // do not report dpkg I/O errors - // XXX - this message is localized, but this only matches the English version. This is better than nothing. - if(strstr(errormsg, "short read in buffer_copy (")) { - std::clog << _("No apport report written because the error message indicates a dpkg I/O error") << std::endl; + // do not report bugs regarding inaccessible local files + if(strstr(errormsg, strerror(ENOENT)) != NULL || + strstr(errormsg, "cannot access archive") != NULL) { + std::clog << _("No apport report written because the error message indicates an issue on the local system") << std::endl; + return; + } + + // do not report errors encountered when decompressing packages + if(strstr(errormsg, "--fsys-tarfile returned error exit status 2") != NULL) { + std::clog << _("No apport report written because the error message indicates an issue on the local system") << std::endl; return; } + // do not report dpkg I/O errors, this is a format string, so we compare + // the prefix and the suffix of the error with the dpkg error message + vector<string> io_errors; + io_errors.push_back(string("failed to read on buffer copy for %s")); + io_errors.push_back(string("failed in write on buffer copy for %s")); + io_errors.push_back(string("short read on buffer copy for %s")); + + for (vector<string>::iterator I = io_errors.begin(); I != io_errors.end(); I++) + { + vector<string> list = VectorizeString(dgettext("dpkg", (*I).c_str()), '%'); + if (list.size() > 1) { + // we need to split %s, VectorizeString only allows char so we need + // to kill the "s" manually + if (list[1].size() > 1) { + list[1].erase(0, 1); + if(strstr(errormsg, list[0].c_str()) && + strstr(errormsg, list[1].c_str())) { + std::clog << _("No apport report written because the error message indicates a dpkg I/O error") << std::endl; + return; + } + } + } + } + // get the pkgname and reportfile pkgname = flNotDir(pkgpath); pos = pkgname.find('_'); @@ -1589,6 +1619,24 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) { while( fgets(buf, sizeof(buf), log) != NULL) fprintf(report, " %s", buf); + fprintf(report, " \n"); + fclose(log); + } + } + + // attach history log it if we have it + string histfile_name = _config->FindFile("Dir::Log::History"); + if (!histfile_name.empty()) + { + FILE *log = NULL; + char buf[1024]; + + fprintf(report, "DpkgHistoryLog:\n"); + log = fopen(histfile_name.c_str(),"r"); + if(log != NULL) + { + while( fgets(buf, sizeof(buf), log) != NULL) + fprintf(report, " %s", buf); fclose(log); } } diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index ddf1909b7..16f2fee96 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -806,9 +806,14 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ (*I).c_str() + CDROM.length()); string TargetF = _config->FindDir("Dir::State::lists") + "partial/"; TargetF += URItoFileName(S); + FileFd Target; if (_config->FindB("APT::CDROM::NoAct",false) == true) + { TargetF = "/dev/null"; - FileFd Target(TargetF,FileFd::WriteAtomic); + Target.Open(TargetF,FileFd::WriteExists); + } else { + Target.Open(TargetF,FileFd::WriteAtomic); + } FILE *TargetFl = fdopen(dup(Target.Fd()),"w"); if (_error->PendingError() == true) return false; diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc index 76278921f..4818174ac 100644 --- a/apt-pkg/init.cc +++ b/apt-pkg/init.cc @@ -92,6 +92,7 @@ bool pkgInitConfig(Configuration &Cnf) Cnf.Set("Dir::Ignore-Files-Silently::", "\\.dpkg-[a-z]+$"); Cnf.Set("Dir::Ignore-Files-Silently::", "\\.save$"); Cnf.Set("Dir::Ignore-Files-Silently::", "\\.orig$"); + Cnf.Set("Dir::Ignore-Files-Silently::", "\\.distUpgrade$"); // Default cdrom mount point Cnf.CndSet("Acquire::cdrom::mount", "/media/cdrom/"); diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 46fc499c6..97a3c8c88 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -338,7 +338,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth) however if there is a loop (A depends on B, B depends on A) this will not be the case, so check for dependencies before configuring. */ bool Bad = false, Changed = false; - const unsigned int max_loops = _config->FindI("APT::pkgPackageManager::MaxLoopCount", 500); + const unsigned int max_loops = _config->FindI("APT::pkgPackageManager::MaxLoopCount", 5000); unsigned int i=0; do { @@ -602,7 +602,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c This will be either dealt with if the package is configured as a dependency of Pkg (if and when Pkg is configured), or by the ConfigureAll call at the end of the for loop in OrderInstall. */ bool Changed = false; - const unsigned int max_loops = _config->FindI("APT::pkgPackageManager::MaxLoopCount", 500); + const unsigned int max_loops = _config->FindI("APT::pkgPackageManager::MaxLoopCount", 5000); unsigned int i = 0; do { @@ -643,7 +643,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c } // Look for something that could be configured. - for (DepIterator Cur = Start; Bad == true; ++Cur) + for (DepIterator Cur = Start; Bad == true && Cur.end() == false; ++Cur) { SPtrArray<Version *> VList = Cur.AllTargets(); for (Version **I = VList; *I != 0; ++I) |