This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=187d689217e274e79fa61018bc23a0d43f7d678c

commit 187d689217e274e79fa61018bc23a0d43f7d678c
Author: Guillem Jover <guil...@debian.org>
AuthorDate: Thu Jul 12 05:09:14 2018 +0200

    libdpkg: Add new pkg_infodb_reset_dir()
    
    This makes it possible to update the infodb directory when we have
    changed the underlying directory with dpkg_db_set_dir().
---
 debian/changelog          |  1 +
 lib/dpkg/db-ctrl-format.c | 18 +++++++++++++-----
 lib/dpkg/db-ctrl.h        |  1 +
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index b52f91e05..881439d4d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -197,6 +197,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium
     - libdpkg: Add new varbuf_new() and varbuf_free() functions.
     - libdpkg: Add new file_slurp() function.
     - libdpkg: Switch db-fsys to use the new file_slurp() function.
+    - libdpkg: Add new pkg_infodb_reset_dir().
   * Build system:
     - Set distribution tarball format to ustar, instead of default v7 format.
     - Mark PO4A and POD2MAN as precious variables.
diff --git a/lib/dpkg/db-ctrl-format.c b/lib/dpkg/db-ctrl-format.c
index 84b873c27..256c7b7e4 100644
--- a/lib/dpkg/db-ctrl-format.c
+++ b/lib/dpkg/db-ctrl-format.c
@@ -36,6 +36,7 @@
 
 static enum pkg_infodb_format db_format = PKG_INFODB_FORMAT_UNKNOWN;
 static bool db_upgrading;
+static char *db_infodir;
 
 static enum pkg_infodb_format
 pkg_infodb_parse_format(const char *file)
@@ -117,12 +118,10 @@ pkg_infodb_is_upgrading(void)
 const char *
 pkg_infodb_get_dir(void)
 {
-       static char *infodir;
+       if (db_infodir == NULL)
+               db_infodir = dpkg_db_get_path(INFODIR);
 
-       if (infodir == NULL)
-               infodir = dpkg_db_get_path(INFODIR);
-
-       return infodir;
+       return db_infodir;
 }
 
 const char *
@@ -148,3 +147,12 @@ pkg_infodb_get_file(struct pkginfo *pkg, struct pkgbin 
*pkgbin,
 
        return vb.buf;
 }
+
+const char *
+pkg_infodb_reset_dir(void)
+{
+       free(db_infodir);
+       db_infodir = NULL;
+
+       return pkg_infodb_get_dir();
+}
diff --git a/lib/dpkg/db-ctrl.h b/lib/dpkg/db-ctrl.h
index 93bed39de..57f67e022 100644
--- a/lib/dpkg/db-ctrl.h
+++ b/lib/dpkg/db-ctrl.h
@@ -40,6 +40,7 @@ void pkg_infodb_upgrade(void);
 const char *pkg_infodb_get_dir(void);
 const char *pkg_infodb_get_file(struct pkginfo *pkg, struct pkgbin *pkgbin,
                                 const char *filetype);
+const char *pkg_infodb_reset_dir(void);
 bool pkg_infodb_has_file(struct pkginfo *pkg, struct pkgbin *pkgbin,
                          const char *name);
 

-- 
Dpkg.Org's dpkg

Reply via email to