From dd2d12365e614e6c31691ce27854140a3ce3913c Mon Sep 17 00:00:00 2001 From: Dostoievski Batista Date: Wed, 16 Apr 2025 14:49:17 -0300 Subject: [PATCH] Fail patch build when package is not found While fetching the debs if the patch-build script can't find one of the packages listed in "stx_packages" field or in "binary_packages" it will fail instead of building the patch without it. I have included two small changes in this review too: - Removed print() call in line 129 - Improved debug description in line 97 Test plan: PASS - Build patch with a non-existent package in "stx_packages" see if error message is displayed. PASS - Build patch with existent package in "stx_packages" see if no error message is displayed. PASS - Build patch with a non-existent package in "binary_packages" see if error message is displayed. PASS - Build patch with existent package in "binary_packages" see if no error message is displayed. Closes-bug: 2107493 Change-Id: Ia63638729a860f2bd9b6f6ea55763aea90dba992 Signed-off-by: Dostoievski Batista --- build-tools/stx/patch/fetch_debs.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/build-tools/stx/patch/fetch_debs.py b/build-tools/stx/patch/fetch_debs.py index 2db81d5e..de189ae6 100644 --- a/build-tools/stx/patch/fetch_debs.py +++ b/build-tools/stx/patch/fetch_debs.py @@ -48,13 +48,13 @@ class FetchDebs(object): subdebs_std = debsentry.get_subdebs(debs_clue_std, pkg, logger) subdebs_rt = debsentry.get_subdebs(debs_clue_rt, pkg, logger) if not subdebs_std and not subdebs_rt: - logger.warning('Failed to get subdebs for %s with local debsentry cache', pkg) - continue - else: - if subdebs_std: - all_debs.update(set(subdebs_std)) - if subdebs_rt: - all_debs.update(set(subdebs_rt)) + logger.error(f"Failed to get subdebs for package {pkg} from local debsentry cache") + sys.exit(1) + + if subdebs_std: + all_debs.update(set(subdebs_std)) + if subdebs_rt: + all_debs.update(set(subdebs_rt)) return all_debs @@ -85,7 +85,7 @@ class FetchDebs(object): ''' dl_debs = self.get_all_debs() if not dl_debs: - logger.warn('No STX packages were found') + logger.warning('No STX packages were found') return else: dl_debs_dict = {} @@ -94,7 +94,7 @@ class FetchDebs(object): name, version = deb.split('_') if name not in dl_debs_dict: dl_debs_dict[name] = version - logger.debug('##dldebs:%s', dl_debs_dict) + logger.debug('Debs found: %s', dl_debs_dict) # filter list based on stx-std.lst - Depecrated on master, replaced by debian_iso_image.inc on each repo stx_pkg_list_file = self.get_debian_pkg_iso_list() @@ -126,7 +126,7 @@ class FetchDebs(object): pkgs = [] cgcs_root_dir = os.environ.get('MY_REPO') package_file_name = 'debian_iso_image.inc' - print(cgcs_root_dir) + for root, dirs, files in os.walk(cgcs_root_dir): for file in files: if file == package_file_name: @@ -161,7 +161,8 @@ class FetchDebs(object): all_debs.add(pkg_entry) break else: - logger.warning(f"Package '{pkg}' not found in the package list") + logger.error(f"Package '{pkg}' not found in the package list") + sys.exit(1) logger.debug('Binary packages to download:%s', all_debs) fetch_ret = self.download(all_debs)