Skip to contentSkip to conversation

upgrade-helper.py: remove unused self.poky_git settings

PATCH Superseded [email protected] 2 participants 18 messages Mar 11 – Mar 16

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/12 upgrade-helper.py: remove unused self.poky_git settings

From: Chen Qi <[email protected]>

---
 upgrade-helper.py | 2 --
 1 file changed, 2 deletions(-)
upgrade-helper.py +0 -2
index 2f38e0a..3b98f7c 100755
@@ -184,11 +184,9 @@ class Updater(object):
                     _layer_settings_error(s)
 
             self.git = Git(self.opts['layer_dir'])
-            self.poky_git = Git(os.path.dirname(os.getenv('PATH', False).split(':')[0]))
         else:
             # XXX: assume that the poky directory is the first entry in the PATH
             self.git = Git(os.path.dirname(os.getenv('PATH', False).split(':')[0]))
-            self.poky_git = None
         self.opts['machines'] = settings.get('machines', 'qemux86-64 qemuarm_musl').split()
 
         self.opts['send_email'] = self.args.send_emails
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 2/12 upgrade-helper.py: use scripts path to locate oe-core directory

From: Chen Qi <[email protected]>

Using the first element in PATH is really awkward and prone to errors. As we have already located the scripts directory by using shutil.which('devtool'), we could well make use of it to locate oe-core directory.

Note that the scripts could be a symbolic link to the real location under oe-core. So we need to use os.path.realpath() to get its real location.

---
 upgrade-helper.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
upgrade-helper.py +3 -3
index 3b98f7c..27e1f48 100755
@@ -67,7 +67,7 @@ if not os.getenv('BUILDDIR', False):
     exit(1)
 
 # Use the location of devtool to find scriptpath and hence bb/oe libs
-scripts_path = os.path.abspath(os.path.dirname(shutil.which("devtool")))
+scripts_path = os.path.realpath(os.path.abspath(os.path.dirname(shutil.which("devtool"))))
 sys.path = sys.path + [scripts_path + '/lib']
 import scriptpath
 scriptpath.add_bitbake_lib_path()
@@ -185,8 +185,8 @@ class Updater(object):
 
             self.git = Git(self.opts['layer_dir'])
         else:
-            # XXX: assume that the poky directory is the first entry in the PATH
-            self.git = Git(os.path.dirname(os.getenv('PATH', False).split(':')[0]))
+            # use scripts_path to get oe-core directory
+            self.git = Git(os.path.dirname(scripts_path))
         self.opts['machines'] = settings.get('machines', 'qemux86-64 qemuarm_musl').split()
 
         self.opts['send_email'] = self.args.send_emails
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 3/12 requirements.txt: remove as it makes no sense

In reply to [email protected]

From: Chen Qi <[email protected]>

AUH is not using GitPython, it's using 'git' command directly. This requirements.txt makes no sense.

---
 requirements.txt | 1 -
 1 file changed, 1 deletion(-)
 delete mode 100644 requirements.txt
requirements.txt deleted +0 -1
deleted file mode 100644
index 64b1ada..0000000
@@ -1 +0,0 @@
-GitPython
Signature · 1 line
2.34.1
#3 lore raw

PATCH v2 4/12 modules/utils/git.py: use warning instead of debugging logging for git command error

In reply to [email protected]

From: Chen Qi <[email protected]>

git command error is obviously critical and should be presented to user more clearly.

---
 modules/utils/git.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
modules/utils/git.py +2 -2
index 3be75bf..0482d26 100644
@@ -24,7 +24,7 @@
 #
 
 import os
-from logging import debug as D
+from logging import warning as W
 
 from utils.bitbake import bb
 from errors import Error
@@ -41,7 +41,7 @@ class Git(object):
         try:
             stdout, stderr = bb.process.run(cmd)
         except bb.process.ExecutionError as e:
-            D("%s executed from %s returned:\n%s" % (cmd, self.repo_dir, e.__str__()))
+            W("%s executed from %s returned:\n%s" % (cmd, self.repo_dir, e.__str__()))
             raise Error("The following git command failed: " + operation,
                         e.stdout, e.stderr)
 
Signature · 1 line
2.34.1
#4 lore raw

PATCH v2 5/12 modules/utils/git.py: cleanup the __init__ function

