public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Cc: "Koch, Stefan" <stefan-koch@siemens.com>,
	"Schmidt, Adriaan" <adriaan.schmidt@siemens.com>
Subject: [PATCH] dpkg: Add support for building packages also for multi archs
Date: Wed, 11 Jan 2023 21:05:12 +0100	[thread overview]
Message-ID: <5963a56f-d89c-1318-a8b5-4d00fa00799e@siemens.com> (raw)

From: Jan Kiszka <jan.kiszka@siemens.com>

This adds an interface to build packages not only for the target but
also for the build host and/or the compat arch. All it takes for a
recipe is to extend the new PACKAGE_ARCHS (note the plural) variable
with the desired architectures.

The convenience variables PACKAGE_HOST_ARCH and PACKAGE_COMPAT_ARCH are
introduced that fall back to empty strings if the cross-build or
compat-arch features are disabled.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

This was too easy to be done already. Even ssbuild seems to work fine 
(Adriaan, please check as well).

I'm currently testing it very successfully to fix/improve our openssl
patching needs, but I think this can also help in the kbuild scenario.
The only thing missing for that is a nice idea how to define per-arch
DEB_BUILD_OPTIONS so that the kernel tool builds can be mapped on build
option, avoiding full builds for only getting those.

 meta/classes/dpkg.bbclass | 34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass
index 7822b14d..7a48aaa7 100644
--- a/meta/classes/dpkg.bbclass
+++ b/meta/classes/dpkg.bbclass
@@ -5,6 +5,12 @@ inherit dpkg-base
 
 PACKAGE_ARCH ?= "${DISTRO_ARCH}"
 
+PACKAGE_ARCHS = "${PACKAGE_ARCH}"
+
+PACKAGE_HOST_ARCH = "${@d.getVar('HOST_ARCH') if d.getVar('ISAR_CROSS_COMPILE') == '1' else '' }"
+PACKAGE_COMPAT_ARCH = ""
+PACKAGE_COMPAT_ARCH_compat-arch = "${COMPAT_DISTRO_ARCH}"
+
 DPKG_PREBUILD_ENV_FILE="${WORKDIR}/dpkg_prebuild.env"
 
 # bitbake variables that should be passed into sbuild env
@@ -101,19 +107,21 @@ dpkg_runbuild() {
     sh -c "cd ${WORKDIR}; dpkg-source -q -b ${PPS}"
     DSC_FILE=$(find ${WORKDIR} -name "${DEB_SOURCE_NAME}*.dsc" -print)
 
-    sbuild -A -n -c ${SBUILD_CHROOT} --extra-repository="${ISAR_APT_REPO}" \
-        --host=${PACKAGE_ARCH} --build=${SBUILD_HOST_ARCH} ${profiles} \
-        --no-run-lintian --no-run-piuparts --no-run-autopkgtest --resolve-alternatives \
-        --no-apt-update \
-        --chroot-setup-commands="echo \"Package: *\nPin: release n=${DEBDISTRONAME}\nPin-Priority: 1000\" > /etc/apt/preferences.d/isar-apt" \
-        --chroot-setup-commands="echo \"APT::Get::allow-downgrades 1;\" > /etc/apt/apt.conf.d/50isar-apt" \
-        --chroot-setup-commands="rm -f /var/log/dpkg.log" \
-        --chroot-setup-commands="cp -n --no-preserve=owner ${ext_deb_dir}/*.deb -t ${deb_dir}/ || :" \
-        --finished-build-commands="rm -f ${deb_dir}/sbuild-build-depends-main-dummy_*.deb" \
-        --finished-build-commands="cp -n --no-preserve=owner ${deb_dir}/*.deb -t ${ext_deb_dir}/ || :" \
-        --finished-build-commands="cp /var/log/dpkg.log ${ext_root}/dpkg_partial.log" \
-        --debbuildopts="--source-option=-I" \
-        --build-dir=${WORKDIR} --dist="isar" ${DSC_FILE}
+    for arch in ${PACKAGE_ARCHS}; do
+        sbuild -A -n -c ${SBUILD_CHROOT} --extra-repository="${ISAR_APT_REPO}" \
+            --host=$arch --build=${SBUILD_HOST_ARCH} ${profiles} \
+            --no-run-lintian --no-run-piuparts --no-run-autopkgtest --resolve-alternatives \
+            --no-apt-update \
+            --chroot-setup-commands="echo \"Package: *\nPin: release n=${DEBDISTRONAME}\nPin-Priority: 1000\" > /etc/apt/preferences.d/isar-apt" \
+            --chroot-setup-commands="echo \"APT::Get::allow-downgrades 1;\" > /etc/apt/apt.conf.d/50isar-apt" \
+            --chroot-setup-commands="rm -f /var/log/dpkg.log" \
+            --chroot-setup-commands="cp -n --no-preserve=owner ${ext_deb_dir}/*.deb -t ${deb_dir}/ || :" \
+            --finished-build-commands="rm -f ${deb_dir}/sbuild-build-depends-main-dummy_*.deb" \
+            --finished-build-commands="cp -n --no-preserve=owner ${deb_dir}/*.deb -t ${ext_deb_dir}/ || :" \
+            --finished-build-commands="cp /var/log/dpkg.log ${ext_root}/dpkg_partial.log" \
+            --debbuildopts="--source-option=-I" \
+            --build-dir=${WORKDIR} --dist="isar" ${DSC_FILE}
+    done
 
     sbuild_dpkg_log_export "${WORKDIR}/rootfs/dpkg_partial.log"
     deb_dl_dir_export "${WORKDIR}/rootfs" "${distro}"
-- 
2.35.3

             reply	other threads:[~2023-01-11 20:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11 20:05 Jan Kiszka [this message]
2023-01-16 11:50 ` Koch, Stefan
2023-01-16 13:09   ` Jan Kiszka

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=5963a56f-d89c-1318-a8b5-4d00fa00799e@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=adriaan.schmidt@siemens.com \
    --cc=isar-users@googlegroups.com \
    --cc=stefan-koch@siemens.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox