public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH] add support for rebuilding essential packages
@ 2023-02-20 10:32 Adriaan Schmidt
  2023-02-20 11:24 ` Jan Kiszka
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Adriaan Schmidt @ 2023-02-20 10:32 UTC (permalink / raw)
  To: isar-users; +Cc: Adriaan Schmidt

There are cases when we need to rebuild a package that is installed during
bootstrap (we call those "essential package" here). This patch introduces
`ISAR_REBUILD_ESSENTIAL_PKGS` which can be set in (distro/layer) config, and
lists all essential packages.

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

Signed-off-by: Adriaan Schmidt <adriaan.schmidt@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
 
 DEPENDS ?= ""
 RPROVIDES ?= "${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 ?= ""
+
+python() {
+    isar_rebuild_essential_pkgs = (d.getVar('ISAR_REBUILD_ESSENTIAL_PKGS', True) or '').split()
+    build_compat = d.getVar('ISAR_ENABLE_COMPAT_ARCH', True) == "1"
+    build_native = not d.getVar('DISTRO_ARCH', True) == d.getVar('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 == HOST_ARCH), don't build native
+    # otherwise, automatically include compat/native when we can build them
+    essential_packages = []
+    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}:do_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() {
 }
 
 inherit multiarch
+inherit essential
 
 ROOTFSDIR = "${IMAGE_ROOTFS}"
 ROOTFS_FEATURES += "clean-package-cache clean-pycache generate-manifest export-dpkg-status clean-log-files clean-debconf-cache"
-- 
2.30.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-06  6:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-20 10:32 [PATCH] add support for rebuilding essential packages Adriaan Schmidt
2023-02-20 11:24 ` Jan Kiszka
2023-02-28  7:06 ` Cedric Hombourger
2023-02-28  7:19   ` Jan Kiszka
2023-03-06  6:06 ` Uladzimir Bely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox