diff mbox series

[AUH,v2,7/9] upgrade-helper.py: Add prebuild option

Message ID 20260424114603.2444938-8-daniel.turull@ericsson.com
State New
Headers show
Series upgrade_helper: scarthgap compatibility, stable updates and changelog extraction | expand

Commit Message

Daniel Turull April 24, 2026, 11:46 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(+)

Comments

Alexander Kanavin April 27, 2026, 10:19 a.m. UTC | #1
There's already a buildhistory option which does such a pre-build and
size comparison? Perhaps you can extend buildhistory with hooks into
additional external checks?

Alex

On Fri, 24 Apr 2026 at 13:46, <daniel.turull@ericsson.com> wrote:
>
> 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 --git a/upgrade-helper.py b/upgrade-helper.py
> index ffa7449..11a97d2 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 upgrades within the same major version (e.g. 3.5.2 -> 3.6.0, 3.99.0)")
>
> +    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(" ".join([p['PN'] for p in g['pkgs']]), 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( \
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/upgrade-helper.py b/upgrade-helper.py
index ffa7449..11a97d2 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 upgrades within the same major version (e.g. 3.5.2 -> 3.6.0, 3.99.0)")
 
+    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(" ".join([p['PN'] for p in g['pkgs']]), 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( \