dpkg: Fix ADMINDIR
PATCH 1/1 dpkg: Fix ADMINDIR
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.
---
Recent pseudo work pointed out that this path was not working properly. Clearly it wasn't causing any functional issues since the value being used was incorrect and pseudo was masking the path issue.
With the realpath fix in pseudo, deb rootfs was failing with:
dpkg: error: cannot canonicalize pathname /srv/pokybuild/yocto-worker/pkgman-non-rpm/build/build/tmp/work/qemux86_64-poky-linux/core-image-minimal/1.0/sdk/image/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86-64-v3-poky-linux/srv/pokybuild/yocto-worker/meta-aws/build/build/tmp/work/x86_64-linux/dpkg-native/1.22.21/recipe-sysroot-native/var/lib/dpkg: Invalid argument
Someone with more knowledge then me should probably review the YP/deb side of things and ensure this is really correct. But this does fix the problem for me.
meta/lib/oe/package_manager/deb/__init__.py | 4 ++ ...-dirs.c-set_rootfs-was-not-checking-.patch | 46 +++++++++++++++++++ meta/recipes-devtools/dpkg/dpkg_1.22.21.bb | 1 + 3 files changed, 51 insertions(+) create mode 100644 meta/recipes-devtools/dpkg/dpkg/0001-lib-dpkg-options-dirs.c-set_rootfs-was-not-checking-.patch
meta/lib/oe/package_manager/deb/__init__.py +4 -0
@@ -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)
meta/recipes-devtools/dpkg/dpkg/0001-lib-dpkg-options-dirs.c-set_rootfs-was-not-checking-.patch new file +46 -0
46 lines not on this page · raw message
meta/recipes-devtools/dpkg/dpkg_1.22.21.bb +1 -0
@@ -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"
Signature · 1 line
2.30.2
meta/recipes-devtools/dpkg/dpkg/0001-lib-dpkg-options-dirs.c-set_rootfs-was-not-checking-.patch line 13
Quoted 10 lines · Mark Hatle via lists.openembedded.org
meta/recipes-devtools/dpkg/dpkg/0001-lib-dpkg-options-dirs.c-set_rootfs-was-not-checking-.patch new file +10
-0+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: Pending
Please no pending patches without a reason. This should be submitted upstream first.
Alex
Quoted 15 lines · Alexander Kanavin via lists.openembedded.org
meta/recipes-devtools/dpkg/dpkg/0001-lib-dpkg-options-dirs.c-set_rootfs-was-not-checking-.patch line 13
Quoted 10 lines · Mark Hatle via lists.openembedded.org
meta/recipes-devtools/dpkg/dpkg/0001-lib-dpkg-options-dirs.c-set_rootfs-was-not-checking-.patch new file +10
-0+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: PendingPlease no pending patches without a reason. This should be submitted upstream first.
I understand the sentiment however I should mention this is blocking pseudo getting updated to resolve several bugs. I did queue and test this overnight and can confirm it does fix problems in dpkg once we merge the pseudo fixes...
Cheers,
Richard
This has been sent to the upstream dpkg mailing list, and should eventually appear in the index at "https://lists.debian.org/debian-dpkg/2026/01/maillist.html"
--Mark
Quoted 36 lines · Richard Purdie via lists.openembedded.org
Quoted 15 lines · Alexander Kanavin via lists.openembedded.org
meta/recipes-devtools/dpkg/dpkg/0001-lib-dpkg-options-dirs.c-set_rootfs-was-not-checking-.patch line 13
Quoted 10 lines · Mark Hatle via lists.openembedded.org
meta/recipes-devtools/dpkg/dpkg/0001-lib-dpkg-options-dirs.c-set_rootfs-was-not-checking-.patch new file +10
-0+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: PendingPlease no pending patches without a reason. This should be submitted upstream first.
I understand the sentiment however I should mention this is blocking pseudo getting updated to resolve several bugs. I did queue and test this overnight and can confirm it does fix problems in dpkg once we merge the pseudo fixes...
Cheers,
Richard
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#229622): https://lists.openembedded.org/g/openembedded-core/message/229622
Mute This Topic: https://lists.openembedded.org/mt/117320584/3616948
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Quoted 3 lines · Mark Hatle
This has been sent to the upstream dpkg mailing list, and should eventually appear in the index at "https://lists.debian.org/debian-dpkg/2026/01/maillist.html"
Thanks! It has now appeared, and the patch to oe-core hasn't yet merged. Can you send a v2, replacing Pending with Submitted
[https://lists.debian.org/debian-dpkg/2026/01/maillist.html] ?
Alex