From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7197016923412889600 X-Received: by 2002:a5b:211:0:b0:94a:ebba:cba6 with SMTP id z17-20020a5b0211000000b0094aebbacba6mr717813ybl.9.1677571091639; Mon, 27 Feb 2023 23:58:11 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:690c:d8f:b0:538:65bd:da4e with SMTP id da15-20020a05690c0d8f00b0053865bdda4els7896959ywb.0.-pod-prod-gmail; Mon, 27 Feb 2023 23:58:11 -0800 (PST) X-Google-Smtp-Source: AK7set+6O6tUleGGwbGp7ERBk7Ck8GzUR4YbeUt471qL8Tt5LTdU7TmMJOPKqo8GX9XInWFdnvhtpE0QHg== X-Received: by 2002:a81:ad43:0:b0:533:91d2:9d94 with SMTP id l3-20020a81ad43000000b0053391d29d94mr1067017ywk.5.1677571090758; Mon, 27 Feb 2023 23:58:10 -0800 (PST) X-Google-Web-Client: true Date: Mon, 27 Feb 2023 23:58:10 -0800 (PST) From: Cedric Hombourger To: isar-users Message-Id: In-Reply-To: <20230206122050.337270-3-adriaan.schmidt@siemens.com> References: <20230206122050.337270-1-adriaan.schmidt@siemens.com> <20230206122050.337270-3-adriaan.schmidt@siemens.com> Subject: Re: [PATCH 2/3] add multiarch support MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_5374_1848463072.1677571090563" X-TUID: EG25G8EsdEvi ------=_Part_5374_1848463072.1677571090563 Content-Type: multipart/alternative; boundary="----=_Part_5375_708565685.1677571090563" ------=_Part_5375_708565685.1677571090563 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Monday, February 6, 2023 at 1:21:27=E2=80=AFPM UTC+1 Adriaan Schmidt wro= te: This adds support for building packages for native and compat architectures= =20 to dpdk-base.bbclass.=20 Thus, all package recipes automatically have a *-native and *-compat=20 target,=20 which can be used in DEPENDS/RDEPENDS definitions.=20 Additionally *-compat targets can be used in IMAGE_INSTALL, where they=20 are automatically converted to install package:${COMPAT_DISTRO_ARCH}.=20 Note that the switch ISAR_ENABLE_COMPAT_ARCH still exist and controls=20 addition of the compat architecture during bootstrapping.=20 Signed-off-by: Adriaan Schmidt =20 ---=20 .../recipes-app/samefile/samefile_2.14.bb | 2 +-=20 meta/classes/compat.bbclass | 49 +++++++++++++++++++=20 meta/classes/debianize.bbclass | 2 +-=20 meta/classes/dpkg-base.bbclass | 1 +=20 meta/classes/image.bbclass | 4 +-=20 meta/classes/multiarch.bbclass | 44 +++++++++++++++++=20 meta/classes/native.bbclass | 10 ++++=20 meta/conf/bitbake.conf | 1 +=20 8 files changed, 110 insertions(+), 3 deletions(-)=20 create mode 100644 meta/classes/compat.bbclass=20 create mode 100644 meta/classes/multiarch.bbclass=20 create mode 100644 meta/classes/native.bbclass=20 diff --git a/meta-isar/recipes-app/samefile/samefile_2.14.bb=20 b/meta-isar/recipes-app/samefile/samefile_2.14.bb=20 index 5e36a2ac..c53c9445 100644=20 --- a/meta-isar/recipes-app/samefile/samefile_2.14.bb=20 +++ b/meta-isar/recipes-app/samefile/samefile_2.14.bb=20 @@ -21,7 +21,7 @@ do_prepare_build() {=20 # deb_debianize. Pre-exisiting files will not be recreated, changelog=20 # will be prepended unless its latest entry is for CHANGELOG_V.=20 cat << EOF > ${WORKDIR}/changelog=20 -${PN} (0.1) unstable; urgency=3Dlow=20 +${BPN} (0.1) unstable; urgency=3Dlow=20 * a long long time ago there was an early version=20 diff --git a/meta/classes/compat.bbclass b/meta/classes/compat.bbclass=20 new file mode 100644=20 index 00000000..7142ec3a=20 --- /dev/null=20 +++ b/meta/classes/compat.bbclass=20 @@ -0,0 +1,49 @@=20 +# This software is a part of ISAR.=20 +# Copyright (C) 2023 Siemens AG=20 +#=20 +# SPDX-License-Identifier: MIT=20 +=20 +# this class is "dual-use": it can be inherited (e.g., by bootstrap and=20 image=20 +# classes) to access variables and functions, and it's also addedd via=20 BBCLASSEXTEND=20 +# when inheriting multiconfig.bbclass.=20 +=20 +##########################################################################= ######=20 +# generic functions=20 +##########################################################################= ######=20 +=20 +# calcucate COMPAT_DISTRO_ARCH typo: calculate (but since it's not really a computation per se, I would=20 just say determine) =20 +# we can't use simple overrides, because in case we're building a package= =20 +# with a PACKAGE_ARCH !=3D DISTRO_ARCH, overrides would find the wrong=20 value.=20 +python() {=20 + distro_arch =3D d.getVar('DISTRO_ARCH')=20 + compat_distro_arch =3D d.getVar('COMPAT_DISTRO_ARCH:' + distro_arch)=20 + if compat_distro_arch is None and 'class-compat' in=20 d.getVar('OVERRIDES').split(':'):=20 + bb.fatal(f"{distro_arch} does not have a compat arch")=20 + d.setVar('COMPAT_DISTRO_ARCH', compat_distro_arch)=20 +}=20 +=20 +# function to convert bitbake targets to installable debian packages,=20 +# e.g., "hello-compat" to "hello:i386".=20 +def isar_compat_packages(var, d):=20 + bb_targets =3D (d.getVar(var, True) or '').split()=20 + packages =3D []=20 + compat_distro_arch =3D d.getVar('COMPAT_DISTRO_ARCH', True)=20 + for t in bb_targets:=20 + if t.endswith('-compat'):=20 + packages.append(t[:-len('-compat')] + ':' + compat_distro_arch)=20 + else:=20 + packages.append(t)=20 + return ' '.join(packages)=20 +=20 +=20 +##########################################################################= ######=20 +# package recipe modifications when actually building *-compat:=20 +##########################################################################= ######=20 +=20 +# check that we can actually build compat (ISAR_ENABLE_COMPAT_ARCH is set)= =20 +python do_fetch:prepend:class-compat() {=20 + if not d.getVar('ISAR_ENABLE_COMPAT_ARCH', True) =3D=3D '1':=20 + bb.fatal("compat package requested, but ISAR_ENABLE_COMPAT_ARCH is not=20 set.")=20 +}=20 +=20 +PACKAGE_ARCH:class-compat =3D "${COMPAT_DISTRO_ARCH}"=20 diff --git a/meta/classes/debianize.bbclass=20 b/meta/classes/debianize.bbclass=20 index a6694a00..1b98c02d 100644=20 --- a/meta/classes/debianize.bbclass=20 +++ b/meta/classes/debianize.bbclass=20 @@ -31,7 +31,7 @@ deb_add_changelog() {=20 date=3D$(LANG=3DC date -R -d @${timestamp})=20 cat < ${S}/debian/changelog=20 -${PN} (${changelog_v}) UNRELEASED; urgency=3Dlow=20 +${BPN} (${changelog_v}) UNRELEASED; urgency=3Dlow=20 * generated by Isar=20 diff --git a/meta/classes/dpkg-base.bbclass=20 b/meta/classes/dpkg-base.bbclass=20 index ad28f7b3..55cc6655 100644=20 --- a/meta/classes/dpkg-base.bbclass=20 +++ b/meta/classes/dpkg-base.bbclass=20 @@ -5,6 +5,7 @@=20 # SPDX-License-Identifier: MIT=20 inherit sbuild=20 +inherit multiarch=20 inherit debianize=20 inherit terminal=20 inherit repository=20 diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass=20 index 539ec51d..8d0dda30 100644=20 --- a/meta/classes/image.bbclass=20 +++ b/meta/classes/image.bbclass=20 @@ -79,9 +79,11 @@ image_do_mounts() {=20 buildchroot_do_mounts=20 }=20 +inherit compat=20 +=20 ROOTFSDIR =3D "${IMAGE_ROOTFS}"=20 ROOTFS_FEATURES +=3D "clean-package-cache clean-pycache generate-manifest= =20 export-dpkg-status clean-log-files clean-debconf-cache"=20 -ROOTFS_PACKAGES +=3D "${IMAGE_PREINSTALL} ${IMAGE_INSTALL}"=20 +ROOTFS_PACKAGES +=3D "${IMAGE_PREINSTALL}=20 ${@isar_compat_packages('IMAGE_INSTALL', d)}"=20 ROOTFS_MANIFEST_DEPLOY_DIR ?=3D "${DEPLOY_DIR_IMAGE}"=20 ROOTFS_DPKGSTATUS_DEPLOY_DIR ?=3D "${DEPLOY_DIR_IMAGE}"=20 ROOTFS_PACKAGE_SUFFIX ?=3D "${PN}-${DISTRO}-${MACHINE}"=20 diff --git a/meta/classes/multiarch.bbclass=20 b/meta/classes/multiarch.bbclass=20 new file mode 100644=20 index 00000000..5b280699=20 --- /dev/null=20 +++ b/meta/classes/multiarch.bbclass=20 @@ -0,0 +1,44 @@=20 +# This software is a part of ISAR.=20 +# Copyright (C) 2021-2022 Siemens AG=20 +#=20 +# SPDX-License-Identifier: MIT=20 +=20 +BBCLASSEXTEND +=3D "native compat"=20 +BPN =3D "${PN}"=20 +=20 +python multiarch_virtclass_handler() {=20 + def fixup_pn_in_vars(d):=20 + vars =3D 'SRC_URI FILESPATH'.split()=20 + for var in vars:=20 + v =3D d.getVar(var, False)=20 + if v is not None:=20 + d.setVar(var, v.replace('${PN}', '${BPN}'))=20 +=20 + def fixup_depends(suffix, d):=20 + vars =3D 'PROVIDES RPROVIDES DEPENDS RDEPENDS'.split()=20 + for var in vars:=20 + multiarch_var =3D []=20 + val =3D d.getVar(var, True)=20 + if val is None:=20 + continue=20 + for v in val.split():=20 + if v.endswith('-compat') or v.endswith('-native'):=20 + multiarch_var.append(v)=20 + else:=20 + multiarch_var.append(v + suffix)=20 + d.setVar(var, ' '.join(multiarch_var))=20 +=20 + pn =3D e.data.getVar('PN')=20 + if pn.endswith('-compat'):=20 + e.data.setVar('BPN', pn[:-len('-compat')])=20 + e.data.appendVar('OVERRIDES', ':class-compat')=20 + fixup_pn_in_vars(e.data)=20 + fixup_depends('-compat', e.data)=20 + elif pn.endswith('-native'):=20 + e.data.setVar('BPN', pn[:-len('-native')])=20 + e.data.appendVar('OVERRIDES', ':class-native')=20 + fixup_pn_in_vars(e.data)=20 + fixup_depends('-native', e.data)=20 +}=20 +addhandler multiarch_virtclass_handler=20 +multiarch_virtclass_handler[eventmask] =3D "bb.event.RecipePreFinalise"=20 diff --git a/meta/classes/native.bbclass b/meta/classes/native.bbclass=20 new file mode 100644=20 index 00000000..ef20e8bc=20 --- /dev/null=20 +++ b/meta/classes/native.bbclass=20 @@ -0,0 +1,10 @@=20 +# This software is a part of ISAR.=20 +# Copyright (C) 2023 Siemens AG=20 +#=20 +# SPDX-License-Identifier: MIT=20 +=20 +##########################################################################= ######=20 +# package recipe modifications when actually building *-native:=20 +##########################################################################= ######=20 +=20 +PACKAGE_ARCH:class-native =3D "${HOST_ARCH}"=20 diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf=20 index f1a9438e..f38bb447 100644=20 --- a/meta/conf/bitbake.conf=20 +++ b/meta/conf/bitbake.conf=20 @@ -81,6 +81,7 @@ QEMU_ARCH:riscv64 =3D "riscv64"=20 # Codename of the repository created by the caching class=20 DEBDISTRONAME ?=3D "isar"=20 +NATIVELSBSTRING ?=3D "isarnative"=20 # Strings used in sstate signature files=20 TARGET_VENDOR =3D ""=20 --=20 2.30.2=20 ------=_Part_5375_708565685.1677571090563 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

On Monday, February 6, 2023 at 1:21:27= =E2=80=AFPM UTC+1 Adriaan Schmidt wrote:
This adds support for building packages for native and compat = architectures
to dpdk-base.bbclass.
Thus, all package recipes automatically have a *-native and *-compat = target,
which can be used in DEPENDS/RDEPENDS definitions.
Additionally *-compat targets can be used in IMAGE_INSTALL, where the= y
are automatically converted to install package:${COMPAT_DISTRO_ARCH}.

Note that the switch ISAR_ENABLE_COMPAT_ARCH still exist and controls
addition of the compat architecture during bootstrapping.

Signed-off-by: Adriaan Schmidt <adri= aan...@siemens.com>
---
.../recipes-app/samefile/samefile_2.14.bb | 2 +-
meta/classes/compat.bbclass | 49 +++++++++++++++++= ++
meta/classes/debianize.bbclass | 2 +-
meta/classes/dpkg-base.bbclass | 1 +
meta/classes/image.bbclass | 4 +-
meta/classes/multiarch.bbclass | 44 +++++++++++++++++
meta/classes/native.bbclass | 10 ++++
meta/conf/bitbake.conf | 1 +
8 files changed, 110 insertions(+), 3 deletions(-)
create mode 100644 meta/classes/compat.bbclass
create mode 100644 meta/classes/multiarch.bbclass
create mode 100644 meta/classes/native.bbclass

