new_variant: clean up variant data
Allow 'None' defaults for cb_config_dir, the FSP/fitimage related
data, and private_yaml_dir. Remove these from variants where the
'None' default is correct.
Remove outdated fields and duplicates from variant data.
Make changes in format strings and if/return/else to fix warnings
from `cros lint`.
BUG=b:158033185
TEST=Use new_variant.py to start a new variant of Hatch, Volteer,
Waddledee (Dedede), and Trembyle (Zork). Name the variant "nonesuch"
so that the Volteer, Dedede, and Zork builds will fail in the first
step (build_config). Hatch will stop for fitimage generation. When
the program stops, examine ~/.new_variant.yaml and observe that
unused keys are still present, e.g. `private_yaml_dir: null`.
Use --abort to discard all changes.
The fact that the program got through the initial load of the
variant's data files (e.g. hatch.py) instead of failing for a
missing key shows that the default setting works.
Change-Id: I807ba15593d2877d39470aa9cd50dd55168316aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2227337
Tested-by: Paul Fagerburg <pfagerburg@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
diff --git a/contrib/variant/hatch.py b/contrib/variant/hatch.py
index c6c0015..0c490e8 100644
--- a/contrib/variant/hatch.py
+++ b/contrib/variant/hatch.py
@@ -37,9 +37,6 @@
# Base directory for coreboot
coreboot_dir = 'third_party/coreboot'
-# Base directory for coreboot configs (None=use default)
-cb_config_dir = None
-
# Package name for FSP
fsp = 'intel-cmlfsp'
@@ -65,7 +62,7 @@
'coreboot', 'libpayload', 'vboot_reference', 'depthcharge', fsp,
fitimage_pkg, 'chromeos-ec', 'chromeos-config-bsp-hatch-private',
'chromeos-config', 'chromeos-config-bsp', 'chromeos-config-bsp-hatch',
- 'coreboot-private-files', fitimage_pkg, 'chromeos-bootimage']
+ 'coreboot-private-files', 'chromeos-bootimage']
# List of packages to cros_workon to build the project config
config_workon_pkgs = ['chromeos-config', 'chromeos-config-bsp-hatch-private']
diff --git a/contrib/variant/new_variant.py b/contrib/variant/new_variant.py
index 96e193f..49845de 100755
--- a/contrib/variant/new_variant.py
+++ b/contrib/variant/new_variant.py
@@ -298,13 +298,13 @@
if continue_flag or abort_flag:
if status.yaml_file_exists():
return status
- else:
- if continue_flag:
- op = '--continue'
- if abort_flag:
- op = '--abort'
- logging.error('%s does not exist; cannot %s', status.yaml_file, op)
- return None
+
+ if continue_flag:
+ op = '--continue'
+ if abort_flag:
+ op = '--abort'
+ logging.error('%s does not exist; cannot %s', status.yaml_file, op)
+ return None
# If we get here, the user provided --board and --variant (because
# check_flags() returned Trued), but the yaml file already exists,
@@ -333,14 +333,14 @@
# Allow extra spaces around = so that we can line things up nicely
status.base = module.base
status.coreboot_dir = module.coreboot_dir
- status.cb_config_dir = module.cb_config_dir
+ status.cb_config_dir = getattr(module, 'cb_config_dir', None)
status.emerge_cmd = module.emerge_cmd
status.emerge_pkgs = module.emerge_pkgs
- status.fitimage_dir = module.fitimage_dir
- status.fitimage_pkg = module.fitimage_pkg
- status.fitimage_cmd = module.fitimage_cmd
- status.fsp = module.fsp
- status.private_yaml_dir = module.private_yaml_dir
+ status.fitimage_dir = getattr(module, 'fitimage_dir', None)
+ status.fitimage_pkg = getattr(module, 'fitimage_pkg', None)
+ status.fitimage_cmd = getattr(module, 'fitimage_cmd', None)
+ status.fsp = getattr(module, 'fsp', None)
+ status.private_yaml_dir = getattr(module, 'private_yaml_dir', None)
status.step_list = module.step_list
status.workon_pkgs = module.workon_pkgs
status.config_workon_pkgs = module.config_workon_pkgs
@@ -1056,7 +1056,7 @@
rc = True
for commit_key in status.coreboot_push_list:
- logging.debug(f'Processing key {commit_key}')
+ logging.debug('Processing key %s', commit_key)
commit = status.commits[commit_key]
if 'gerrit' not in commit or 'cl_number' not in commit:
change_id = commit['change_id']
@@ -1064,7 +1064,7 @@
if cl is not None:
save_cl_data(status, commit_key, cl)
else:
- logging.debug(f'Not found {change_id}, need to upload')
+ logging.debug('Not found %s, need to upload', change_id)
logging.error('The following commit needs to be pushed to coreboot.org:')
logging.error(' Branch "%s"', commit['branch_name'])
logging.error(' in directory "%s"', commit['dir'])
@@ -1077,7 +1077,7 @@
else:
instance_name = commit['gerrit']
cl_number = commit['cl_number']
- logging.debug(f'Already uploaded ({instance_name}, {cl_number})')
+ logging.debug('Already uploaded (%s, %s)', instance_name, cl_number)
return rc
@@ -1219,7 +1219,7 @@
logging.info('Running step upload_CLs')
for commit_key in status.repo_upload_list:
- logging.debug(f'Processing key {commit_key}')
+ logging.debug('Processing key %s', commit_key)
commit = status.commits[commit_key]
if 'gerrit' not in commit or 'cl_number' not in commit:
change_id = commit['change_id']
@@ -1227,7 +1227,7 @@
if cl is not None:
save_cl_data(status, commit_key, cl)
else:
- logging.debug(f'Not found {change_id}, need to upload')
+ logging.debug('Not found %s, need to upload', change_id)
if not repo_upload(commit['branch_name'], commit['dir']):
logging.error('Repo upload %s in %s failed!',
commit['branch_name'],
@@ -1235,14 +1235,14 @@
return False
cl = find_change_id(change_id)
if cl is None:
- logging.error(f'repo upload {commit_key} succeeded, ' \
- 'but change_id is not found!')
+ logging.error('repo upload %s succeeded, but change_id is not found!',
+ commit_key)
return False
save_cl_data(status, commit_key, cl)
else:
instance_name = commit['gerrit']
cl_number = commit['cl_number']
- logging.debug(f'Already uploaded ({instance_name}, {cl_number})')
+ logging.debug('Already uploaded (%s, %s)', instance_name, cl_number)
return True
@@ -1279,7 +1279,7 @@
if 'gerrit' in commit and 'cl_number' in commit:
instance_name = commit['gerrit']
cl_number = commit['cl_number']
- logging.debug(f'Already found ({instance_name}, {cl_number})')
+ logging.debug('Already found (%s, %s)', instance_name, cl_number)
return True
# Make sure we have a CB_VARIANT commit and a change_id for it
diff --git a/contrib/variant/trembyle.py b/contrib/variant/trembyle.py
index 01ec9ba..c72ea51 100644
--- a/contrib/variant/trembyle.py
+++ b/contrib/variant/trembyle.py
@@ -34,18 +34,6 @@
# Base directory for coreboot configs (None=use default)
cb_config_dir = 'overlays/overlay-zork/sys-boot/coreboot-zork/files/configs'
-# Package name for FSP
-fsp = None
-
-# Package name for the fitimage (None, because Zork doesn't use FIT)
-fitimage_pkg = None
-
-# Directory for fitimage (None, because Zork doesn't use FIT)
-fitimage_dir = None
-
-# Explanation of gen_fit_image command (None, because Zork doesn't use FIT)
-fitimage_cmd = None
-
# List of packages to cros_workon
workon_pkgs = ['coreboot-zork', 'chromeos-ec', 'chromeos-config-bsp-zork-private']
@@ -67,14 +55,10 @@
'chromeos-config-bsp', 'chromeos-config',
'chromeos-config-bsp-zork-private']
-# Directory for the private yaml file
-private_yaml_dir = '~/trunk/src/private-overlays/overlay-zork-private/'\
- 'chromeos-base/chromeos-config-bsp-zork-private'
-
# List of commits that will be uploaded with `repo upload`
repo_upload_list = [
step_names.CB_VARIANT, step_names.CB_CONFIG,
- step_names.CRAS_CONFIG, step_names.EC_IMAGE, step_names.ADD_PRIV_YAML]
+ step_names.CRAS_CONFIG, step_names.EC_IMAGE]
# List of commits that will be pushed to review.coreboot.org
coreboot_push_list = None
diff --git a/contrib/variant/volteer.py b/contrib/variant/volteer.py
index b89cda7..3f861cc 100644
--- a/contrib/variant/volteer.py
+++ b/contrib/variant/volteer.py
@@ -35,9 +35,6 @@
# Base directory for coreboot
coreboot_dir = 'third_party/coreboot'
-# Base directory for coreboot configs (None=use default)
-cb_config_dir = None
-
# Package name for FSP
fsp = 'intel-tglfsp'
@@ -72,10 +69,6 @@
# List of packages to emerge to build the project config
config_emerge_pkgs = ['chromeos-config-bsp-volteer-private']
-# Directory for the private yaml file
-# None; volteer doesn't use model.yaml
-private_yaml_dir = None
-
# List of commits that will be uploaded with `repo upload`
repo_upload_list = [
step_names.CB_CONFIG, step_names.COMMIT_FIT,
diff --git a/contrib/variant/waddledee.py b/contrib/variant/waddledee.py
index 804236d..e0aad43 100644
--- a/contrib/variant/waddledee.py
+++ b/contrib/variant/waddledee.py
@@ -35,9 +35,6 @@
# Base directory for coreboot
coreboot_dir = 'third_party/coreboot'
-# Base directory for coreboot configs (None=use default)
-cb_config_dir = None
-
# Package name for FSP
fsp = 'intel-jslfsp'
@@ -72,10 +69,6 @@
# List of packages to emerge to build the project config
config_emerge_pkgs = ['chromeos-config-bsp-dedede-private']
-# Directory for the private yaml file
-# None; dedede doesn't use model.yaml
-private_yaml_dir = None
-
# List of commits that will be uploaded with `repo upload`
repo_upload_list = [
step_names.CB_CONFIG, step_names.COMMIT_FIT,