All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Orling <tim.orling@konsulko.com>
To: meta-virtualization@lists.yoctoproject.org
Cc: Tim Orling <tim.orling@konsulko.com>
Subject: [meta-virtualization][PATCH v2 1/3] image-oci: track multi-layer rootfs directories with pseudo
Date: Wed, 25 Nov 2026 16:47:54 -0800	[thread overview]
Message-ID: <20261126004756.89781-2-tim.orling@konsulko.com> (raw)
In-Reply-To: <20261126004756.89781-1-tim.orling@konsulko.com>

oci_install_layer_packages() installs each packages: layer into
${WORKDIR}/oci-layer-rootfs/layer-N-<name> from do_image_oci. Since
oe-core moved to dnf 5.4.7.0, every rpm layer install fails:

  error: cannot open Packages database in
  Failed to load system repo from root ".../oci-layer-rootfs/layer-1-base":
  rpmtsOpenDB failed: Invalid argument

do_image_oci runs under pseudo, so getuid() returns 0 in dnf and rpm,
but the layer rootfs is not in PSEUDO_INCLUDE_PATHS, so pseudo passes
their syscalls through unchanged. When dnf5 loads the system repo,
libsolv calls rpmtsOpenDB(), and rpm's openDatabase() runs
rpmioMkpath(dbhome, 0755, getuid(), getgid()). That creates var/lib/rpm
and then chowns it to 0:0 for real. bitbake runs the task in a user
namespace that maps only the build user's uid (bb.utils.disable_network),
so the kernel rejects a chown to the unmapped uid 0 with EINVAL. rpm
returns before the sqlite rpmdb is created.

dnf4 never showed this: its CLI loads the system repo with
load_system_repo='auto' and ignores the failure, and the next open finds
the directories already present and skips the chown. dnf5 makes the
failure fatal.

Opening the rpmdb is only the first place rpm needs root. With
getuid() == 0 it chowns every file it installs (fsmChown() in
lib/fsm.cc), and every transaction chroots into the install root
(rpmChrootIn() in lib/transaction.cc), as do scriptlets. Both fail
outside pseudo.

Running dnf with PSEUDO_DISABLED=1 instead avoids the chowns, but the
chroot then fails with EPERM and every transaction aborts with "Rpm
transaction failed", leaving all package layers empty (tried on the
containers-library autobuilder target).

So the layer rootfs needs pseudo for the same reason ${WORKDIR}/rootfs
does for do_rootfs. Add it to PSEUDO_INCLUDE_PATHS, as image.bbclass
does for MULTILIB_TEMP_ROOTFS. The ownership pseudo records there does
not reach the image: the layer is copied into the bundle with
--no-owner --no-group, and umoci records ownership itself.

To reproduce, build a multi-layer rpm image, for example:

  inherit image image-oci
  IMAGE_INSTALL = "base-files"
  IMAGE_PKGTYPE = "rpm"
  OCI_LAYER_MODE = "multi"
  OCI_LAYERS = "base:packages:base-files+coreutils"

Without this change, log.do_image_oci shows the error above, demoted to
"OCI: Package installation had issues", and the layer is empty.

The EINVAL can be shown on its own with:

  unshare --user --net --map-current-user sh -c 'touch f && chown 0:0 f'

Tested with the containers-library autobuilder target (aarch64 and
x86-64).

[YOCTO #16531]

AI-Generated: Uses Claude Code (Claude Opus 5.5)
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
 classes/image-oci.bbclass | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/classes/image-oci.bbclass b/classes/image-oci.bbclass
index 141cd2a8..d4c3096a 100644
--- a/classes/image-oci.bbclass
+++ b/classes/image-oci.bbclass
@@ -69,6 +69,8 @@ do_image_oci[depends] += "jq-native:do_populate_sysroot"
 # Package manager native tools for multi-layer mode with package installation
 OCI_PM_DEPENDS = "${@oci_get_pm_depends(d)}"
 do_image_oci[depends] += "${OCI_PM_DEPENDS}"
+# rpm installs layers as fake root (chown, chroot), so pseudo must track them
+PSEUDO_INCLUDE_PATHS .= ",${WORKDIR}/oci-layer-rootfs"
 
 def oci_pkg_type(d):
     """Resolve IMAGE_PKGTYPE with a single, documented default.
-- 
2.56.1


  reply	other threads:[~2026-11-26  0:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  0:47 [meta-virtualization][PATCH v2 0/3] OCI multi-layer fixes for dnf5 and nginx Tim Orling
2026-11-26  0:47 ` Tim Orling [this message]
2026-11-30  3:48   ` [meta-virtualization][PATCH v2 1/3] image-oci: track multi-layer rootfs directories with pseudo Bruce Ashfield
2026-11-26  0:47 ` [meta-virtualization][PATCH v2 2/3] container-volatile-fixup: run after empty_var_volatile Tim Orling
2026-11-30  3:48   ` Bruce Ashfield
2026-11-26  0:47 ` [meta-virtualization][PATCH v2 3/3] app-container-nginx: create /run/nginx and /var/log/nginx in rootfs Tim Orling
2026-11-30  3:48   ` Bruce Ashfield

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261126004756.89781-2-tim.orling@konsulko.com \
    --to=tim.orling@konsulko.com \
    --cc=meta-virtualization@lists.yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.