summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire.cc21
-rw-r--r--apt-pkg/acquire.h8
-rw-r--r--apt-pkg/algorithms.cc21
-rw-r--r--apt-pkg/contrib/fileutl.cc21
-rw-r--r--apt-pkg/contrib/fileutl.h9
-rw-r--r--apt-pkg/deb/dpkgpm.cc3
-rw-r--r--apt-pkg/indexcopy.cc10
-rw-r--r--apt-pkg/versionmatch.cc2
8 files changed, 41 insertions, 54 deletions
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 63825da93..6ec557397 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -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 bd9a9df62..3c8711b74 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -987,24 +987,6 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
pkgCache::VerIterator Ver(Cache,*V);
pkgCache::PkgIterator Pkg = Ver.ParentPkg();
- /* Ignore a target that is not a candidate
- This can happen if:
- installed package provides video-6
- candidate provides video-8
- now if a package Start breaks/conflicts video-6
- Start.AllTargets() will return the now-installed
- versions even though these are not candidates
- we can ignore them
- */
- if (Cache[Pkg].CandidateVerIter(Cache) != Ver)
- {
- if (Debug)
- clog << " Version " << Ver.VerStr() << " for "
- << Pkg.Name() << " is not a candidate, ignoring"
- << endl;
- continue;
- }
-
if (Debug == true)
clog << " Considering " << Pkg.FullName(false) << ' ' << (int)Scores[Pkg->ID] <<
" as a solution to " << I.FullName(false) << ' ' << (int)Scores[I->ID] << endl;
@@ -1098,7 +1080,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
// FIXME: use DoUpgrade(Pkg) instead?
@@ -1123,7 +1105,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/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 2b73d1424..94d994e8b 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;
}
/*}}}*/
+// 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 CheckDirectory(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..f79c9032f 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 CheckDirectory(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..d3c432ce1 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(CheckDirectory(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..fb33ed461 100644
--- a/apt-pkg/indexcopy.cc
+++ b/apt-pkg/indexcopy.cc
@@ -673,9 +673,13 @@ 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);
- if (FileExists(trustedFile) == true)
- keyrings.push_back(trustedFile);
+ std::vector<string> keyrings;
+ if (DirectoryExists(trustedPath))
+ {
+ keyrings = GetListOfFilesInDir(trustedPath, "gpg", false, true);
+ if (FileExists(trustedFile) == true)
+ keyrings.push_back(trustedFile);
+ }
std::vector<const char *> Args;
Args.reserve(30);
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;