From e25a639d57023260db5eae0251b0dde39ff8cd8d Mon Sep 17 00:00:00 2001 From: Troy Dawson Date: Sep 07 2023 16:36:01 +0000 Subject: Add rhel-target none option Signed-off-by: Troy Dawson --- diff --git a/src/centpkg/cli.py b/src/centpkg/cli.py index e87dc56..4b7f830 100755 --- a/src/centpkg/cli.py +++ b/src/centpkg/cli.py @@ -202,40 +202,43 @@ class centpkgClient(cliClient): * zstream - If pre-GA of a y-stream release, this will build for 0day. If post-GA of a Y-stream release, this will build for the Z-stream of that release. * latest - This will always build for the next Y-stream release + * none - This will not build in brew. No rhel metadata is set. '''.format('\n'.join(textwrap.wrap(build_parser.description)))) # Now add our additional option build_parser.add_argument( '--rhel-target', - choices=['exception', 'zstream', 'latest'], + choices=['exception', 'zstream', 'latest', 'none'], help='Set the rhel-target metadata') # Overloaded _build def _build(self, sets=None): - # Only do rhel-target if we are centpkg, not centpkg-sig + # Only do rhel-target if we are centpkg, not centpkg-sig, or if we are doing scratch if not os.path.basename(sys.argv[0]).endswith('-sig') and not self.args.scratch: - # Only run if we have internal configuraions, or scratch + # Only run if we have internal configuraions internal_config_file = "/etc/rpkg/centpkg_internal.conf" if os.path.exists(internal_config_file): # If rhel-target is set, no need to check, just use it if hasattr(self.args, 'rhel_target') and self.args.rhel_target: - # If custom-user-metadata set, add onto it - if hasattr(self.args, 'custom_user_metadata') and self.args.custom_user_metadata: - try: - temp_custom_user_metadata = json.loads(self.args.custom_user_metadata) - # Use ValueError instead of json.JSONDecodeError for Python 2 and 3 compatibility - except ValueError as e: - self.parser.error("--custom-user-metadata is not valid JSON: %s" % e) - if not isinstance(temp_custom_user_metadata, dict): - self.parser.error("--custom-user-metadata must be a JSON object") - temp_custom_user_metadata["rhel-target"] = self.args.rhel_target - else: - temp_custom_user_metadata = {"rhel-target": self.args.rhel_target} - self.args.custom_user_metadata = json.dumps(temp_custom_user_metadata) + # If rhel-target set to none, do nothing with metadata + if self.args.rhel_target.lower() != "none": + # If custom-user-metadata set, add onto it + if hasattr(self.args, 'custom_user_metadata') and self.args.custom_user_metadata: + try: + temp_custom_user_metadata = json.loads(self.args.custom_user_metadata) + # Use ValueError instead of json.JSONDecodeError for Python 2 and 3 compatibility + except ValueError as e: + self.parser.error("--custom-user-metadata is not valid JSON: %s" % e) + if not isinstance(temp_custom_user_metadata, dict): + self.parser.error("--custom-user-metadata must be a JSON object") + temp_custom_user_metadata["rhel-target"] = self.args.rhel_target + else: + temp_custom_user_metadata = {"rhel-target": self.args.rhel_target} + self.args.custom_user_metadata = json.dumps(temp_custom_user_metadata) else: # Get our internal only variables