In reply to [email protected]

From: Chen Qi <[email protected]>

The "dir" is not a good parameter name as "dir" is a built-in function of python. Use repodir instead.

Besides, the super() call is not needed as Git inherits object directly.

---
 modules/utils/git.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
modules/utils/git.py +2 -3
index 0482d26..b504ab0 100644
@@ -30,9 +30,8 @@ from utils.bitbake import bb
 from errors import Error
 
 class Git(object):
-    def __init__(self, dir):
-        self.repo_dir = dir
-        super(Git, self).__init__()
+    def __init__(self, repodir):
+        self.repo_dir = repodir
 
     def _cmd(self, operation):
         os.chdir(self.repo_dir)
Signature · 1 line
2.34.1
#5 lore raw

PATCH v2 6/12 modules/utils/git.py: include repo_dir information in the raised exception

In reply to [email protected]

From: Chen Qi <[email protected]>

This help people know where the git command is actually executed.

---
 modules/utils/git.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
modules/utils/git.py +1 -1
index b504ab0..38c6a72 100644
@@ -41,7 +41,7 @@ class Git(object):
             stdout, stderr = bb.process.run(cmd)
         except bb.process.ExecutionError as e:
             W("%s executed from %s returned:\n%s" % (cmd, self.repo_dir, e.__str__()))
