diff mbox series

[AUH] PATCH 5/6] upgrade-helper.py: Add prebuild option

Message ID 20260409090815.1731294-6-daniel.turull@ericsson.com
State New
Headers show
Series [AUH] PATCH 5/6] upgrade-helper.py: Add prebuild option | expand

Commit Message

Daniel Turull April 9, 2026, 9:08 a.m. UTC
From: Daniel Turull <daniel.turull@ericsson.com>

Add --prebuild option to build each recipe at its current version before
attempting the upgrade. This allows verifying that recipes build before
applying the upgrade and enables comparing binaries produced before and
after, for example for build size or ABI compatibility checks.

Recipes that fail the pre-build are skipped and recorded as failures.

Assisted-by: Claude, Anthropic
Signed-off-by: Daniel Turull <daniel.turull@ericsson.com>
---
 upgrade-helper.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff mbox series

Patch

diff --git a/upgrade-helper.py b/upgrade-helper.py
index bef9bca..945c4fc 100755
--- a/upgrade-helper.py
+++ b/upgrade-helper.py
@@ -105,6 +105,9 @@  def parse_cmdline():
     parser.add_argument("--minor", action="store_true", default=False,
                         help="allow minor version upgrades within the same major (e.g. 3.5.x -> 3.6.x)")
 
+    parser.add_argument("--prebuild", action="store_true", default=False,
+                        help="build each recipe at its current version before attempting upgrade")
+
     parser.add_argument("-d", "--debug-level", type=int, default=4, choices=range(1, 6),
                         help="set the debug level: CRITICAL=1, ERROR=2, WARNING=3, INFO=4, DEBUG=5")
     parser.add_argument("-e", "--send-emails", action="store_true", default=False,
@@ -516,6 +519,21 @@  class Updater(object):
             attempted_pkggroups += 1
             pkggroup_name = g["name"]
             I(" ATTEMPT PACKAGE GROUP %d/%d" % (attempted_pkggroups, total_pkggroups))
+
+            # Build current version first to verify it builds and seed ABI reference
+            if self.args.prebuild and not self.args.skip_compilation:
+                I(" %s: Pre-building current version ..." % pkggroup_name)
+                try:
+                    for machine in self.opts['machines']:
+                        self.bb.complete(pkggroup_name, machine)
+                except Exception as e:
+                    E(" %s: Pre-build FAILED, skipping upgrade" % pkggroup_name)
+                    if isinstance(e, Error):
+                        E(e.stdout + e.stderr)
+                    g['error'] = e if isinstance(e, Error) else Error(message=str(e))
+                    failed_pkggroups_ctx.append(g)
+                    continue
+
             try:
                 for pkg_ctx in g['pkgs']:
                     I(" %s: Upgrading to %s" % (pkg_ctx['PN'], pkg_ctx['NPV']))
@@ -571,6 +589,8 @@  class Updater(object):
             tim.run()
 
         for g in pkggroups_ctx:
+            if 'workdir' not in g:
+                continue
 
             if g in succeeded_pkggroups_ctx:
                 os.symlink(g['workdir'], os.path.join( \