The set_rootfs function was using the hardcoded ADMINDIR (define).  It
should be checking the environment, and then falling back to the define
if not set.

This matches the behavior in dbdir.c. dpkg_db_new_dir.

Signed-off-by: Mark Hatle <[email protected]>
---
 lib/dpkg/options-dirs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/dpkg/options-dirs.c b/lib/dpkg/options-dirs.c
index 9b7a122..34869d7 100644
--- a/lib/dpkg/options-dirs.c
+++ b/lib/dpkg/options-dirs.c
@@ -49,13 +49,18 @@ set_admindir(const struct cmdinfo *cip, const char *value)
 void
 set_root(const struct cmdinfo *cip, const char *value)
 {
+       const char *env;
        char *db_dir;
 
        /* Initialize the root directory. */
        dpkg_fsys_set_dir(value);
 
        /* Set the database directory based on the new root directory. */
-       db_dir = dpkg_fsys_get_path(ADMINDIR);
+       env = getenv("DPKG_ADMINDIR");
+       if (env)
+               db_dir = dpkg_fsys_get_path(env);
+       else
+               db_dir = dpkg_fsys_get_path(ADMINDIR);
        dpkg_db_set_dir(db_dir);
        free(db_dir);
 }
-- 
1.8.3.1

Reply via email to