diff --git a/meta-isar/recipes-app/samefile/samefile_2.14.bb b/meta-i= sar/recipes-app/samefile/samefile_2.14.bb
index 5e36a2ac..c53c9445 100644
--- a/meta-isar/recipes-app/samefile/samefile_2.14.bb
+++ b/meta-isar/recipes-app/samefile/samefile_2.14.bb
@@ -21,7 +21,7 @@ do_prepare_build() {
# deb_debianize. Pre-exisiting files will not be recreated, chan= gelog
# will be prepended unless its latest entry is for CHANGELOG_V.
cat << EOF > ${WORKDIR}/changelog
-${PN} (0.1) unstable; urgency=3Dlow
+${BPN} (0.1) unstable; urgency=3Dlow
=20
* a long long time ago there was an early version
=20
diff --git a/meta/classes/compat.bbclass b/meta/classes/compat.bbclas= s
new file mode 100644
index 00000000..7142ec3a
--- /dev/null
+++ b/meta/classes/compat.bbclass
@@ -0,0 +1,49 @@
+# This software is a part of ISAR.
+# Copyright (C) 2023 Siemens AG
+#
+# SPDX-License-Identifier: MIT
+
+# this class is "dual-use": it can be inherited (e.g., by bootstrap = and image
+# classes) to access variables and functions, and it's also addedd v= ia BBCLASSEXTEND
+# when inheriting multiconfig.bbclass.
+
+####################################################################= ############
+# generic functions
+####################################################################= ############
+
+# calcucate COMPAT_DISTRO_ARCH

typ= o: calculate (but since it's not really a computation per se, I would just = say determine)
=C2=A0

+# we can't use simple overrides, because in case we're building a pa= ckage
+# with a PACKAGE_ARCH !=3D DISTRO_ARCH, overrides would find the wro= ng value.
+python() {
+ distro_arch =3D d.getVar('DISTRO_ARCH')
+ compat_distro_arch =3D d.getVar('COMPAT_DISTRO_ARCH:' + distro_a= rch)
+ if compat_distro_arch is None and 'class-compat' in d.getVar('OV= ERRIDES').split(':'):
+ bb.fatal(f"{distro_arch} does not have a compat arch")
+ d.setVar('COMPAT_DISTRO_ARCH', compat_distro_arch)
+}
+
+# function to convert bitbake targets to installable debian packages= ,
+# e.g., "hello-compat" to "hello:i386".
+def isar_compat_packages(var, d):
+ bb_targets =3D (d.getVar(var, True) or '').split()
+ packages =3D []
+ compat_distro_arch =3D d.getVar('COMPAT_DISTRO_ARCH', True)
+ for t in bb_targets:
+ if t.endswith('-compat'):
+ packages.append(t[:-len('-compat')] + ':' + compat_distr= o_arch)
+ else:
+ packages.append(t)
+ return ' '.join(packages)
+
+
+####################################################################= ############
+# package recipe modifications when actually building *-compat:
+####################################################################= ############
+
+# check that we can actually build compat (ISAR_ENABLE_COMPAT_ARCH i= s set)
+python do_fetch:prepend:class-compat() {
+ if not d.getVar('ISAR_ENABLE_COMPAT_ARCH', True) =3D=3D '1':
+ bb.fatal("compat package requested, but ISAR_ENABLE_COMPAT_A= RCH is not set.")
+}
+
+PACKAGE_ARCH:class-compat =3D "${COMPAT_DISTRO_ARCH}"
diff --git a/meta/classes/debianize.bbclass b/meta/classes/debianize.= bbclass
index a6694a00..1b98c02d 100644
--- a/meta/classes/debianize.bbclass
+++ b/meta/classes/debianize.bbclass
@@ -31,7 +31,7 @@ deb_add_changelog() {
=20
=09date=3D$(LANG=3DC date -R -d @${timestamp})
=09cat <<EOF > ${S}/debian/changelog
-${PN} (${changelog_v}) UNRELEASED; urgency=3Dlow
+${BPN} (${changelog_v}) UNRELEASED; urgency=3Dlow
=20
* generated by Isar
=20
diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.= bbclass
index ad28f7b3..55cc6655 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -5,6 +5,7 @@
# SPDX-License-Identifier: MIT
=20
inherit sbuild
+inherit multiarch
inherit debianize
inherit terminal
inherit repository
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 539ec51d..8d0dda30 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -79,9 +79,11 @@ image_do_mounts() {
buildchroot_do_mounts
}
=20
+inherit compat
+
ROOTFSDIR =3D "${IMAGE_ROOTFS}"
ROOTFS_FEATURES +=3D "clean-package-cache clean-pycache generate-man= ifest export-dpkg-status clean-log-files clean-debconf-cache"
-ROOTFS_PACKAGES +=3D "${IMAGE_PREINSTALL} ${IMAGE_INSTALL}"
+ROOTFS_PACKAGES +=3D "${IMAGE_PREINSTALL} ${@isar_compat_packages('I= MAGE_INSTALL', d)}"
ROOTFS_MANIFEST_DEPLOY_DIR ?=3D "${DEPLOY_DIR_IMAGE}"
ROOTFS_DPKGSTATUS_DEPLOY_DIR ?=3D "${DEPLOY_DIR_IMAGE}"
ROOTFS_PACKAGE_SUFFIX ?=3D "${PN}-${DISTRO}-${MACHINE}"
diff --git a/meta/classes/multiarch.bbclass b/meta/classes/multiarch.= bbclass
new file mode 100644
index 00000000..5b280699
--- /dev/null
+++ b/meta/classes/multiarch.bbclass
@@ -0,0 +1,44 @@
+# This software is a part of ISAR.
+# Copyright (C) 2021-2022 Siemens AG
+#
+# SPDX-License-Identifier: MIT
+
+BBCLASSEXTEND +=3D "native compat"
+BPN =3D "${PN}"
+
+python multiarch_virtclass_handler() {
+ def fixup_pn_in_vars(d):
+ vars =3D 'SRC_URI FILESPATH'.split()
+ for var in vars:
+ v =3D d.getVar(var, False)
+ if v is not None:
+ d.setVar(var, v.replace('${PN}', '${BPN}'))
+
+ def fixup_depends(suffix, d):
+ vars =3D 'PROVIDES RPROVIDES DEPENDS RDEPENDS'.split()
+ for var in vars:
+ multiarch_var =3D []
+ val =3D d.getVar(var, True)
+ if val is None:
+ continue
+ for v in val.split():
+ if v.endswith('-compat') or v.endswith('-native'):
+ multiarch_var.append(v)
+ else:
+ multiarch_var.append(v + suffix)
+ d.setVar(var, ' '.join(multiarch_var))
+
+ pn =3D e.data.getVar('PN')
+ if pn.endswith('-compat'):
+ e.data.setVar('BPN', pn[:-len('-compat')])
+ e.data.appendVar('OVERRIDES', ':class-compat')
+ fixup_pn_in_vars(e.data)
+ fixup_depends('-compat', e.data)
+ elif pn.endswith('-native'):
+ e.data.setVar('BPN', pn[:-len('-native')])
+ e.data.appendVar('OVERRIDES', ':class-native')
+ fixup_pn_in_vars(e.data)
+ fixup_depends('-native', e.data)
+}
+addhandler multiarch_virtclass_handler
+multiarch_virtclass_handler[eventmask] =3D "bb.event.RecipePreFinali= se"
diff --git a/meta/classes/native.bbclass b/meta/classes/native.bbclas= s
new file mode 100644
index 00000000..ef20e8bc
--- /dev/null
+++ b/meta/classes/native.bbclass
@@ -0,0 +1,10 @@
+# This software is a part of ISAR.
+# Copyright (C) 2023 Siemens AG
+#
+# SPDX-License-Identifier: MIT
+
+####################################################################= ############
+# package recipe modifications when actually building *-native:
+####################################################################= ############
+
+PACKAGE_ARCH:class-native =3D "${HOST_ARCH}"
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index f1a9438e..f38bb447 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -81,6 +81,7 @@ QEMU_ARCH:riscv64 =3D "riscv64"
=20
# Codename of the repository created by the caching class
DEBDISTRONAME ?=3D "isar"
+NATIVELSBSTRING ?=3D "isarnative"
=20
# Strings used in sstate signature files
TARGET_VENDOR =3D ""
--=20
2.30.2

------=_Part_5375_708565685.1677571090563-- ------=_Part_5374_1848463072.1677571090563--