From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7202184025122799616 X-Received: by 2002:a05:6902:906:b0:a27:3ecd:6 with SMTP id bu6-20020a056902090600b00a273ecd0006mr2034445ybb.1.1677568002002; Mon, 27 Feb 2023 23:06:42 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a25:6854:0:b0:912:7e8d:8005 with SMTP id d81-20020a256854000000b009127e8d8005ls7032875ybc.3.-pod-prod-gmail; Mon, 27 Feb 2023 23:06:41 -0800 (PST) X-Google-Smtp-Source: AK7set/7t/h66WMEr3qsDg7IsyCproJaOkv137ba3asvQ8/UsF5IKYboaG5OzwM5FpkyS9z9mUTV4tiKVA== X-Received: by 2002:a5b:c88:0:b0:a86:eba7:c3ca with SMTP id i8-20020a5b0c88000000b00a86eba7c3camr595930ybq.1.1677568001198; Mon, 27 Feb 2023 23:06:41 -0800 (PST) X-Google-Web-Client: true Date: Mon, 27 Feb 2023 23:06:40 -0800 (PST) From: Cedric Hombourger To: isar-users Message-Id: In-Reply-To: <20230220103214.2704911-1-adriaan.schmidt@siemens.com> References: <20230220103214.2704911-1-adriaan.schmidt@siemens.com> Subject: Re: [PATCH] add support for rebuilding essential packages MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_4730_1058260311.1677568000967" X-TUID: XVgCIcXn3Kfn ------=_Part_4730_1058260311.1677568000967 Content-Type: multipart/alternative; boundary="----=_Part_4731_1585265593.1677568000967" ------=_Part_4731_1585265593.1677568000967 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Monday, February 20, 2023 at 11:32:22=E2=80=AFAM UTC+1 Adriaan Schmidt w= rote: There are cases when we need to rebuild a package that is installed during= =20 bootstrap (we call those "essential package" here). This patch introduces= =20 `ISAR_REBUILD_ESSENTIAL_PKGS` which can be set in (distro/layer) config,=20 and=20 lists all essential packages.=20 During build, Isar ensures that essential packages are built before any=20 others,=20 so that their locally built versions are available in isar-apt, and will=20 be used in any subsequent package builds.=20 Signed-off-by: Adriaan Schmidt =20 ---=20 This has interdependencies with the proposed multiarch feature,=20 and builds on v2 of that series.=20 Adriaan=20 ---=20 meta/classes/dpkg-base.bbclass | 1 +=20 meta/classes/essential.bbclass | 39 ++++++++++++++++++++++++++++++++++=20 meta/classes/image.bbclass | 1 +=20 3 files changed, 41 insertions(+)=20 create mode 100644 meta/classes/essential.bbclass=20 diff --git a/meta/classes/dpkg-base.bbclass=20 b/meta/classes/dpkg-base.bbclass=20 index 55cc6655..ce301346 100644=20 --- a/meta/classes/dpkg-base.bbclass=20 +++ b/meta/classes/dpkg-base.bbclass=20 @@ -10,6 +10,7 @@ inherit debianize=20 inherit terminal=20 inherit repository=20 inherit deb-dl-dir=20 +inherit essential=20 DEPENDS ?=3D ""=20 RPROVIDES ?=3D "${PROVIDES}"=20 diff --git a/meta/classes/essential.bbclass=20 b/meta/classes/essential.bbclass=20 new file mode 100644=20 index 00000000..cb444674=20 --- /dev/null=20 +++ b/meta/classes/essential.bbclass=20 @@ -0,0 +1,39 @@=20 +# This software is a part of ISAR.=20 +# Copyright (C) 2023 Siemens AG=20 +=20 +ISAR_REBUILD_ESSENTIAL_PKGS ?=3D ""=20 +=20 +python() {=20 + isar_rebuild_essential_pkgs =3D (d.getVar('ISAR_REBUILD_ESSENTIAL_PKGS',= =20 True) or '').split() ",True" should not be necessary here's getVar()'s signature: def getVar(self, var, expand=3DTrue, noweakdefault=3DFalse, parsing=3DFalse= ) =20 + build_compat =3D d.getVar('ISAR_ENABLE_COMPAT_ARCH', True) =3D=3D "1"=20 + build_native =3D not d.getVar('DISTRO_ARCH', True) =3D=3D d.getVar('HOST_= ARCH')=20 +=20 + # construct list of essential packages that should be rebuilt:=20 + # if we can't build compat, don't include any -compat packages=20 + # if we don't need native (because DISTRO_ARCH =3D=3D HOST_ARCH), don't b= uild=20 native=20 + # otherwise, automatically include compat/native when we can build them= =20 + essential_packages =3D []=20 + for p in isar_rebuild_essential_pkgs:=20 + if p.endswith('-compat') and build_compat:=20 + essential_packages.append(p)=20 + elif p.endswith('-native') and build_native:=20 + essential_packages.append(p)=20 + else:=20 + essential_packages.append(p)=20 + if build_compat:=20 + essential_packages.append(f'{p}-compat')=20 + if build_native:=20 + essential_packages.append(f'{p}-native')=20 +=20 + # bail out if this recipe is in the essential list=20 + if d.getVar('PN') in essential_packages:=20 + return=20 +=20 + # add dependencies to all packages from the essential list=20 + for p in essential_packages:=20 + if d.getVar('do_prepare_build'):=20 + d.appendVarFlag('do_prepare_build', 'depends', f' {p}:do_deploy_deb')=20 + if d.getVar('do_install_rootfs'):=20 + d.appendVarFlag('do_install_rootfs', 'depends', f' {p}:do_deploy_deb')=20 +}=20 +=20 diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass=20 index ce7c549c..550785ea 100644=20 --- a/meta/classes/image.bbclass=20 +++ b/meta/classes/image.bbclass=20 @@ -80,6 +80,7 @@ image_do_mounts() {=20 }=20 inherit multiarch=20 +inherit essential=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 --=20 2.30.2=20 ------=_Part_4731_1585265593.1677568000967 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

