]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
dpkg: Fix ADMINDIR
authorMark Hatle <mark.hatle@kernel.crashing.org>
Sat, 17 Jan 2026 20:57:11 +0000 (14:57 -0600)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 21 Jan 2026 22:44:18 +0000 (22:44 +0000)
dpkg has a hard coded path (from build time) for the ADMINDIR, for some
reason the "set_root" function was using this hard coded value instead
of the value from apt.conf or the environment.

Follow the example of db_dir.c and use the environment if set.

Adjust the matching oe package_manager functions to set the ADMINDIR,
even though the apt.conf sets --admindir.  Note it's unclear if the
--admindir value that is set is reasonable or not.

Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
[AG: add Upstream-Status - Submitted to patch]
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oe/package_manager/deb/__init__.py
meta/recipes-devtools/dpkg/dpkg/0001-lib-dpkg-options-dirs.c-set_rootfs-was-not-checking-.patch [new file with mode: 0644]
meta/recipes-devtools/dpkg/dpkg_1.22.21.bb

index eb48f3f98228f586f736b786e8c0fb0a0b06b60e..cdb58bee1018b09594d699f1e657fc4505e78d65 100644 (file)
@@ -213,6 +213,7 @@ class DpkgPM(OpkgDpkgPM):
 
     def update(self):
         os.environ['APT_CONFIG'] = self.apt_conf_file
+        os.environ['DPKG_ADMINDIR'] = '/var/lib/dpkg'
 
         self.deploy_dir_lock()
 
@@ -231,6 +232,7 @@ class DpkgPM(OpkgDpkgPM):
             return
 
         os.environ['APT_CONFIG'] = self.apt_conf_file
+        os.environ['DPKG_ADMINDIR'] = '/var/lib/dpkg'
 
         extra_args = ""
         if hard_depends_only:
@@ -282,6 +284,7 @@ class DpkgPM(OpkgDpkgPM):
         os.environ['IPKG_OFFLINE_ROOT'] = self.target_rootfs
         os.environ['OPKG_OFFLINE_ROOT'] = self.target_rootfs
         os.environ['INTERCEPT_DIR'] = self.intercepts_dir
+        os.environ['DPKG_ADMINDIR'] = '/var/lib/dpkg'
 
         if with_dependencies:
             os.environ['APT_CONFIG'] = self.apt_conf_file
@@ -424,6 +427,7 @@ class DpkgPM(OpkgDpkgPM):
 
     def fix_broken_dependencies(self):
         os.environ['APT_CONFIG'] = self.apt_conf_file
+        os.environ['DPKG_ADMINDIR'] = '/var/lib/dpkg'
 
         cmd = "%s %s --allow-unauthenticated -f install" % (self.apt_get_cmd, self.apt_args)
 
diff --git a/meta/recipes-devtools/dpkg/dpkg/0001-lib-dpkg-options-dirs.c-set_rootfs-was-not-checking-.patch b/meta/recipes-devtools/dpkg/dpkg/0001-lib-dpkg-options-dirs.c-set_rootfs-was-not-checking-.patch
new file mode 100644 (file)
index 0000000..34060c7
--- /dev/null
@@ -0,0 +1,46 @@
+From c036cfa1ee53a900b4ed45bc91e45a0792547eea Mon Sep 17 00:00:00 2001
+From: Mark Hatle <mark.hatle@kernel.crashing.org>
+Date: Sat, 17 Jan 2026 20:20:23 +0000
+Subject: [PATCH] lib/dpkg/options-dirs.c: set_rootfs was not checking
+ environment
+
+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 db_dir.c.
+
+Upstream-Status: Submitted [https://lists.debian.org/debian-dpkg/2026/01/maillist.html]]
+
+Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
+---
+ 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 9b7a122fe..34869d792 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);
+ }
+-- 
+2.30.2
+
index d793c26d57abe5b164bd4f8fb11d42936b9afe43..20f98d5d2d38e8aa263ebf0a37c797bb0baf6c81 100644 (file)
@@ -14,6 +14,7 @@ SRC_URI = "git://salsa.debian.org/dpkg-team/dpkg.git;protocol=https;branch=1.22.
            file://0007-dpkg-deb-build.c-Remove-usage-of-clamp-mtime-in-tar.patch \
            file://0001-dpkg-Support-muslx32-build.patch \
            file://0001-Add-support-for-riscv32-CPU.patch \
+           file://0001-lib-dpkg-options-dirs.c-set_rootfs-was-not-checking-.patch \
            "
 
 SRC_URI:append:class-native = " file://0001-build.c-ignore-return-of-1-from-tar-cf.patch"