* apt-pkg/deb/dpkgpm.cc:
authorDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 2 Sep 2010 10:47:48 +0000 (12:47 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 2 Sep 2010 10:47:48 +0000 (12:47 +0200)
  - create Dir::Log if needed to support /var/log as tmpfs or similar,
    inspired by Thomas Bechtold, thanks! (Closes: #523919, LP: #220239)

Easily done by moving a private method from pkgAcquire into the public
area of fileutl.cc to be able to use it also in here

apt-pkg/acquire.cc
apt-pkg/acquire.h
apt-pkg/contrib/fileutl.cc
apt-pkg/contrib/fileutl.h
apt-pkg/deb/dpkgpm.cc
debian/changelog
test/integration/framework

index 63825da..6ec5573 100644 (file)
@@ -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) */
index 82be8b8..e3a4435 100644 (file)
@@ -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
index 2b73d14..94d994e 100644 (file)
@@ -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
index cb46557..f79c903 100644 (file)
@@ -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,
index 5530ef1..d3c432c 100644 (file)
@@ -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
index e37a550..2a3a9d8 100644 (file)
@@ -40,8 +40,11 @@ apt (0.8.1) UNRELEASED; urgency=low
     - let the pin origin actually work as advertised in the manpage
       which means "" are optional and pinning a local archive does
       work - even if it is a non-flat archive (Closes: #594435)
+  * apt-pkg/deb/dpkgpm.cc:
+    - create Dir::Log if needed to support /var/log as tmpfs or similar,
+      inspired by Thomas Bechtold, thanks! (Closes: #523919, LP: #220239)
 
- -- Michael Vogt <mvo@debian.org>  Mon, 30 Aug 2010 11:53:30 +0200
+ -- David Kalnischkies <kalnischkies@gmail.com>  Thu, 02 Sep 2010 12:41:32 +0200
 
 apt (0.8.0) unstable; urgency=low
 
index ba5f9df..2b26fc8 100644 (file)
@@ -88,8 +88,8 @@ setupenvironment() {
        cd $TMPWORKINGDIRECTORY
        mkdir rootdir aptarchive keys
        cd rootdir
-       mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d var/cache
-       mkdir -p var/log/apt var/lib/apt
+       mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d
+       mkdir -p var/cache var/lib var/log
        mkdir -p var/lib/dpkg/info var/lib/dpkg/updates var/lib/dpkg/triggers
        local STATUSFILE=$(echo "$(basename $0)" | sed 's/^test-/status-/')
        if [ -f "${TESTDIR}/${STATUSFILE}" ]; then