On Monday, February 20, 2023 at 11:32:22= =E2=80=AFAM UTC+1 Adriaan Schmidt wrote:
There are cases when we need to rebuild a package that is inst= alled during
bootstrap (we call those "essential package" here). This patch introd= uces
`ISAR_REBUILD_ESSENTIAL_PKGS` which can be set in (distro/layer) conf= ig, and
lists all essential packages.

During build, Isar ensures that essential packages are built before a= ny others,
so that their locally built versions are available in isar-apt, and w= ill
be used in any subsequent package builds.

Signed-off-by: Adriaan Schmidt <adri= aan...@siemens.com>

---
This has interdependencies with the proposed multiarch feature,
and builds on v2 of that series.

Adriaan
---
meta/classes/dpkg-base.bbclass | 1 +
meta/classes/essential.bbclass | 39 ++++++++++++++++++++++++++++++++= ++
meta/classes/image.bbclass | 1 +
3 files changed, 41 insertions(+)
create mode 100644 meta/classes/essential.bbclass

diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.= bbclass
index 55cc6655..ce301346 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -10,6 +10,7 @@ inherit debianize
inherit terminal
inherit repository
inherit deb-dl-dir
+inherit essential
=20
DEPENDS ?=3D ""
RPROVIDES ?=3D "${PROVIDES}"
diff --git a/meta/classes/essential.bbclass b/meta/classes/essential.= bbclass
new file mode 100644
index 00000000..cb444674
--- /dev/null
+++ b/meta/classes/essential.bbclass
@@ -0,0 +1,39 @@
+# This software is a part of ISAR.
+# Copyright (C) 2023 Siemens AG
+
+ISAR_REBUILD_ESSENTIAL_PKGS ?=3D ""
+
+python() {
+ isar_rebuild_essential_pkgs =3D (d.getVar('ISAR_REBUILD_ESSENTIA= L_PKGS', True) or '').split()

",True" sho= uld not be necessary
here's getVar()'s signature:

def getVar(self, var, expand=3DTrue, noweakdefault=3DFalse, par= sing=3DFalse)
=C2=A0

+ build_compat =3D d.getVar('ISAR_ENABLE_COMPAT_ARCH', True) =3D= =3D "1"
+ build_native =3D not d.getVar('DISTRO_ARCH', True) =3D=3D d.getV= ar('HOST_ARCH')
+
+ # construct list of essential packages that should be rebuilt:
+ # if we can't build compat, don't include any -compat packages
+ # if we don't need native (because DISTRO_ARCH =3D=3D HOST_ARCH)= , don't build native
+ # otherwise, automatically include compat/native when we can bui= ld them
+ essential_packages =3D []
+ for p in isar_rebuild_essential_pkgs:
+ if p.endswith('-compat') and build_compat:
+ essential_packages.append(p)
+ elif p.endswith('-native') and build_native:
+ essential_packages.append(p)
+ else:
+ essential_packages.append(p)
+ if build_compat:
+ essential_packages.append(f'{p}-compat')
+ if build_native:
+ essential_packages.append(f'{p}-native')
+
+ # bail out if this recipe is in the essential list
+ if d.getVar('PN') in essential_packages:
+ return
+
+ # add dependencies to all packages from the essential list
+ for p in essential_packages:
+ if d.getVar('do_prepare_build'):
+ d.appendVarFlag('do_prepare_build', 'depends', f' {p}:do= _deploy_deb')
+ if d.getVar('do_install_rootfs'):
+ d.appendVarFlag('do_install_rootfs', 'depends', f' {p}:d= o_deploy_deb')
+}
+
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index ce7c549c..550785ea 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -80,6 +80,7 @@ image_do_mounts() {
}
=20
inherit multiarch
+inherit essential
=20
ROOTFSDIR =3D "${IMAGE_ROOTFS}"
ROOTFS_FEATURES +=3D "clean-package-cache clean-pycache generate-man= ifest export-dpkg-status clean-log-files clean-debconf-cache"
--=20
2.30.2

------=_Part_4731_1585265593.1677568000967-- ------=_Part_4730_1058260311.1677568000967--