diff options
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire-item.cc | 18 | ||||
-rw-r--r-- | apt-pkg/acquire.cc | 29 | ||||
-rw-r--r-- | apt-pkg/acquire.h | 8 | ||||
-rw-r--r-- | apt-pkg/algorithms.cc | 3 | ||||
-rw-r--r-- | apt-pkg/contrib/cdromutl.cc | 24 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 21 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.h | 9 | ||||
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 3 | ||||
-rw-r--r-- | apt-pkg/indexcopy.cc | 15 | ||||
-rw-r--r-- | apt-pkg/init.cc | 3 | ||||
-rw-r--r-- | apt-pkg/init.h | 2 | ||||
-rw-r--r-- | apt-pkg/versionmatch.cc | 2 |
12 files changed, 83 insertions, 54 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 752bc6a99..2c4ce91a0 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1060,12 +1060,6 @@ void pkgAcqMetaIndex::Done(string Message,unsigned long Size,string Hash, /*{{{* // all cool, move Release file into place Complete = true; - - string FinalFile = _config->FindDir("Dir::State::lists"); - FinalFile += URItoFileName(RealURI); - Rename(DestFile,FinalFile); - chmod(FinalFile.c_str(),0644); - DestFile = FinalFile; } else { @@ -1092,8 +1086,18 @@ void pkgAcqMetaIndex::Done(string Message,unsigned long Size,string Hash, /*{{{* Desc.URI = "gpgv:" + SigFile; QueueURI(Desc); Mode = "gpgv"; + return; } } + + if (Complete == true) + { + string FinalFile = _config->FindDir("Dir::State::lists"); + FinalFile += URItoFileName(RealURI); + Rename(DestFile,FinalFile); + chmod(FinalFile.c_str(),0644); + DestFile = FinalFile; + } } /*}}}*/ void pkgAcqMetaIndex::RetrievalDone(string Message) /*{{{*/ @@ -1323,7 +1327,7 @@ void pkgAcqMetaIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) Status = StatTransientNetworkError; _error->Warning(_("A error occurred during the signature " "verification. The repository is not updated " - "and the previous index files will be used." + "and the previous index files will be used. " "GPG error: %s: %s\n"), Desc.Description.c_str(), LookupTag(Message,"Message").c_str()); diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 63825da93..9478cdfb4 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -74,12 +74,12 @@ bool pkgAcquire::Setup(pkgAcquireStatus *Progress, string const &Lock) string const archivesDir = _config->FindDir("Dir::Cache::Archives"); string const partialArchivesDir = archivesDir + "partial/"; - if (CheckDirectory(_config->FindDir("Dir::State"), partialListDir) == false && - CheckDirectory(listDir, partialListDir) == false) + if (CreateAPTDirectoryIfNeeded(_config->FindDir("Dir::State"), partialListDir) == false && + CreateAPTDirectoryIfNeeded(listDir, partialListDir) == false) return _error->Errno("Acquire", _("List directory %spartial is missing."), listDir.c_str()); - if (CheckDirectory(_config->FindDir("Dir::Cache"), partialArchivesDir) == false && - CheckDirectory(archivesDir, partialArchivesDir) == false) + if (CreateAPTDirectoryIfNeeded(_config->FindDir("Dir::Cache"), partialArchivesDir) == false && + CreateAPTDirectoryIfNeeded(archivesDir, partialArchivesDir) == false) return _error->Errno("Acquire", _("Archives directory %spartial is missing."), archivesDir.c_str()); if (Lock.empty() == true || _config->FindB("Debug::NoLocking", false) == true) @@ -93,27 +93,6 @@ bool pkgAcquire::Setup(pkgAcquireStatus *Progress, string const &Lock) return true; } /*}}}*/ -// Acquire::CheckDirectory - ensure that the given directory exists /*{{{*/ -// --------------------------------------------------------------------- -/* a small wrapper around CreateDirectory to check if it exists and to - remove the trailing "/apt/" from the parent directory if needed */ -bool pkgAcquire::CheckDirectory(string const &Parent, string const &Path) const -{ - if (DirectoryExists(Path) == true) - return true; - - size_t const len = Parent.size(); - if (len > 5 && Parent.find("/apt/", len - 6, 5) == len - 5) - { - if (CreateDirectory(Parent.substr(0,len-5), Path) == true) - return true; - } - else if (CreateDirectory(Parent, Path) == true) - return true; - - return false; -} - /*}}}*/ // Acquire::~pkgAcquire - Destructor /*{{{*/ // --------------------------------------------------------------------- /* Free our memory, clean up the queues (destroy the workers) */ diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 82be8b843..e3a4435b8 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -362,14 +362,6 @@ class pkgAcquire private: /** \brief FD of the Lock file we acquire in Setup (if any) */ int LockFD; - - /** \brief Ensure the existence of the given Path - * - * \param Parent directory of the Path directory - a trailing - * /apt/ will be removed before CreateDirectory call. - * \param Path which should exist after (successful) call - */ - bool CheckDirectory(string const &Parent, string const &Path) const; }; /** \brief Represents a single download source from which an item diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index a298be493..961f5c2fa 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1088,7 +1088,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) { if (Start->Type == pkgCache::Dep::DpkgBreaks) { - // first, try upgrading the package, if that + // first, try upgradring the package, if that // does not help, the breaks goes onto the // kill list // @@ -1114,7 +1114,6 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) LEnd++; if (Start->Type != pkgCache::Dep::Conflicts && - Start->Type != pkgCache::Dep::DpkgBreaks && Start->Type != pkgCache::Dep::Obsoletes) break; } diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 6dce82fe1..68b980407 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -156,6 +156,19 @@ bool MountCdrom(string Path, string DeviceName) bool IdentCdrom(string CD,string &Res,unsigned int Version) { MD5Summation Hash; + bool writable_media = false; + + // if we are on a writable medium (like a usb-stick) that is just + // used like a cdrom don't use "." as it will constantly change, + // use .disk instead + if (access(CD.c_str(), W_OK) == 0 && DirectoryExists(CD+string("/.disk"))) + { + writable_media = true; + CD = CD.append("/.disk"); + if (_config->FindB("Debug::aptcdrom",false) == true) + std::clog << "Found writable cdrom, using alternative path: " << CD + << std::endl; + } string StartDir = SafeGetCWD(); if (chdir(CD.c_str()) != 0) @@ -202,10 +215,15 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version) struct statvfs Buf; if (statvfs(CD.c_str(),&Buf) != 0) return _error->Errno("statfs",_("Failed to stat the cdrom")); - + // We use a kilobyte block size to advoid overflow - sprintf(S,"%lu %lu",(long)(Buf.f_blocks*(Buf.f_bsize/1024)), - (long)(Buf.f_bfree*(Buf.f_bsize/1024))); + if (writable_media) + { + sprintf(S,"%lu",(long)(Buf.f_blocks*(Buf.f_bsize/1024))); + } else { + sprintf(S,"%lu %lu",(long)(Buf.f_blocks*(Buf.f_bsize/1024)), + (long)(Buf.f_bfree*(Buf.f_bsize/1024))); + } Hash.Add(S); sprintf(S,"-%u",Version); } diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 2b73d1424..eabaadf90 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -251,6 +251,27 @@ bool CreateDirectory(string const &Parent, string const &Path) return true; } /*}}}*/ +// CreateAPTDirectoryIfNeeded - ensure that the given directory exists /*{{{*/ +// --------------------------------------------------------------------- +/* a small wrapper around CreateDirectory to check if it exists and to + remove the trailing "/apt/" from the parent directory if needed */ +bool CreateAPTDirectoryIfNeeded(string const &Parent, string const &Path) +{ + if (DirectoryExists(Path) == true) + return true; + + size_t const len = Parent.size(); + if (len > 5 && Parent.find("/apt/", len - 6, 5) == len - 5) + { + if (CreateDirectory(Parent.substr(0,len-5), Path) == true) + return true; + } + else if (CreateDirectory(Parent, Path) == true) + return true; + + return false; +} + /*}}}*/ // GetListOfFilesInDir - returns a vector of files in the given dir /*{{{*/ // --------------------------------------------------------------------- /* If an extension is given only files with this extension are included diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index cb4655798..419506273 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -94,6 +94,15 @@ int GetLock(string File,bool Errors = true); bool FileExists(string File); bool DirectoryExists(string const &Path) __attrib_const; bool CreateDirectory(string const &Parent, string const &Path); + +/** \brief Ensure the existence of the given Path + * + * \param Parent directory of the Path directory - a trailing + * /apt/ will be removed before CreateDirectory call. + * \param Path which should exist after (successful) call + */ +bool CreateAPTDirectoryIfNeeded(string const &Parent, string const &Path); + std::vector<string> GetListOfFilesInDir(string const &Dir, string const &Ext, bool const &SortList, bool const &AllowNoExt=false); std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> const &Ext, diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 5530ef129..395c3fb1a 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -641,7 +641,8 @@ void pkgDPkgPM::WriteHistoryTag(string const &tag, string value) bool pkgDPkgPM::OpenLog() { string const logdir = _config->FindDir("Dir::Log"); - if(not FileExists(logdir)) + if(CreateAPTDirectoryIfNeeded(logdir, logdir) == false) + // FIXME: use a better string after freeze return _error->Error(_("Directory '%s' missing"), logdir.c_str()); // get current time diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index a2a1d5934..f88d51fc5 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -132,9 +132,14 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List, (*I).c_str() + CDROM.length(),GetFileName()); 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; @@ -661,7 +666,7 @@ bool SigVerify::RunGPGV(std::string const &File, std::string const &FileGPG, { string const gpgvpath = _config->Find("Dir::Bin::gpg", "/usr/bin/gpgv"); // FIXME: remove support for deprecated APT::GPGV setting - string const trustedFile = _config->FindFile("Dir::Etc::Trusted"); + string const trustedFile = _config->Find("APT::GPGV::TrustedKeyring", _config->FindFile("Dir::Etc::Trusted")); string const trustedPath = _config->FindDir("Dir::Etc::TrustedParts"); bool const Debug = _config->FindB("Debug::Acquire::gpgv", false); @@ -673,9 +678,11 @@ bool SigVerify::RunGPGV(std::string const &File, std::string const &FileGPG, std::clog << "Keyring path: " << trustedPath << std::endl; } - std::vector<string> keyrings = GetListOfFilesInDir(trustedPath, "gpg", false); + std::vector<string> keyrings; + if (DirectoryExists(trustedPath)) + keyrings = GetListOfFilesInDir(trustedPath, "gpg", false, true); if (FileExists(trustedFile) == true) - keyrings.push_back(trustedFile); + keyrings.push_back(trustedFile); std::vector<const char *> Args; Args.reserve(30); diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc index 846b27313..f0bad78df 100644 --- a/apt-pkg/init.cc +++ b/apt-pkg/init.cc @@ -70,8 +70,7 @@ bool pkgInitConfig(Configuration &Cnf) Cnf.Set("Dir::Etc::parts","apt.conf.d"); Cnf.Set("Dir::Etc::preferences","preferences"); Cnf.Set("Dir::Etc::preferencesparts","preferences.d"); - string const deprecated = _config->Find("APT::GPGV::TrustedKeyring"); - Cnf.Set("Dir::Etc::trusted", deprecated.empty() ? "trusted.gpg" : deprecated); + Cnf.Set("Dir::Etc::trusted", "trusted.gpg"); Cnf.Set("Dir::Etc::trustedparts","trusted.gpg.d"); Cnf.Set("Dir::Bin::methods","/usr/lib/apt/methods"); Cnf.Set("Dir::Media::MountPath","/media/apt"); diff --git a/apt-pkg/init.h b/apt-pkg/init.h index 6e7340dfe..15a1165b9 100644 --- a/apt-pkg/init.h +++ b/apt-pkg/init.h @@ -23,7 +23,7 @@ // See also buildlib/libversion.mak #define APT_PKG_MAJOR 4 #define APT_PKG_MINOR 10 -#define APT_PKG_RELEASE 0 +#define APT_PKG_RELEASE 1 extern const char *pkgVersion; extern const char *pkgLibVersion; diff --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc index 17a54bc4c..c40b1fdbc 100644 --- a/apt-pkg/versionmatch.cc +++ b/apt-pkg/versionmatch.cc @@ -118,7 +118,7 @@ pkgVersionMatch::pkgVersionMatch(string Data,MatchType Type) : Type(Type) if (Type == Origin) { - if (Data[0] == '"' && Data.end()[-1] == '"') + if (Data[0] == '"' && Data.length() >= 2 && Data.end()[-1] == '"') OrSite = Data.substr(1, Data.length() - 2); else OrSite = Data; |