[PATCH 0/2] handle DPKG_ARCH=all case for transitive deps

3 views
Skip to first unread message

Felix Moessbauer

unread,
Aug 20, 2025, 8:42:02 AMAug 20
to isar-...@googlegroups.com, jan.k...@siemens.com, cedric.h...@siemens.com, adriaan...@siemens.com, christop...@siemens.com, Felix Moessbauer
This series fixes an issue with DPKG_ARCH=all packages that have
dependencies to other DPKG_ARCH=all packages. Hereby, the transitive
packages were built for the wrong architecture. The issue became
apparent when testing the SBOM series by Christoph, which builds
packages to be used during the ISAR build (not for the final target).

While fixing this, another issue surfaced where files are missing in
dpkg-raw packages.

Best regards,
Felix

Felix Moessbauer (2):
dpkg-raw: add files to source package
handle DPKG_ARCH=all case for transitive deps

meta/classes/dpkg-raw.bbclass | 4 ++--
meta/classes/multiarch.bbclass | 18 +++++++++++++++++-
2 files changed, 19 insertions(+), 3 deletions(-)

--
2.50.1

Felix Moessbauer

unread,
Aug 20, 2025, 8:42:06 AMAug 20
to isar-...@googlegroups.com, jan.k...@siemens.com, cedric.h...@siemens.com, adriaan...@siemens.com, christop...@siemens.com, Felix Moessbauer
In dpkg-raw, the user can place files in ${D} which are then installed
into the resulting binary package. Hereby, ${D} is a directory outside
of ${S} (since b19cd25) to not interfere with other data added to ${S}.
However, by that the files are not added to the source package. This
remained unnoticed, as the directory dh_install installs from is set
to absolute path, hence the installed files actually came from the
absolute path and not from the extracted source package. In case of
${PN} == ${BPN}, this path was always there as it has been created by
previous tasks. However, with the switch in 2ca3a7e5 to only build the
source package once, the path is not always there.

We fix this by adding the files to the source package (under image) and
install from a relative base. We further use a sub-path (image) in ${S}
as a temporary location to not run into the issue solved in b19cd25.

Fixes: 2ca3a7e5 ("dpkg-source: Build source package only once")
Signed-off-by: Felix Moessbauer <felix.mo...@siemens.com>
---
meta/classes/dpkg-raw.bbclass | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/classes/dpkg-raw.bbclass b/meta/classes/dpkg-raw.bbclass
index a7bf204a..d4cb7d8a 100644
--- a/meta/classes/dpkg-raw.bbclass
+++ b/meta/classes/dpkg-raw.bbclass
@@ -5,7 +5,7 @@

inherit dpkg

-D = "${WORKDIR}/image"
+D = "${S}/image"

# Default to creating a binary-indep package
DPKG_ARCH ??= "all"
@@ -30,6 +30,6 @@ do_prepare_build() {
cat <<EOF >> ${S}/debian/rules

override_dh_install:
- dh_install --sourcedir=${PP}/image
+ dh_install --sourcedir=image
EOF
}
--
2.50.1

Felix Moessbauer

unread,
Aug 20, 2025, 8:42:07 AMAug 20
to isar-...@googlegroups.com, jan.k...@siemens.com, cedric.h...@siemens.com, adriaan...@siemens.com, christop...@siemens.com, Felix Moessbauer
Arch=all packages might build depend on other arch=all packages, hence we
need to correctly model the dependency chain. Otherwise the transitive
dependencies are built for the distro arch instead of the native arch.

We implement this by dispatching the non-native variant of DPKG_ARCH=all
packages to the -native variant by adding a dependency. We further
replace the non-native do_deploy_dep task with a noop to preserve the
dependency chain.

Co-developed-by: Adriaan Schmidt <adriaan...@siemens.com>
Signed-off-by: Felix Moessbauer <felix.mo...@siemens.com>
---
meta/classes/multiarch.bbclass | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/meta/classes/multiarch.bbclass b/meta/classes/multiarch.bbclass
index babdfbd4..c2bba21f 100644
--- a/meta/classes/multiarch.bbclass
+++ b/meta/classes/multiarch.bbclass
@@ -29,7 +29,11 @@ python() {
d.appendVar('BBCLASSEXTEND', ' compat')

# build native separately only when it differs from the target variant
- if not archIsAll and archDiffers:
+ # We must not short-circuit for DPKG_ARCH=all packages, as they might
+ # have transitive dependencies which need to be built for -native.
+ # This special handling for DPKG_ARCH=all packages is left to the
+ # multiarch_virtclass_handler
+ if archDiffers:
d.appendVar('BBCLASSEXTEND', ' native')
else:
extend_provides(pn, 'native', d)
@@ -86,6 +90,8 @@ python multiarch_virtclass_handler() {
d.setVar(var, ' '.join(multiarch_var))

pn = e.data.getVar('PN')
+ archDiffers = d.getVar('HOST_ARCH') != d.getVar('DISTRO_ARCH')
+ archIsAll = d.getVar('DPKG_ARCH') == 'all'
if pn.endswith('-compat'):
e.data.setVar('BPN', pn[:-len('-compat')])
e.data.appendVar('OVERRIDES', ':class-compat')
@@ -96,6 +102,16 @@ python multiarch_virtclass_handler() {
e.data.appendVar('OVERRIDES', ':class-native')
fixup_pn_in_vars(e.data)
fixup_depends('-native', e.data)
+ elif archIsAll and archDiffers:
+ # Arch=all packages might build depend on other arch=all packages,
+ # hence we need to correctly model the dependency chain.
+ # We implement this by dispatching the non-native variant to the -native
+ # variant by adding a dependency. We further replace the non-native
+ # do_deploy_dep task with a noop to preserve the dependency chain.
+ e.data.setVar('do_deploy_deb', '')
+ bb.build.deltask('deploy_deb', e.data)
+ bb.build.addtask('deploy_deb', 'do_build', '', e.data)
+ e.data.setVarFlag('do_deploy_deb', 'depends', f'{pn}-native:do_deploy_deb')
}
addhandler multiarch_virtclass_handler
multiarch_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
--
2.50.1

Reply all
Reply to author
Forward
0 new messages