-            raise Error("The following git command failed: " + operation,
+            raise Error("The following git command failed in %s: %s" % (self.repo_dir, operation),
                         e.stdout, e.stderr)
 
         return stdout
Signature · 1 line
2.34.1
#6 lore raw

Re: [auh][PATCH V2 06/12] modules/utils/git.py: include repo_dir information in the raised exception

modules/utils/git.py class Git(object): · line 45

Quoted 6 lines · On Wed, 11 Mar 2026 at 07:48, <[email protected]> wrote:

stdout, stderr = bb.process.run(cmd)
except bb.process.ExecutionError as e:
W("%s executed from %s returned:\n%s" % (cmd, self.repo_dir, e.__str__()))

modules/utils/git.py +1 -1
-            raise Error("The following git command failed: " + operation,
+            raise Error("The following git command failed in %s: %s" % (self.repo_dir, operation),
                         e.stdout, e.stderr)

Hello Chen,

can you combine patch 4 and 6 (this one) into a single patch that removes the debug/warning print, and just puts all relevant information into the exception?

The reason is that:
- auh works in such a way that having git fail is sometimes okay, and the caller will handle the exception (e.g. see the 'nothing to commit' handling in upgrade-helper.py)
- if git does fail, we don't want to flood the console with warnings when it is not a real failure. Rather just handle the exception, or if there's no handler, then it will be raised and print everything relevant.

Alex

author
#7 lore raw

RE: [auh][PATCH V2 06/12] modules/utils/git.py: include repo_dir information in the raised exception

Hi Alex,

Thanks for your review. I'll fix this and send out V3.

Regards,
Qi

-----Original Message-----
From: Alexander Kanavin <[email protected]>
Sent: Thursday, March 12, 2026 3:10 AM
To: Chen, Qi <[email protected]>
Cc: [email protected]; MacLeod, Randy <[email protected]>
Subject: Re: [auh][PATCH V2 06/12] modules/utils/git.py: include repo_dir information in the raised exception

modules/utils/git.py class Git(object): · line 45

Quoted 7 lines · On Wed, 11 Mar 2026 at 07:48, <[email protected]> wrote:

stdout, stderr = bb.process.run(cmd)
except bb.process.ExecutionError as e:
W("%s executed from %s returned:\n%s" % (cmd, self.repo_dir, e.__str__()))

modules/utils/git.py +2 -1
-            raise Error("The following git command failed: " + operation,
+            raise Error("The following git command failed in %s: %s" 
+ % (self.repo_dir, operation),
                         e.stdout, e.stderr)

Hello Chen,

can you combine patch 4 and 6 (this one) into a single patch that removes the debug/warning print, and just puts all relevant information into the exception?

The reason is that:
- auh works in such a way that having git fail is sometimes okay, and the caller will handle the exception (e.g. see the 'nothing to commit'
handling in upgrade-helper.py)
- if git does fail, we don't want to flood the console with warnings when it is not a real failure. Rather just handle the exception, or if there's no handler, then it will be raised and print everything relevant.

Alex

#8 lore raw

Re: [auh][PATCH V2 06/12] modules/utils/git.py: include repo_dir information in the raised exception

Quoted 1 line · Qi

Thanks for your review. I'll fix this and send out V3.

Hello Qi,

I applied and pushed all 11 patches from v3. Note that AUH does not have a test suite, it's basically tested twice a month by running updates for oe-core, and fixing any possible issues after the fact.

Unfortunately AUH is prone to even simple and straightforward looking changes causing some kind of regression in an unanticipated corner case, so let's see how the next round goes, and I'd appreciate if you are around, if/when problems occur.

Alex

author
#9 lore raw

Re: [yocto-patches] [auh][PATCH V2 06/12] modules/utils/git.py: include repo_dir information in the raised exception

Quoted 8 lines · Alexander Kanavin via lists.yoctoproject.org
Quoted 1 line · Qi

Thanks for your review. I'll fix this and send out V3.

Hello Qi,

I applied and pushed all 11 patches from v3. Note that AUH does not have a test suite, it's basically tested twice a month by running updates for oe-core, and fixing any possible issues after the fact.

Quoted 6 lines

Unfortunately AUH is prone to even simple and straightforward looking changes causing some kind of regression in an unanticipated corner case, so let's see how the next round goes, and I'd appreciate if you are around, if/when problems occur.

Alex

Of course. If any program occurs, please let me know and I'll fix it.

Regards,
Qi

Quoted 10 lines

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#3450): https://lists.yoctoproject.org/g/yocto-patches/message/3450
Mute This Topic: https://lists.yoctoproject.org/mt/118256064/7304865
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto-patches/leave/13175947/7304865/1848005690/xyzzy [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#10 lore raw

Re: [yocto-patches] [auh][PATCH V2 06/12] modules/utils/git.py: include repo_dir information in the raised exception

Quoted 9 lines · ChenQi
Quoted 8 lines

I applied and pushed all 11 patches from v3. Note that AUH does not have a test suite, it's basically tested twice a month by running updates for oe-core, and fixing any possible issues after the fact.

Unfortunately AUH is prone to even simple and straightforward looking changes causing some kind of regression in an unanticipated corner case, so let's see how the next round goes, and I'd appreciate if you are around, if/when problems occur.

Of course. If any program occurs, please let me know and I'll fix it.

I just went over the latest AUH-made round of oe-core upgrade patches, and I'm not seeing anything unusual, so I think it's all good :)

Alex

#11 lore raw

PATCH v2 7/12 upgrade-helper.py: fix exception handling for commit_changes

In reply to [email protected]

From: Chen Qi <[email protected]>

The previous exception handling is basically self-contradictory. It has g['error'] = e below, so it thinks e is of type Error. But it does not make use of Error's message, stdout and stderr. And the e could well not be of type Error.

Fix the logic by checking the type of e and handles it differently.

---
 upgrade-helper.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
upgrade-helper.py +5 -2
index 27e1f48..428d66f 100755
@@ -523,8 +523,11 @@ class Updater(object):
             try:
                 self.commit_changes(g)
             except Exception as e:
-                import traceback
-                E(" Couldn't commit changes to %s:\n%s" % (pkggroup_name, traceback.format_exc()))
+                if not isinstance(e, Error):
+                    import traceback
+                    msg = "Failed(unknown error)\n" + traceback.format_exc()
+                    e = Error(message=msg)
+                E(" Couldn't commit changes to %s:\nmessage: %s\nstdout: %s\nstderr: %s" % (pkggroup_name, e.message, e.stdout, e.stderr))
                 # Ensure commit failures are recorded as group errors
                 g['error'] = e
                 if g in succeeded_pkggroups_ctx:
Signature · 1 line
2.34.1
#12 lore raw

PATCH v2 8/12 upgrade-helper.py: avoid unnecessary and confusing short names

In reply to [email protected]

From: Chen Qi <[email protected]>

The following two import...as... statements bring developers little benefit.
import logging as log
import configparser as cp

For example, the second one is only used here:
cfg = cp.ConfigParser()

It should be clearer that we just use:
cfg = configparser.ConfigParser()

These two short names are not necessary and they will just confuse users. Use their original module names directly.

---
 upgrade-helper.py | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
upgrade-helper.py +8 -8
index 428d66f..9920126 100755
@@ -31,7 +31,7 @@ import argparse
 import os
 import subprocess
 
-import logging as log
+import logging
 from logging import debug as D
 from logging import info as I
 from logging import warning as W
@@ -41,7 +41,7 @@ from logging import critical as C
 import re
 import signal
 import sys
-import configparser as cp
+import configparser
 from datetime import datetime
 from datetime import date
 import shutil
@@ -125,7 +125,7 @@ def parse_config_file(config_file):
 
     if os.path.exists(cfg_file):
         D("Reading config file %s" % cfg_file)
-        cfg = cp.ConfigParser()
+        cfg = configparser.ConfigParser()
         cfg.read(cfg_file)
         try:
             settings_list = cfg.items("settings")
@@ -217,8 +217,8 @@ class Updater(object):
         os.mkdir(self.uh_recipes_failed_dir)
 
     def _add_file_logger(self):
-        fh = log.FileHandler(os.path.join(self.uh_work_dir, "upgrade-helper.log"))
-        logger = log.getLogger()
+        fh = logging.FileHandler(os.path.join(self.uh_work_dir, "upgrade-helper.log"))
+        logger = logging.getLogger()
         logger.addHandler(fh)
 
     def _get_status_msg(self, err):
@@ -755,10 +755,10 @@ if __name__ == "__main__":
 
     signal.signal(signal.SIGINT, close_child_processes)
 
-    debug_levels = [log.CRITICAL, log.ERROR, log.WARNING, log.INFO, log.DEBUG]
+    debug_levels = [logging.CRITICAL, logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG]
     args = parse_cmdline()
-    log.basicConfig(format='%(levelname)s:%(message)s',
-                    level=debug_levels[args.debug_level - 1])
+    logging.basicConfig(format='%(levelname)s:%(message)s',
+                        level=debug_levels[args.debug_level - 1])
     settings, maintainer_override = parse_config_file(args.config_file)
     if args.layer_names != '' and args.layer_dir == '':
         E("layer-dir is mandatory if layers are defined")
Signature · 1 line
2.34.1
#13 lore raw

PATCH v2 9/12 upgrade-helper.conf: remove layer_machines from reference config file

In reply to [email protected]

From: Chen Qi <[email protected]>

The layer_machines has been dropped by the following commit:
0ea93cb upgrade-helper: Drop layer_machines

Let's also remove it from the reference configuration file to reflect the current status.

---
 upgrade-helper.conf | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
upgrade-helper.conf +1 -2
index 251c36a..269bde3 100644
@@ -116,9 +116,8 @@
 # This can be used to upgrade recipes in a specific layer,
 # for example meta-intel, instead of upgrading oe-core recipes.
 #
-# When layer_mode is enabled, layer_name, layer_dir and layer_machines are
+# When layer_mode is enabled, layer_name, layer_dir are
 # mandatory. 'blacklist' setting does not apply when in layer_mode.
 #layer_mode=no
 #layer_name=meta-intel
 #layer_dir=DIR/meta-intel
-#layer_machines=intel-core2-32 intel-corei7-64 intel-quark
Signature · 1 line
2.34.1
#14 lore raw

PATCH v2 10/12 upgrade-helper.py: use global_maintainer_override if it's set and the recipe has no maintainer

In reply to [email protected]

From: Chen Qi <[email protected]>

If a recipe has no maintainer, it will be skipped, and there's currently no switch to force the upgrade. Note that for recipes out of oe-core, it's so common that they do not have some dedicated maintainer.

The global_maintainer_override setting has the meaning of sending upgrading emails to the specified person. When it's set, someone must be using auh to do upgrade. In such case, skipping a recipe merely because it has no maintainer does not make much sense.

So We could extend the meaning of global_maintainer_override a little bit so that when people set it, recipes with no maintainer can still be upgraded.

---
 upgrade-helper.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
upgrade-helper.py +4 -1
index 9920126..8589f8d 100755
@@ -712,7 +712,10 @@ class UniverseUpdater(Updater):
             for group in pkggroups:
                 upgrade_group = []
                 for pkg in group:
-                    pkg_to_upgrade = _get_pkg_to_upgrade(self, layer_name, pkg['pn'], pkg['status'], pkg['cur_ver'], pkg['next_ver'], pkg['maintainer'], pkg['revision'], pkg['no_upgrade_reason'])
+                    maintainer = pkg['maintainer']
+                    if not maintainer and 'global_maintainer_override' in settings:
+                        maintainer = settings['global_maintainer_override']
+                    pkg_to_upgrade = _get_pkg_to_upgrade(self, layer_name, pkg['pn'], pkg['status'], pkg['cur_ver'], pkg['next_ver'], maintainer, pkg['revision'], pkg['no_upgrade_reason'])
                     if pkg_to_upgrade:
                         upgrade_group.append(pkg_to_upgrade)
                 if upgrade_group:
Signature · 1 line
2.34.1
#15 lore raw

PATCH v2 11/12 upgrade-helper.py: add logging info about running bitbake-layers

In reply to [email protected]

From: Chen Qi <[email protected]>

When layer mode is used, 'bitbake-layers show-recipes' will run. This usually takes several minutes. If there's no output from auh, what people see is that they invoke auh and it gives no output for several minutes, making people wonder if things are stuck.

---
 upgrade-helper.py | 1 +
 1 file changed, 1 insertion(+)
upgrade-helper.py +1 -0
index 8589f8d..7edb6da 100755
@@ -619,6 +619,7 @@ class UniverseUpdater(Updater):
 
         name = ''
 
+        I("Running bitbake-layers show-recipes ... (this may take several minutes)")
         output = subprocess.check_output('bitbake-layers show-recipes',
                 shell=True)
         for line in output.decode("utf-8") .split('\n'):
Signature · 1 line
2.34.1
#16 lore raw

PATCH v2 12/12 upgrade-helper.py: respect recipe parameter from command line in case of layer mode

In reply to [email protected]

From: Chen Qi <[email protected]>

The recipe parameter in command line is not respected. For example, upgrade-helper.py --config-file upgrade-helper/upgrade-helper.meta-python.conf python3-sqlparse This command still tries to upgrade all recipes from meta-python instead
of just python3-sqlparse.

This is a regression introduced by the following commit:
ff1c2aa0d2 upgrade-helper.py: Add layer command line option

Fix this regression by adding a filtering mechanism.

Note that 'all' is handled specially and it means upgrading all recipes in the specific layer.

---
 upgrade-helper.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
upgrade-helper.py +6 -3
index 7edb6da..40f31c4 100755
@@ -595,12 +595,15 @@ class UniverseUpdater(Updater):
         if len(args.recipe) == 1 and args.recipe[0] == "all" and self.opts['layer_mode'] != 'yes':
             self.recipes = [('', [])]
         elif self.opts['layer_mode'] == 'yes':
-            # when layer mode is enabled and no recipes are specified
+            # layer mode is enabled
             # we need to figure out what recipes are provided by the
-            # layer to try upgrade
+            # layer and filter it recipes provided
             self.recipes = []
             for layer in self.opts['layer_name'].split(' '):
-                recipes_for_layer = self._get_recipes_by_layer(layer)
+                if args.recipe[0] != "all":
+                    recipes_for_layer = args.recipe
+                else:
+                    recipes_for_layer = self._get_recipes_by_layer(layer)
                 I("layer %s => Recipes %s", layer, recipes_for_layer)
                 self.recipes.append((layer, recipes_for_layer))
         else:
Signature · 1 line
2.34.1
#17 lore raw

Re: [auh][PATCH V2 12/12] upgrade-helper.py: respect recipe parameter from command line in case of layer mode

On Wed, 11 Mar 2026 at 07:48, <[email protected]> wrote:
\> The recipe parameter in command line is not respected. For example,

Quoted 8 lines

upgrade-helper.py --config-file upgrade-helper/upgrade-helper.meta-python.conf python3-sqlparse This command still tries to upgrade all recipes from meta-python instead
of just python3-sqlparse.

This is a regression introduced by the following commit:
ff1c2aa0d2 upgrade-helper.py: Add layer command line option

Fix this regression by adding a filtering mechanism.

Thanks, the patchset otherwise looks okay, so if you can do the tweak for patches 4/6 and resend, I'll take it.

Alex