upgrade-helper.py: remove unused self.poky_git settings
PATCH v3 1/11 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
@@ -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
PATCH v3 2/11 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
@@ -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
PATCH v3 3/11 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
@@ -1 +0,0 @@ -GitPython
Signature · 1 line
2.34.1
PATCH v3 4/11 modules/utils/git.py: include repo_dir in exception and unneeded debug
In reply to [email protected]From: Chen Qi <[email protected]>
Including the repo_dir in exception helps people know where the git command is actually executed.
There's no need for the debug output here, because all the information has already been in the exception.
--- modules/utils/git.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
modules/utils/git.py +1 -3
@@ -24,7 +24,6 @@ # import os -from logging import debug as D from utils.bitbake import bb from errors import Error
@@ -41,8 +40,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__())) - 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
PATCH v3 5/11 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
@@ -29,9 +29,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
PATCH v3 6/11 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
@@ -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
PATCH v3 7/11 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
@@ -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
PATCH v3 8/11 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
@@ -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
PATCH v3 9/11 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
@@ -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
PATCH v3 10/11 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
@@ -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
PATCH v3 11/11 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
@@ -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